-
Notifications
You must be signed in to change notification settings - Fork 407
Syntax definitions for Chemformula package. #2235
Copy link
Copy link
Closed
Labels
Description
Chemformula is a comprehensive package for chemistry-related typesetting. It features a single main command: \ch{}.
VimTeX offers a very handy function to check whether the cursor (scope?) is currently in a "mathzone". This is really useful in defining math-specific snippets. I would like to replicate this functionality with \ch{}.
The \ch{} command has 2 use cases:
- In line with text:
Zinc deposition (\ch{Zn^{2+} + 2 e^{-} -> Zn}) at \SI{<-0.76}{\V}. - Inside a math environment:
\begin{gather(align, etc.)}
\beforetext{Metal oxidation} \ch{M -> M^{n+} + ne^{-}}
\end{gather}
Describe the solution you'd like
Since vimtex#syntax#in_mathzone() relies on syntax definitions, I would like similar syntax definitions for \ch{}.
Describe alternatives you've considered
I have tried the following:
syntax match texChemCmd nextgroup=texChemArgs skipwhite "\\ch\>"
call vimtex#syntax#core#new_arg('texChemArgs', {'opts': 'contained transparent'})
This works for inline \ch, but not within math environments.
Reactions are currently unavailable