-
Notifications
You must be signed in to change notification settings - Fork 391
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Custom syntax cmd gets overwritten on package detection #2629
Comments
The reason is that VimTeX has syntax addons for these packages:
These addons are loaded on demand after compilation. Since the addons define syntax for the specified commands, they will overload the user customization. If my intuition is right, you should have the same issue even if the packages are not commented out when you load the file? |
Yes, exactly. When the packages are not commented out on load, the same behavior happens. In the meantime, I found out that I can disable loading those syntax addons via I was wondering whether the custom syntax can be applied after / on top of the predefined syntax addons. |
Thanks for confirming.
Yes, you are correct on both accounts. The functionality you loose is (subjectively) better syntax highlighting of several commands from those packages, including
Well, perhaps, but only partially. The syntax extensions from latex packages are loaded in two different stages:
The purpose of 2 is to load syntax extensions after the So, what we can do here is to move the custom syntax to the end of stage 1. That should work in most cases, but it may be overriden in stage 2. One minor issue with this is that it will create an inconsistent behaviour. E.g., with your minimal example. Start with a fresh uncompiled project with the This inconsistency may be harder for people to recognize and debug. Still, I'm tempted to go with this, because I think it will be closer to what users would expected. Do you agree? |
I think my favoured solution would be that syntax customisations gets applied both after stage 1 and after stage 2. The solution you suggested creates an inconsistency that is even more likely to create user confusion, as it is unclear why the override works on one stage, but not the other. I had been confused myself, but once realising that package detection caused the issue, the behaviour made sense. But that might come from my particular use case, where I generally always turn the continuous compilation of the file on while working. So I rarely am in that spot in between stage 1 and 2, where customisations apply. Of course, I have no idea at all whether my suggestion is easy to implement. |
Yes, I agree. Choosing between imperfects.
That should be possible, yes. It would add a minor cost, but I think it is negligible. Let's try it; please open an issue if you should find any issues afterwards. |
Tried out the update and it seems to be working great. Appreciate the effort! ❤️ |
Glad to hear it! |
Description
Custom syntax command for concealment breaks after vimtex detects the packages containing those commands.
Steps to reproduce
minimal.vim
minimal.tex
vim -u minimal.vim minimal.tex
<leader>ll
\ch
and\qty
commands before and after compilationExpected behavior
The custom conceal commands to work both before and after package detection.
Actual behavior
The custom conceal commands break when packages
chemformula
andsiunitx
are detected.Do you use a latexmkrc file?
No
VimtexInfo
The text was updated successfully, but these errors were encountered: