rafamadriz / friendly-snippets

Set of preconfigured snippets for different languages.
MIT License
1.96k stars 441 forks source link

Escaping in LaTeX snippets involving math #459

Closed pitkling closed 2 months ago

pitkling commented 4 months ago

The vscode LaTeX snippets that involve math (or at least some of them) do not properly escape the math delimiter $. See for example the Inline Math snippet. It's body is $ $1 $$0, but from the vscode grammar definition I would have expected the body should be \\$ $1 \\$$0 (double escape necessary because of the JSON file format).

Is this intended? It seems some snippet engines can cope without the escaping (e.g., LuaSnip plugin for Neovim), while others (like the integrated snippet expansion in Neovim 10+ via vim.snippet.expand) choke on the unescaped snippets.

DimitrisDimitropoulos commented 3 months ago

I think you are correct. I tested your suggestion and it seems to work as expected, at least with luasnip. I think that the escaping fixes the issue with native snippets. I created a PR #473

OkelleyDevelopment commented 2 months ago

That PR has been merged, perhaps @pitkling can confirm as well?

pitkling commented 2 months ago

Great, thanks @DimitrisDimitropoulos! The updated snippets work fine with the native snippet expansion :).

I spotted a few more that need a similar update: Pretty much every snippet in vscode-latex-snippets.json that has a line containing addlegendentry does not properly escape the math inside the addlegendentry macro. The only such snippet that does the escaping correctly at the moment is plotgraph3d. Other than that, I think the remaining math-related snippets in that file are ok.

OkelleyDevelopment commented 2 months ago

Just approved and merged #476. If @pitkling can confirm, then I think this issue can be (finally) closed :partying_face:

pitkling commented 2 months ago

Everything seems fine now, thanks! :)