antonk52 / basics-language-server

Buffer, path, and snippet completions
MIT License
53 stars 0 forks source link

FR: Add setting to allow for a more "fuzzy" match for snippets to use "contains" instead of "startsWith" #8

Open GitMurf opened 1 week ago

GitMurf commented 1 week ago

Great job on the LSP! I am testing it with Neovim right now and it is working nicely.

One thing that would be very useful is to add a setting for ability to match more fuzzily for snippet candidates. Currently there are two "problems" for me (see the link to the specific code below):

  1. I often do not know exactly what my snippet is called and especially what it starts with, so if I type "diagnostic" I would like it to match my snippet that is called disableDiagnosticError. Current the snippet will only show up if I start with "disabl...". Instead of using a startsWith it would be nice to just match any part of the string.

  2. Currently the matches are case sensitive. So in my previous example, if I start typing "Disabl..." it will not match because it starts with "disabl..." (lower case). Would be nice if you could do a toLowerCase for them before comparing.

Snippets are very important to me and unlike buffer text, there are far less (most the time) so being more loose with how many snippets are matched and returned I think is more appropriate than buffer words.

https://github.com/antonk52/basics-language-server/blob/dc2f861d1c4df57b447efbde164862a0cf982cda/src/connection.ts#L244-L249

antonk52 commented 1 week ago

Hi and glad you're enjoying it. I agree that match strategy can be more loose. Let me think if we want to have a global setting or individual per buffer and snippet completions. I am leaning towards individual one but would like to sleep on this. I will take a look tomorrow.

Thanks for the suggestion

UPD: late travel, still plan to do this in the new few days

antonk52 commented 4 days ago

I've opened a PR #9 that adds multiple completion strategies. I will let it hang for a day or two before merging. Feel free to comment/review.

antonk52 commented 8 hours ago

Released in v1.1.1