-
Notifications
You must be signed in to change notification settings - Fork 407
Integrating LaTeX3 syntax #1798
Description
This ticket is related to #1781 about adopting a syntax highlighter specific to vimtex.
Since February 2020 (more or less) the LaTeX3 programming layer (expl3) has been incorporated in the default LaTeX format (at least for pdflatex, lualatex and xelatex). It is used more and more and, for people that are programming packages, it is quite the layer to use nowadays.
Syntax highlight of expl3 code snippets is quite awful:
There is a plugin available at https://github.com/wtsnjp/vim-expl3 that makes things quite better:
But it has the problems that:
- it has to be switched manually (
set ft=expl3) - it acts on the whole file, and the highlighting of the "normal" part of the document is better handled with the existing highlighter.
The expl3 syntax should be enabled only:
- locally, for code enclosed in
\ExplSyntaxOnand\ExplSyntaxOff; - for the whole buffer, if the file starts with
\ProvideExplPackage,\ProvideExplClass,\ProvideExplFile.
A quick-and-dirty stopgap solution I use now is having in my .vimrc:
"
" latex3 syntax highlight fix
"
nnoremap <leader>3 :syn match texStatement "\\[a-zA-Z_:@]\+"<CR>
nnoremap <leader>2 :syn match texStatement "\\[a-zA-Z@]\+"<CR>and manually switching when needed, but at this point doing the same with the @wtsnjp package is quite better.
"
nnoremap <leader>3 :set ft=expl3<CR>
nnoremap <leader>2 :set ft=tex<CR>
