latex.tmbundle icon indicating copy to clipboard operation
latex.tmbundle copied to clipboard

expl3 syntax highlighting

Open yoblanco opened this issue 11 years ago • 5 comments

When would this be available? Is it planned to be added soon?

yoblanco avatar Mar 14 '14 15:03 yoblanco

Looking at the Latex 3 page it appears that it is still in a very incomplete state, I don't suspect that anyone will put the time into adding support until it gets closer to a usable state. I'm not aware of how great the differences are between the two versions but if it is too great it may be better to fork a new version of the bundle for it.

Going to close this issue to keep things cleaner since it's not something we plan to tackle soon.

infininight avatar Mar 31 '14 05:03 infininight

After a few time, here I'm again. Sorry for the late response.

There's no difference rather than : and _ can be included in macro names, that is

  • \somemacroname is the usual,
  • between \makeatletter and \makeatother the letter @ is also part of macro names, like \some@macro@name,
  • with expl3, now between \ExplSyntaxOn and \ExplSyntaxOff there can be : and _ in macro names (not @ in this case), like in \cs_new_protected_nopar:Npn.

It would be nice to add that, so names with _ and : between \ExplSyntaxOn and \ExplSyntaxOff are highlighted as macros (I'm not sure if that scoping is possible).

In case it's done, since _ and : are only intended to separate different parts of the macro name, it would be nice to highlight them in a “lighter” way, so it doesn't draw attention to them.

Moreover, the part after the : is the “signature”, which is also less relevant, and could also be highlighted in a “less important” color.

A little more info here: http://tex.stackexchange.com/questions/129439/latex3-sensitive-editors (It's particularly nice the WinEdt solution, but that's definitely some extra work, just adding : and _ to the accepted characters in macro names is enough.)

yoblanco avatar Jan 15 '15 18:01 yoblanco

Hi yoblanco,

I just reopened the issue. It might take some time until I have time to revisit this issue tough. I plan to fix the grammar related issue after after all the other problems are taken care of.

Kind regards, René

sanssecours avatar Jan 16 '15 15:01 sanssecours

It would be better if it was possible that kind of scoping, so in “normal” text \sum_a is \sum with a subscript _a. And only inside \ExplSyntaxOn .. \ExplSyntaxOff that \l_tmpa_tl is recognised as what it is: a macro. If that scoping is not possible, well, it's not perfect, but I think enabling : and _ globally would be nice. In case the scoping is possible it would be good also to scope @ in macro names only inside \makeatletter .. \makeatother.

EDIT: Yes, scoping is definitely possible: it's done with Lua code between \begin{luacode} and \end{luacode} (or, may be I'm mixing memories, it's from the ConTeXt bundle, in that case the Lua code is highlighted between \startlua and \stoplua). So it would be perfect to have, say, two “sublanguages”, LaTeX and expl3, so between \ExplSyntaxOn and \ExplSyntaxOff the highlighting rules are taken from expl3.

yoblanco avatar Jan 16 '15 22:01 yoblanco

Note that expl3 syntax has been added into LaTeX-workshop: LaTeX-Expl3.tmLanguage.json. Translate from json to plist is not difficult, so please consider to add it. Thank you!

stone-zeng avatar Sep 18 '19 18:09 stone-zeng