runtime(tex): add amsmath support to tex syntax script
Commit:
https://github.com/vim/vim/commit/05e44e978fc7acb5314ce16f5a41d8e75d34bd21
Author: Eisuke Kawashima <
e-k...@users.noreply.github.com>
Date: Mon Sep 29 19:43:51 2025 +0000
runtime(tex): add amsmath support to tex syntax script
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-k...@users.noreply.github.com>
Signed-off-by: Christian Brabandt <
c...@256bit.org>
diff --git a/runtime/syntax/testdir/dumps/tex_03_00.dump b/runtime/syntax/testdir/dumps/tex_03_00.dump
new file mode 100644
index 000000000..36fa6e801
--- /dev/null
+++ b/runtime/syntax/testdir/dumps/tex_03_00.dump
@@ -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
index 000000000..25d57eab3
--- /dev/null
+++ b/runtime/syntax/testdir/input/tex_03.tex
@@ -0,0 +1,11 @@
+\documentclass{article}
+\usepackage{amsmath}
+ egin{document}
+ egin{align}
+ egin{bmatrix}
+ 1 & x & x^{2} \
+ 1 & y & y^{2} \
+ 1 & z & z^{2} \
+ nd{bmatrix}
+ nd{align}
+ nd{document}
diff --git a/runtime/syntax/tex.vim b/runtime/syntax/tex.vim
index 109ce61b7..ec9d90510 100644
--- a/runtime/syntax/tex.vim
+++ b/runtime/syntax/tex.vim
@@ -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,
"
ewcommand and
ewenvironment #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*
.\)"
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'