Skip to content
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

add fuzzy matching via lua and fts_fuzzy_match.lua #16

Closed
wants to merge 3 commits into from

Conversation

prabirshrestha
Copy link
Owner

Do not merge

This is me trying out fuzzy search. I would need to dog-food this more before I merge to master. Would most likely need a refactor too.

fuzzy-matching

Fuzzy only works if lua is supported. Currently doesn't yet work in neovim so it should fallback to prefix search.

Related blog post about https://blog.forrestthewoods.com/reverse-engineering-sublime-text-s-fuzzy-match-4cffeed33fdb

@lithammer
Copy link
Contributor

I guess this is a prerequisite for Neovim support: neovim/neovim#4411

@prabirshrestha
Copy link
Owner Author

@Renstrom Yes. Waiting for neovim support before I finally merge this. Also there are some improvements that I would like to squeeze too. I have been using Plug 'prabirshrestha/asyncomplete.vim', { 'branch': 'fuzzy' } for vim8 for few weeks and has been working well for me.

@roxma seems to have converted ncm to use completefunc and omnifunc instead which means every keypress actually calls the complete func we can just sort there. Currently I don't like my implementation of when fuzzy search is called. My original implementation when using async completion was using it omnifunc https://gist.github.com/prabirshrestha/0b3b7b4e2112c662979bfeeec4e1edb7. I will continue to play with this a bit more.

@tutysara
Copy link

looks like neovim/neovim#4411 is merged

@roxma
Copy link

roxma commented May 12, 2017

@roxma seems to have converted ncm to use completefunc and omnifunc instead which means every keypress actually calls the complete func we can just sort there.

The reason that I use omnifunc or completefunc instead of complete() call for fuzzy matching, is to reduce the popup menu flickering, see
roxma/nvim-completion-manager#8 (comment)

If the menu is opened by complete() call, vim will auto hide it when the typed text and the popup menu item don't match by prefix. And then the completion plugin open the menu again, since text is fuzzy matched. And again, and again as the user keeps typing. This is obvious and terribe for remote terminal user.

omnifunc and completefunc is pretty much the same thing, except that they are triggered by different keys, and completefunc also remap the <c-u> key. Use omnifunc when you want to use the <c-u> key for something else.

@prabirshrestha
Copy link
Owner Author

@roxma thanks for the explanation. Does that mean that if vim and neovim patches complete() so it doesn't close if it is already open it would solve the flickering issue? If so I would rather wait for vim to have the patch than update to omnifunc or completefunc as the api call complete(startcol, candidates) seems to be much cleaner.

@tutysara Lua support in neovim is merged which is awesome, but seems like has('lua') returns false. But currently due to flickering issue, my priority would be to solve this before adding lua fuzzy matcher. I have also been thinking whether to support async matcher api instead of just sync matcher api. This way anyone can extend the matcher and sorter to their needs.

@tutysara
Copy link

@tutysara Lua support in neovim is merged which is awesome, but seems like has('lua') returns false. But currently due to flickering issue, my priority would be to solve this before adding lua fuzzy matcher. I have also been thinking whether to support async matcher api instead of just sync matcher api. This way anyone can extend the matcher and sorter to their needs.

Sure thanks, good idea to have the matcher and sorter separate and allow user to extend/substitute them. I haven't looked much into the code. I came here from the lsp repo, I was looking for an lsp impl for vim to setup with java lsp server. I will watch for updates from here as well

@prabirshrestha
Copy link
Owner Author

I'm waiting for calling complete() flickers if popup menu is already open in vim and neovim to be fixed first. Will give it around a month or so if not I may have to first migrate to completefunc or omnifunc :( before merging this PR.

In the meantime people can continue to use this branch if they want fuzzy matching with lua. I have been using this branch as default in my vimrc and haven't had much problems.

@purpleP
Copy link

purpleP commented Aug 29, 2017

If you want to have good fuzzy matching checkout https://github.com/jhawthorn/fzy It's better than fzy selecta. It uses the same algorithm used for DNA matching I believe, although with customisations.

@tracyone
Copy link

tracyone commented Feb 4, 2018

Any process?

This feature has lua dependency?

@prabirshrestha
Copy link
Owner Author

Closing this in favor of #49. Feel free to give that a try, It has fuzzy completion enabled.
You need to have vim 8 with TextChangedP support. Patch to neovim is also getting ported.

@prabirshrestha prabirshrestha deleted the fuzzy branch February 12, 2018 06:26
prabirshrestha pushed a commit that referenced this pull request May 24, 2020
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.

None yet

6 participants