LuaSnip
LuaSnip copied to clipboard
LSP + LuaSnip / Friendly-Snippets multiple popups
Hi, I stumbled upon the following issue, using nvim-cmp, LuaSnip and friendly snippets.
For scss and using for example 'dis' for 'display' [snippet], and letting expand the friendliest snippet I get the following popup:
. As you can see, there is a 'cmp' popup as well a LSP popup. The snip popup is generated by this code.

As you can see in the gif above, after pressing <C> first the LuaSnip PopUp appears and shortly after that, the LSP PopUp overlaps the LuaSnip PopUP.
How do I prevent the LSP popup and only use the Lua Snip selection popup on pressing <CR>?
== Feek
Hey :) Sounds like you'll have to dynamically turn off cmp's autocompletion, take a look at cmps github, maybe there already are instructions on how to do this.
HI @L3MON4D3, I already expected some like that, but on searching no results so far....
It happens also for a Lua Snippet:
ls.parser.parse_snippet(
{trig = "nice"},
"nice: ${1|test1,test2,test3,test4,test5|} ${2:edit}"
),
but you only want to disable cmp lsp for an option, like ${1|...} but for ${2} (as "inset mode") you definitely want to keep LSP insertions active (for setting variables).
hi
Maybe something like this:
enabled = function()
if luasnip.jumpable() then
return false
else
return true
end
end
see. But I'am not sure what condition of luasnip I should use luasnip.expand_or_jumpable() ? luasnip.expand_or_jump()
Hi, when using the following code:
enabled = function()
if ( luasnip.expand_or_jumpable() and luasnip.choice_active() ) then
return false
else
return true
end
end
the expanding is almost going as expected. But it seems like choice_active() is only true when the choice is expanded as popup not when the cursor is on the current choice position (before pressing tab to expand the choice).
So is there a condition combinations that's return true for entering the choice position?
Ahh, you could just set some global boolean when the choice-window is opened (set in choice_popup, unset in choice_popup_close) and check it in enabled
Hi @L3MON4D3 , thnx again for the prompt reply..... I'am quite new in the vim and lua world, so sorry for being a 'noob' .
No I do not think so, that will do the trick because the LSP is triggered before the choice popup is opened. I'am looking for a kind of "on_choice" (before activate choice).
Ad how do I set a global variable inside the choice_popup?
I'am quite new in the vim and lua world, so sorry for being a 'noob' .
No worries about that, it's pretty rough to get up to speed
Normally, the choiceNode-popup should open immediately after jumping to the choiceNode, I'd be stumped if it doesn't.
Maybe the currently open cmp-window has to be closed too, there's probably some api-call to do so.
I'am looking for a kind of "on_choice" (before activate choice).
Take a look here, that's also how the choiceNode-popup works.
Ad how do I set a global variable inside the choice_popup?
Oh, just
my_global_var = "global value"
(eg. just omit the local from the variable-declaration)