Skip to content

Syntax definitions for Chemformula package. #2235

@Neelfrost

Description

@Neelfrost

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:

  1. In line with text: Zinc deposition (\ch{Zn^{2+} + 2 e^{-} -> Zn}) at \SI{<-0.76}{\V}.
  2. 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.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions