Open voidkrc opened 1 month ago
To add on this, I can see my custom snippets in the cmp window.
Hi :)
It seems a bit like you're conflating what luasnip does and what cmp/cmp_luasnip does, so to make sure that's not the case I'll outline what each of them is responsible for:
ls.expand_or_jumpable()
returns whether the current snippet is jumpable or whether the text immediately before the cursor matches a snippet added via add_snippets
. This does not include lsp-snippets!
cmp_luasnip takes all snippets added via add_snippets
and lists them as a cmp-source. This means all snippets can be expanded from the cmp-list by accepting the item (<C-y>
in your case)
cmp (or, the nvim_lsp
-source) takes snippets generated by the languageserver, and, upon accepting the item, it expands them via the ls.lsp_expand()
-function.
Does this help clear the issue, or were we on the same page before? :D
Hi :) It seems a bit like you're conflating what luasnip does and what cmp/cmp_luasnip does, so to make sure that's not the case I'll outline what each of them is responsible for:
ls.expand_or_jumpable()
returns whether the current snippet is jumpable or whether the text immediately before the cursor matches a snippet added viaadd_snippets
. This does not include lsp-snippets! cmp_luasnip takes all snippets added viaadd_snippets
and lists them as a cmp-source. This means all snippets can be expanded from the cmp-list by accepting the item (<C-y>
in your case) cmp (or, thenvim_lsp
-source) takes snippets generated by the languageserver, and, upon accepting the item, it expands them via thels.lsp_expand()
-function.Does this help clear the issue, or were we on the same page before? :D
Thanks @L3MON4D3 , I got confused because I thought luasnip would match the snippet even if i wasn't writing the full word. Is there a way to implement that?
luasnip only expands snippets if the whole trigger matches, cmp_luasnip should also list snippet-items if there is a partial match with the typed text.
So #incl
-> list snippet-items with cmp -> select one with <C-y>
-> snippet expands. At least that's how that should work.
Is this not working for you?
I am currently at commit
7552e65
and when running this code, the snippet does not expand. This happens for both LSP snippets and custom snippets.Configuration file:
Plugin file:
Example of what I see: