Closed Alexandre867 closed 2 years ago
I found out I can fix it by manually adding every custom environment using
call vimtex#syntax#core#new_region_math('nsflalign')
for example in my ftplugin/tex.vim.
This is precisely how you should handle this specific case.
Is it possible to have vimtex detect custom math environment?
No, that's too hard. Sorry!
Do you have any clue why putting that line in my ftplugin/tex.vim does not work, but typing it in the command line after a tex file is loaded works?
Thanks for that questions - it shows that I was too quick in my previous reply!
You need to execute that line after the VimTeX syntax scripts have executed. Putting the line in your personal ftplugin/tex.vim
does not ensure this. A more appropriate place to put this (and similar) customizations would be in your after/syntax/tex.vim
, because this script will be executed after all the main syntax scripts.
That works! I have another question: is there a way to disable conceal in certain environments?
Partly; you can control the conceal options with :help g:vimtex_syntax_conceal
. It is not very customizable, sorry.
It would be easier to answer a concrete question, though...
For example, I want math-mode highlighting but not math-mode conceal inside the environment tikzcd
, since I want to be able to align by &
(tikzcd
turns on math mode on the inside and it is fundamentally a tabular
-like environment); I added it to the list of math env delimiters for the former purpose, but then the math symbols are concealed, making manual alignment useless.
Yes, that sounds like an understandable thing to want.
However, I am sorry to say it is currently not possible. Implementing support for this would be a lot of work, and I don't really have the time for it. I would need to change some core ideas for the syntax highlighting of math zones.
I personally don't like conceals at all, so I have them disabled. I think you will need to consider that as an option.
Is it possible to have vimtex detect custom math environment? It's causing me issues when using context-dependant snippets.
I found out I can fix it by manually adding every custom environment using
call vimtex#syntax#core#new_region_math('nsflalign')
for example in my ftplugin/tex.vim.Here's a .tex example, with how it looks without and with adding the custom environment manually.