blob: b8756a88fccf1095ad1207354a293f6ff7d651e4 [file] [log] [blame]
Bram Moolenaar071d4272004-06-13 20:20:40 +00001" Vim syntax file
2" Language: TeX
Bram Moolenaar488c6512005-08-11 20:09:58 +00003" Maintainer: Dr. Charles E. Campbell, Jr. <NdrchipO@ScampbellPfamily.AbizM>
Bram Moolenaard960d762011-09-21 19:22:10 +02004" Last Change: Aug 22, 2011
5" Version: 68
Bram Moolenaar488c6512005-08-11 20:09:58 +00006" URL: http://mysite.verizon.net/astronaut/vim/index.html#vimlinks_syntax
Bram Moolenaar071d4272004-06-13 20:20:40 +00007"
8" Notes: {{{1
9"
10" 1. If you have a \begin{verbatim} that appears to overrun its boundaries,
11" use %stopzone.
12"
13" 2. Run-on equations ($..$ and $$..$$, particularly) can also be stopped
14" by suitable use of %stopzone.
15"
16" 3. If you have a slow computer, you may wish to modify
17"
18" syn sync maxlines=200
19" syn sync minlines=50
20"
21" to values that are more to your liking.
22"
23" 4. There is no match-syncing for $...$ and $$...$$; hence large
24" equation blocks constructed that way may exhibit syncing problems.
25" (there's no difference between begin/end patterns)
26"
27" 5. If you have the variable "g:tex_no_error" defined then none of the
28" lexical error-checking will be done.
29"
30" ie. let g:tex_no_error=1
31
32" Version Clears: {{{1
33" For version 5.x: Clear all syntax items
34" For version 6.x: Quit when a syntax file was already loaded
35if version < 600
36 syntax clear
37elseif exists("b:current_syntax")
38 finish
39endif
Bram Moolenaar4b22cdb2010-08-02 22:12:46 +020040scriptencoding utf-8
Bram Moolenaar071d4272004-06-13 20:20:40 +000041
42" Define the default highlighting. {{{1
43" For version 5.7 and earlier: only when not done already
44" For version 5.8 and later: only when an item doesn't have highlighting yet
45if version >= 508 || !exists("did_tex_syntax_inits")
46 let did_tex_syntax_inits = 1
47 if version < 508
48 command -nargs=+ HiLink hi link <args>
49 else
50 command -nargs=+ HiLink hi def link <args>
51 endif
52endif
53if exists("g:tex_tex") && !exists("g:tex_no_error")
54 let g:tex_no_error= 1
55endif
56
Bram Moolenaar4b22cdb2010-08-02 22:12:46 +020057" let user determine which classes of concealment will be supported
Bram Moolenaar7fc0c062010-08-10 21:43:35 +020058" a=accents/ligatures d=delimiters m=math symbols g=Greek s=superscripts/subscripts
Bram Moolenaar4b22cdb2010-08-02 22:12:46 +020059if !exists("g:tex_conceal")
Bram Moolenaar7fc0c062010-08-10 21:43:35 +020060 let s:tex_conceal= 'admgs'
Bram Moolenaar4b22cdb2010-08-02 22:12:46 +020061else
62 let s:tex_conceal= g:tex_conceal
63endif
64
Bram Moolenaarf1f8bc52005-03-07 23:20:08 +000065" Determine whether or not to use "*.sty" mode {{{1
Bram Moolenaar071d4272004-06-13 20:20:40 +000066" The user may override the normal determination by setting
67" g:tex_stylish to 1 (for "*.sty" mode)
68" or to 0 else (normal "*.tex" mode)
69" or on a buffer-by-buffer basis with b:tex_stylish
Bram Moolenaar81af9252010-12-10 20:35:50 +010070let s:extfname=expand("%:e")
Bram Moolenaar071d4272004-06-13 20:20:40 +000071if exists("g:tex_stylish")
72 let b:tex_stylish= g:tex_stylish
73elseif !exists("b:tex_stylish")
Bram Moolenaar81af9252010-12-10 20:35:50 +010074 if s:extfname == "sty" || s:extfname == "cls" || s:extfname == "clo" || s:extfname == "dtx" || s:extfname == "ltx"
Bram Moolenaar071d4272004-06-13 20:20:40 +000075 let b:tex_stylish= 1
76 else
77 let b:tex_stylish= 0
78 endif
79endif
80
Bram Moolenaarf1f8bc52005-03-07 23:20:08 +000081" handle folding {{{1
82if !exists("g:tex_fold_enabled")
83 let g:tex_fold_enabled= 0
84elseif g:tex_fold_enabled && !has("folding")
Bram Moolenaarab194812005-09-14 21:40:12 +000085 let g:tex_fold_enabled= 0
Bram Moolenaarf1f8bc52005-03-07 23:20:08 +000086 echomsg "Ignoring g:tex_fold_enabled=".g:tex_fold_enabled."; need to re-compile vim for +fold support"
87endif
88if g:tex_fold_enabled && &fdm == "manual"
Bram Moolenaar00a927d2010-05-14 23:24:24 +020089 setl fdm=syntax
Bram Moolenaarf1f8bc52005-03-07 23:20:08 +000090endif
91
Bram Moolenaaradc21822011-04-01 18:03:16 +020092" (La)TeX keywords: uses the characters 0-9,a-z,A-Z,192-255 only... {{{1
Bram Moolenaar071d4272004-06-13 20:20:40 +000093" but _ is the only one that causes problems.
Bram Moolenaaradc21822011-04-01 18:03:16 +020094" One may override this iskeyword setting by providing
95" g:tex_isk
96if exists("g:tex_isk")
97 exe "setlocal isk=".g:tex_isk
Bram Moolenaar071d4272004-06-13 20:20:40 +000098else
Bram Moolenaaradc21822011-04-01 18:03:16 +020099 setlocal isk=48-57,a-z,A-Z,192-255
100endif
101if b:tex_stylish
102 setlocal isk+=@-@
Bram Moolenaar071d4272004-06-13 20:20:40 +0000103endif
Bram Moolenaard960d762011-09-21 19:22:10 +0200104if exists("g:tex_nospell") && g:tex_nospell && !exists("g:tex_comment_nospell")
105 let g:tex_comment_nospell= 1
106endif
Bram Moolenaar071d4272004-06-13 20:20:40 +0000107
108" Clusters: {{{1
109" --------
110syn cluster texCmdGroup contains=texCmdBody,texComment,texDefParm,texDelimiter,texDocType,texInput,texLength,texLigature,texMathDelim,texMathOper,texNewCmd,texNewEnv,texRefZone,texSection,texSectionMarker,texSectionName,texSpecialChar,texStatement,texString,texTypeSize,texTypeStyle
111if !exists("g:tex_no_error")
112 syn cluster texCmdGroup add=texMathError
113endif
114syn cluster texEnvGroup contains=texMatcher,texMathDelim,texSpecialChar,texStatement
Bram Moolenaar488c6512005-08-11 20:09:58 +0000115syn cluster texFoldGroup contains=texAccent,texBadMath,texComment,texDefCmd,texDelimiter,texDocType,texInput,texInputFile,texLength,texLigature,texMatcher,texMathZoneV,texMathZoneW,texMathZoneX,texMathZoneY,texMathZoneZ,texNewCmd,texNewEnv,texOnlyMath,texOption,texParen,texRefZone,texSection,texSectionMarker,texSectionZone,texSpaceCode,texSpecialChar,texStatement,texString,texTypeSize,texTypeStyle,texZone,@texMathZones,texTitle,texAbstract
Bram Moolenaard960d762011-09-21 19:22:10 +0200116if !exists("g:tex_nospell") || !g:tex_nospell
117 syn cluster texMatchGroup contains=texAccent,texBadMath,texComment,texDefCmd,texDelimiter,texDocType,texInput,texLength,texLigature,texMatcher,texNewCmd,texNewEnv,texOnlyMath,texParen,texRefZone,texSection,texSpecialChar,texStatement,texString,texTypeSize,texTypeStyle,texZone,texInputFile,texOption,@Spell
118 syn cluster texStyleGroup contains=texAccent,texBadMath,texComment,texDefCmd,texDelimiter,texDocType,texInput,texLength,texLigature,texNewCmd,texNewEnv,texOnlyMath,texParen,texRefZone,texSection,texSpecialChar,texStatement,texString,texTypeSize,texTypeStyle,texZone,texInputFile,texOption,texStyleStatement,@Spell,texStyleMatcher
119else
120 syn cluster texMatchGroup contains=texAccent,texBadMath,texComment,texDefCmd,texDelimiter,texDocType,texInput,texLength,texLigature,texMatcher,texNewCmd,texNewEnv,texOnlyMath,texParen,texRefZone,texSection,texSpecialChar,texStatement,texString,texTypeSize,texTypeStyle,texZone,texInputFile,texOption
121 syn cluster texStyleGroup contains=texAccent,texBadMath,texComment,texDefCmd,texDelimiter,texDocType,texInput,texLength,texLigature,texNewCmd,texNewEnv,texOnlyMath,texParen,texRefZone,texSection,texSpecialChar,texStatement,texString,texTypeSize,texTypeStyle,texZone,texInputFile,texOption,texStyleStatement,texStyleMatcher
122endif
Bram Moolenaarcfbc5ee2004-07-02 15:38:35 +0000123syn cluster texRefGroup contains=texMatcher,texComment,texDelimiter
Bram Moolenaar071d4272004-06-13 20:20:40 +0000124if !exists("tex_no_math")
125 syn cluster texMathZones contains=texMathZoneV,texMathZoneW,texMathZoneX,texMathZoneY,texMathZoneZ
126 syn cluster texMatchGroup add=@texMathZones
127 syn cluster texMathDelimGroup contains=texMathDelimBad,texMathDelimKey,texMathDelimSet1,texMathDelimSet2
128 syn cluster texMathMatchGroup contains=@texMathZones,texComment,texDefCmd,texDelimiter,texDocType,texInput,texLength,texLigature,texMathDelim,texMathMatcher,texMathOper,texNewCmd,texNewEnv,texRefZone,texSection,texSpecialChar,texStatement,texString,texTypeSize,texTypeStyle,texZone
Bram Moolenaar74cbdf02010-08-04 23:03:17 +0200129 syn cluster texMathZoneGroup contains=texComment,texDelimiter,texLength,texMathDelim,texMathMatcher,texMathOper,texMathSymbol,texMathText,texRefZone,texSpecialChar,texStatement,texTypeSize,texTypeStyle
Bram Moolenaar071d4272004-06-13 20:20:40 +0000130 if !exists("g:tex_no_error")
131 syn cluster texMathMatchGroup add=texMathError
132 syn cluster texMathZoneGroup add=texMathError
133 endif
Bram Moolenaar5b8d8fd2005-08-16 23:01:50 +0000134 syn cluster texMathZoneGroup add=@NoSpell
135 " following used in the \part \chapter \section \subsection \subsubsection
136 " \paragraph \subparagraph \author \title highlighting
137 syn cluster texDocGroup contains=texPartZone,@texPartGroup
138 syn cluster texPartGroup contains=texChapterZone,texSectionZone,texParaZone
139 syn cluster texChapterGroup contains=texSectionZone,texParaZone
140 syn cluster texSectionGroup contains=texSubSectionZone,texParaZone
141 syn cluster texSubSectionGroup contains=texSubSubSectionZone,texParaZone
142 syn cluster texSubSubSectionGroup contains=texParaZone
143 syn cluster texParaGroup contains=texSubParaZone
Bram Moolenaarb2c03502010-07-02 20:20:09 +0200144 if has("conceal") && &enc == 'utf-8'
Bram Moolenaare0021c72010-07-28 17:25:21 +0200145 syn cluster texMathZoneGroup add=texGreek,texSuperscript,texSubscript,texMathSymbol
146 syn cluster texMathMatchGroup add=texGreek,texSuperscript,texSubscript,texMathSymbol
Bram Moolenaarb2c03502010-07-02 20:20:09 +0200147 endif
Bram Moolenaar071d4272004-06-13 20:20:40 +0000148endif
149
150" Try to flag {} and () mismatches: {{{1
151if !exists("g:tex_no_error")
152 syn region texMatcher matchgroup=Delimiter start="{" skip="\\\\\|\\[{}]" end="}" contains=@texMatchGroup,texError
153 syn region texMatcher matchgroup=Delimiter start="\[" end="]" contains=@texMatchGroup,texError
154else
155 syn region texMatcher matchgroup=Delimiter start="{" skip="\\\\\|\\[{}]" end="}" contains=@texMatchGroup
156 syn region texMatcher matchgroup=Delimiter start="\[" end="]" contains=@texMatchGroup
157endif
Bram Moolenaard960d762011-09-21 19:22:10 +0200158if !exists("g:tex_nospell") || !g:tex_nospell
159 syn region texParen start="(" end=")" contains=@texMatchGroup,@Spell
160else
161 syn region texParen start="(" end=")" contains=@texMatchGroup
162endif
Bram Moolenaar071d4272004-06-13 20:20:40 +0000163if !exists("g:tex_no_error")
164 syn match texError "[}\])]"
165endif
166if !exists("tex_no_math")
167 if !exists("g:tex_no_error")
168 syn match texMathError "}" contained
169 endif
Bram Moolenaard960d762011-09-21 19:22:10 +0200170 syn region texMathMatcher matchgroup=Delimiter start="{" skip="\\\\\|\\}" end="}" end="%stopzone\>" contained contains=@texMathMatchGroup
171" syn region texMathMatcher matchgroup=Unique start="[^\\]\zs{" skip="\\\\\|\\[{}]" end="}" end="%stopzone\>" contained contains=@texMathMatchGroup
Bram Moolenaar071d4272004-06-13 20:20:40 +0000172endif
173
174" TeX/LaTeX keywords: {{{1
175" Instead of trying to be All Knowing, I just match \..alphameric..
176" Note that *.tex files may not have "@" in their \commands
177if exists("g:tex_tex") || b:tex_stylish
178 syn match texStatement "\\[a-zA-Z@]\+"
179else
180 syn match texStatement "\\\a\+"
181 if !exists("g:tex_no_error")
182 syn match texError "\\\a*@[a-zA-Z@]*"
183 endif
184endif
185
186" TeX/LaTeX delimiters: {{{1
187syn match texDelimiter "&"
188syn match texDelimiter "\\\\"
Bram Moolenaard960d762011-09-21 19:22:10 +0200189syn match texDelimiter "[{}]"
Bram Moolenaar071d4272004-06-13 20:20:40 +0000190
191" Tex/Latex Options: {{{1
192syn match texOption "[^\\]\zs#\d\+\|^#\d\+"
193
194" texAccent (tnx to Karim Belabas) avoids annoying highlighting for accents: {{{1
195if b:tex_stylish
196 syn match texAccent "\\[bcdvuH][^a-zA-Z@]"me=e-1
197 syn match texLigature "\\\([ijolL]\|ae\|oe\|ss\|AA\|AE\|OE\)[^a-zA-Z@]"me=e-1
198else
199 syn match texAccent "\\[bcdvuH]\A"me=e-1
200 syn match texLigature "\\\([ijolL]\|ae\|oe\|ss\|AA\|AE\|OE\)\A"me=e-1
201endif
202syn match texAccent "\\[bcdvuH]$"
203syn match texAccent +\\[=^.\~"`']+
204syn match texAccent +\\['=t'.c^ud"vb~Hr]{\a}+
205syn match texLigature "\\\([ijolL]\|ae\|oe\|ss\|AA\|AE\|OE\)$"
206
207" \begin{}/\end{} section markers: {{{1
208syn match texSectionMarker "\\begin\>\|\\end\>" nextgroup=texSectionName
Bram Moolenaar5c736222010-01-06 20:54:52 +0100209syn region texSectionName matchgroup=Delimiter start="{" end="}" contained nextgroup=texSectionModifier contains=texComment
210syn region texSectionModifier matchgroup=Delimiter start="\[" end="]" contained contains=texComment
Bram Moolenaar071d4272004-06-13 20:20:40 +0000211
212" \documentclass, \documentstyle, \usepackage: {{{1
213syn match texDocType "\\documentclass\>\|\\documentstyle\>\|\\usepackage\>" nextgroup=texSectionName,texDocTypeArgs
Bram Moolenaar5c736222010-01-06 20:54:52 +0100214syn region texDocTypeArgs matchgroup=Delimiter start="\[" end="]" contained nextgroup=texSectionName contains=texComment
Bram Moolenaar071d4272004-06-13 20:20:40 +0000215
Bram Moolenaara9a568c2006-03-14 23:04:27 +0000216" Preamble syntax-based folding support: {{{1
217if g:tex_fold_enabled && has("folding")
Bram Moolenaar5c736222010-01-06 20:54:52 +0100218 syn region texPreamble transparent fold start='\zs\\documentclass\>' end='\ze\\begin{document}' contains=texStyle,@texMatchGroup
Bram Moolenaara9a568c2006-03-14 23:04:27 +0000219endif
220
Bram Moolenaar071d4272004-06-13 20:20:40 +0000221" TeX input: {{{1
222syn match texInput "\\input\s\+[a-zA-Z/.0-9_^]\+"hs=s+7 contains=texStatement
Bram Moolenaar5c736222010-01-06 20:54:52 +0100223syn match texInputFile "\\include\(graphics\|list\)\=\(\[.\{-}\]\)\=\s*{.\{-}}" contains=texStatement,texInputCurlies,texInputFileOpt
Bram Moolenaar071d4272004-06-13 20:20:40 +0000224syn match texInputFile "\\\(epsfig\|input\|usepackage\)\s*\(\[.*\]\)\={.\{-}}" contains=texStatement,texInputCurlies,texInputFileOpt
225syn match texInputCurlies "[{}]" contained
Bram Moolenaar5c736222010-01-06 20:54:52 +0100226syn region texInputFileOpt matchgroup=Delimiter start="\[" end="\]" contained contains=texComment
Bram Moolenaar071d4272004-06-13 20:20:40 +0000227
228" Type Styles (LaTeX 2.09): {{{1
229syn match texTypeStyle "\\rm\>"
230syn match texTypeStyle "\\em\>"
231syn match texTypeStyle "\\bf\>"
232syn match texTypeStyle "\\it\>"
233syn match texTypeStyle "\\sl\>"
234syn match texTypeStyle "\\sf\>"
235syn match texTypeStyle "\\sc\>"
236syn match texTypeStyle "\\tt\>"
237
238" Type Styles: attributes, commands, families, etc (LaTeX2E): {{{1
239syn match texTypeStyle "\\textbf\>"
240syn match texTypeStyle "\\textit\>"
241syn match texTypeStyle "\\textmd\>"
242syn match texTypeStyle "\\textrm\>"
243syn match texTypeStyle "\\textsc\>"
244syn match texTypeStyle "\\textsf\>"
245syn match texTypeStyle "\\textsl\>"
246syn match texTypeStyle "\\texttt\>"
247syn match texTypeStyle "\\textup\>"
248syn match texTypeStyle "\\emph\>"
249
250syn match texTypeStyle "\\mathbb\>"
251syn match texTypeStyle "\\mathbf\>"
252syn match texTypeStyle "\\mathcal\>"
253syn match texTypeStyle "\\mathfrak\>"
254syn match texTypeStyle "\\mathit\>"
255syn match texTypeStyle "\\mathnormal\>"
256syn match texTypeStyle "\\mathrm\>"
257syn match texTypeStyle "\\mathsf\>"
258syn match texTypeStyle "\\mathtt\>"
259
260syn match texTypeStyle "\\rmfamily\>"
261syn match texTypeStyle "\\sffamily\>"
262syn match texTypeStyle "\\ttfamily\>"
263
264syn match texTypeStyle "\\itshape\>"
265syn match texTypeStyle "\\scshape\>"
266syn match texTypeStyle "\\slshape\>"
267syn match texTypeStyle "\\upshape\>"
268
269syn match texTypeStyle "\\bfseries\>"
270syn match texTypeStyle "\\mdseries\>"
271
272" Some type sizes: {{{1
273syn match texTypeSize "\\tiny\>"
274syn match texTypeSize "\\scriptsize\>"
275syn match texTypeSize "\\footnotesize\>"
276syn match texTypeSize "\\small\>"
277syn match texTypeSize "\\normalsize\>"
278syn match texTypeSize "\\large\>"
279syn match texTypeSize "\\Large\>"
280syn match texTypeSize "\\LARGE\>"
281syn match texTypeSize "\\huge\>"
282syn match texTypeSize "\\Huge\>"
283
284" Spacecodes (TeX'isms): {{{1
285" \mathcode`\^^@="2201 \delcode`\(="028300 \sfcode`\)=0 \uccode`X=`X \lccode`x=`x
286syn match texSpaceCode "\\\(math\|cat\|del\|lc\|sf\|uc\)code`"me=e-1 nextgroup=texSpaceCodeChar
287syn match texSpaceCodeChar "`\\\=.\(\^.\)\==\(\d\|\"\x\{1,6}\|`.\)" contained
288
289" Sections, subsections, etc: {{{1
Bram Moolenaard960d762011-09-21 19:22:10 +0200290if !exists("g:tex_nospell") || !g:tex_nospell
291 if g:tex_fold_enabled && has("folding")
292 syn region texDocZone matchgroup=texSection start='\\begin\s*{\s*document\s*}' end='\\end\s*{\s*document\s*}' fold contains=@texFoldGroup,@texDocGroup,@Spell
293 syn region texPartZone matchgroup=texSection start='\\part\>' end='\ze\s*\\\%(part\>\|end\s*{\s*document\s*}\)' fold contains=@texFoldGroup,@texPartGroup,@Spell
294 syn region texChapterZone matchgroup=texSection start='\\chapter\>' end='\ze\s*\\\%(chapter\>\|part\>\|end\s*{\s*document\s*}\)' fold contains=@texFoldGroup,@texChapterGroup,@Spell
295 syn region texSectionZone matchgroup=texSection start='\\section\>' end='\ze\s*\\\%(section\>\|chapter\>\|part\>\|end\s*{\s*document\s*}\)' fold contains=@texFoldGroup,@texSectionGroup,@Spell
296 syn region texSubSectionZone matchgroup=texSection start='\\subsection\>' end='\ze\s*\\\%(\%(sub\)\=section\>\|chapter\>\|part\>\|end\s*{\s*document\s*}\)' fold contains=@texFoldGroup,@texSubSectionGroup,@Spell
297 syn region texSubSubSectionZone matchgroup=texSection start='\\subsubsection\>' end='\ze\s*\\\%(\%(sub\)\{,2}section\>\|chapter\>\|part\>\|end\s*{\s*document\s*}\)' fold contains=@texFoldGroup,@texSubSubSectionGroup,@Spell
298 syn region texParaZone matchgroup=texSection start='\\paragraph\>' end='\ze\s*\\\%(paragraph\>\|\%(sub\)*section\>\|chapter\>\|part\>\|end\s*{\s*document\s*}\)' fold contains=@texFoldGroup,@texParaGroup,@Spell
299 syn region texSubParaZone matchgroup=texSection start='\\subparagraph\>' end='\ze\s*\\\%(\%(sub\)\=paragraph\>\|\%(sub\)*section\>\|chapter\>\|part\>\|end\s*{\s*document\s*}\)' fold contains=@texFoldGroup,@Spell
300 syn region texTitle matchgroup=texSection start='\\\%(author\|title\)\>\s*{' end='}' fold contains=@texFoldGroup,@Spell
301 syn region texAbstract matchgroup=texSection start='\\begin\s*{\s*abstract\s*}' end='\\end\s*{\s*abstract\s*}' fold contains=@texFoldGroup,@Spell
302 else
303 syn region texDocZone matchgroup=texSection start='\\begin\s*{\s*document\s*}' end='\\end\s*{\s*document\s*}' contains=@texFoldGroup,@texDocGroup,@Spell
304 syn region texPartZone matchgroup=texSection start='\\part\>' end='\ze\s*\\\%(part\>\|end\s*{\s*document\s*}\)' contains=@texFoldGroup,@texPartGroup,@Spell
305 syn region texChapterZone matchgroup=texSection start='\\chapter\>' end='\ze\s*\\\%(chapter\>\|part\>\|end\s*{\s*document\s*}\)' contains=@texFoldGroup,@texChapterGroup,@Spell
306 syn region texSectionZone matchgroup=texSection start='\\section\>' end='\ze\s*\\\%(section\>\|chapter\>\|part\>\|end\s*{\s*document\s*}\)' contains=@texFoldGroup,@texSectionGroup,@Spell
307 syn region texSubSectionZone matchgroup=texSection start='\\subsection\>' end='\ze\s*\\\%(\%(sub\)\=section\>\|chapter\>\|part\>\|end\s*{\s*document\s*}\)' contains=@texFoldGroup,@texSubSectionGroup,@Spell
308 syn region texSubSubSectionZone matchgroup=texSection start='\\subsubsection\>' end='\ze\s*\\\%(\%(sub\)\{,2}section\>\|chapter\>\|part\>\|end\s*{\s*document\s*}\)' contains=@texFoldGroup,@texSubSubSectionGroup,@Spell
309 syn region texParaZone matchgroup=texSection start='\\paragraph\>' end='\ze\s*\\\%(paragraph\>\|\%(sub\)*section\>\|chapter\>\|part\>\|end\s*{\s*document\s*}\)' contains=@texFoldGroup,@texParaGroup,@Spell
310 syn region texSubParaZone matchgroup=texSection start='\\subparagraph\>' end='\ze\s*\\\%(\%(sub\)\=paragraph\>\|\%(sub\)*section\>\|chapter\>\|part\>\|end\s*{\s*document\s*}\)' contains=@texFoldGroup,@Spell
311 syn region texTitle matchgroup=texSection start='\\\%(author\|title\)\>\s*{' end='}' contains=@texFoldGroup,@Spell
312 syn region texAbstract matchgroup=texSection start='\\begin\s*{\s*abstract\s*}' end='\\end\s*{\s*abstract\s*}' contains=@texFoldGroup,@Spell
313 endif
Bram Moolenaar293ee4d2004-12-09 21:34:53 +0000314else
Bram Moolenaard960d762011-09-21 19:22:10 +0200315 if g:tex_fold_enabled && has("folding")
316 syn region texDocZone matchgroup=texSection start='\\begin\s*{\s*document\s*}' end='\\end\s*{\s*document\s*}' fold contains=@texFoldGroup,@texDocGroup
317 syn region texPartZone matchgroup=texSection start='\\part\>' end='\ze\s*\\\%(part\>\|end\s*{\s*document\s*}\)' fold contains=@texFoldGroup,@texPartGroup
318 syn region texChapterZone matchgroup=texSection start='\\chapter\>' end='\ze\s*\\\%(chapter\>\|part\>\|end\s*{\s*document\s*}\)' fold contains=@texFoldGroup,@texChapterGroup
319 syn region texSectionZone matchgroup=texSection start='\\section\>' end='\ze\s*\\\%(section\>\|chapter\>\|part\>\|end\s*{\s*document\s*}\)' fold contains=@texFoldGroup,@texSectionGroup
320 syn region texSubSectionZone matchgroup=texSection start='\\subsection\>' end='\ze\s*\\\%(\%(sub\)\=section\>\|chapter\>\|part\>\|end\s*{\s*document\s*}\)' fold contains=@texFoldGroup,@texSubSectionGroup
321 syn region texSubSubSectionZone matchgroup=texSection start='\\subsubsection\>' end='\ze\s*\\\%(\%(sub\)\{,2}section\>\|chapter\>\|part\>\|end\s*{\s*document\s*}\)' fold contains=@texFoldGroup,@texSubSubSectionGroup
322 syn region texParaZone matchgroup=texSection start='\\paragraph\>' end='\ze\s*\\\%(paragraph\>\|\%(sub\)*section\>\|chapter\>\|part\>\|end\s*{\s*document\s*}\)' fold contains=@texFoldGroup,@texParaGroup
323 syn region texSubParaZone matchgroup=texSection start='\\subparagraph\>' end='\ze\s*\\\%(\%(sub\)\=paragraph\>\|\%(sub\)*section\>\|chapter\>\|part\>\|end\s*{\s*document\s*}\)' fold contains=@texFoldGroup
324 syn region texTitle matchgroup=texSection start='\\\%(author\|title\)\>\s*{' end='}' fold contains=@texFoldGroup
325 syn region texAbstract matchgroup=texSection start='\\begin\s*{\s*abstract\s*}' end='\\end\s*{\s*abstract\s*}' fold contains=@texFoldGroup
326 else
327 syn region texDocZone matchgroup=texSection start='\\begin\s*{\s*document\s*}' end='\\end\s*{\s*document\s*}' contains=@texFoldGroup,@texDocGroup
328 syn region texPartZone matchgroup=texSection start='\\part\>' end='\ze\s*\\\%(part\>\|end\s*{\s*document\s*}\)' contains=@texFoldGroup,@texPartGroup
329 syn region texChapterZone matchgroup=texSection start='\\chapter\>' end='\ze\s*\\\%(chapter\>\|part\>\|end\s*{\s*document\s*}\)' contains=@texFoldGroup,@texChapterGroup
330 syn region texSectionZone matchgroup=texSection start='\\section\>' end='\ze\s*\\\%(section\>\|chapter\>\|part\>\|end\s*{\s*document\s*}\)' contains=@texFoldGroup,@texSectionGroup
331 syn region texSubSectionZone matchgroup=texSection start='\\subsection\>' end='\ze\s*\\\%(\%(sub\)\=section\>\|chapter\>\|part\>\|end\s*{\s*document\s*}\)' contains=@texFoldGroup,@texSubSectionGroup
332 syn region texSubSubSectionZone matchgroup=texSection start='\\subsubsection\>' end='\ze\s*\\\%(\%(sub\)\{,2}section\>\|chapter\>\|part\>\|end\s*{\s*document\s*}\)' contains=@texFoldGroup,@texSubSubSectionGroup
333 syn region texParaZone matchgroup=texSection start='\\paragraph\>' end='\ze\s*\\\%(paragraph\>\|\%(sub\)*section\>\|chapter\>\|part\>\|end\s*{\s*document\s*}\)' contains=@texFoldGroup,@texParaGroup
334 syn region texSubParaZone matchgroup=texSection start='\\subparagraph\>' end='\ze\s*\\\%(\%(sub\)\=paragraph\>\|\%(sub\)*section\>\|chapter\>\|part\>\|end\s*{\s*document\s*}\)' contains=@texFoldGroup
335 syn region texTitle matchgroup=texSection start='\\\%(author\|title\)\>\s*{' end='}' contains=@texFoldGroup
336 syn region texAbstract matchgroup=texSection start='\\begin\s*{\s*abstract\s*}' end='\\end\s*{\s*abstract\s*}' contains=@texFoldGroup
337 endif
Bram Moolenaar293ee4d2004-12-09 21:34:53 +0000338endif
Bram Moolenaar071d4272004-06-13 20:20:40 +0000339
340" Bad Math (mismatched): {{{1
341if !exists("tex_no_math")
Bram Moolenaard960d762011-09-21 19:22:10 +0200342 syn match texBadMath "\\end\s*{\s*\(array\|gathered\|bBpvV]matrix\|split\|subequations\|smallmatrix\|xxalignat\)\s*}"
Bram Moolenaar071d4272004-06-13 20:20:40 +0000343 syn match texBadMath "\\end\s*{\s*\(align\|alignat\|displaymath\|displaymath\|eqnarray\|equation\|flalign\|gather\|math\|multline\|xalignat\)\*\=\s*}"
344 syn match texBadMath "\\[\])]"
345endif
346
347" Math Zones: {{{1
348if !exists("tex_no_math")
Bram Moolenaar488c6512005-08-11 20:09:58 +0000349 " TexNewMathZone: function creates a mathzone with the given suffix and mathzone name. {{{2
Bram Moolenaar071d4272004-06-13 20:20:40 +0000350 " Starred forms are created if starform is true. Starred
351 " forms have syntax group and synchronization groups with a
352 " "S" appended. Handles: cluster, syntax, sync, and HiLink.
353 fun! TexNewMathZone(sfx,mathzone,starform)
354 let grpname = "texMathZone".a:sfx
355 let syncname = "texSyncMathZone".a:sfx
Bram Moolenaar3577c6f2008-06-24 21:16:56 +0000356 if g:tex_fold_enabled
357 let foldcmd= " fold"
358 else
359 let foldcmd= ""
360 endif
Bram Moolenaar071d4272004-06-13 20:20:40 +0000361 exe "syn cluster texMathZones add=".grpname
Bram Moolenaar3577c6f2008-06-24 21:16:56 +0000362 exe 'syn region '.grpname.' start='."'".'\\begin\s*{\s*'.a:mathzone.'\s*}'."'".' end='."'".'\\end\s*{\s*'.a:mathzone.'\s*}'."'".' keepend contains=@texMathZoneGroup'.foldcmd
Bram Moolenaar071d4272004-06-13 20:20:40 +0000363 exe 'syn sync match '.syncname.' grouphere '.grpname.' "\\begin\s*{\s*'.a:mathzone.'\*\s*}"'
364 exe 'syn sync match '.syncname.' grouphere '.grpname.' "\\begin\s*{\s*'.a:mathzone.'\*\s*}"'
Bram Moolenaar5c736222010-01-06 20:54:52 +0100365 exe 'hi def link '.grpname.' texMath'
Bram Moolenaar071d4272004-06-13 20:20:40 +0000366 if a:starform
367 let grpname = "texMathZone".a:sfx.'S'
368 let syncname = "texSyncMathZone".a:sfx.'S'
369 exe "syn cluster texMathZones add=".grpname
Bram Moolenaar3577c6f2008-06-24 21:16:56 +0000370 exe 'syn region '.grpname.' start='."'".'\\begin\s*{\s*'.a:mathzone.'\*\s*}'."'".' end='."'".'\\end\s*{\s*'.a:mathzone.'\*\s*}'."'".' keepend contains=@texMathZoneGroup'.foldcmd
Bram Moolenaar071d4272004-06-13 20:20:40 +0000371 exe 'syn sync match '.syncname.' grouphere '.grpname.' "\\begin\s*{\s*'.a:mathzone.'\*\s*}"'
372 exe 'syn sync match '.syncname.' grouphere '.grpname.' "\\begin\s*{\s*'.a:mathzone.'\*\s*}"'
Bram Moolenaar5c736222010-01-06 20:54:52 +0100373 exe 'hi def link '.grpname.' texMath'
Bram Moolenaar071d4272004-06-13 20:20:40 +0000374 endif
375 endfun
376
377 " Standard Math Zones: {{{2
378 call TexNewMathZone("A","align",1)
379 call TexNewMathZone("B","alignat",1)
380 call TexNewMathZone("C","displaymath",1)
381 call TexNewMathZone("D","eqnarray",1)
382 call TexNewMathZone("E","equation",1)
383 call TexNewMathZone("F","flalign",1)
384 call TexNewMathZone("G","gather",1)
385 call TexNewMathZone("H","math",1)
386 call TexNewMathZone("I","multline",1)
Bram Moolenaard960d762011-09-21 19:22:10 +0200387 call TexNewMathZone("J","subequations",0)
Bram Moolenaar071d4272004-06-13 20:20:40 +0000388 call TexNewMathZone("K","xalignat",1)
389 call TexNewMathZone("L","xxalignat",0)
390
391 " Inline Math Zones: {{{2
Bram Moolenaar7fc0c062010-08-10 21:43:35 +0200392 if has("conceal") && &enc == 'utf-8' && s:tex_conceal =~ 'd'
Bram Moolenaare0021c72010-07-28 17:25:21 +0200393 syn region texMathZoneV matchgroup=Delimiter start="\\(" matchgroup=Delimiter end="\\)\|%stopzone\>" keepend concealends contains=@texMathZoneGroup
394 syn region texMathZoneW matchgroup=Delimiter start="\\\[" matchgroup=Delimiter end="\\]\|%stopzone\>" keepend concealends contains=@texMathZoneGroup
395 syn region texMathZoneX matchgroup=Delimiter start="\$" skip="\\\\\|\\\$" matchgroup=Delimiter end="\$" end="%stopzone\>" concealends contains=@texMathZoneGroup
396 syn region texMathZoneY matchgroup=Delimiter start="\$\$" matchgroup=Delimiter end="\$\$" end="%stopzone\>" concealends keepend contains=@texMathZoneGroup
397 else
398 syn region texMathZoneV matchgroup=Delimiter start="\\(" matchgroup=Delimiter end="\\)\|%stopzone\>" keepend contains=@texMathZoneGroup
399 syn region texMathZoneW matchgroup=Delimiter start="\\\[" matchgroup=Delimiter end="\\]\|%stopzone\>" keepend contains=@texMathZoneGroup
400 syn region texMathZoneX matchgroup=Delimiter start="\$" skip="\\\\\|\\\$" matchgroup=Delimiter end="\$" end="%stopzone\>" contains=@texMathZoneGroup
401 syn region texMathZoneY matchgroup=Delimiter start="\$\$" matchgroup=Delimiter end="\$\$" end="%stopzone\>" keepend contains=@texMathZoneGroup
402 endif
Bram Moolenaarb2c03502010-07-02 20:20:09 +0200403 syn region texMathZoneZ matchgroup=texStatement start="\\ensuremath\s*{" matchgroup=texStatement end="}" end="%stopzone\>" contains=@texMathZoneGroup
Bram Moolenaar071d4272004-06-13 20:20:40 +0000404
405 syn match texMathOper "[_^=]" contained
406
Bram Moolenaar74cbdf02010-08-04 23:03:17 +0200407 " Text Inside Math Zones: {{{2
Bram Moolenaard960d762011-09-21 19:22:10 +0200408 if !exists("g:tex_nospell") || !g:tex_nospell
409 syn region texMathText matchgroup=texStatement start='\\\(\(inter\)\=text\|mbox\)\s*{' end='}' contains=@texFoldGroup,@Spell
410 else
411 syn region texMathText matchgroup=texStatement start='\\\(\(inter\)\=text\|mbox\)\s*{' end='}' contains=@texFoldGroup
412 endif
Bram Moolenaar74cbdf02010-08-04 23:03:17 +0200413
Bram Moolenaar071d4272004-06-13 20:20:40 +0000414 " \left..something.. and \right..something.. support: {{{2
415 syn match texMathDelimBad contained "\S"
Bram Moolenaar4b22cdb2010-08-02 22:12:46 +0200416 if has("conceal") && &enc == 'utf-8' && s:tex_conceal =~ 'm'
417 syn match texMathDelim contained "\\left\\{\>" skipwhite nextgroup=texMathDelimSet1,texMathDelimSet2,texMathDelimBad contains=texMathSymbol cchar={
418 syn match texMathDelim contained "\\right\\}\>" skipwhite nextgroup=texMathDelimSet1,texMathDelimSet2,texMathDelimBad contains=texMathSymbol cchar=}
Bram Moolenaaradc21822011-04-01 18:03:16 +0200419 let s:texMathDelimList=[
420 \ ['<' , '<'] ,
421 \ ['>' , '>'] ,
422 \ ['(' , '('] ,
423 \ [')' , ')'] ,
424 \ ['\[' , '['] ,
425 \ [']' , ']'] ,
426 \ ['\\{' , '{'] ,
427 \ ['\\}' , '}'] ,
428 \ ['|' , '|'] ,
429 \ ['\\|' , '‖'] ,
430 \ ['\\backslash' , '\'] ,
431 \ ['\\downarrow' , '↓'] ,
432 \ ['\\Downarrow' , '⇓'] ,
433 \ ['\\langle' , '<'] ,
434 \ ['\\lbrace' , '['] ,
435 \ ['\\lceil' , '⌈'] ,
436 \ ['\\lfloor' , '⌊'] ,
437 \ ['\\lgroup' , '⌊'] ,
438 \ ['\\lmoustache' , '⎛'] ,
439 \ ['\\rangle' , '>'] ,
440 \ ['\\rbrace' , ']'] ,
441 \ ['\\rceil' , '⌉'] ,
442 \ ['\\rfloor' , '⌋'] ,
443 \ ['\\rgroup' , '⌋'] ,
444 \ ['\\rmoustache' , '⎞'] ,
445 \ ['\\uparrow' , '↑'] ,
446 \ ['\\Uparrow' , '↑'] ,
447 \ ['\\updownarrow', '↕'] ,
448 \ ['\\Updownarrow', '⇕']]
449 syn match texMathDelim '\\[bB]igg\=[lr]' contained nextgroup=texMathDelimBad
450 for texmath in s:texMathDelimList
451 exe "syn match texMathDelim '\\\\[bB]igg\\=[lr]\\=".texmath[0]."' contained conceal cchar=".texmath[1]
452 endfor
453
Bram Moolenaar4b22cdb2010-08-02 22:12:46 +0200454 else
455 syn match texMathDelim contained "\\\(left\|right\)\>" skipwhite nextgroup=texMathDelimSet1,texMathDelimSet2,texMathDelimBad
Bram Moolenaaradc21822011-04-01 18:03:16 +0200456 syn match texMathDelim contained "\\[bB]igg\=[lr]\=\>" skipwhite nextgroup=texMathDelimSet1,texMathDelimSet2,texMathDelimBad
457 syn match texMathDelimSet2 contained "\\" nextgroup=texMathDelimKey,texMathDelimBad
458 syn match texMathDelimSet1 contained "[<>()[\]|/.]\|\\[{}|]"
459 syn keyword texMathDelimKey contained backslash lceil lVert rgroup uparrow
460 syn keyword texMathDelimKey contained downarrow lfloor rangle rmoustache Uparrow
461 syn keyword texMathDelimKey contained Downarrow lgroup rbrace rvert updownarrow
462 syn keyword texMathDelimKey contained langle lmoustache rceil rVert Updownarrow
463 syn keyword texMathDelimKey contained lbrace lvert rfloor
Bram Moolenaar4b22cdb2010-08-02 22:12:46 +0200464 endif
Bram Moolenaar071d4272004-06-13 20:20:40 +0000465 syn match texMathDelim contained "\\\(left\|right\)arrow\>\|\<\([aA]rrow\|brace\)\=vert\>"
466 syn match texMathDelim contained "\\lefteqn\>"
Bram Moolenaar071d4272004-06-13 20:20:40 +0000467endif
468
469" Special TeX characters ( \$ \& \% \# \{ \} \_ \S \P ) : {{{1
470syn match texSpecialChar "\\[$&%#{}_]"
471if b:tex_stylish
472 syn match texSpecialChar "\\[SP@][^a-zA-Z@]"me=e-1
473else
474 syn match texSpecialChar "\\[SP@]\A"me=e-1
475endif
476syn match texSpecialChar "\\\\"
477if !exists("tex_no_math")
478 syn match texOnlyMath "[_^]"
479endif
480syn match texSpecialChar "\^\^[0-9a-f]\{2}\|\^\^\S"
481
482" Comments: {{{1
483" Normal TeX LaTeX : %....
484" Documented TeX Format: ^^A... -and- leading %s (only)
Bram Moolenaar3577c6f2008-06-24 21:16:56 +0000485if !exists("g:tex_comment_nospell") || !g:tex_comment_nospell
486 syn cluster texCommentGroup contains=texTodo,@Spell
487else
488 syn cluster texCommentGroup contains=texTodo,@NoSpell
489endif
Bram Moolenaar071d4272004-06-13 20:20:40 +0000490syn case ignore
Bram Moolenaar18144c82006-04-12 21:52:12 +0000491syn keyword texTodo contained combak fixme todo xxx
Bram Moolenaar071d4272004-06-13 20:20:40 +0000492syn case match
Bram Moolenaar81af9252010-12-10 20:35:50 +0100493if s:extfname == "dtx"
Bram Moolenaar071d4272004-06-13 20:20:40 +0000494 syn match texComment "\^\^A.*$" contains=@texCommentGroup
495 syn match texComment "^%\+" contains=@texCommentGroup
496else
Bram Moolenaarfd2ac762006-03-01 22:09:21 +0000497 if g:tex_fold_enabled
498 " allows syntax-folding of 2 or more contiguous comment lines
499 " single-line comments are not folded
500 syn match texComment "%.*$" contains=@texCommentGroup
501 syn region texComment start="^\zs\s*%.*\_s*%" skip="^\s*%" end='^\ze\s*[^%]' fold
502 else
503 syn match texComment "%.*$" contains=@texCommentGroup
504 endif
Bram Moolenaar071d4272004-06-13 20:20:40 +0000505endif
506
507" Separate lines used for verb` and verb# so that the end conditions {{{1
Bram Moolenaar74cbdf02010-08-04 23:03:17 +0200508" will appropriately terminate.
509" If g:tex_verbspell exists, then verbatim texZones will permit spellchecking there.
510if exists("g:tex_verbspell") && g:tex_verbspell
511 syn region texZone start="\\begin{[vV]erbatim}" end="\\end{[vV]erbatim}\|%stopzone\>" contains=@Spell
512 " listings package:
513 syn region texZone start="\\begin{lstlisting}" end="\\end{lstlisting}\|%stopzone\>" contains=@Spell
514 " moreverb package:
515 syn region texZone start="\\begin{verbatimtab}" end="\\end{verbatimtab}\|%stopzone\>" contains=@Spell
516 syn region texZone start="\\begin{verbatimwrite}" end="\\end{verbatimwrite}\|%stopzone\>" contains=@Spell
517 syn region texZone start="\\begin{boxedverbatim}" end="\\end{boxedverbatim}\|%stopzone\>" contains=@Spell
518 if version < 600
519 syn region texZone start="\\verb\*\=`" end="`\|%stopzone\>" contains=@Spell
520 syn region texZone start="\\verb\*\=#" end="#\|%stopzone\>" contains=@Spell
521 else
522 if b:tex_stylish
523 syn region texZone start="\\verb\*\=\z([^\ta-zA-Z@]\)" end="\z1\|%stopzone\>" contains=@Spell
524 else
525 syn region texZone start="\\verb\*\=\z([^\ta-zA-Z]\)" end="\z1\|%stopzone\>" contains=@Spell
526 endif
527 endif
Bram Moolenaar071d4272004-06-13 20:20:40 +0000528else
Bram Moolenaar74cbdf02010-08-04 23:03:17 +0200529 syn region texZone start="\\begin{[vV]erbatim}" end="\\end{[vV]erbatim}\|%stopzone\>"
530 " listings package:
531 syn region texZone start="\\begin{lstlisting}" end="\\end{lstlisting}\|%stopzone\>"
532 " moreverb package:
533 syn region texZone start="\\begin{verbatimtab}" end="\\end{verbatimtab}\|%stopzone\>"
534 syn region texZone start="\\begin{verbatimwrite}" end="\\end{verbatimwrite}\|%stopzone\>"
535 syn region texZone start="\\begin{boxedverbatim}" end="\\end{boxedverbatim}\|%stopzone\>"
536 if version < 600
537 syn region texZone start="\\verb\*\=`" end="`\|%stopzone\>"
538 syn region texZone start="\\verb\*\=#" end="#\|%stopzone\>"
539 else
540 if b:tex_stylish
541 syn region texZone start="\\verb\*\=\z([^\ta-zA-Z@]\)" end="\z1\|%stopzone\>"
542 else
543 syn region texZone start="\\verb\*\=\z([^\ta-zA-Z]\)" end="\z1\|%stopzone\>"
544 endif
545 endif
Bram Moolenaar071d4272004-06-13 20:20:40 +0000546endif
547
548" Tex Reference Zones: {{{1
Bram Moolenaard960d762011-09-21 19:22:10 +0200549syn region texZone matchgroup=texStatement start="@samp{" end="}\|%stopzone\>" contains=@texRefGroup
550syn region texRefZone matchgroup=texStatement start="\\nocite{" end="}\|%stopzone\>" contains=@texRefGroup
551syn region texRefZone matchgroup=texStatement start="\\bibliography{" end="}\|%stopzone\>" contains=@texRefGroup
552syn region texRefZone matchgroup=texStatement start="\\label{" end="}\|%stopzone\>" contains=@texRefGroup
553syn region texRefZone matchgroup=texStatement start="\\\(page\|eq\)ref{" end="}\|%stopzone\>" contains=@texRefGroup
554syn region texRefZone matchgroup=texStatement start="\\v\=ref{" end="}\|%stopzone\>" contains=@texRefGroup
555syn match texRefZone '\\cite\%([tp]\*\=\)\=' nextgroup=texRefOption,texCite
556syn region texRefOption contained matchgroup=Delimiter start='\[' end=']' contains=@texRefGroup,texRefZone nextgroup=texRefOption,texCite
557syn region texCite contained matchgroup=Delimiter start='{' end='}' contains=@texRefGroup,texRefZone,texCite
Bram Moolenaar071d4272004-06-13 20:20:40 +0000558
559" Handle newcommand, newenvironment : {{{1
560syn match texNewCmd "\\newcommand\>" nextgroup=texCmdName skipwhite skipnl
561syn region texCmdName contained matchgroup=Delimiter start="{"rs=s+1 end="}" nextgroup=texCmdArgs,texCmdBody skipwhite skipnl
562syn region texCmdArgs contained matchgroup=Delimiter start="\["rs=s+1 end="]" nextgroup=texCmdBody skipwhite skipnl
563syn region texCmdBody contained matchgroup=Delimiter start="{"rs=s+1 skip="\\\\\|\\[{}]" matchgroup=Delimiter end="}" contains=@texCmdGroup
564syn match texNewEnv "\\newenvironment\>" nextgroup=texEnvName skipwhite skipnl
565syn region texEnvName contained matchgroup=Delimiter start="{"rs=s+1 end="}" nextgroup=texEnvBgn skipwhite skipnl
566syn region texEnvBgn contained matchgroup=Delimiter start="{"rs=s+1 end="}" nextgroup=texEnvEnd skipwhite skipnl contains=@texEnvGroup
567syn region texEnvEnd contained matchgroup=Delimiter start="{"rs=s+1 end="}" skipwhite skipnl contains=@texEnvGroup
568
569" Definitions/Commands: {{{1
570syn match texDefCmd "\\def\>" nextgroup=texDefName skipwhite skipnl
571if b:tex_stylish
572 syn match texDefName contained "\\[a-zA-Z@]\+" nextgroup=texDefParms,texCmdBody skipwhite skipnl
573 syn match texDefName contained "\\[^a-zA-Z@]" nextgroup=texDefParms,texCmdBody skipwhite skipnl
574else
575 syn match texDefName contained "\\\a\+" nextgroup=texDefParms,texCmdBody skipwhite skipnl
576 syn match texDefName contained "\\\A" nextgroup=texDefParms,texCmdBody skipwhite skipnl
577endif
578syn match texDefParms contained "#[^{]*" contains=texDefParm nextgroup=texCmdBody skipwhite skipnl
579syn match texDefParm contained "#\d\+"
580
581" TeX Lengths: {{{1
Bram Moolenaar9964e462007-05-05 17:54:07 +0000582syn match texLength "\<\d\+\([.,]\d\+\)\=\s*\(true\)\=\s*\(bp\|cc\|cm\|dd\|em\|ex\|in\|mm\|pc\|pt\|sp\)\>"
Bram Moolenaar071d4272004-06-13 20:20:40 +0000583
584" TeX String Delimiters: {{{1
585syn match texString "\(``\|''\|,,\)"
586
Bram Moolenaar5c736222010-01-06 20:54:52 +0100587" makeatletter -- makeatother sections
588if !exists("g:tex_no_error")
589 syn region texStyle matchgroup=texStatement start='\\makeatletter' end='\\makeatother' contains=@texStyleGroup contained
590 syn match texStyleStatement "\\[a-zA-Z@]\+" contained
591 syn region texStyleMatcher matchgroup=Delimiter start="{" skip="\\\\\|\\[{}]" end="}" contains=@texStyleGroup,texError contained
592 syn region texStyleMatcher matchgroup=Delimiter start="\[" end="]" contains=@texStyleGroup,texError contained
593endif
594
Bram Moolenaar7fc0c062010-08-10 21:43:35 +0200595" Conceal mode support (supports set cole=2) {{{1
Bram Moolenaarb2c03502010-07-02 20:20:09 +0200596if has("conceal") && &enc == 'utf-8'
Bram Moolenaar611df5b2010-07-26 22:51:56 +0200597
598 " Math Symbols {{{2
Bram Moolenaar7fc0c062010-08-10 21:43:35 +0200599 " (many of these symbols were contributed by Björn Winckler)
Bram Moolenaar4b22cdb2010-08-02 22:12:46 +0200600 if s:tex_conceal =~ 'm'
Bram Moolenaar7fc0c062010-08-10 21:43:35 +0200601 let s:texMathList=[
Bram Moolenaaradc21822011-04-01 18:03:16 +0200602 \ ['|' , '‖'],
Bram Moolenaard960d762011-09-21 19:22:10 +0200603 \ ['aleph' , 'ℵ'],
Bram Moolenaar7fc0c062010-08-10 21:43:35 +0200604 \ ['angle' , '∠'],
605 \ ['approx' , '≈'],
606 \ ['ast' , '∗'],
607 \ ['asymp' , '≍'],
608 \ ['backepsilon' , '∍'],
609 \ ['backsimeq' , '≃'],
Bram Moolenaard960d762011-09-21 19:22:10 +0200610 \ ['backslash' , '∖'],
Bram Moolenaar7fc0c062010-08-10 21:43:35 +0200611 \ ['barwedge' , '⊼'],
612 \ ['because' , '∵'],
613 \ ['between' , '≬'],
614 \ ['bigcap' , '∩'],
615 \ ['bigcup' , '∪'],
616 \ ['bigodot' , '⊙'],
617 \ ['bigoplus' , '⊕'],
618 \ ['bigotimes' , '⊗'],
619 \ ['bigsqcup' , '⊔'],
620 \ ['bigtriangledown', '∇'],
621 \ ['bigvee' , '⋁'],
622 \ ['bigwedge' , '⋀'],
623 \ ['blacksquare' , '∎'],
624 \ ['bot' , '⊥'],
625 \ ['boxdot' , '⊡'],
626 \ ['boxminus' , '⊟'],
627 \ ['boxplus' , '⊞'],
628 \ ['boxtimes' , '⊠'],
629 \ ['bumpeq' , '≏'],
630 \ ['Bumpeq' , '≎'],
631 \ ['cap' , '∩'],
632 \ ['Cap' , '⋒'],
633 \ ['cdot' , '·'],
634 \ ['cdots' , '⋯'],
635 \ ['circ' , '∘'],
636 \ ['circeq' , '≗'],
637 \ ['circlearrowleft', '↺'],
638 \ ['circlearrowright', '↻'],
639 \ ['circledast' , '⊛'],
640 \ ['circledcirc' , '⊚'],
Bram Moolenaard960d762011-09-21 19:22:10 +0200641 \ ['clubsuit' , '♣'],
Bram Moolenaar7fc0c062010-08-10 21:43:35 +0200642 \ ['complement' , '∁'],
643 \ ['cong' , '≅'],
644 \ ['coprod' , '∐'],
Bram Moolenaard960d762011-09-21 19:22:10 +0200645 \ ['copyright' , '©'],
Bram Moolenaar7fc0c062010-08-10 21:43:35 +0200646 \ ['cup' , '∪'],
647 \ ['Cup' , '⋓'],
648 \ ['curlyeqprec' , '⋞'],
649 \ ['curlyeqsucc' , '⋟'],
650 \ ['curlyvee' , '⋎'],
651 \ ['curlywedge' , '⋏'],
652 \ ['dashv' , '⊣'],
653 \ ['diamond' , '⋄'],
Bram Moolenaard960d762011-09-21 19:22:10 +0200654 \ ['diamondsuit' , '♢'],
Bram Moolenaar7fc0c062010-08-10 21:43:35 +0200655 \ ['div' , '÷'],
656 \ ['doteq' , '≐'],
657 \ ['doteqdot' , '≑'],
658 \ ['dotplus' , '∔'],
659 \ ['dotsb' , '⋯'],
660 \ ['dotsc' , '…'],
661 \ ['dots' , '…'],
662 \ ['dotsi' , '⋯'],
663 \ ['dotso' , '…'],
664 \ ['doublebarwedge' , '⩞'],
665 \ ['downarrow' , '↓'],
666 \ ['Downarrow' , '⇓'],
667 \ ['emptyset' , '∅'],
668 \ ['eqcirc' , '≖'],
669 \ ['eqsim' , '≂'],
670 \ ['eqslantgtr' , '⪖'],
671 \ ['eqslantless' , '⪕'],
672 \ ['equiv' , '≡'],
Bram Moolenaard960d762011-09-21 19:22:10 +0200673 \ ['ell' , 'ℓ'],
Bram Moolenaar7fc0c062010-08-10 21:43:35 +0200674 \ ['exists' , '∃'],
675 \ ['fallingdotseq' , '≒'],
Bram Moolenaard960d762011-09-21 19:22:10 +0200676 \ ['flat' , '♭'],
Bram Moolenaar7fc0c062010-08-10 21:43:35 +0200677 \ ['forall' , '∀'],
678 \ ['ge' , '≥'],
679 \ ['geq' , '≥'],
680 \ ['geqq' , '≧'],
681 \ ['gets' , '←'],
682 \ ['gneqq' , '≩'],
683 \ ['gtrdot' , '⋗'],
684 \ ['gtreqless' , '⋛'],
685 \ ['gtrless' , '≷'],
686 \ ['gtrsim' , '≳'],
Bram Moolenaard960d762011-09-21 19:22:10 +0200687 \ ['hbar' , 'ℏ'],
688 \ ['heartsuit' , '♡'],
Bram Moolenaar7fc0c062010-08-10 21:43:35 +0200689 \ ['hookleftarrow' , '↩'],
690 \ ['hookrightarrow' , '↪'],
691 \ ['iiint' , '∭'],
692 \ ['iint' , '∬'],
693 \ ['Im' , 'ℑ'],
Bram Moolenaard960d762011-09-21 19:22:10 +0200694 \ ['imath' , 'ɩ'],
Bram Moolenaar7fc0c062010-08-10 21:43:35 +0200695 \ ['in' , '∈'],
696 \ ['infty' , '∞'],
697 \ ['int' , '∫'],
698 \ ['lceil' , '⌈'],
699 \ ['ldots' , '…'],
700 \ ['le' , '≤'],
701 \ ['leftarrow' , '⟵'],
702 \ ['Leftarrow' , '⟸'],
703 \ ['leftarrowtail' , '↢'],
704 \ ['left(' , '('],
705 \ ['left\[' , '['],
706 \ ['left\\{' , '{'],
Bram Moolenaard960d762011-09-21 19:22:10 +0200707 \ ['leftrightarrow' , '⇔'],
Bram Moolenaar7fc0c062010-08-10 21:43:35 +0200708 \ ['leftrightsquigarrow', '↭'],
709 \ ['leftthreetimes' , '⋋'],
710 \ ['leq' , '≤'],
711 \ ['leqq' , '≦'],
712 \ ['lessdot' , '⋖'],
713 \ ['lesseqgtr' , '⋚'],
714 \ ['lesssim' , '≲'],
715 \ ['lfloor' , '⌊'],
Bram Moolenaaradc21822011-04-01 18:03:16 +0200716 \ ['lmoustache' , '╭'],
Bram Moolenaar7fc0c062010-08-10 21:43:35 +0200717 \ ['lneqq' , '≨'],
718 \ ['ltimes' , '⋉'],
719 \ ['mapsto' , '↦'],
720 \ ['measuredangle' , '∡'],
721 \ ['mid' , '∣'],
722 \ ['mp' , '∓'],
723 \ ['nabla' , '∇'],
Bram Moolenaard960d762011-09-21 19:22:10 +0200724 \ ['natural' , '♮'],
Bram Moolenaar7fc0c062010-08-10 21:43:35 +0200725 \ ['ncong' , '≇'],
726 \ ['nearrow' , '↗'],
727 \ ['ne' , '≠'],
728 \ ['neg' , '¬'],
729 \ ['neq' , '≠'],
730 \ ['nexists' , '∄'],
731 \ ['ngeq' , '≱'],
732 \ ['ngeqq' , '≱'],
733 \ ['ngtr' , '≯'],
734 \ ['ni' , '∋'],
735 \ ['nleftarrow' , '↚'],
736 \ ['nLeftarrow' , '⇍'],
737 \ ['nLeftrightarrow', '⇎'],
738 \ ['nleq' , '≰'],
739 \ ['nleqq' , '≰'],
740 \ ['nless' , '≮'],
741 \ ['nmid' , '∤'],
742 \ ['notin' , '∉'],
743 \ ['nprec' , '⊀'],
744 \ ['nrightarrow' , '↛'],
745 \ ['nRightarrow' , '⇏'],
746 \ ['nsim' , '≁'],
747 \ ['nsucc' , '⊁'],
748 \ ['ntriangleleft' , '⋪'],
749 \ ['ntrianglelefteq', '⋬'],
750 \ ['ntriangleright' , '⋫'],
751 \ ['ntrianglerighteq', '⋭'],
752 \ ['nvdash' , '⊬'],
753 \ ['nvDash' , '⊭'],
754 \ ['nVdash' , '⊮'],
755 \ ['nwarrow' , '↖'],
756 \ ['odot' , '⊙'],
757 \ ['oint' , '∮'],
758 \ ['ominus' , '⊖'],
759 \ ['oplus' , '⊕'],
760 \ ['oslash' , '⊘'],
761 \ ['otimes' , '⊗'],
762 \ ['owns' , '∋'],
Bram Moolenaard960d762011-09-21 19:22:10 +0200763 \ ['P' , '¶'],
Bram Moolenaar7fc0c062010-08-10 21:43:35 +0200764 \ ['partial' , '∂'],
765 \ ['perp' , '⊥'],
766 \ ['pitchfork' , '⋔'],
767 \ ['pm' , '±'],
768 \ ['precapprox' , '⪷'],
769 \ ['prec' , '≺'],
770 \ ['preccurlyeq' , '≼'],
771 \ ['preceq' , '⪯'],
772 \ ['precnapprox' , '⪹'],
773 \ ['precneqq' , '⪵'],
774 \ ['precsim' , '≾'],
Bram Moolenaard960d762011-09-21 19:22:10 +0200775 \ ['prime' , '′'],
Bram Moolenaar7fc0c062010-08-10 21:43:35 +0200776 \ ['prod' , '∏'],
777 \ ['propto' , '∝'],
778 \ ['rceil' , '⌉'],
779 \ ['Re' , 'ℜ'],
780 \ ['rfloor' , '⌋'],
781 \ ['rightarrow' , '⟶'],
782 \ ['Rightarrow' , '⟹'],
783 \ ['rightarrowtail' , '↣'],
784 \ ['right)' , ')'],
785 \ ['right]' , ']'],
786 \ ['right\\}' , '}'],
787 \ ['rightsquigarrow', '↝'],
788 \ ['rightthreetimes', '⋌'],
789 \ ['risingdotseq' , '≓'],
Bram Moolenaaradc21822011-04-01 18:03:16 +0200790 \ ['rmoustache' , '╮'],
Bram Moolenaar7fc0c062010-08-10 21:43:35 +0200791 \ ['rtimes' , '⋊'],
Bram Moolenaard960d762011-09-21 19:22:10 +0200792 \ ['S' , '§'],
Bram Moolenaar7fc0c062010-08-10 21:43:35 +0200793 \ ['searrow' , '↘'],
794 \ ['setminus' , '∖'],
Bram Moolenaard960d762011-09-21 19:22:10 +0200795 \ ['sharp' , '♯'],
Bram Moolenaar7fc0c062010-08-10 21:43:35 +0200796 \ ['sim' , '∼'],
Bram Moolenaard960d762011-09-21 19:22:10 +0200797 \ ['spadesuit' , '♠'],
Bram Moolenaar7fc0c062010-08-10 21:43:35 +0200798 \ ['sphericalangle' , '∢'],
799 \ ['sqcap' , '⊓'],
800 \ ['sqcup' , '⊔'],
801 \ ['sqsubset' , '⊏'],
802 \ ['sqsubseteq' , '⊑'],
803 \ ['sqsupset' , '⊐'],
804 \ ['sqsupseteq' , '⊒'],
805 \ ['subset' , '⊂'],
806 \ ['Subset' , '⋐'],
807 \ ['subseteq' , '⊆'],
808 \ ['subseteqq' , '⫅'],
809 \ ['subsetneq' , '⊊'],
810 \ ['subsetneqq' , '⫋'],
811 \ ['succapprox' , '⪸'],
812 \ ['succ' , '≻'],
813 \ ['succcurlyeq' , '≽'],
814 \ ['succeq' , '⪰'],
815 \ ['succnapprox' , '⪺'],
816 \ ['succneqq' , '⪶'],
817 \ ['succsim' , '≿'],
818 \ ['sum' , '∑'],
819 \ ['Supset' , '⋑'],
820 \ ['supseteq' , '⊇'],
821 \ ['supseteqq' , '⫆'],
822 \ ['supsetneq' , '⊋'],
823 \ ['supsetneqq' , '⫌'],
824 \ ['surd' , '√'],
825 \ ['swarrow' , '↙'],
826 \ ['therefore' , '∴'],
827 \ ['times' , '×'],
828 \ ['to' , '→'],
829 \ ['top' , '⊤'],
Bram Moolenaard960d762011-09-21 19:22:10 +0200830 \ ['triangle' , '∆'],
Bram Moolenaar7fc0c062010-08-10 21:43:35 +0200831 \ ['triangleleft' , '⊲'],
832 \ ['trianglelefteq' , '⊴'],
833 \ ['triangleq' , '≜'],
834 \ ['triangleright' , '⊳'],
835 \ ['trianglerighteq', '⊵'],
836 \ ['twoheadleftarrow', '↞'],
837 \ ['twoheadrightarrow', '↠'],
838 \ ['uparrow' , '↑'],
839 \ ['Uparrow' , '⇑'],
840 \ ['updownarrow' , '↕'],
841 \ ['Updownarrow' , '⇕'],
842 \ ['varnothing' , '∅'],
843 \ ['vartriangle' , '∆'],
844 \ ['vdash' , '⊢'],
845 \ ['vDash' , '⊨'],
846 \ ['Vdash' , '⊩'],
847 \ ['vdots' , '⋮'],
848 \ ['veebar' , '⊻'],
849 \ ['vee' , '∨'],
850 \ ['Vvdash' , '⊪'],
851 \ ['wedge' , '∧'],
Bram Moolenaard960d762011-09-21 19:22:10 +0200852 \ ['wp' , '℘'],
Bram Moolenaar7fc0c062010-08-10 21:43:35 +0200853 \ ['wr' , '≀']]
854 for texmath in s:texMathList
Bram Moolenaar81af9252010-12-10 20:35:50 +0100855 if texmath[0] =~ '\w$'
856 exe "syn match texMathSymbol '\\\\".texmath[0]."\\>' contained conceal cchar=".texmath[1]
857 else
858 exe "syn match texMathSymbol '\\\\".texmath[0]."' contained conceal cchar=".texmath[1]
859 endif
Bram Moolenaar7fc0c062010-08-10 21:43:35 +0200860 endfor
Bram Moolenaar74cbdf02010-08-04 23:03:17 +0200861
862 if &ambw == "double"
863 syn match texMathSymbol '\\gg\>' contained conceal cchar=≫
864 syn match texMathSymbol '\\ll\>' contained conceal cchar=≪
865 else
866 syn match texMathSymbol '\\gg\>' contained conceal cchar=⟫
867 syn match texMathSymbol '\\ll\>' contained conceal cchar=⟪
868 endif
Bram Moolenaard960d762011-09-21 19:22:10 +0200869
870 syn match texMathSymbol '\\hat{a}' contained conceal cchar=â
871 syn match texMathSymbol '\\hat{A}' contained conceal cchar=Â
872 syn match texMathSymbol '\\hat{c}' contained conceal cchar=ĉ
873 syn match texMathSymbol '\\hat{C}' contained conceal cchar=Ĉ
874 syn match texMathSymbol '\\hat{e}' contained conceal cchar=ê
875 syn match texMathSymbol '\\hat{E}' contained conceal cchar=Ê
876 syn match texMathSymbol '\\hat{g}' contained conceal cchar=ĝ
877 syn match texMathSymbol '\\hat{G}' contained conceal cchar=Ĝ
878 syn match texMathSymbol '\\hat{i}' contained conceal cchar=î
879 syn match texMathSymbol '\\hat{I}' contained conceal cchar=Î
880 syn match texMathSymbol '\\hat{o}' contained conceal cchar=ô
881 syn match texMathSymbol '\\hat{O}' contained conceal cchar=Ô
882 syn match texMathSymbol '\\hat{s}' contained conceal cchar=ŝ
883 syn match texMathSymbol '\\hat{S}' contained conceal cchar=Ŝ
884 syn match texMathSymbol '\\hat{u}' contained conceal cchar=û
885 syn match texMathSymbol '\\hat{U}' contained conceal cchar=Û
886 syn match texMathSymbol '\\hat{w}' contained conceal cchar=ŵ
887 syn match texMathSymbol '\\hat{W}' contained conceal cchar=Ŵ
888 syn match texMathSymbol '\\hat{y}' contained conceal cchar=ŷ
889 syn match texMathSymbol '\\hat{Y}' contained conceal cchar=Ŷ
Bram Moolenaar4b22cdb2010-08-02 22:12:46 +0200890 endif
Bram Moolenaar611df5b2010-07-26 22:51:56 +0200891
892 " Greek {{{2
Bram Moolenaar4b22cdb2010-08-02 22:12:46 +0200893 if s:tex_conceal =~ 'g'
894 fun! s:Greek(group,pat,cchar)
895 exe 'syn match '.a:group." '".a:pat."' contained conceal cchar=".a:cchar
896 endfun
897 call s:Greek('texGreek','\\alpha\>' ,'α')
898 call s:Greek('texGreek','\\beta\>' ,'β')
899 call s:Greek('texGreek','\\gamma\>' ,'γ')
900 call s:Greek('texGreek','\\delta\>' ,'δ')
901 call s:Greek('texGreek','\\epsilon\>' ,'ϵ')
902 call s:Greek('texGreek','\\varepsilon\>' ,'ε')
903 call s:Greek('texGreek','\\zeta\>' ,'ζ')
904 call s:Greek('texGreek','\\eta\>' ,'η')
905 call s:Greek('texGreek','\\theta\>' ,'θ')
906 call s:Greek('texGreek','\\vartheta\>' ,'ϑ')
907 call s:Greek('texGreek','\\kappa\>' ,'κ')
908 call s:Greek('texGreek','\\lambda\>' ,'λ')
909 call s:Greek('texGreek','\\mu\>' ,'μ')
910 call s:Greek('texGreek','\\nu\>' ,'ν')
911 call s:Greek('texGreek','\\xi\>' ,'ξ')
912 call s:Greek('texGreek','\\pi\>' ,'π')
913 call s:Greek('texGreek','\\varpi\>' ,'ϖ')
914 call s:Greek('texGreek','\\rho\>' ,'ρ')
915 call s:Greek('texGreek','\\varrho\>' ,'ϱ')
916 call s:Greek('texGreek','\\sigma\>' ,'σ')
917 call s:Greek('texGreek','\\varsigma\>' ,'ς')
918 call s:Greek('texGreek','\\tau\>' ,'τ')
919 call s:Greek('texGreek','\\upsilon\>' ,'υ')
920 call s:Greek('texGreek','\\phi\>' ,'φ')
921 call s:Greek('texGreek','\\varphi\>' ,'ϕ')
922 call s:Greek('texGreek','\\chi\>' ,'χ')
923 call s:Greek('texGreek','\\psi\>' ,'ψ')
924 call s:Greek('texGreek','\\omega\>' ,'ω')
925 call s:Greek('texGreek','\\Gamma\>' ,'Γ')
926 call s:Greek('texGreek','\\Delta\>' ,'Δ')
927 call s:Greek('texGreek','\\Theta\>' ,'Θ')
928 call s:Greek('texGreek','\\Lambda\>' ,'Λ')
929 call s:Greek('texGreek','\\Xi\>' ,'Χ')
930 call s:Greek('texGreek','\\Pi\>' ,'Π')
931 call s:Greek('texGreek','\\Sigma\>' ,'Σ')
932 call s:Greek('texGreek','\\Upsilon\>' ,'Υ')
933 call s:Greek('texGreek','\\Phi\>' ,'Φ')
934 call s:Greek('texGreek','\\Psi\>' ,'Ψ')
935 call s:Greek('texGreek','\\Omega\>' ,'Ω')
936 delfun s:Greek
937 endif
Bram Moolenaar611df5b2010-07-26 22:51:56 +0200938
939 " Superscripts/Subscripts {{{2
Bram Moolenaar4b22cdb2010-08-02 22:12:46 +0200940 if s:tex_conceal =~ 's'
Bram Moolenaard960d762011-09-21 19:22:10 +0200941 syn region texSuperscript matchgroup=Delimiter start='\^{' skip="\\\\\|\\[{}]" end='}' contained concealends contains=texSpecialChar,texSuperscripts,texStatement,texSubscript,texSuperscript,texMathMatcher
942 syn region texSubscript matchgroup=Delimiter start='_{' skip="\\\\\|\\[{}]" end='}' contained concealends contains=texSpecialChar,texSubscripts,texStatement,texSubscript,texSuperscript,texMathMatcher
Bram Moolenaar4b22cdb2010-08-02 22:12:46 +0200943 fun! s:SuperSub(group,leader,pat,cchar)
944 exe 'syn match '.a:group." '".a:leader.a:pat."' contained conceal cchar=".a:cchar
945 exe 'syn match '.a:group."s '".a:pat."' contained conceal cchar=".a:cchar.' nextgroup='.a:group.'s'
946 endfun
947 call s:SuperSub('texSuperscript','\^','0','⁰')
948 call s:SuperSub('texSuperscript','\^','1','¹')
949 call s:SuperSub('texSuperscript','\^','2','²')
950 call s:SuperSub('texSuperscript','\^','3','³')
951 call s:SuperSub('texSuperscript','\^','4','⁴')
952 call s:SuperSub('texSuperscript','\^','5','⁵')
953 call s:SuperSub('texSuperscript','\^','6','⁶')
954 call s:SuperSub('texSuperscript','\^','7','⁷')
955 call s:SuperSub('texSuperscript','\^','8','⁸')
956 call s:SuperSub('texSuperscript','\^','9','⁹')
957 call s:SuperSub('texSuperscript','\^','a','ᵃ')
958 call s:SuperSub('texSuperscript','\^','b','ᵇ')
959 call s:SuperSub('texSuperscript','\^','c','ᶜ')
960 call s:SuperSub('texSuperscript','\^','d','ᵈ')
961 call s:SuperSub('texSuperscript','\^','e','ᵉ')
962 call s:SuperSub('texSuperscript','\^','f','ᶠ')
963 call s:SuperSub('texSuperscript','\^','g','ᵍ')
964 call s:SuperSub('texSuperscript','\^','h','ʰ')
965 call s:SuperSub('texSuperscript','\^','i','ⁱ')
966 call s:SuperSub('texSuperscript','\^','j','ʲ')
967 call s:SuperSub('texSuperscript','\^','k','ᵏ')
968 call s:SuperSub('texSuperscript','\^','l','ˡ')
969 call s:SuperSub('texSuperscript','\^','m','ᵐ')
970 call s:SuperSub('texSuperscript','\^','n','ⁿ')
971 call s:SuperSub('texSuperscript','\^','o','ᵒ')
972 call s:SuperSub('texSuperscript','\^','p','ᵖ')
973 call s:SuperSub('texSuperscript','\^','r','ʳ')
974 call s:SuperSub('texSuperscript','\^','s','ˢ')
975 call s:SuperSub('texSuperscript','\^','t','ᵗ')
976 call s:SuperSub('texSuperscript','\^','u','ᵘ')
977 call s:SuperSub('texSuperscript','\^','v','ᵛ')
978 call s:SuperSub('texSuperscript','\^','w','ʷ')
979 call s:SuperSub('texSuperscript','\^','x','ˣ')
980 call s:SuperSub('texSuperscript','\^','y','ʸ')
981 call s:SuperSub('texSuperscript','\^','z','ᶻ')
982 call s:SuperSub('texSuperscript','\^','A','ᴬ')
983 call s:SuperSub('texSuperscript','\^','B','ᴮ')
984 call s:SuperSub('texSuperscript','\^','D','ᴰ')
985 call s:SuperSub('texSuperscript','\^','E','ᴱ')
986 call s:SuperSub('texSuperscript','\^','G','ᴳ')
987 call s:SuperSub('texSuperscript','\^','H','ᴴ')
988 call s:SuperSub('texSuperscript','\^','I','ᴵ')
989 call s:SuperSub('texSuperscript','\^','J','ᴶ')
990 call s:SuperSub('texSuperscript','\^','K','ᴷ')
991 call s:SuperSub('texSuperscript','\^','L','ᴸ')
992 call s:SuperSub('texSuperscript','\^','M','ᴹ')
993 call s:SuperSub('texSuperscript','\^','N','ᴺ')
994 call s:SuperSub('texSuperscript','\^','O','ᴼ')
995 call s:SuperSub('texSuperscript','\^','P','ᴾ')
996 call s:SuperSub('texSuperscript','\^','R','ᴿ')
997 call s:SuperSub('texSuperscript','\^','T','ᵀ')
998 call s:SuperSub('texSuperscript','\^','U','ᵁ')
999 call s:SuperSub('texSuperscript','\^','W','ᵂ')
1000 call s:SuperSub('texSuperscript','\^','+','⁺')
1001 call s:SuperSub('texSuperscript','\^','-','⁻')
1002 call s:SuperSub('texSuperscript','\^','<','˂')
1003 call s:SuperSub('texSuperscript','\^','>','˃')
1004 call s:SuperSub('texSuperscript','\^','/','ˊ')
1005 call s:SuperSub('texSuperscript','\^','(','⁽')
1006 call s:SuperSub('texSuperscript','\^',')','⁾')
1007 call s:SuperSub('texSuperscript','\^','\.','˙')
1008 call s:SuperSub('texSuperscript','\^','=','˭')
1009 call s:SuperSub('texSubscript','_','0','₀')
1010 call s:SuperSub('texSubscript','_','1','₁')
1011 call s:SuperSub('texSubscript','_','2','₂')
1012 call s:SuperSub('texSubscript','_','3','₃')
1013 call s:SuperSub('texSubscript','_','4','₄')
1014 call s:SuperSub('texSubscript','_','5','₅')
1015 call s:SuperSub('texSubscript','_','6','₆')
1016 call s:SuperSub('texSubscript','_','7','₇')
1017 call s:SuperSub('texSubscript','_','8','₈')
1018 call s:SuperSub('texSubscript','_','9','₉')
1019 call s:SuperSub('texSubscript','_','a','ₐ')
1020 call s:SuperSub('texSubscript','_','e','ₑ')
1021 call s:SuperSub('texSubscript','_','i','ᵢ')
1022 call s:SuperSub('texSubscript','_','o','ₒ')
1023 call s:SuperSub('texSubscript','_','u','ᵤ')
1024 call s:SuperSub('texSubscript','_','+','₊')
1025 call s:SuperSub('texSubscript','_','-','₋')
1026 call s:SuperSub('texSubscript','_','/','ˏ')
1027 call s:SuperSub('texSubscript','_','(','₍')
1028 call s:SuperSub('texSubscript','_',')','₎')
1029 call s:SuperSub('texSubscript','_','\.','‸')
1030 call s:SuperSub('texSubscript','_','r','ᵣ')
1031 call s:SuperSub('texSubscript','_','v','ᵥ')
1032 call s:SuperSub('texSubscript','_','x','ₓ')
1033 call s:SuperSub('texSubscript','_','\\beta\>' ,'ᵦ')
1034 call s:SuperSub('texSubscript','_','\\delta\>','ᵨ')
1035 call s:SuperSub('texSubscript','_','\\phi\>' ,'ᵩ')
1036 call s:SuperSub('texSubscript','_','\\gamma\>','ᵧ')
1037 call s:SuperSub('texSubscript','_','\\chi\>' ,'ᵪ')
1038 delfun s:SuperSub
1039 endif
Bram Moolenaar611df5b2010-07-26 22:51:56 +02001040
1041 " Accented characters: {{{2
Bram Moolenaar4b22cdb2010-08-02 22:12:46 +02001042 if s:tex_conceal =~ 'a'
1043 if b:tex_stylish
1044 syn match texAccent "\\[bcdvuH][^a-zA-Z@]"me=e-1
1045 syn match texLigature "\\\([ijolL]\|ae\|oe\|ss\|AA\|AE\|OE\)[^a-zA-Z@]"me=e-1
1046 else
1047 fun! s:Accents(chr,...)
1048 let i= 1
Bram Moolenaar7fc0c062010-08-10 21:43:35 +02001049 for accent in ["`","\\'","^",'"','\~','\.',"c","H","k","r","u","v"]
Bram Moolenaar4b22cdb2010-08-02 22:12:46 +02001050 if i > a:0
1051 break
1052 endif
Bram Moolenaar7fc0c062010-08-10 21:43:35 +02001053 if strlen(a:{i}) == 0 || a:{i} == ' ' || a:{i} == '?'
Bram Moolenaar4b22cdb2010-08-02 22:12:46 +02001054 let i= i + 1
1055 continue
1056 endif
Bram Moolenaar7fc0c062010-08-10 21:43:35 +02001057 if accent =~ '\a'
1058 exe "syn match texAccent '".'\\'.accent.'\(\s*{'.a:chr.'}\|\s\+'.a:chr.'\)'."' conceal cchar=".a:{i}
1059 else
1060 exe "syn match texAccent '".'\\'.accent.'\s*\({'.a:chr.'}\|'.a:chr.'\)'."' conceal cchar=".a:{i}
1061 endif
Bram Moolenaare0021c72010-07-28 17:25:21 +02001062 let i= i + 1
Bram Moolenaar4b22cdb2010-08-02 22:12:46 +02001063 endfor
1064 endfun
Bram Moolenaar7fc0c062010-08-10 21:43:35 +02001065 " \` \' \^ \" \~ \. \c \H \k \r \u \v
Bram Moolenaard960d762011-09-21 19:22:10 +02001066 call s:Accents('a','à','á','â','ä','ã','ȧ',' ',' ','ą','å','ă','ă')
1067 call s:Accents('A','À','Á','Â','Ä','Ã','Ȧ',' ',' ','Ą','Å','Ă','Ă')
Bram Moolenaar7fc0c062010-08-10 21:43:35 +02001068 call s:Accents('c',' ','ć','ĉ',' ',' ','ċ','ç',' ',' ',' ',' ','č')
1069 call s:Accents('C',' ','Ć','Ĉ',' ',' ','Ċ','Ç',' ',' ',' ',' ','Č')
1070 call s:Accents('d',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','ď')
1071 call s:Accents('D',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','Ď')
1072 call s:Accents('e','è','é','ê','ë','ẽ','ė','ȩ',' ','ę',' ','ĕ','ě')
1073 call s:Accents('E','È','É','Ê','Ë','Ẽ','Ė','Ȩ',' ','Ę',' ','Ĕ','Ě')
Bram Moolenaard960d762011-09-21 19:22:10 +02001074 call s:Accents('g',' ','ǵ','ĝ',' ',' ','ġ','ģ',' ',' ',' ','ğ',' ')
1075 call s:Accents('G',' ','Ǵ','Ĝ',' ',' ','Ġ','Ģ',' ',' ',' ','Ğ',' ')
1076 call s:Accents('h',' ',' ','ĥ',' ',' ',' ',' ',' ',' ',' ',' ','ȟ')
1077 call s:Accents('H',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','Ȟ')
Bram Moolenaar7fc0c062010-08-10 21:43:35 +02001078 call s:Accents('i','ì','í','î','ï','ĩ','į',' ',' ',' ',' ','ĭ',' ')
1079 call s:Accents('I','Ì','Í','Î','Ï','Ĩ','İ',' ',' ',' ',' ','Ĭ',' ')
Bram Moolenaard960d762011-09-21 19:22:10 +02001080 call s:Accents('J',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','ǰ')
1081 call s:Accents('k',' ',' ',' ',' ',' ',' ','ķ',' ',' ',' ',' ',' ')
1082 call s:Accents('K',' ',' ',' ',' ',' ',' ','Ķ',' ',' ',' ',' ',' ')
Bram Moolenaar7fc0c062010-08-10 21:43:35 +02001083 call s:Accents('l',' ','ĺ','ľ',' ',' ',' ','ļ',' ',' ',' ',' ','ľ')
1084 call s:Accents('L',' ','Ĺ','Ľ',' ',' ',' ','Ļ',' ',' ',' ',' ','Ľ')
1085 call s:Accents('n',' ','ń',' ',' ','ñ',' ','ņ',' ',' ',' ',' ','ň')
1086 call s:Accents('N',' ','Ń',' ',' ','Ñ',' ','Ņ',' ',' ',' ',' ','Ň')
1087 call s:Accents('o','ò','ó','ô','ö','õ','ȯ',' ','ő','ǫ',' ','ŏ',' ')
1088 call s:Accents('O','Ò','Ó','Ô','Ö','Õ','Ȯ',' ','Ő','Ǫ',' ','Ŏ',' ')
1089 call s:Accents('r',' ','ŕ',' ',' ',' ',' ','ŗ',' ',' ',' ',' ','ř')
1090 call s:Accents('R',' ','Ŕ',' ',' ',' ',' ','Ŗ',' ',' ',' ',' ','Ř')
Bram Moolenaard960d762011-09-21 19:22:10 +02001091 call s:Accents('s',' ','ś','ŝ',' ',' ',' ','ş',' ','ȿ',' ',' ','š')
Bram Moolenaar7fc0c062010-08-10 21:43:35 +02001092 call s:Accents('S',' ','Ś','Ŝ',' ',' ',' ','Ş',' ',' ',' ',' ','Š')
1093 call s:Accents('t',' ',' ',' ',' ',' ',' ','ţ',' ',' ',' ',' ','ť')
1094 call s:Accents('T',' ',' ',' ',' ',' ',' ','Ţ',' ',' ',' ',' ','Ť')
Bram Moolenaard960d762011-09-21 19:22:10 +02001095 call s:Accents('u','ù','ú','û','ü','ũ',' ',' ','ű','ų','ů','ŭ','ǔ')
1096 call s:Accents('U','Ù','Ú','Û','Ü','Ũ',' ',' ','Ű','Ų','Ů','Ŭ','Ǔ')
Bram Moolenaar7fc0c062010-08-10 21:43:35 +02001097 call s:Accents('w',' ',' ','ŵ',' ',' ',' ',' ',' ',' ',' ',' ',' ')
1098 call s:Accents('W',' ',' ','Ŵ',' ',' ',' ',' ',' ',' ',' ',' ',' ')
1099 call s:Accents('y','ỳ','ý','ŷ','ÿ','ỹ',' ',' ',' ',' ',' ',' ',' ')
1100 call s:Accents('Y','Ỳ','Ý','Ŷ','Ÿ','Ỹ',' ',' ',' ',' ',' ',' ',' ')
1101 call s:Accents('z',' ','ź',' ',' ',' ','ż',' ',' ',' ',' ',' ','ž')
1102 call s:Accents('Z',' ','Ź',' ',' ',' ','Ż',' ',' ',' ',' ',' ','Ž')
1103 call s:Accents('\\i','ì','í','î','ï','ĩ','į',' ',' ',' ',' ','ĭ',' ')
1104 " \` \' \^ \" \~ \. \c \H \k \r \u \v
Bram Moolenaar4b22cdb2010-08-02 22:12:46 +02001105 delfun s:Accents
1106 syn match texAccent '\\aa\>' conceal cchar=å
1107 syn match texAccent '\\AA\>' conceal cchar=Å
Bram Moolenaar4b22cdb2010-08-02 22:12:46 +02001108 syn match texAccent '\\o\>' conceal cchar=ø
1109 syn match texAccent '\\O\>' conceal cchar=Ø
Bram Moolenaar4b22cdb2010-08-02 22:12:46 +02001110 syn match texLigature '\\AE\>' conceal cchar=Æ
1111 syn match texLigature '\\ae\>' conceal cchar=æ
1112 syn match texLigature '\\oe\>' conceal cchar=œ
1113 syn match texLigature '\\OE\>' conceal cchar=Œ
1114 syn match texLigature '\\ss\>' conceal cchar=ß
1115 endif
Bram Moolenaar611df5b2010-07-26 22:51:56 +02001116 endif
Bram Moolenaarb2c03502010-07-02 20:20:09 +02001117endif
1118
1119" ---------------------------------------------------------------------
Bram Moolenaar071d4272004-06-13 20:20:40 +00001120" LaTeX synchronization: {{{1
1121syn sync maxlines=200
1122syn sync minlines=50
1123
1124syn sync match texSyncStop groupthere NONE "%stopzone\>"
1125
1126" Synchronization: {{{1
1127" The $..$ and $$..$$ make for impossible sync patterns
1128" (one can't tell if a "$$" starts or stops a math zone by itself)
1129" The following grouptheres coupled with minlines above
1130" help improve the odds of good syncing.
1131if !exists("tex_no_math")
1132 syn sync match texSyncMathZoneA groupthere NONE "\\end{abstract}"
1133 syn sync match texSyncMathZoneA groupthere NONE "\\end{center}"
1134 syn sync match texSyncMathZoneA groupthere NONE "\\end{description}"
1135 syn sync match texSyncMathZoneA groupthere NONE "\\end{enumerate}"
1136 syn sync match texSyncMathZoneA groupthere NONE "\\end{itemize}"
1137 syn sync match texSyncMathZoneA groupthere NONE "\\end{table}"
1138 syn sync match texSyncMathZoneA groupthere NONE "\\end{tabular}"
1139 syn sync match texSyncMathZoneA groupthere NONE "\\\(sub\)*section\>"
1140endif
1141
Bram Moolenaarb2c03502010-07-02 20:20:09 +02001142" ---------------------------------------------------------------------
Bram Moolenaar071d4272004-06-13 20:20:40 +00001143" Highlighting: {{{1
1144if did_tex_syntax_inits == 1
1145 let did_tex_syntax_inits= 2
1146 " TeX highlighting groups which should share similar highlighting
1147 if !exists("g:tex_no_error")
1148 if !exists("tex_no_math")
1149 HiLink texBadMath texError
1150 HiLink texMathDelimBad texError
1151 HiLink texMathError texError
1152 if !b:tex_stylish
1153 HiLink texOnlyMath texError
1154 endif
1155 endif
1156 HiLink texError Error
1157 endif
1158
Bram Moolenaard960d762011-09-21 19:22:10 +02001159 HiLink texCite texRefZone
Bram Moolenaar071d4272004-06-13 20:20:40 +00001160 HiLink texDefCmd texDef
1161 HiLink texDefName texDef
1162 HiLink texDocType texCmdName
1163 HiLink texDocTypeArgs texCmdArgs
1164 HiLink texInputFileOpt texCmdArgs
1165 HiLink texInputCurlies texDelimiter
1166 HiLink texLigature texSpecialChar
1167 if !exists("tex_no_math")
1168 HiLink texMathDelimSet1 texMathDelim
1169 HiLink texMathDelimSet2 texMathDelim
1170 HiLink texMathDelimKey texMathDelim
1171 HiLink texMathMatcher texMath
Bram Moolenaar7fc0c062010-08-10 21:43:35 +02001172 HiLink texAccent texStatement
1173 HiLink texGreek texStatement
1174 HiLink texSuperscript texStatement
1175 HiLink texSubscript texStatement
1176 HiLink texMathSymbol texStatement
Bram Moolenaar5c736222010-01-06 20:54:52 +01001177 HiLink texMathZoneV texMath
Bram Moolenaar071d4272004-06-13 20:20:40 +00001178 HiLink texMathZoneW texMath
1179 HiLink texMathZoneX texMath
1180 HiLink texMathZoneY texMath
Bram Moolenaar3577c6f2008-06-24 21:16:56 +00001181 HiLink texMathZoneV texMath
Bram Moolenaar071d4272004-06-13 20:20:40 +00001182 HiLink texMathZoneZ texMath
1183 endif
1184 HiLink texSectionMarker texCmdName
1185 HiLink texSectionName texSection
1186 HiLink texSpaceCode texStatement
Bram Moolenaar5c736222010-01-06 20:54:52 +01001187 HiLink texStyleStatement texStatement
Bram Moolenaar071d4272004-06-13 20:20:40 +00001188 HiLink texTypeSize texType
1189 HiLink texTypeStyle texType
1190
1191 " Basic TeX highlighting groups
1192 HiLink texCmdArgs Number
1193 HiLink texCmdName Statement
1194 HiLink texComment Comment
1195 HiLink texDef Statement
1196 HiLink texDefParm Special
1197 HiLink texDelimiter Delimiter
1198 HiLink texInput Special
1199 HiLink texInputFile Special
1200 HiLink texLength Number
1201 HiLink texMath Special
1202 HiLink texMathDelim Statement
1203 HiLink texMathOper Operator
1204 HiLink texNewCmd Statement
1205 HiLink texNewEnv Statement
1206 HiLink texOption Number
Bram Moolenaard960d762011-09-21 19:22:10 +02001207 HiLink texRefZone Special
Bram Moolenaar071d4272004-06-13 20:20:40 +00001208 HiLink texSection PreCondit
1209 HiLink texSpaceCodeChar Special
1210 HiLink texSpecialChar SpecialChar
1211 HiLink texStatement Statement
1212 HiLink texString String
1213 HiLink texTodo Todo
1214 HiLink texType Type
1215 HiLink texZone PreCondit
1216
1217 delcommand HiLink
1218endif
1219
1220" Current Syntax: {{{1
Bram Moolenaar81af9252010-12-10 20:35:50 +01001221unlet s:extfname
Bram Moolenaar071d4272004-06-13 20:20:40 +00001222let b:current_syntax = "tex"
Bram Moolenaare90ee312010-08-05 22:08:47 +02001223" vim: ts=8 fdm=marker