diff --git a/autoload/vimtex/syntax/p/amsmath.vim b/autoload/vimtex/syntax/p/amsmath.vim index c9e1d784a8..394acac886 100644 --- a/autoload/vimtex/syntax/p/amsmath.vim +++ b/autoload/vimtex/syntax/p/amsmath.vim @@ -31,17 +31,45 @@ function! vimtex#syntax#p#amsmath#load(cfg) abort " {{{1 syntax match texMathCmdEnv contained contains=texCmdMathEnv "\\end{x\?alignat\*\?}" syntax match texMathCmdEnv contained contains=texCmdMathEnv "\\end{xxalignat}" + " numberwithin + syntax match texCmdNumberWithin "\\numberwithin\>" + \ nextgroup=texNumberWithinArg1 skipwhite skipnl + call vimtex#syntax#core#new_arg('texNumberWithinArg1', { + \ 'next': 'texNumberWithinArg2', + \ 'contains': 'TOP,@Spell' + \}) + call vimtex#syntax#core#new_arg('texNumberWithinArg2', { + \ 'contains': 'TOP,@Spell' + \}) + + " subjclass + syntax match texCmdSubjClass "\\subjclass\>" + \ nextgroup=texSubjClassOpt,texSubjClassArg skipwhite skipnl + call vimtex#syntax#core#new_opt('texSubjClassOpt', { + \ 'next': 'texSubjClassArg', + \ 'contains': 'TOP,@Spell' + \}) + call vimtex#syntax#core#new_arg('texSubjClassArg', { + \ 'contains': 'TOP,@Spell' + \}) + " DeclareMathOperator syntax match texCmdDeclmathoper nextgroup=texDeclmathoperArgName skipwhite skipnl "\\DeclareMathOperator\>\*\?" call vimtex#syntax#core#new_arg('texDeclmathoperArgName', { \ 'next': 'texDeclmathoperArgBody', \ 'contains': '' \}) - call vimtex#syntax#core#new_arg('texDeclmathoperArgBody') + call vimtex#syntax#core#new_arg('texDeclmathoperArgBody', {'contains': 'TOP,@Spell'}) + + " operatorname + syntax match texCmdOpname nextgroup=texOpnameArg skipwhite skipnl "\\operatorname\>" + call vimtex#syntax#core#new_arg('texOpnameArg', { + \ 'contains': 'TOP,@Spell' + \}) " \tag{label} or \tag*{label} syntax match texMathCmd "\\tag\>\*\?" contained nextgroup=texMathTagArg - call vimtex#syntax#core#new_arg('texMathTagArg') + call vimtex#syntax#core#new_arg('texMathTagArg', {'contains': 'TOP,@Spell'}) " Conceal the command and delims of "\operatorname{ ... }" if g:vimtex_syntax_conceal.math_delimiters @@ -52,8 +80,17 @@ function! vimtex#syntax#p#amsmath#load(cfg) abort " {{{1 endif highlight def link texCmdDeclmathoper texCmdNew + highlight def link texCmdNumberWithin texCmd + highlight def link texCmdOpName texCmd + highlight def link texCmdSubjClass texCmd highlight def link texDeclmathoperArgName texArgNew + highlight def link texDeclmathoperArgBody texMathZone highlight def link texMathConcealedArg texMathTextArg + highlight def link texNumberWithinArg1 texArg + highlight def link texNumberWithinArg2 texArg + highlight def link texOpnameArg texMathZone + highlight def link texSubjClassArg texArg + highlight def link texSubjClassOpt texOpt endfunction " }}}1 diff --git a/autoload/vimtex/syntax/p/amsthm.vim b/autoload/vimtex/syntax/p/amsthm.vim index def523f5c8..fbb30f03db 100644 --- a/autoload/vimtex/syntax/p/amsthm.vim +++ b/autoload/vimtex/syntax/p/amsthm.vim @@ -15,7 +15,15 @@ function! vimtex#syntax#p#amsthm#load(cfg) abort " {{{1 \ 'contains': 'TOP,@NoSpell' \}) + syntax match texCmdThmStyle "\\theoremstyle\>" + \ nextgroup=texThmStyleArg skipwhite skipnl + call vimtex#syntax#core#new_arg('texThmStyleArg', { + \ 'contains': 'TOP,@Spell' + \}) + + highlight def link texCmdThmStyle texCmd highlight def link texProofEnvOpt texEnvOpt + highlight def link texThmStyleArg texArg endfunction " }}}1 diff --git a/test/test-syntax/test-amsmath.tex b/test/test-syntax/test-amsmath.tex index e2a79dd64c..04235533bd 100644 --- a/test/test-syntax/test-amsmath.tex +++ b/test/test-syntax/test-amsmath.tex @@ -1,6 +1,13 @@ -\documentclass{article} +\documentclass{amsart} \usepackage{amsmath} +\DeclareMathOperator{\GL}{GL} +\newcommand{\SL}{\operatorname{SL}} + +\numberwithin{equation}{section} + +\subjclass[2010]{Primary: 11F67} + \begin{document} \begin{align} diff --git a/test/test-syntax/test-amsmath.vim b/test/test-syntax/test-amsmath.vim index 4821e708a9..482146b290 100644 --- a/test/test-syntax/test-amsmath.vim +++ b/test/test-syntax/test-amsmath.vim @@ -2,7 +2,23 @@ source common.vim silent edit test-amsmath.tex +set spell + if empty($INMAKE) | finish | endif +call assert_true(vimtex#syntax#in('texCmdDeclmathoper', 4, 1)) +call assert_true(vimtex#syntax#in('texDeclmathoperArgName', 4, 22)) +call assert_true(vimtex#syntax#in('texDeclmathoperArgBody', 4, 27)) + +call assert_true(vimtex#syntax#in('texCmdOpname', 5, 18)) +call assert_true(vimtex#syntax#in('texOpnameArg', 5, 32)) + +call assert_true(vimtex#syntax#in('texCmdNumberWithin', 7, 1)) +call assert_true(vimtex#syntax#in('texNumberWithinArg1', 7, 15)) +call assert_true(vimtex#syntax#in('texNumberWithinArg2', 7, 25)) + +call assert_true(vimtex#syntax#in('texCmdSubjClass', 9, 1)) +call assert_true(vimtex#syntax#in('texSubjClassOpt', 9, 12)) +call assert_true(vimtex#syntax#in('texSubjClassArg', 9, 18)) -quit! +call vimtex#test#finished() diff --git a/test/test-syntax/test-amsthm.tex b/test/test-syntax/test-amsthm.tex index c8e9ed3323..264f628a24 100644 --- a/test/test-syntax/test-amsthm.tex +++ b/test/test-syntax/test-amsthm.tex @@ -1,6 +1,7 @@ \documentclass{article} \usepackage{amsthm} +\theoremstyle{plain} \newtheorem{thm}{Theorem}[section] \newtheorem{prp}[thm]{Proposition} \newtheorem{lemma}{Lemma} @@ -19,4 +20,8 @@ A lemma here. \end{lemma} +\begin{proof}[Proof of theorem abc] + Proof goes here. +\end{proof} + \end{document} diff --git a/test/test-syntax/test-amsthm.vim b/test/test-syntax/test-amsthm.vim index a1c0048e14..6b5047ed0f 100644 --- a/test/test-syntax/test-amsthm.vim +++ b/test/test-syntax/test-amsthm.vim @@ -6,15 +6,20 @@ set spell if empty($INMAKE) | finish | endif -call assert_true(vimtex#syntax#in('texNewthmOptNumberby', 4, 32)) -call assert_true(vimtex#syntax#in('texNewthmOptCounter', 5, 19)) +call assert_true(vimtex#syntax#in('texCmdThmStyle', 4, 1)) +call assert_true(vimtex#syntax#in('texThmStyleArg', 4, 15)) +call assert_true(vimtex#syntax#in('texNewthmOptNumberby', 5, 32)) +call assert_true(vimtex#syntax#in('texNewthmOptCounter', 6, 19)) -call assert_true(vimtex#syntax#in('texTheoremEnvBgn', 10, 1)) -call assert_true(vimtex#syntax#in('texTheoremEnvBgn', 14, 1)) -call assert_true(vimtex#syntax#in('texTheoremEnvBgn', 18, 1)) +call assert_true(vimtex#syntax#in('texProofEnvBgn', 23, 1)) +call assert_true(vimtex#syntax#in('texProofEnvOpt', 23, 15)) -call assert_true(vimtex#syntax#in('texTheoremEnvOpt', 10, 36)) -call assert_true(vimtex#syntax#in('texCmdRefConcealed', 10, 42)) -call assert_true(vimtex#syntax#in('texRefConcealedArg', 10, 47)) +call assert_true(vimtex#syntax#in('texTheoremEnvBgn', 11, 1)) +call assert_true(vimtex#syntax#in('texTheoremEnvBgn', 15, 1)) +call assert_true(vimtex#syntax#in('texTheoremEnvBgn', 19, 1)) + +call assert_true(vimtex#syntax#in('texTheoremEnvOpt', 11, 36)) +call assert_true(vimtex#syntax#in('texCmdRefConcealed', 11, 42)) +call assert_true(vimtex#syntax#in('texRefConcealedArg', 11, 47)) call vimtex#test#finished()