-
-
Notifications
You must be signed in to change notification settings - Fork 247
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
feat: add snippet completion for injected languages #226
feat: add snippet completion for injected languages #226
Conversation
IMHO it should not be the default, but configurable, it's true that tree-sitter is more precise in embedded languages, but there are some users of multi-filetype (like 'markdown,jekyll') and for them, it will be a breaking change. |
Maybe another option is to make it "smarter" and fallback to the
That's maybe too convoluted but should make multi-filetypes work as expected. |
We could provide a setting, (sidenote: we probably also need some mechanism for switching configs based on filetype, out of scope for this particular PR, but something to consider). |
Also ty @ner0-m for porting it so quickly :) |
Nice, this looks very clean 👌 One thing I just realized: |
One option could be deprecate lazy loading, we have not measured how fast is the normal loader since we added the new JSON parser. |
Other way could be to trigger a custom event once a new ft is found by the new heuristic and subscribe the lazy load to it as well. |
Tempting.. :D
That sounds good, although a custom event is probably overkill, just calling from |
Mhhh, I'm a little lost now. Can you help me out, with the changes to the lazy load? :) |
Actually, even if we load the new snippets in |
I said a new event 'cause the core does not know about loaders. |
Also true, putting the snippets into the main module was a bit of a mistake to begin with 😅. |
I was thinking about the option of having several sources of snippets as for example:
Each one provides a way to ask for a list of snippets for certain That will remove the issue of having to call the loaders after setting the snippet table and could make it possible to lazy load or not depending of the intricacies of each loadable format. |
Not a bad idea, that way we could also reload snippets for a single source only 👍
👀 |
@ner0-m First of all, this is an amazing idea! Would you mind if I use some of your treesitter-related code for cmp-nvim-ultisnips? I will of course credit you since this was your idea and initial implementation. |
0a45d4c
to
f813c0a
Compare
I've finally found time to get back to this, sorry for the delay, my studies keep me busy. I've added a note in the docs regarding the lazy loading and make changed the formatting of the functions. Any other suggestions? @smjonas I'd be very happy and don't mind it at all! |
No problem, and I've no more suggestions, very pleased with this PR 👌 |
This is the port of this PR for cmp_luasnip.
It uses the language at the cursor position by default and falls back to the filetype if treesitter isn't available. I'm not sure about the parameter if such a thing is good. I appreciate the feedback!