blob: 9f27ccefc90dfb055c232725a54470fa13556528 [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 Moolenaar611df5b2010-07-26 22:51:56 +02004" Last Change: Jul 26, 2010
5" Version: 49
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
40
41" Define the default highlighting. {{{1
42" For version 5.7 and earlier: only when not done already
43" For version 5.8 and later: only when an item doesn't have highlighting yet
44if version >= 508 || !exists("did_tex_syntax_inits")
45 let did_tex_syntax_inits = 1
46 if version < 508
47 command -nargs=+ HiLink hi link <args>
48 else
49 command -nargs=+ HiLink hi def link <args>
50 endif
51endif
52if exists("g:tex_tex") && !exists("g:tex_no_error")
53 let g:tex_no_error= 1
54endif
55
Bram Moolenaarf1f8bc52005-03-07 23:20:08 +000056" Determine whether or not to use "*.sty" mode {{{1
Bram Moolenaar071d4272004-06-13 20:20:40 +000057" The user may override the normal determination by setting
58" g:tex_stylish to 1 (for "*.sty" mode)
59" or to 0 else (normal "*.tex" mode)
60" or on a buffer-by-buffer basis with b:tex_stylish
61let b:extfname=expand("%:e")
62if exists("g:tex_stylish")
63 let b:tex_stylish= g:tex_stylish
64elseif !exists("b:tex_stylish")
65 if b:extfname == "sty" || b:extfname == "cls" || b:extfname == "clo" || b:extfname == "dtx" || b:extfname == "ltx"
66 let b:tex_stylish= 1
67 else
68 let b:tex_stylish= 0
69 endif
70endif
71
Bram Moolenaarf1f8bc52005-03-07 23:20:08 +000072" handle folding {{{1
73if !exists("g:tex_fold_enabled")
74 let g:tex_fold_enabled= 0
75elseif g:tex_fold_enabled && !has("folding")
Bram Moolenaarab194812005-09-14 21:40:12 +000076 let g:tex_fold_enabled= 0
Bram Moolenaarf1f8bc52005-03-07 23:20:08 +000077 echomsg "Ignoring g:tex_fold_enabled=".g:tex_fold_enabled."; need to re-compile vim for +fold support"
78endif
79if g:tex_fold_enabled && &fdm == "manual"
Bram Moolenaar00a927d2010-05-14 23:24:24 +020080 setl fdm=syntax
Bram Moolenaarf1f8bc52005-03-07 23:20:08 +000081endif
82
Bram Moolenaar071d4272004-06-13 20:20:40 +000083" (La)TeX keywords: only use the letters a-zA-Z {{{1
84" but _ is the only one that causes problems.
85if version < 600
86 set isk-=_
87 if b:tex_stylish
88 set isk+=@
89 endif
90else
91 setlocal isk-=_
92 if b:tex_stylish
93 setlocal isk+=@
94 endif
95endif
96
97" Clusters: {{{1
98" --------
99syn cluster texCmdGroup contains=texCmdBody,texComment,texDefParm,texDelimiter,texDocType,texInput,texLength,texLigature,texMathDelim,texMathOper,texNewCmd,texNewEnv,texRefZone,texSection,texSectionMarker,texSectionName,texSpecialChar,texStatement,texString,texTypeSize,texTypeStyle
100if !exists("g:tex_no_error")
101 syn cluster texCmdGroup add=texMathError
102endif
103syn cluster texEnvGroup contains=texMatcher,texMathDelim,texSpecialChar,texStatement
Bram Moolenaar488c6512005-08-11 20:09:58 +0000104syn 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 Moolenaar5b8d8fd2005-08-16 23:01:50 +0000105syn 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
Bram Moolenaar5c736222010-01-06 20:54:52 +0100106syn 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
Bram Moolenaarcfbc5ee2004-07-02 15:38:35 +0000107syn cluster texRefGroup contains=texMatcher,texComment,texDelimiter
Bram Moolenaar071d4272004-06-13 20:20:40 +0000108if !exists("tex_no_math")
109 syn cluster texMathZones contains=texMathZoneV,texMathZoneW,texMathZoneX,texMathZoneY,texMathZoneZ
110 syn cluster texMatchGroup add=@texMathZones
111 syn cluster texMathDelimGroup contains=texMathDelimBad,texMathDelimKey,texMathDelimSet1,texMathDelimSet2
112 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 Moolenaar611df5b2010-07-26 22:51:56 +0200113 syn cluster texMathZoneGroup contains=texComment,texDelimiter,texLength,texMathDelim,texMathMatcher,texMathOper,texMathSymbol,texRefZone,texSpecialChar,texStatement,texTypeSize,texTypeStyle
Bram Moolenaar071d4272004-06-13 20:20:40 +0000114 if !exists("g:tex_no_error")
115 syn cluster texMathMatchGroup add=texMathError
116 syn cluster texMathZoneGroup add=texMathError
117 endif
Bram Moolenaar5b8d8fd2005-08-16 23:01:50 +0000118 syn cluster texMathZoneGroup add=@NoSpell
119 " following used in the \part \chapter \section \subsection \subsubsection
120 " \paragraph \subparagraph \author \title highlighting
121 syn cluster texDocGroup contains=texPartZone,@texPartGroup
122 syn cluster texPartGroup contains=texChapterZone,texSectionZone,texParaZone
123 syn cluster texChapterGroup contains=texSectionZone,texParaZone
124 syn cluster texSectionGroup contains=texSubSectionZone,texParaZone
125 syn cluster texSubSectionGroup contains=texSubSubSectionZone,texParaZone
126 syn cluster texSubSubSectionGroup contains=texParaZone
127 syn cluster texParaGroup contains=texSubParaZone
Bram Moolenaarb2c03502010-07-02 20:20:09 +0200128 if has("conceal") && &enc == 'utf-8'
129 syn cluster texMathZoneGroup add=texGreek,texSuperscript,texSubscript
130 syn cluster texMathMatchGroup add=texGreek,texSuperscript,texSubscript
131 endif
Bram Moolenaar071d4272004-06-13 20:20:40 +0000132endif
133
134" Try to flag {} and () mismatches: {{{1
135if !exists("g:tex_no_error")
136 syn region texMatcher matchgroup=Delimiter start="{" skip="\\\\\|\\[{}]" end="}" contains=@texMatchGroup,texError
137 syn region texMatcher matchgroup=Delimiter start="\[" end="]" contains=@texMatchGroup,texError
138else
139 syn region texMatcher matchgroup=Delimiter start="{" skip="\\\\\|\\[{}]" end="}" contains=@texMatchGroup
140 syn region texMatcher matchgroup=Delimiter start="\[" end="]" contains=@texMatchGroup
141endif
Bram Moolenaar293ee4d2004-12-09 21:34:53 +0000142syn region texParen start="(" end=")" contains=@texMatchGroup,@Spell
Bram Moolenaar071d4272004-06-13 20:20:40 +0000143if !exists("g:tex_no_error")
144 syn match texError "[}\])]"
145endif
146if !exists("tex_no_math")
147 if !exists("g:tex_no_error")
148 syn match texMathError "}" contained
149 endif
150 syn region texMathMatcher matchgroup=Delimiter start="{" skip="\\\\\|\\}" end="}" end="%stopzone\>" contained contains=@texMathMatchGroup
151endif
152
153" TeX/LaTeX keywords: {{{1
154" Instead of trying to be All Knowing, I just match \..alphameric..
155" Note that *.tex files may not have "@" in their \commands
156if exists("g:tex_tex") || b:tex_stylish
157 syn match texStatement "\\[a-zA-Z@]\+"
158else
159 syn match texStatement "\\\a\+"
160 if !exists("g:tex_no_error")
161 syn match texError "\\\a*@[a-zA-Z@]*"
162 endif
163endif
164
165" TeX/LaTeX delimiters: {{{1
166syn match texDelimiter "&"
167syn match texDelimiter "\\\\"
168
169" Tex/Latex Options: {{{1
170syn match texOption "[^\\]\zs#\d\+\|^#\d\+"
171
172" texAccent (tnx to Karim Belabas) avoids annoying highlighting for accents: {{{1
173if b:tex_stylish
174 syn match texAccent "\\[bcdvuH][^a-zA-Z@]"me=e-1
175 syn match texLigature "\\\([ijolL]\|ae\|oe\|ss\|AA\|AE\|OE\)[^a-zA-Z@]"me=e-1
176else
177 syn match texAccent "\\[bcdvuH]\A"me=e-1
178 syn match texLigature "\\\([ijolL]\|ae\|oe\|ss\|AA\|AE\|OE\)\A"me=e-1
179endif
180syn match texAccent "\\[bcdvuH]$"
181syn match texAccent +\\[=^.\~"`']+
182syn match texAccent +\\['=t'.c^ud"vb~Hr]{\a}+
183syn match texLigature "\\\([ijolL]\|ae\|oe\|ss\|AA\|AE\|OE\)$"
184
185" \begin{}/\end{} section markers: {{{1
186syn match texSectionMarker "\\begin\>\|\\end\>" nextgroup=texSectionName
Bram Moolenaar5c736222010-01-06 20:54:52 +0100187syn region texSectionName matchgroup=Delimiter start="{" end="}" contained nextgroup=texSectionModifier contains=texComment
188syn region texSectionModifier matchgroup=Delimiter start="\[" end="]" contained contains=texComment
Bram Moolenaar071d4272004-06-13 20:20:40 +0000189
190" \documentclass, \documentstyle, \usepackage: {{{1
191syn match texDocType "\\documentclass\>\|\\documentstyle\>\|\\usepackage\>" nextgroup=texSectionName,texDocTypeArgs
Bram Moolenaar5c736222010-01-06 20:54:52 +0100192syn region texDocTypeArgs matchgroup=Delimiter start="\[" end="]" contained nextgroup=texSectionName contains=texComment
Bram Moolenaar071d4272004-06-13 20:20:40 +0000193
Bram Moolenaara9a568c2006-03-14 23:04:27 +0000194" Preamble syntax-based folding support: {{{1
195if g:tex_fold_enabled && has("folding")
Bram Moolenaar5c736222010-01-06 20:54:52 +0100196 syn region texPreamble transparent fold start='\zs\\documentclass\>' end='\ze\\begin{document}' contains=texStyle,@texMatchGroup
Bram Moolenaara9a568c2006-03-14 23:04:27 +0000197endif
198
Bram Moolenaar071d4272004-06-13 20:20:40 +0000199" TeX input: {{{1
200syn match texInput "\\input\s\+[a-zA-Z/.0-9_^]\+"hs=s+7 contains=texStatement
Bram Moolenaar5c736222010-01-06 20:54:52 +0100201syn match texInputFile "\\include\(graphics\|list\)\=\(\[.\{-}\]\)\=\s*{.\{-}}" contains=texStatement,texInputCurlies,texInputFileOpt
Bram Moolenaar071d4272004-06-13 20:20:40 +0000202syn match texInputFile "\\\(epsfig\|input\|usepackage\)\s*\(\[.*\]\)\={.\{-}}" contains=texStatement,texInputCurlies,texInputFileOpt
203syn match texInputCurlies "[{}]" contained
Bram Moolenaar5c736222010-01-06 20:54:52 +0100204syn region texInputFileOpt matchgroup=Delimiter start="\[" end="\]" contained contains=texComment
Bram Moolenaar071d4272004-06-13 20:20:40 +0000205
206" Type Styles (LaTeX 2.09): {{{1
207syn match texTypeStyle "\\rm\>"
208syn match texTypeStyle "\\em\>"
209syn match texTypeStyle "\\bf\>"
210syn match texTypeStyle "\\it\>"
211syn match texTypeStyle "\\sl\>"
212syn match texTypeStyle "\\sf\>"
213syn match texTypeStyle "\\sc\>"
214syn match texTypeStyle "\\tt\>"
215
216" Type Styles: attributes, commands, families, etc (LaTeX2E): {{{1
217syn match texTypeStyle "\\textbf\>"
218syn match texTypeStyle "\\textit\>"
219syn match texTypeStyle "\\textmd\>"
220syn match texTypeStyle "\\textrm\>"
221syn match texTypeStyle "\\textsc\>"
222syn match texTypeStyle "\\textsf\>"
223syn match texTypeStyle "\\textsl\>"
224syn match texTypeStyle "\\texttt\>"
225syn match texTypeStyle "\\textup\>"
226syn match texTypeStyle "\\emph\>"
227
228syn match texTypeStyle "\\mathbb\>"
229syn match texTypeStyle "\\mathbf\>"
230syn match texTypeStyle "\\mathcal\>"
231syn match texTypeStyle "\\mathfrak\>"
232syn match texTypeStyle "\\mathit\>"
233syn match texTypeStyle "\\mathnormal\>"
234syn match texTypeStyle "\\mathrm\>"
235syn match texTypeStyle "\\mathsf\>"
236syn match texTypeStyle "\\mathtt\>"
237
238syn match texTypeStyle "\\rmfamily\>"
239syn match texTypeStyle "\\sffamily\>"
240syn match texTypeStyle "\\ttfamily\>"
241
242syn match texTypeStyle "\\itshape\>"
243syn match texTypeStyle "\\scshape\>"
244syn match texTypeStyle "\\slshape\>"
245syn match texTypeStyle "\\upshape\>"
246
247syn match texTypeStyle "\\bfseries\>"
248syn match texTypeStyle "\\mdseries\>"
249
250" Some type sizes: {{{1
251syn match texTypeSize "\\tiny\>"
252syn match texTypeSize "\\scriptsize\>"
253syn match texTypeSize "\\footnotesize\>"
254syn match texTypeSize "\\small\>"
255syn match texTypeSize "\\normalsize\>"
256syn match texTypeSize "\\large\>"
257syn match texTypeSize "\\Large\>"
258syn match texTypeSize "\\LARGE\>"
259syn match texTypeSize "\\huge\>"
260syn match texTypeSize "\\Huge\>"
261
262" Spacecodes (TeX'isms): {{{1
263" \mathcode`\^^@="2201 \delcode`\(="028300 \sfcode`\)=0 \uccode`X=`X \lccode`x=`x
264syn match texSpaceCode "\\\(math\|cat\|del\|lc\|sf\|uc\)code`"me=e-1 nextgroup=texSpaceCodeChar
265syn match texSpaceCodeChar "`\\\=.\(\^.\)\==\(\d\|\"\x\{1,6}\|`.\)" contained
266
267" Sections, subsections, etc: {{{1
Bram Moolenaarf1f8bc52005-03-07 23:20:08 +0000268if g:tex_fold_enabled && has("folding")
Bram Moolenaar3577c6f2008-06-24 21:16:56 +0000269 syn region texDocZone matchgroup=texSection start='\\begin\s*{\s*document\s*}' end='\\end\s*{\s*document\s*}' fold contains=@texFoldGroup,@texDocGroup,@Spell
270 syn region texPartZone matchgroup=texSection start='\\part\>' end='\ze\s*\\\%(part\>\|end\s*{\s*document\s*}\)' fold contains=@texFoldGroup,@texPartGroup,@Spell
271 syn region texChapterZone matchgroup=texSection start='\\chapter\>' end='\ze\s*\\\%(chapter\>\|part\>\|end\s*{\s*document\s*}\)' fold contains=@texFoldGroup,@texChapterGroup,@Spell
272 syn region texSectionZone matchgroup=texSection start='\\section\>' end='\ze\s*\\\%(section\>\|chapter\>\|part\>\|end\s*{\s*document\s*}\)' fold contains=@texFoldGroup,@texSectionGroup,@Spell
273 syn region texSubSectionZone matchgroup=texSection start='\\subsection\>' end='\ze\s*\\\%(\%(sub\)\=section\>\|chapter\>\|part\>\|end\s*{\s*document\s*}\)' fold contains=@texFoldGroup,@texSubSectionGroup,@Spell
274 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
275 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
276 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
277 syn region texTitle matchgroup=texSection start='\\\%(author\|title\)\>\s*{' end='}' fold contains=@texFoldGroup,@Spell
278 syn region texAbstract matchgroup=texSection start='\\begin\s*{\s*abstract\s*}' end='\\end\s*{\s*abstract\s*}' fold contains=@texFoldGroup,@Spell
Bram Moolenaar293ee4d2004-12-09 21:34:53 +0000279else
Bram Moolenaar3577c6f2008-06-24 21:16:56 +0000280 syn region texDocZone matchgroup=texSection start='\\begin\s*{\s*document\s*}' end='\\end\s*{\s*document\s*}' contains=@texFoldGroup,@texDocGroup,@Spell
281 syn region texPartZone matchgroup=texSection start='\\part\>' end='\ze\s*\\\%(part\>\|end\s*{\s*document\s*}\)' contains=@texFoldGroup,@texPartGroup,@Spell
282 syn region texChapterZone matchgroup=texSection start='\\chapter\>' end='\ze\s*\\\%(chapter\>\|part\>\|end\s*{\s*document\s*}\)' contains=@texFoldGroup,@texChapterGroup,@Spell
283 syn region texSectionZone matchgroup=texSection start='\\section\>' end='\ze\s*\\\%(section\>\|chapter\>\|part\>\|end\s*{\s*document\s*}\)' contains=@texFoldGroup,@texSectionGroup,@Spell
284 syn region texSubSectionZone matchgroup=texSection start='\\subsection\>' end='\ze\s*\\\%(\%(sub\)\=section\>\|chapter\>\|part\>\|end\s*{\s*document\s*}\)' contains=@texFoldGroup,@texSubSectionGroup,@Spell
285 syn region texSubSubSectionZone matchgroup=texSection start='\\subsubsection\>' end='\ze\s*\\\%(\%(sub\)\{,2}section\>\|chapter\>\|part\>\|end\s*{\s*document\s*}\)' contains=@texFoldGroup,@texSubSubSectionGroup,@Spell
286 syn region texParaZone matchgroup=texSection start='\\paragraph\>' end='\ze\s*\\\%(paragraph\>\|\%(sub\)*section\>\|chapter\>\|part\>\|end\s*{\s*document\s*}\)' contains=@texFoldGroup,@texParaGroup,@Spell
287 syn region texSubParaZone matchgroup=texSection start='\\subparagraph\>' end='\ze\s*\\\%(\%(sub\)\=paragraph\>\|\%(sub\)*section\>\|chapter\>\|part\>\|end\s*{\s*document\s*}\)' contains=@texFoldGroup,@Spell
288 syn region texTitle matchgroup=texSection start='\\\%(author\|title\)\>\s*{' end='}' contains=@texFoldGroup,@Spell
289 syn region texAbstract matchgroup=texSection start='\\begin\s*{\s*abstract\s*}' end='\\end\s*{\s*abstract\s*}' contains=@texFoldGroup,@Spell
Bram Moolenaar293ee4d2004-12-09 21:34:53 +0000290endif
Bram Moolenaar071d4272004-06-13 20:20:40 +0000291
292" Bad Math (mismatched): {{{1
293if !exists("tex_no_math")
294 syn match texBadMath "\\end\s*{\s*\(array\|gathered\|bBpvV]matrix\|split\|subequations\|smallmatrix\|xxalignat\)\s*}"
295 syn match texBadMath "\\end\s*{\s*\(align\|alignat\|displaymath\|displaymath\|eqnarray\|equation\|flalign\|gather\|math\|multline\|xalignat\)\*\=\s*}"
296 syn match texBadMath "\\[\])]"
297endif
298
299" Math Zones: {{{1
300if !exists("tex_no_math")
Bram Moolenaar488c6512005-08-11 20:09:58 +0000301 " TexNewMathZone: function creates a mathzone with the given suffix and mathzone name. {{{2
Bram Moolenaar071d4272004-06-13 20:20:40 +0000302 " Starred forms are created if starform is true. Starred
303 " forms have syntax group and synchronization groups with a
304 " "S" appended. Handles: cluster, syntax, sync, and HiLink.
305 fun! TexNewMathZone(sfx,mathzone,starform)
306 let grpname = "texMathZone".a:sfx
307 let syncname = "texSyncMathZone".a:sfx
Bram Moolenaar3577c6f2008-06-24 21:16:56 +0000308 if g:tex_fold_enabled
309 let foldcmd= " fold"
310 else
311 let foldcmd= ""
312 endif
Bram Moolenaar071d4272004-06-13 20:20:40 +0000313 exe "syn cluster texMathZones add=".grpname
Bram Moolenaar3577c6f2008-06-24 21:16:56 +0000314 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 +0000315 exe 'syn sync match '.syncname.' grouphere '.grpname.' "\\begin\s*{\s*'.a:mathzone.'\*\s*}"'
316 exe 'syn sync match '.syncname.' grouphere '.grpname.' "\\begin\s*{\s*'.a:mathzone.'\*\s*}"'
Bram Moolenaar5c736222010-01-06 20:54:52 +0100317 exe 'hi def link '.grpname.' texMath'
Bram Moolenaar071d4272004-06-13 20:20:40 +0000318 if a:starform
319 let grpname = "texMathZone".a:sfx.'S'
320 let syncname = "texSyncMathZone".a:sfx.'S'
321 exe "syn cluster texMathZones add=".grpname
Bram Moolenaar3577c6f2008-06-24 21:16:56 +0000322 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 +0000323 exe 'syn sync match '.syncname.' grouphere '.grpname.' "\\begin\s*{\s*'.a:mathzone.'\*\s*}"'
324 exe 'syn sync match '.syncname.' grouphere '.grpname.' "\\begin\s*{\s*'.a:mathzone.'\*\s*}"'
Bram Moolenaar5c736222010-01-06 20:54:52 +0100325 exe 'hi def link '.grpname.' texMath'
Bram Moolenaar071d4272004-06-13 20:20:40 +0000326 endif
327 endfun
328
329 " Standard Math Zones: {{{2
330 call TexNewMathZone("A","align",1)
331 call TexNewMathZone("B","alignat",1)
332 call TexNewMathZone("C","displaymath",1)
333 call TexNewMathZone("D","eqnarray",1)
334 call TexNewMathZone("E","equation",1)
335 call TexNewMathZone("F","flalign",1)
336 call TexNewMathZone("G","gather",1)
337 call TexNewMathZone("H","math",1)
338 call TexNewMathZone("I","multline",1)
339 call TexNewMathZone("J","subequations",0)
340 call TexNewMathZone("K","xalignat",1)
341 call TexNewMathZone("L","xxalignat",0)
342
343 " Inline Math Zones: {{{2
Bram Moolenaarb2c03502010-07-02 20:20:09 +0200344 syn region texMathZoneV matchgroup=Delimiter start="\\(" matchgroup=Delimiter end="\\)\|%stopzone\>" keepend contains=@texMathZoneGroup
345 syn region texMathZoneW matchgroup=Delimiter start="\\\[" matchgroup=Delimiter end="\\]\|%stopzone\>" keepend contains=@texMathZoneGroup
346 syn region texMathZoneX matchgroup=Delimiter start="\$" skip="\\\\\|\\\$" matchgroup=Delimiter end="\$" end="%stopzone\>" contains=@texMathZoneGroup
347 syn region texMathZoneY matchgroup=Delimiter start="\$\$" matchgroup=Delimiter end="\$\$" end="%stopzone\>" keepend contains=@texMathZoneGroup
348 syn region texMathZoneZ matchgroup=texStatement start="\\ensuremath\s*{" matchgroup=texStatement end="}" end="%stopzone\>" contains=@texMathZoneGroup
Bram Moolenaar071d4272004-06-13 20:20:40 +0000349
350 syn match texMathOper "[_^=]" contained
351
352 " \left..something.. and \right..something.. support: {{{2
353 syn match texMathDelimBad contained "\S"
354 syn match texMathDelim contained "\\\(left\|right\|[bB]igg\=[lr]\)\>" skipwhite nextgroup=texMathDelimSet1,texMathDelimSet2,texMathDelimBad
355 syn match texMathDelim contained "\\\(left\|right\)arrow\>\|\<\([aA]rrow\|brace\)\=vert\>"
356 syn match texMathDelim contained "\\lefteqn\>"
357 syn match texMathDelimSet2 contained "\\" nextgroup=texMathDelimKey,texMathDelimBad
358 syn match texMathDelimSet1 contained "[<>()[\]|/.]\|\\[{}|]"
359 syn keyword texMathDelimKey contained backslash lceil lVert rgroup uparrow
360 syn keyword texMathDelimKey contained downarrow lfloor rangle rmoustache Uparrow
361 syn keyword texMathDelimKey contained Downarrow lgroup rbrace rvert updownarrow
362 syn keyword texMathDelimKey contained langle lmoustache rceil rVert Updownarrow
363 syn keyword texMathDelimKey contained lbrace lvert rfloor
364endif
365
366" Special TeX characters ( \$ \& \% \# \{ \} \_ \S \P ) : {{{1
367syn match texSpecialChar "\\[$&%#{}_]"
368if b:tex_stylish
369 syn match texSpecialChar "\\[SP@][^a-zA-Z@]"me=e-1
370else
371 syn match texSpecialChar "\\[SP@]\A"me=e-1
372endif
373syn match texSpecialChar "\\\\"
374if !exists("tex_no_math")
375 syn match texOnlyMath "[_^]"
376endif
377syn match texSpecialChar "\^\^[0-9a-f]\{2}\|\^\^\S"
378
379" Comments: {{{1
380" Normal TeX LaTeX : %....
381" Documented TeX Format: ^^A... -and- leading %s (only)
Bram Moolenaar3577c6f2008-06-24 21:16:56 +0000382if !exists("g:tex_comment_nospell") || !g:tex_comment_nospell
383 syn cluster texCommentGroup contains=texTodo,@Spell
384else
385 syn cluster texCommentGroup contains=texTodo,@NoSpell
386endif
Bram Moolenaar071d4272004-06-13 20:20:40 +0000387syn case ignore
Bram Moolenaar18144c82006-04-12 21:52:12 +0000388syn keyword texTodo contained combak fixme todo xxx
Bram Moolenaar071d4272004-06-13 20:20:40 +0000389syn case match
390if b:extfname == "dtx"
391 syn match texComment "\^\^A.*$" contains=@texCommentGroup
392 syn match texComment "^%\+" contains=@texCommentGroup
393else
Bram Moolenaarfd2ac762006-03-01 22:09:21 +0000394 if g:tex_fold_enabled
395 " allows syntax-folding of 2 or more contiguous comment lines
396 " single-line comments are not folded
397 syn match texComment "%.*$" contains=@texCommentGroup
398 syn region texComment start="^\zs\s*%.*\_s*%" skip="^\s*%" end='^\ze\s*[^%]' fold
399 else
400 syn match texComment "%.*$" contains=@texCommentGroup
401 endif
Bram Moolenaar071d4272004-06-13 20:20:40 +0000402endif
403
404" Separate lines used for verb` and verb# so that the end conditions {{{1
405" will appropriately terminate. Ideally vim would let me save a
406" character from the start pattern and re-use it in the end-pattern.
Bram Moolenaar5c736222010-01-06 20:54:52 +0100407syn region texZone start="\\begin{[vV]erbatim}" end="\\end{[vV]erbatim}\|%stopzone\>" contains=@Spell
Bram Moolenaarc1e37902006-04-18 21:55:01 +0000408" listings package:
409syn region texZone start="\\begin{lstlisting}" end="\\end{lstlisting}\|%stopzone\>" contains=@Spell
410" moreverb package:
411syn region texZone start="\\begin{verbatimtab}" end="\\end{verbatimtab}\|%stopzone\>" contains=@Spell
412syn region texZone start="\\begin{verbatimwrite}" end="\\end{verbatimwrite}\|%stopzone\>" contains=@Spell
413syn region texZone start="\\begin{boxedverbatim}" end="\\end{boxedverbatim}\|%stopzone\>" contains=@Spell
Bram Moolenaar071d4272004-06-13 20:20:40 +0000414if version < 600
415 syn region texZone start="\\verb\*\=`" end="`\|%stopzone\>"
416 syn region texZone start="\\verb\*\=#" end="#\|%stopzone\>"
417else
418 if b:tex_stylish
419 syn region texZone start="\\verb\*\=\z([^\ta-zA-Z@]\)" end="\z1\|%stopzone\>"
420 else
421 syn region texZone start="\\verb\*\=\z([^\ta-zA-Z]\)" end="\z1\|%stopzone\>"
422 endif
423endif
424
425" Tex Reference Zones: {{{1
Bram Moolenaarcfbc5ee2004-07-02 15:38:35 +0000426syn region texZone matchgroup=texStatement start="@samp{" end="}\|%stopzone\>" contains=@texRefGroup
427syn region texRefZone matchgroup=texStatement start="\\nocite{" end="}\|%stopzone\>" contains=@texRefGroup
428syn region texRefZone matchgroup=texStatement start="\\bibliography{" end="}\|%stopzone\>" contains=@texRefGroup
Bram Moolenaarcfbc5ee2004-07-02 15:38:35 +0000429syn region texRefZone matchgroup=texStatement start="\\label{" end="}\|%stopzone\>" contains=@texRefGroup
430syn region texRefZone matchgroup=texStatement start="\\\(page\|eq\)ref{" end="}\|%stopzone\>" contains=@texRefGroup
431syn region texRefZone matchgroup=texStatement start="\\v\=ref{" end="}\|%stopzone\>" contains=@texRefGroup
Bram Moolenaarcc016f52005-12-10 20:23:46 +0000432syn match texRefZone '\\cite\%([tp]\*\=\)\=' nextgroup=texRefOption,texCite
433syn region texRefOption contained matchgroup=Delimiter start='\[' end=']' contains=@texRefGroup nextgroup=texRefOption,texCite
434syn region texCite contained matchgroup=Delimiter start='{' end='}' contains=@texRefGroup
Bram Moolenaar071d4272004-06-13 20:20:40 +0000435
436" Handle newcommand, newenvironment : {{{1
437syn match texNewCmd "\\newcommand\>" nextgroup=texCmdName skipwhite skipnl
438syn region texCmdName contained matchgroup=Delimiter start="{"rs=s+1 end="}" nextgroup=texCmdArgs,texCmdBody skipwhite skipnl
439syn region texCmdArgs contained matchgroup=Delimiter start="\["rs=s+1 end="]" nextgroup=texCmdBody skipwhite skipnl
440syn region texCmdBody contained matchgroup=Delimiter start="{"rs=s+1 skip="\\\\\|\\[{}]" matchgroup=Delimiter end="}" contains=@texCmdGroup
441syn match texNewEnv "\\newenvironment\>" nextgroup=texEnvName skipwhite skipnl
442syn region texEnvName contained matchgroup=Delimiter start="{"rs=s+1 end="}" nextgroup=texEnvBgn skipwhite skipnl
443syn region texEnvBgn contained matchgroup=Delimiter start="{"rs=s+1 end="}" nextgroup=texEnvEnd skipwhite skipnl contains=@texEnvGroup
444syn region texEnvEnd contained matchgroup=Delimiter start="{"rs=s+1 end="}" skipwhite skipnl contains=@texEnvGroup
445
446" Definitions/Commands: {{{1
447syn match texDefCmd "\\def\>" nextgroup=texDefName skipwhite skipnl
448if b:tex_stylish
449 syn match texDefName contained "\\[a-zA-Z@]\+" nextgroup=texDefParms,texCmdBody skipwhite skipnl
450 syn match texDefName contained "\\[^a-zA-Z@]" nextgroup=texDefParms,texCmdBody skipwhite skipnl
451else
452 syn match texDefName contained "\\\a\+" nextgroup=texDefParms,texCmdBody skipwhite skipnl
453 syn match texDefName contained "\\\A" nextgroup=texDefParms,texCmdBody skipwhite skipnl
454endif
455syn match texDefParms contained "#[^{]*" contains=texDefParm nextgroup=texCmdBody skipwhite skipnl
456syn match texDefParm contained "#\d\+"
457
458" TeX Lengths: {{{1
Bram Moolenaar9964e462007-05-05 17:54:07 +0000459syn 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 +0000460
461" TeX String Delimiters: {{{1
462syn match texString "\(``\|''\|,,\)"
463
Bram Moolenaar5c736222010-01-06 20:54:52 +0100464" makeatletter -- makeatother sections
465if !exists("g:tex_no_error")
466 syn region texStyle matchgroup=texStatement start='\\makeatletter' end='\\makeatother' contains=@texStyleGroup contained
467 syn match texStyleStatement "\\[a-zA-Z@]\+" contained
468 syn region texStyleMatcher matchgroup=Delimiter start="{" skip="\\\\\|\\[{}]" end="}" contains=@texStyleGroup,texError contained
469 syn region texStyleMatcher matchgroup=Delimiter start="\[" end="]" contains=@texStyleGroup,texError contained
470endif
471
Bram Moolenaar611df5b2010-07-26 22:51:56 +0200472" Conceal mode support (supports set cole=1) {{{1
Bram Moolenaarb2c03502010-07-02 20:20:09 +0200473if has("conceal") && &enc == 'utf-8'
Bram Moolenaar611df5b2010-07-26 22:51:56 +0200474
475 " Math Symbols {{{2
476 syn match texMathSymbol '\\left(' contained conceal cchar=(
477 syn match texMathSymbol '\\right)' contained conceal cchar=)
478 syn match texMathSymbol '\\left{' contained conceal cchar={
479 syn match texMathSymbol '\\right}' contained conceal cchar=}
480 syn match texMathSymbol '\\cdot\>' contained conceal cchar=·
481 syn match texMathSymbol '\\leq\>' contained conceal cchar=≤
482 syn match texMathSymbol '\\geq\>' contained conceal cchar=≥
483 syn match texMathSymbol '\\cdot\>' contained conceal cchar=·
484 syn match texMathSymbol '\\times\>' contained conceal cchar=×
485 syn match texMathSymbol '\\div\>' contained conceal cchar=÷
486 syn match texMathSymbol '\\pm\>' contained conceal cchar=±
487 syn match texMathSymbol '\\neq\>' contained conceal cchar=≠
488 syn match texMathSymbol '\\cong\>' contained conceal cchar=≅
489
490 " Greek {{{2
491 fun! s:Greek(group,pat,cchar)
492 exe 'syn match '.a:group." '".a:pat."' contained conceal cchar=".a:cchar
493 endfun
494 call s:Greek('texGreek','\\alpha\>' ,'α')
495 call s:Greek('texGreek','\\beta\>' ,'β')
496 call s:Greek('texGreek','\\gamma\>' ,'γ')
497 call s:Greek('texGreek','\\delta\>' ,'δ')
498 call s:Greek('texGreek','\\epsilon\>' ,'ϵ')
499 call s:Greek('texGreek','\\varepsilon\>' ,'ε')
500 call s:Greek('texGreek','\\zeta\>' ,'ζ')
501 call s:Greek('texGreek','\\eta\>' ,'η')
502 call s:Greek('texGreek','\\theta\>' ,'θ')
503 call s:Greek('texGreek','\\vartheta\>' ,'ϑ')
504 call s:Greek('texGreek','\\kappa\>' ,'κ')
505 call s:Greek('texGreek','\\lambda\>' ,'λ')
506 call s:Greek('texGreek','\\mu\>' ,'μ')
507 call s:Greek('texGreek','\\nu\>' ,'ν')
508 call s:Greek('texGreek','\\xi\>' ,'ξ')
509 call s:Greek('texGreek','\\pi\>' ,'π')
510 call s:Greek('texGreek','\\varpi\>' ,'ϖ')
511 call s:Greek('texGreek','\\rho\>' ,'ρ')
512 call s:Greek('texGreek','\\varrho\>' ,'ϱ')
513 call s:Greek('texGreek','\\sigma\>' ,'σ')
514 call s:Greek('texGreek','\\varsigma\>' ,'ς')
515 call s:Greek('texGreek','\\tau\>' ,'τ')
516 call s:Greek('texGreek','\\upsilon\>' ,'υ')
517 call s:Greek('texGreek','\\phi\>' ,'φ')
518 call s:Greek('texGreek','\\varphi\>' ,'ϕ')
519 call s:Greek('texGreek','\\chi\>' ,'χ')
520 call s:Greek('texGreek','\\psi\>' ,'ψ')
521 call s:Greek('texGreek','\\omega\>' ,'ω')
522 call s:Greek('texGreek','\\Gamma\>' ,'Γ')
523 call s:Greek('texGreek','\\Delta\>' ,'Δ')
524 call s:Greek('texGreek','\\Theta\>' ,'Θ')
525 call s:Greek('texGreek','\\Lambda\>' ,'Λ')
526 call s:Greek('texGreek','\\Xi\>' ,'Χ')
527 call s:Greek('texGreek','\\Pi\>' ,'Π')
528 call s:Greek('texGreek','\\Sigma\>' ,'Σ')
529 call s:Greek('texGreek','\\Upsilon\>' ,'Υ')
530 call s:Greek('texGreek','\\Phi\>' ,'Φ')
531 call s:Greek('texGreek','\\Psi\>' ,'Ψ')
532 call s:Greek('texGreek','\\Omega\>' ,'Ω')
533
534 " Superscripts/Subscripts {{{2
535 syn region texSuperscript start='\^{' end='}' contained contains=texSuperscripts
536 syn region texSubscript start='_{' end='}' contained contains=texSubscripts
537 fun! s:SuperSub(group,leader,pat,cchar)
538 exe 'syn match '.a:group." '".a:leader.a:pat."' contained conceal cchar=".a:cchar
539 exe 'syn match '.a:group."s '".a:pat."' contained conceal cchar=".a:cchar.' nextgroup='.a:group.'s'
540 endfun
541 call s:SuperSub('texSuperscript','\^','0','⁰')
542 call s:SuperSub('texSuperscript','\^','1','¹')
543 call s:SuperSub('texSuperscript','\^','2','²')
544 call s:SuperSub('texSuperscript','\^','3','³')
545 call s:SuperSub('texSuperscript','\^','4','⁴')
546 call s:SuperSub('texSuperscript','\^','5','⁵')
547 call s:SuperSub('texSuperscript','\^','6','⁶')
548 call s:SuperSub('texSuperscript','\^','7','⁷')
549 call s:SuperSub('texSuperscript','\^','8','⁸')
550 call s:SuperSub('texSuperscript','\^','9','⁹')
551 call s:SuperSub('texSuperscript','\^','a','ᵃ')
552 call s:SuperSub('texSuperscript','\^','b','ᵇ')
553 call s:SuperSub('texSuperscript','\^','c','ᶜ')
554 call s:SuperSub('texSuperscript','\^','d','ᵈ')
555 call s:SuperSub('texSuperscript','\^','e','ᵉ')
556 call s:SuperSub('texSuperscript','\^','f','ᶠ')
557 call s:SuperSub('texSuperscript','\^','g','ᵍ')
558 call s:SuperSub('texSuperscript','\^','h','ʰ')
559 call s:SuperSub('texSuperscript','\^','i','ⁱ')
560 call s:SuperSub('texSuperscript','\^','j','ʲ')
561 call s:SuperSub('texSuperscript','\^','k','ᵏ')
562 call s:SuperSub('texSuperscript','\^','l','ˡ')
563 call s:SuperSub('texSuperscript','\^','m','ᵐ')
564 call s:SuperSub('texSuperscript','\^','n','ⁿ')
565 call s:SuperSub('texSuperscript','\^','o','ᵒ')
566 call s:SuperSub('texSuperscript','\^','p','ᵖ')
567 call s:SuperSub('texSuperscript','\^','r','ʳ')
568 call s:SuperSub('texSuperscript','\^','s','ˢ')
569 call s:SuperSub('texSuperscript','\^','t','ᵗ')
570 call s:SuperSub('texSuperscript','\^','u','ᵘ')
571 call s:SuperSub('texSuperscript','\^','v','ᵛ')
572 call s:SuperSub('texSuperscript','\^','w','ʷ')
573 call s:SuperSub('texSuperscript','\^','x','ˣ')
574 call s:SuperSub('texSuperscript','\^','y','ʸ')
575 call s:SuperSub('texSuperscript','\^','z','ᶻ')
576 call s:SuperSub('texSuperscript','\^','A','ᴬ')
577 call s:SuperSub('texSuperscript','\^','B','ᴮ')
578 call s:SuperSub('texSuperscript','\^','D','ᴰ')
579 call s:SuperSub('texSuperscript','\^','E','ᴱ')
580 call s:SuperSub('texSuperscript','\^','G','ᴳ')
581 call s:SuperSub('texSuperscript','\^','H','ᴴ')
582 call s:SuperSub('texSuperscript','\^','I','ᴵ')
583 call s:SuperSub('texSuperscript','\^','J','ᴶ')
584 call s:SuperSub('texSuperscript','\^','K','ᴷ')
585 call s:SuperSub('texSuperscript','\^','L','ᴸ')
586 call s:SuperSub('texSuperscript','\^','M','ᴹ')
587 call s:SuperSub('texSuperscript','\^','N','ᴺ')
588 call s:SuperSub('texSuperscript','\^','O','ᴼ')
589 call s:SuperSub('texSuperscript','\^','P','ᴾ')
590 call s:SuperSub('texSuperscript','\^','R','ᴿ')
591 call s:SuperSub('texSuperscript','\^','T','ᵀ')
592 call s:SuperSub('texSuperscript','\^','U','ᵁ')
593 call s:SuperSub('texSuperscript','\^','W','ᵂ')
594 call s:SuperSub('texSuperscript','\^','+','⁺')
595 call s:SuperSub('texSuperscript','\^','-','⁻')
596 call s:SuperSub('texSuperscript','\^','<','˂')
597 call s:SuperSub('texSuperscript','\^','>','˃')
598 call s:SuperSub('texSuperscript','\^','/','ˊ')
599 call s:SuperSub('texSuperscript','\^','(','⁽')
600 call s:SuperSub('texSuperscript','\^',')','⁾')
601 call s:SuperSub('texSuperscript','\^','\.','˙')
602 call s:SuperSub('texSuperscript','\^','=','˭')
603 call s:SuperSub('texSubscript','_','0','₀')
604 call s:SuperSub('texSubscript','_','1','₁')
605 call s:SuperSub('texSubscript','_','2','₂')
606 call s:SuperSub('texSubscript','_','3','₃')
607 call s:SuperSub('texSubscript','_','4','₄')
608 call s:SuperSub('texSubscript','_','5','₅')
609 call s:SuperSub('texSubscript','_','6','₆')
610 call s:SuperSub('texSubscript','_','7','₇')
611 call s:SuperSub('texSubscript','_','8','₈')
612 call s:SuperSub('texSubscript','_','9','₉')
613 call s:SuperSub('texSubscript','_','a','ₐ')
614 call s:SuperSub('texSubscript','_','e','ₑ')
615 call s:SuperSub('texSubscript','_','i','ᵢ')
616 call s:SuperSub('texSubscript','_','o','ₒ')
617 call s:SuperSub('texSubscript','_','u','ᵤ')
618 call s:SuperSub('texSubscript','_','+','₊')
619 call s:SuperSub('texSubscript','_','-','₋')
620 call s:SuperSub('texSubscript','_','/','ˏ')
621 call s:SuperSub('texSubscript','_','(','₍')
622 call s:SuperSub('texSubscript','_',')','₎')
623 call s:SuperSub('texSubscript','_','\.','‸')
624 call s:SuperSub('texSubscript','_','r','ᵣ')
625 call s:SuperSub('texSubscript','_','v','ᵥ')
626 call s:SuperSub('texSubscript','_','x','ₓ')
627 call s:SuperSub('texSubscript','_','\\beta\>' ,'ᵦ')
628 call s:SuperSub('texSubscript','_','\\delta\>','ᵨ')
629 call s:SuperSub('texSubscript','_','\\phi\>' ,'ᵩ')
630 call s:SuperSub('texSubscript','_','\\gamma\>','ᵧ')
631 call s:SuperSub('texSubscript','_','\\chi\>' ,'ᵪ')
632
633 " Accented characters: {{{2
634 if b:tex_stylish
635 syn match texAccent "\\[bcdvuH][^a-zA-Z@]"me=e-1
636 syn match texLigature "\\\([ijolL]\|ae\|oe\|ss\|AA\|AE\|OE\)[^a-zA-Z@]"me=e-1
637 else
638 syn match texAccent '\\`{a}' conceal cchar=à
639 syn match texAccent '\\\'{a}' conceal cchar=á
640 syn match texAccent '\\^{a}' conceal cchar=â
641 syn match texAccent '\\"{a}' conceal cchar=ä
642 syn match texAccent '\\\~{a}' conceal cchar=ã
643 syn match texAccent '\\r{a}' conceal cchar=å
644 syn match texAccent '\\`{A}' conceal cchar=À
645 syn match texAccent '\\\'{A}' conceal cchar=Á
646 syn match texAccent '\\^{A}' conceal cchar=Â
647 syn match texAccent '\\"{A}' conceal cchar=Ä
648 syn match texAccent '\\\~{A}' conceal cchar=Ã
649 syn match texAccent '\\r{A}' conceal cchar=Å
650 syn match texAccent '\\c{c}' conceal cchar=ç
651 syn match texAccent '\\`{e}' conceal cchar=è
652 syn match texAccent '\\\'{e}' conceal cchar=é
653 syn match texAccent '\\^{e}' conceal cchar=ê
654 syn match texAccent '\\"{e}' conceal cchar=ë
655 syn match texAccent '\\\~{e}' conceal cchar=ẽ
656 syn match texAccent '\\`{E}' conceal cchar=È
657 syn match texAccent '\\\'{E}' conceal cchar=É
658 syn match texAccent '\\^{E}' conceal cchar=Ê
659 syn match texAccent '\\"{E}' conceal cchar=Ë
660 syn match texAccent '\\\~{E}' conceal cchar=Ẽ
661 syn match texAccent '\\`{i}' conceal cchar=ì
662 syn match texAccent '\\\'{i}' conceal cchar=í
663 syn match texAccent '\\^{i}' conceal cchar=î
664 syn match texAccent '\\"{i}' conceal cchar=ï
665 syn match texAccent '\\\~{i}' conceal cchar=ĩ
666 syn match texAccent '\\`{I}' conceal cchar=Ì
667 syn match texAccent '\\\'{I}' conceal cchar=Í
668 syn match texAccent '\\^{I}' conceal cchar=Î
669 syn match texAccent '\\"{I}' conceal cchar=Ï
670 syn match texAccent '\\\~{I}' conceal cchar=Ĩ
671 syn match texAccent '\\`{o}' conceal cchar=ò
672 syn match texAccent '\\\'{o}' conceal cchar=ó
673 syn match texAccent '\\^{o}' conceal cchar=ô
674 syn match texAccent '\\"{o}' conceal cchar=ö
675 syn match texAccent '\\\~{o}' conceal cchar=õ
676 syn match texAccent '\\`{O}' conceal cchar=Ò
677 syn match texAccent '\\\'{O}' conceal cchar=Ó
678 syn match texAccent '\\^{O}' conceal cchar=Ô
679 syn match texAccent '\\"{O}' conceal cchar=Ö
680 syn match texAccent '\\\~{O}' conceal cchar=Õ
681 syn match texAccent '\\`{u}' conceal cchar=ù
682 syn match texAccent '\\\'{u}' conceal cchar=ú
683 syn match texAccent '\\^{u}' conceal cchar=û
684 syn match texAccent '\\"{u}' conceal cchar=ü
685 syn match texAccent '\\\~{u}' conceal cchar=ũ
686 syn match texAccent '\\`{U}' conceal cchar=Ù
687 syn match texAccent '\\\'{U}' conceal cchar=Ú
688 syn match texAccent '\\^{U}' conceal cchar=Û
689 syn match texAccent '\\"{U}' conceal cchar=Ü
690 syn match texAccent '\\\~{U}' conceal cchar=Ũ
691 syn match texAccent '\\`{y}' conceal cchar=ỳ
692 syn match texAccent '\\\'{y}' conceal cchar=ý
693 syn match texAccent '\\^{y}' conceal cchar=ŷ
694 syn match texAccent '\\"{y}' conceal cchar=ÿ
695 syn match texAccent '\\\~{y}' conceal cchar=ỹ
696 syn match texAccent '\\`{Y}' conceal cchar=Ỳ
697 syn match texAccent '\\\'{Y}' conceal cchar=Ý
698 syn match texAccent '\\^{Y}' conceal cchar=Ŷ
699 syn match texAccent '\\"{Y}' conceal cchar=Ÿ
700 syn match texAccent '\\\~{Y}' conceal cchar=Ỹ
701 endif
Bram Moolenaarb2c03502010-07-02 20:20:09 +0200702endif
703
704" ---------------------------------------------------------------------
Bram Moolenaar071d4272004-06-13 20:20:40 +0000705" LaTeX synchronization: {{{1
706syn sync maxlines=200
707syn sync minlines=50
708
709syn sync match texSyncStop groupthere NONE "%stopzone\>"
710
711" Synchronization: {{{1
712" The $..$ and $$..$$ make for impossible sync patterns
713" (one can't tell if a "$$" starts or stops a math zone by itself)
714" The following grouptheres coupled with minlines above
715" help improve the odds of good syncing.
716if !exists("tex_no_math")
717 syn sync match texSyncMathZoneA groupthere NONE "\\end{abstract}"
718 syn sync match texSyncMathZoneA groupthere NONE "\\end{center}"
719 syn sync match texSyncMathZoneA groupthere NONE "\\end{description}"
720 syn sync match texSyncMathZoneA groupthere NONE "\\end{enumerate}"
721 syn sync match texSyncMathZoneA groupthere NONE "\\end{itemize}"
722 syn sync match texSyncMathZoneA groupthere NONE "\\end{table}"
723 syn sync match texSyncMathZoneA groupthere NONE "\\end{tabular}"
724 syn sync match texSyncMathZoneA groupthere NONE "\\\(sub\)*section\>"
725endif
726
Bram Moolenaarb2c03502010-07-02 20:20:09 +0200727" ---------------------------------------------------------------------
Bram Moolenaar071d4272004-06-13 20:20:40 +0000728" Highlighting: {{{1
729if did_tex_syntax_inits == 1
730 let did_tex_syntax_inits= 2
731 " TeX highlighting groups which should share similar highlighting
732 if !exists("g:tex_no_error")
733 if !exists("tex_no_math")
734 HiLink texBadMath texError
735 HiLink texMathDelimBad texError
736 HiLink texMathError texError
737 if !b:tex_stylish
738 HiLink texOnlyMath texError
739 endif
740 endif
741 HiLink texError Error
742 endif
743
Bram Moolenaarcc016f52005-12-10 20:23:46 +0000744 HiLink texCite texRefZone
Bram Moolenaar071d4272004-06-13 20:20:40 +0000745 HiLink texDefCmd texDef
746 HiLink texDefName texDef
747 HiLink texDocType texCmdName
748 HiLink texDocTypeArgs texCmdArgs
749 HiLink texInputFileOpt texCmdArgs
750 HiLink texInputCurlies texDelimiter
751 HiLink texLigature texSpecialChar
752 if !exists("tex_no_math")
753 HiLink texMathDelimSet1 texMathDelim
754 HiLink texMathDelimSet2 texMathDelim
755 HiLink texMathDelimKey texMathDelim
756 HiLink texMathMatcher texMath
Bram Moolenaar5c736222010-01-06 20:54:52 +0100757 HiLink texMathZoneV texMath
Bram Moolenaar071d4272004-06-13 20:20:40 +0000758 HiLink texMathZoneW texMath
759 HiLink texMathZoneX texMath
760 HiLink texMathZoneY texMath
Bram Moolenaar3577c6f2008-06-24 21:16:56 +0000761 HiLink texMathZoneV texMath
Bram Moolenaar071d4272004-06-13 20:20:40 +0000762 HiLink texMathZoneZ texMath
763 endif
764 HiLink texSectionMarker texCmdName
765 HiLink texSectionName texSection
766 HiLink texSpaceCode texStatement
Bram Moolenaar5c736222010-01-06 20:54:52 +0100767 HiLink texStyleStatement texStatement
Bram Moolenaar071d4272004-06-13 20:20:40 +0000768 HiLink texTypeSize texType
769 HiLink texTypeStyle texType
770
771 " Basic TeX highlighting groups
772 HiLink texCmdArgs Number
773 HiLink texCmdName Statement
774 HiLink texComment Comment
775 HiLink texDef Statement
776 HiLink texDefParm Special
777 HiLink texDelimiter Delimiter
778 HiLink texInput Special
779 HiLink texInputFile Special
780 HiLink texLength Number
781 HiLink texMath Special
782 HiLink texMathDelim Statement
783 HiLink texMathOper Operator
784 HiLink texNewCmd Statement
785 HiLink texNewEnv Statement
786 HiLink texOption Number
787 HiLink texRefZone Special
788 HiLink texSection PreCondit
789 HiLink texSpaceCodeChar Special
790 HiLink texSpecialChar SpecialChar
791 HiLink texStatement Statement
792 HiLink texString String
793 HiLink texTodo Todo
794 HiLink texType Type
795 HiLink texZone PreCondit
796
797 delcommand HiLink
798endif
799
800" Current Syntax: {{{1
801unlet b:extfname
802let b:current_syntax = "tex"
803" vim: ts=8 fdm=marker