LuaSnip
LuaSnip copied to clipboard
Adding custom conditions to snip mate snippets
Is there any way to apply conditions to snip mate snippets?
I.e. is there a way to do the following but as a snip-mate snippet?
s({ trig = "@a", condition = tex.math_mode }, t("\\alpha")),
No, not really, but you can do
ls.parser.parse_snipmate({ trig = "@a", condition = tex.math_mode }, "\\alpha"),
Thanks! Do you think this would be a feature worth implementing? Either by extending the snipmate syntax (probably a lot of work) or by adding a parameter to the snip-mate/vscode loader.
TBH, I don't think so. Writing the snippet-body in snipmate is very comfortable, and defining all the options to the snippets in lua is great because we don't need custom parsing/don't need to think about how to define all these operators. The only minor downside is that one may have to create a second snippet-collection, but that's pretty simple with the lua-loader :)