LuaSnip
LuaSnip copied to clipboard
Show a snippet only at "the top level"
Hello! Not a bug but more of a question :)
I'm struggling to make a snippet show up in completions only when at the top level of a file (so in an empty line). I've tried using the line parameter of show_condition, but that includes the trigger text.
How can I achieve this functionality?
main| // <- Show snippet triggered by main
int foo() {
main| // Don't show it here
}
Hi :)
Ah, using show_condition you'll have to manually remove the trigger-text (which may be trivial or not, depending on the trigEngine).
Maybe we should pass the snippet itself to show_condition then one could manually call snippet:matches(line_to_cursor) and get the complete trigger-region luasnip would use
Maybe we should pass the snippet itself to
show_conditionthen one could manually callsnippet:matches(line_to_cursor)and get the complete trigger-region luasnip would use
That sounds like a good idea! It might break some people's configs though, so we should notify them of the breaking change.
Oh, I would've passed it after the current line_to_cursor, there shouldn't be any breakage.
One small issue with changing what is passed to show_condition is that we aren't actually call it, that's the responsibility of eg. cmp_luasnip, so all of those plugins have to make a small change