]> git.ipfire.org Git - thirdparty/vim.git/commitdiff
runtime(tex): add amsmath support to tex syntax script
authorEisuke Kawashima <e-kwsm@users.noreply.github.com>
Mon, 29 Sep 2025 19:43:51 +0000 (19:43 +0000)
committerChristian Brabandt <cb@256bit.org>
Mon, 29 Sep 2025 19:43:51 +0000 (19:43 +0000)
Problem:  tex syntax file does not support some of the math equation
          environments provided by amsmath.sty, therefore well-formed
          snippet is highlighted as "texBadMath"
Solution: add the environments

closes: #18433

Signed-off-by: Eisuke Kawashima <e-kwsm@users.noreply.github.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
runtime/syntax/testdir/dumps/tex_03_00.dump [new file with mode: 0644]
runtime/syntax/testdir/input/tex_03.tex [new file with mode: 0644]
runtime/syntax/tex.vim

diff --git a/runtime/syntax/testdir/dumps/tex_03_00.dump b/runtime/syntax/testdir/dumps/tex_03_00.dump
new file mode 100644 (file)
index 0000000..36fa6e8
--- /dev/null
@@ -0,0 +1,20 @@
+>\+0#af5f00255#ffffff0|d|o|c|u|m|e|n|t|c|l|a|s@1|{+0#e000e06&|a|r|t|i|c|l|e|}| +0#0000000&@51
+|\+0#af5f00255&|u|s|e|p|a|c|k|a|g|e|{+0#e000e06&|a|m|s|m|a|t|h|}| +0#0000000&@54
+|\+0#e000e06&|b|e|g|i|n|{|d|o|c|u|m|e|n|t|}| +0#0000000&@58
+|\+0#af5f00255&|b|e|g|i|n|{+0#e000e06&|a|l|i|g|n|}| +0#0000000&@61
+| +0#e000e06&@7|\+0#af5f00255&|b|e|g|i|n|{+0#e000e06&|b|m|a|t|r|i|x|}| +0#0000000&@51
+| +0#e000e06&@15|1| |&| |x| |&| |x|^|{|2+0#af5f00255&|}+0#e000e06&| |\@1| +0#0000000&@42
+| +0#e000e06&@15|1| |&| |y| |&| |y|^|{|2+0#af5f00255&|}+0#e000e06&| |\@1| +0#0000000&@42
+| +0#e000e06&@15|1| |&| |z| |&| |z|^|{|2+0#af5f00255&|}+0#e000e06&| |\@1| +0#0000000&@42
+| +0#e000e06&@7|\+0#af5f00255&|e|n|d|{+0#e000e06&|b|m|a|t|r|i|x|}| +0#0000000&@53
+|\+0#af5f00255&|e|n|d|{+0#e000e06&|a|l|i|g|n|}| +0#0000000&@63
+|\+0#e000e06&|e|n|d|{|d|o|c|u|m|e|n|t|}| +0#0000000&@60
+|~+0#4040ff13&| @73
+|~| @73
+|~| @73
+|~| @73
+|~| @73
+|~| @73
+|~| @73
+|~| @73
+| +0#0000000&@56|1|,|1| @10|A|l@1| 
diff --git a/runtime/syntax/testdir/input/tex_03.tex b/runtime/syntax/testdir/input/tex_03.tex
new file mode 100644 (file)
index 0000000..25d57ea
--- /dev/null
@@ -0,0 +1,11 @@
+\documentclass{article}
+\usepackage{amsmath}
+\begin{document}
+\begin{align}
+       \begin{bmatrix}
+               1 & x & x^{2} \\
+               1 & y & y^{2} \\
+               1 & z & z^{2} \\
+       \end{bmatrix}
+\end{align}
+\end{document}
index 109ce61b787e7aa1dfc3fcf7e67a525f296c1b60..ec9d90510ddb3ac295137778e8ff143d8d18f416 100644 (file)
@@ -7,6 +7,7 @@
 "   2025 Jan 18 by Vim Project: add texEmphStyle to texMatchGroup, #16228
 "   2025 Feb 08 by Vim Project: improve macro option, \providecommand, 
 "                               \newcommand and \newenvironment #16543
+"   2025 Sep 29 by Vim Project: add amsmath support #18433
 " Version:     121
 " Former URL:  http://www.drchip.org/astronaut/vim/index.html#SYNTAX_TEX
 "
@@ -443,7 +444,7 @@ endif
 " Bad Math (mismatched): {{{1
 if !exists("g:tex_no_math") && !s:tex_no_error
  syn match texBadMath          "\\end\s*{\s*\(array\|[bBpvV]matrix\|split\|smallmatrix\)\s*}"
- syn match texBadMath          "\\end\s*{\s*\(displaymath\|equation\|eqnarray\|math\)\*\=\s*}"
+ syn match texBadMath          "\\end\s*{\s*\(align\|alignat\|displaymath\|eqnarray\|equation\|flalign\|gather\|math\|multline\)\*\=\s*}"
  syn match texBadMath          "\\[\])]"
  syn match texBadPar   contained  "\%(\\par\>\|^\s*\n.\)"
 endif
@@ -487,6 +488,11 @@ if !exists("g:tex_no_math")
  call TexNewMathZone("B","eqnarray",1)
  call TexNewMathZone("C","equation",1)
  call TexNewMathZone("D","math",1)
+ call TexNewMathZone("E","align",1)
+ call TexNewMathZone("F","alignat",1)
+ call TexNewMathZone("G","flalign",1)
+ call TexNewMathZone("H","gather",1)
+ call TexNewMathZone("I","multline",1)
 
  " Inline Math Zones: {{{2
  if s:tex_fast =~# 'M'