From f0fd1c5477b38161446d9f74e6f3df3f2f37cd49 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gonzalo=20Tornar=C3=ADa?= Date: Mon, 26 Jul 2021 22:35:54 -0300 Subject: [PATCH 1/7] \DeclareMathOperator: don't spell check body --- autoload/vimtex/syntax/p/amsmath.vim | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/autoload/vimtex/syntax/p/amsmath.vim b/autoload/vimtex/syntax/p/amsmath.vim index c9e1d784a8..601ab49a03 100644 --- a/autoload/vimtex/syntax/p/amsmath.vim +++ b/autoload/vimtex/syntax/p/amsmath.vim @@ -37,7 +37,7 @@ function! vimtex#syntax#p#amsmath#load(cfg) abort " {{{1 \ 'next': 'texDeclmathoperArgBody', \ 'contains': '' \}) - call vimtex#syntax#core#new_arg('texDeclmathoperArgBody') + call vimtex#syntax#core#new_arg('texDeclmathoperArgBody', {'contains': 'TOP,@Spell'}) " \tag{label} or \tag*{label} syntax match texMathCmd "\\tag\>\*\?" contained nextgroup=texMathTagArg @@ -53,6 +53,7 @@ function! vimtex#syntax#p#amsmath#load(cfg) abort " {{{1 highlight def link texCmdDeclmathoper texCmdNew highlight def link texDeclmathoperArgName texArgNew + highlight def link texDeclmathoperArgBody texMathZone highlight def link texMathConcealedArg texMathTextArg endfunction From 86eee47eccb38d43775253bc1ea9f6d302f2c467 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gonzalo=20Tornar=C3=ADa?= Date: Mon, 26 Jul 2021 22:51:25 -0300 Subject: [PATCH 2/7] \theoremstyle: don't spell check argument --- autoload/vimtex/syntax/p/amsthm.vim | 8 ++++++++ 1 file changed, 8 insertions(+) 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 From 891cf22617cd61e51e33c833e28db800d804f6b4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gonzalo=20Tornar=C3=ADa?= Date: Mon, 26 Jul 2021 22:51:47 -0300 Subject: [PATCH 3/7] \numberwithin: don't spell check arguments --- autoload/vimtex/syntax/p/amsmath.vim | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/autoload/vimtex/syntax/p/amsmath.vim b/autoload/vimtex/syntax/p/amsmath.vim index 601ab49a03..241c7f7cbd 100644 --- a/autoload/vimtex/syntax/p/amsmath.vim +++ b/autoload/vimtex/syntax/p/amsmath.vim @@ -31,6 +31,17 @@ 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' + \}) + " DeclareMathOperator syntax match texCmdDeclmathoper nextgroup=texDeclmathoperArgName skipwhite skipnl "\\DeclareMathOperator\>\*\?" call vimtex#syntax#core#new_arg('texDeclmathoperArgName', { @@ -52,9 +63,12 @@ function! vimtex#syntax#p#amsmath#load(cfg) abort " {{{1 endif highlight def link texCmdDeclmathoper texCmdNew + highlight def link texCmdNumberWithin 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 endfunction " }}}1 From dcdd6b9aabf88e797d2355b91a9bda6e51125aa3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gonzalo=20Tornar=C3=ADa?= Date: Mon, 26 Jul 2021 23:03:34 -0300 Subject: [PATCH 4/7] \subjclass: don't spell check arguments --- autoload/vimtex/syntax/p/amsmath.vim | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/autoload/vimtex/syntax/p/amsmath.vim b/autoload/vimtex/syntax/p/amsmath.vim index 241c7f7cbd..ba773f7c86 100644 --- a/autoload/vimtex/syntax/p/amsmath.vim +++ b/autoload/vimtex/syntax/p/amsmath.vim @@ -42,6 +42,17 @@ function! vimtex#syntax#p#amsmath#load(cfg) abort " {{{1 \ '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', { @@ -64,11 +75,14 @@ function! vimtex#syntax#p#amsmath#load(cfg) abort " {{{1 highlight def link texCmdDeclmathoper texCmdNew highlight def link texCmdNumberWithin 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 texSubjClassArg texArg + highlight def link texSubjClassOpt texOpt endfunction " }}}1 From 0fa9aec74ca5b4f05bcdc21dd3f11c8a8c1f419e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gonzalo=20Tornar=C3=ADa?= Date: Thu, 26 Aug 2021 18:29:38 -0300 Subject: [PATCH 5/7] \operatorname: don't spell check body --- autoload/vimtex/syntax/p/amsmath.vim | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/autoload/vimtex/syntax/p/amsmath.vim b/autoload/vimtex/syntax/p/amsmath.vim index ba773f7c86..394acac886 100644 --- a/autoload/vimtex/syntax/p/amsmath.vim +++ b/autoload/vimtex/syntax/p/amsmath.vim @@ -61,9 +61,15 @@ function! vimtex#syntax#p#amsmath#load(cfg) abort " {{{1 \}) 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 @@ -75,12 +81,14 @@ function! vimtex#syntax#p#amsmath#load(cfg) abort " {{{1 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 From 8c8099c63bc7281ba0d114895b6e12b1c9cad793 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gonzalo=20Tornar=C3=ADa?= Date: Thu, 26 Aug 2021 18:32:14 -0300 Subject: [PATCH 6/7] amsmath: add example and tests - \DeclareMathOperator - \operatorname - \numberwithin - \subjclass --- test/test-syntax/test-amsmath.tex | 9 ++++++++- test/test-syntax/test-amsmath.vim | 18 +++++++++++++++++- 2 files changed, 25 insertions(+), 2 deletions(-) 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() From 08308f16c974e8bf16a4f51a2064bac0d7ac60d4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gonzalo=20Tornar=C3=ADa?= Date: Thu, 26 Aug 2021 18:37:47 -0300 Subject: [PATCH 7/7] amsthm: add example and tests - \theoremstyle - \newtheorem - \begin{proof} - theorem-like environments --- test/test-syntax/test-amsthm.tex | 5 +++++ test/test-syntax/test-amsthm.vim | 21 +++++++++++++-------- 2 files changed, 18 insertions(+), 8 deletions(-) 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()