evesdropper / luasnip-latex-snippets.nvim

A set of preconfigured snippets for LaTeX for the snippet engine LuaSnip.
https://evesdropper.dev/files/luasnip/
MIT License
66 stars 9 forks source link

Auto snippet matches alpha and \alpha #5

Closed mmiddlezong closed 4 months ago

mmiddlezong commented 4 months ago

Hey, just wanted to say I really appreciate this plugin. In math mode, typing alpha turns into \alpha and typing \alpha turns into \\alpha. Is this intended? I would expect typing \alpha to not trigger the snippet and return \alpha (unaffected). This issue is not noticed with \angle, for example.

evesdropper commented 4 months ago

Ah, this is because there's no regex pattern to prevent this snippet from triggering again when prefaced by a backslash. This should be a pretty quick fix; it should be updated now.

mmiddlezong commented 4 months ago

Thank you for the quick response and fix!

mmiddlezong commented 4 months ago

A similar issue exists with \sqrt, and I've implemented a similar fix in my fork of this repository but wanted to let you know.

evesdropper commented 4 months ago

Essentially the issue lies with snippets which have some trigger trig but produce something like \trig[optional stuff]; therefore I found a more efficient fix - just need to put a check that context.trig is contained within the command. This also eliminates the need for the backslash flag.