LuaSnip icon indicating copy to clipboard operation
LuaSnip copied to clipboard

Adding custom conditions to snip mate snippets

Open haasal opened this issue 1 year ago • 3 comments

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")),

haasal avatar Aug 29 '24 14:08 haasal

No, not really, but you can do

ls.parser.parse_snipmate({ trig = "@a", condition = tex.math_mode }, "\\alpha"),

L3MON4D3 avatar Aug 30 '24 08:08 L3MON4D3

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.

haasal avatar Aug 30 '24 16:08 haasal

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 :)

L3MON4D3 avatar Aug 30 '24 20:08 L3MON4D3