latex-lsp / texlab

An implementation of the Language Server Protocol for LaTeX
GNU General Public License v3.0
1.55k stars 53 forks source link

LaTeX 3 support (expl3) #410

Open hcsch opened 3 years ago

hcsch commented 3 years ago

When writing packages LaTeX3 provides many a benefit over LaTeX2e. One of these is a "new" uniform syntax for macros which integrates namespacing and information about the macros parameters (e.g. \fp_sub:Nn). There is also the notion of private macros, which use two underscores before the module name, rather than one (e.g. \g__mylib_some_internal_flag_bool) in case of a variable or none in case of a function. LaTeX3 provides many convenient interfaces for manipulation of different kinds of data (e.g. comma separated lists, sequences and stacks, key-value options, error / warning / info log messages, templating etc.), so I prefer using that for the few packages I write (mostly for myself, as-needed).

While I don't know exactly how many packages use LaTeX3 syntax today, I do know that a couple really popular ones like siunitx, fontspec, biblatex, polyglossia, microtype and probably some more make use of it.

Currently I already am using TeXLab to write LaTeX3 code, but I feel like at least the syntax highlighting could use some improvements. Currently the module name or gobal/local variable prefix gets highlighted in blue (unlike with normal macros where the whole macro name is highlighted), but information like whether or not a macro is private or public are not considered. In case of a private macro function, the leading \_ gets highlighted and the rest stays the default text color. I'm honestly unsure of what else is feasible to implement that could be helpful for LaTeX3 development. A thing that would be really nice is documentation for the LaTeX3 interfaces on hover, but I can imagine that being anything but simple to extract and display in a sensible format.

See http://mirrors.ctan.org/macros/latex/contrib/l3kernel/expl3.pdf and other documents from https://ctan.org/pkg/l3kernel and related packages for details on the syntax. The linked PDF gives a (IMO) pretty good introduction to LaTeX 3 and is probably the document to go after.

lukeflo commented 11 months ago

Are there any news on this resp. is any progress made regarding this enhancement? I want to use a Latex lsp with emacs eglot package. Its working as supposed -- for regualr latex2e syntax. Unfortunatley, latex3 seems not to be supported so far. Since most of my packages rely heavily on latex3 a lsp support would be great! The other Latex lsp usable with eglot, digestif, is missing latex3 support as well...