Skip to content

feat(autocomplete): Fuzzy match autocompletion #1024

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 14, 2025

Conversation

kristijanhusak
Copy link
Member

Summary

Add support for fuzzy matching in autocompletion.

Related Issues

Related #1010

Changes

  • Both blink.cmp and nvim-cmp now do fuzzy matching by default
  • Ominfunc does fuzzy matching only if completeopt has fuzzy

Checklist

I confirm that I have:

  • Followed the
    Conventional Commits
    specification
    (e.g., feat: add new feature, fix: correct bug,
    docs: update documentation).
  • My PR title also follows the conventional commits specification.
  • Updated relevant documentation, if necessary.
  • Thoroughly tested my changes.
  • Added tests (if applicable) and verified existing tests pass with
    make test.
  • Checked for breaking changes and documented them, if any.

@kristijanhusak
Copy link
Member Author

@seflue give this PR a test. It should provide fuzzy completion for most of the things. Only one thing that I found, which was probably a bug even before, is that relative path completion that goes up more than one directory doesn't work (so ../ works but ../../ does not work). That can be addressed later.

Let me know how it works for you.

@kristijanhusak kristijanhusak force-pushed the feat/autocomplete-fuzzy branch from 84ce1ba to b409b4d Compare August 12, 2025 20:52
@kristijanhusak kristijanhusak force-pushed the feat/autocomplete-fuzzy branch from b409b4d to 5bbc31f Compare August 12, 2025 20:59
@seflue
Copy link
Contributor

seflue commented Aug 14, 2025

Thanks @kristijanhusak for the response. I am giving your PR a try and get back to you as soon as I have some feedback.

I just skimmed through the code but didn't fully understand, in which way #1010 broke things and how your code avoided it. What I think I understood is, that you now provide fuzzy matching using vim.fn.matchfuzzy, circumventing the fuzzy completion of blink itself.

@kristijanhusak
Copy link
Member Author

@seflue the simplified base that is provided is not enough context for some of the autocompletion, most specifically the "target" part of the link completion. For example, if you type this with a valid path to org file:

[[file:/path/to/my/org/todos.org::*

You will get list of all headlines in that file as autocompletion. With your solution, the file context is never there for the autocompletion to provide that list. I solved it by providing the whole base value down, but the matching in the lower layers use the fuzzy matching. Previously it was doing substring matching everywhere.

What I think I understood is, that you now provide fuzzy matching using vim.fn.matchfuzzy, circumventing the fuzzy completion of blink itself

That is correct. It's not ideal solution, but this way we provide fuzzy completion for everything, and implementation is not tied to blink.cmp. It would need a lot of changes to adapt to each framework, and I'd like to avoid that.

@seflue
Copy link
Contributor

seflue commented Aug 14, 2025

Understood. From what I tried today, your PR is much better than what we had before, so I would appreciate, if you merge it. I would close my PR.

@kristijanhusak kristijanhusak merged commit b924cbb into master Aug 14, 2025
20 checks passed
@kristijanhusak kristijanhusak deleted the feat/autocomplete-fuzzy branch August 14, 2025 15:25
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.

2 participants