Skip to content

Enable fuzzy matching for ref completion#2474

Open
ro0gr wants to merge 2 commits into
tpope:masterfrom
ro0gr:fuzzy-complete
Open

Enable fuzzy matching for ref completion#2474
ro0gr wants to merge 2 commits into
tpope:masterfrom
ro0gr:fuzzy-complete

Conversation

@ro0gr
Copy link
Copy Markdown

@ro0gr ro0gr commented Apr 24, 2026

Enable fuzzy matching for Fugitive ref completion using Vim's matchfuzzy().
This applies to branch, tag, remote, push, edit, and --fixup= / --squash= commit-subject completion.

Command and file path completion keep their existing prefix-matching behavior.
On older Vim versions that do not support matchfuzzy(), completion falls back to the previous prefix-based matching.

For now, this uses Fugitive's existing shared ref completion source, so fuzzy matching applies across branches, remotes, tags like v1.2.3, and symbolic refs such as HEAD and FETCH_HEAD. If you find that too noisy, narrowing it later to branches and remotes may be breaking, so early feedback on that tradeoff is useful.

For commit completion, the change is limited to --fixup= / --squash= subject suggestions, where fuzzy matching commit subjects is useful. Other commit completion paths keep their existing behavior.

Related references:

Examples

  • :Git switch fz<Tab>
    can match a narrower subset from a wider set of branch names, for example:

    • fuzzy-match
    • potato-fuzzy
  • :Git rebase hd<Tab>
    can match entries from the shared ref pool, for example:

    • FETCH_HEAD
    • feature/hotdog
    • origin/feature/hotdog
  • :Git commit --fixup=rdme<Tab>
    can match a commit subject like update README formatting

Requirements

  • Support for matchfuzzy() (neovim or vim@9+).
  • set wildoptions+=fuzzy

Testing

This repo does not appear to have an automated test suite.

I have been using this locally on real repositories for a while without issues. Tested in both: neovim@0.12 and vim@9.

Use matchfuzzy() for branch, tag, remote, push, and edit completion.
For now, this uses Fugitive's existing shared ref completion source,
so fuzzy matching applies across branches, remotes, tags like v1.2.3,
and symbolic refs such as HEAD and FETCH_HEAD. If you find that too
noisy, narrowing it later to branches and remotes may be breaking, so
early feedback on that tradeoff is useful.

For commit completion, fuzzy matching is enabled specifically for
--fixup= and --squash= subject suggestions, where matching commit
subjects is useful; other commit completion paths keep their existing
behavior.

Preserves case-sensitive prefix filtering for commands and file paths.
Includes a compatibility guard for Vim versions lacking matchfuzzy().

Assisted-by: AI tools
Copilot AI review requested due to automatic review settings April 24, 2026 23:55

This comment was marked as spam.

@tpope
Copy link
Copy Markdown
Owner

tpope commented Apr 27, 2026

@ro0gr Hi, did you request that Copilot review or was that something GitHub did automatically?

I have been too busy to stay on top of incoming PRs lately, but I want to make sure some bot isn't wasting people's time.

@ro0gr
Copy link
Copy Markdown
Author

ro0gr commented Apr 27, 2026

@tpope I didn't enable it explicitly, but I still have a Copilot subscription. I just noticed that "Copilot Review" was enabled in my settings. Thanks for the heads up!

In addition to matchfuzzy() availability, respect user preference via
wildoptions. Works for both Vim (9.0+) and Neovim.

Generated by Mistral Vibe.
Co-Authored-By: Mistral Vibe <vibe@mistral.ai>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants