3 " Maintainer: Dr. Charles E. Campbell, Jr. <NdrchipO@ScampbellPfamily.AbizM>
4 " Last Change: Aug 12, 2010
6 " URL: http://mysite.verizon.net/astronaut/vim/index.html#vimlinks_syntax
10 " 1. If you have a \begin{verbatim} that appears to overrun its boundaries,
13 " 2. Run-on equations ($..$ and $$..$$, particularly) can also be stopped
14 " by suitable use of %stopzone.
16 " 3. If you have a slow computer, you may wish to modify
18 " syn sync maxlines=200
19 " syn sync minlines=50
21 " to values that are more to your liking.
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)
27 " 5. If you have the variable "g:tex_no_error" defined then none of the
28 " lexical error-checking will be done.
30 " ie. let g:tex_no_error=1
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
37 elseif exists("b:current_syntax")
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
45 if version >= 508 || !exists("did_tex_syntax_inits")
46 let did_tex_syntax_inits = 1
48 command -nargs=+ HiLink hi link <args>
50 command -nargs=+ HiLink hi def link <args>
53 if exists("g:tex_tex") && !exists("g:tex_no_error")
57 " let user determine which classes of concealment will be supported
58 " a=accents/ligatures d=delimiters m=math symbols g=Greek s=superscripts/subscripts
59 if !exists("g:tex_conceal")
60 let s:tex_conceal= 'admgs'
62 let s:tex_conceal= g:tex_conceal
65 " Determine whether or not to use "*.sty" mode {{{1
66 " 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
70 let b:extfname=expand("%:e")
71 if exists("g:tex_stylish")
72 let b:tex_stylish= g:tex_stylish
73 elseif !exists("b:tex_stylish")
74 if b:extfname == "sty" || b:extfname == "cls" || b:extfname == "clo" || b:extfname == "dtx" || b:extfname == "ltx"
82 if !exists("g:tex_fold_enabled")
83 let g:tex_fold_enabled= 0
84 elseif g:tex_fold_enabled && !has("folding")
85 let g:tex_fold_enabled= 0
86 echomsg "Ignoring g:tex_fold_enabled=".g:tex_fold_enabled."; need to re-compile vim for +fold support"
88 if g:tex_fold_enabled && &fdm == "manual"
92 " (La)TeX keywords: only use the letters a-zA-Z {{{1
93 " but _ is the only one that causes problems.
108 syn cluster texCmdGroup contains=texCmdBody,texComment,texDefParm,texDelimiter,texDocType,texInput,texLength,texLigature,texMathDelim,texMathOper,texNewCmd,texNewEnv,texRefZone,texSection,texSectionMarker,texSectionName,texSpecialChar,texStatement,texString,texTypeSize,texTypeStyle
109 if !exists("g:tex_no_error")
110 syn cluster texCmdGroup add=texMathError
112 syn cluster texEnvGroup contains=texMatcher,texMathDelim,texSpecialChar,texStatement
113 syn 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
114 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
115 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
116 syn cluster texRefGroup contains=texMatcher,texComment,texDelimiter
117 if !exists("tex_no_math")
118 syn cluster texMathZones contains=texMathZoneV,texMathZoneW,texMathZoneX,texMathZoneY,texMathZoneZ
119 syn cluster texMatchGroup add=@texMathZones
120 syn cluster texMathDelimGroup contains=texMathDelimBad,texMathDelimKey,texMathDelimSet1,texMathDelimSet2
121 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
122 syn cluster texMathZoneGroup contains=texComment,texDelimiter,texLength,texMathDelim,texMathMatcher,texMathOper,texMathSymbol,texMathText,texRefZone,texSpecialChar,texStatement,texTypeSize,texTypeStyle
123 if !exists("g:tex_no_error")
124 syn cluster texMathMatchGroup add=texMathError
125 syn cluster texMathZoneGroup add=texMathError
127 syn cluster texMathZoneGroup add=@NoSpell
128 " following used in the \part \chapter \section \subsection \subsubsection
129 " \paragraph \subparagraph \author \title highlighting
130 syn cluster texDocGroup contains=texPartZone,@texPartGroup
131 syn cluster texPartGroup contains=texChapterZone,texSectionZone,texParaZone
132 syn cluster texChapterGroup contains=texSectionZone,texParaZone
133 syn cluster texSectionGroup contains=texSubSectionZone,texParaZone
134 syn cluster texSubSectionGroup contains=texSubSubSectionZone,texParaZone
135 syn cluster texSubSubSectionGroup contains=texParaZone
136 syn cluster texParaGroup contains=texSubParaZone
137 if has("conceal") && &enc == 'utf-8'
138 syn cluster texMathZoneGroup add=texGreek,texSuperscript,texSubscript,texMathSymbol
139 syn cluster texMathMatchGroup add=texGreek,texSuperscript,texSubscript,texMathSymbol
143 " Try to flag {} and () mismatches: {{{1
144 if !exists("g:tex_no_error")
145 syn region texMatcher matchgroup=Delimiter start="{" skip="\\\\\|\\[{}]" end="}" contains=@texMatchGroup,texError
146 syn region texMatcher matchgroup=Delimiter start="\[" end="]" contains=@texMatchGroup,texError
148 syn region texMatcher matchgroup=Delimiter start="{" skip="\\\\\|\\[{}]" end="}" contains=@texMatchGroup
149 syn region texMatcher matchgroup=Delimiter start="\[" end="]" contains=@texMatchGroup
151 syn region texParen start="(" end=")" contains=@texMatchGroup,@Spell
152 if !exists("g:tex_no_error")
153 syn match texError "[}\])]"
155 if !exists("tex_no_math")
156 if !exists("g:tex_no_error")
157 syn match texMathError "}" contained
159 syn region texMathMatcher matchgroup=Delimiter start="{" skip="\\\\\|\\}" end="}" end="%stopzone\>" contained contains=@texMathMatchGroup
162 " TeX/LaTeX keywords: {{{1
163 " Instead of trying to be All Knowing, I just match \..alphameric..
164 " Note that *.tex files may not have "@" in their \commands
165 if exists("g:tex_tex") || b:tex_stylish
166 syn match texStatement "\\[a-zA-Z@]\+"
168 syn match texStatement "\\\a\+"
169 if !exists("g:tex_no_error")
170 syn match texError "\\\a*@[a-zA-Z@]*"
174 " TeX/LaTeX delimiters: {{{1
175 syn match texDelimiter "&"
176 syn match texDelimiter "\\\\"
178 " Tex/Latex Options: {{{1
179 syn match texOption "[^\\]\zs#\d\+\|^#\d\+"
181 " texAccent (tnx to Karim Belabas) avoids annoying highlighting for accents: {{{1
183 syn match texAccent "\\[bcdvuH][^a-zA-Z@]"me=e-1
184 syn match texLigature "\\\([ijolL]\|ae\|oe\|ss\|AA\|AE\|OE\)[^a-zA-Z@]"me=e-1
186 syn match texAccent "\\[bcdvuH]\A"me=e-1
187 syn match texLigature "\\\([ijolL]\|ae\|oe\|ss\|AA\|AE\|OE\)\A"me=e-1
189 syn match texAccent "\\[bcdvuH]$"
190 syn match texAccent +\\[=^.\~"`']+
191 syn match texAccent +\\['=t'.c^ud"vb~Hr]{\a}+
192 syn match texLigature "\\\([ijolL]\|ae\|oe\|ss\|AA\|AE\|OE\)$"
194 " \begin{}/\end{} section markers: {{{1
195 syn match texSectionMarker "\\begin\>\|\\end\>" nextgroup=texSectionName
196 syn region texSectionName matchgroup=Delimiter start="{" end="}" contained nextgroup=texSectionModifier contains=texComment
197 syn region texSectionModifier matchgroup=Delimiter start="\[" end="]" contained contains=texComment
199 " \documentclass, \documentstyle, \usepackage: {{{1
200 syn match texDocType "\\documentclass\>\|\\documentstyle\>\|\\usepackage\>" nextgroup=texSectionName,texDocTypeArgs
201 syn region texDocTypeArgs matchgroup=Delimiter start="\[" end="]" contained nextgroup=texSectionName contains=texComment
203 " Preamble syntax-based folding support: {{{1
204 if g:tex_fold_enabled && has("folding")
205 syn region texPreamble transparent fold start='\zs\\documentclass\>' end='\ze\\begin{document}' contains=texStyle,@texMatchGroup
209 syn match texInput "\\input\s\+[a-zA-Z/.0-9_^]\+"hs=s+7 contains=texStatement
210 syn match texInputFile "\\include\(graphics\|list\)\=\(\[.\{-}\]\)\=\s*{.\{-}}" contains=texStatement,texInputCurlies,texInputFileOpt
211 syn match texInputFile "\\\(epsfig\|input\|usepackage\)\s*\(\[.*\]\)\={.\{-}}" contains=texStatement,texInputCurlies,texInputFileOpt
212 syn match texInputCurlies "[{}]" contained
213 syn region texInputFileOpt matchgroup=Delimiter start="\[" end="\]" contained contains=texComment
215 " Type Styles (LaTeX 2.09): {{{1
216 syn match texTypeStyle "\\rm\>"
217 syn match texTypeStyle "\\em\>"
218 syn match texTypeStyle "\\bf\>"
219 syn match texTypeStyle "\\it\>"
220 syn match texTypeStyle "\\sl\>"
221 syn match texTypeStyle "\\sf\>"
222 syn match texTypeStyle "\\sc\>"
223 syn match texTypeStyle "\\tt\>"
225 " Type Styles: attributes, commands, families, etc (LaTeX2E): {{{1
226 syn match texTypeStyle "\\textbf\>"
227 syn match texTypeStyle "\\textit\>"
228 syn match texTypeStyle "\\textmd\>"
229 syn match texTypeStyle "\\textrm\>"
230 syn match texTypeStyle "\\textsc\>"
231 syn match texTypeStyle "\\textsf\>"
232 syn match texTypeStyle "\\textsl\>"
233 syn match texTypeStyle "\\texttt\>"
234 syn match texTypeStyle "\\textup\>"
235 syn match texTypeStyle "\\emph\>"
237 syn match texTypeStyle "\\mathbb\>"
238 syn match texTypeStyle "\\mathbf\>"
239 syn match texTypeStyle "\\mathcal\>"
240 syn match texTypeStyle "\\mathfrak\>"
241 syn match texTypeStyle "\\mathit\>"
242 syn match texTypeStyle "\\mathnormal\>"
243 syn match texTypeStyle "\\mathrm\>"
244 syn match texTypeStyle "\\mathsf\>"
245 syn match texTypeStyle "\\mathtt\>"
247 syn match texTypeStyle "\\rmfamily\>"
248 syn match texTypeStyle "\\sffamily\>"
249 syn match texTypeStyle "\\ttfamily\>"
251 syn match texTypeStyle "\\itshape\>"
252 syn match texTypeStyle "\\scshape\>"
253 syn match texTypeStyle "\\slshape\>"
254 syn match texTypeStyle "\\upshape\>"
256 syn match texTypeStyle "\\bfseries\>"
257 syn match texTypeStyle "\\mdseries\>"
259 " Some type sizes: {{{1
260 syn match texTypeSize "\\tiny\>"
261 syn match texTypeSize "\\scriptsize\>"
262 syn match texTypeSize "\\footnotesize\>"
263 syn match texTypeSize "\\small\>"
264 syn match texTypeSize "\\normalsize\>"
265 syn match texTypeSize "\\large\>"
266 syn match texTypeSize "\\Large\>"
267 syn match texTypeSize "\\LARGE\>"
268 syn match texTypeSize "\\huge\>"
269 syn match texTypeSize "\\Huge\>"
271 " Spacecodes (TeX'isms): {{{1
272 " \mathcode`\^^@="2201 \delcode`\(="028300 \sfcode`\)=0 \uccode`X=`X \lccode`x=`x
273 syn match texSpaceCode "\\\(math\|cat\|del\|lc\|sf\|uc\)code`"me=e-1 nextgroup=texSpaceCodeChar
274 syn match texSpaceCodeChar "`\\\=.\(\^.\)\==\(\d\|\"\x\{1,6}\|`.\)" contained
276 " Sections, subsections, etc: {{{1
277 if g:tex_fold_enabled && has("folding")
278 syn region texDocZone matchgroup=texSection start='\\begin\s*{\s*document\s*}' end='\\end\s*{\s*document\s*}' fold contains=@texFoldGroup,@texDocGroup,@Spell
279 syn region texPartZone matchgroup=texSection start='\\part\>' end='\ze\s*\\\%(part\>\|end\s*{\s*document\s*}\)' fold contains=@texFoldGroup,@texPartGroup,@Spell
280 syn region texChapterZone matchgroup=texSection start='\\chapter\>' end='\ze\s*\\\%(chapter\>\|part\>\|end\s*{\s*document\s*}\)' fold contains=@texFoldGroup,@texChapterGroup,@Spell
281 syn region texSectionZone matchgroup=texSection start='\\section\>' end='\ze\s*\\\%(section\>\|chapter\>\|part\>\|end\s*{\s*document\s*}\)' fold contains=@texFoldGroup,@texSectionGroup,@Spell
282 syn region texSubSectionZone matchgroup=texSection start='\\subsection\>' end='\ze\s*\\\%(\%(sub\)\=section\>\|chapter\>\|part\>\|end\s*{\s*document\s*}\)' fold contains=@texFoldGroup,@texSubSectionGroup,@Spell
283 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
284 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
285 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
286 syn region texTitle matchgroup=texSection start='\\\%(author\|title\)\>\s*{' end='}' fold contains=@texFoldGroup,@Spell
287 syn region texAbstract matchgroup=texSection start='\\begin\s*{\s*abstract\s*}' end='\\end\s*{\s*abstract\s*}' fold contains=@texFoldGroup,@Spell
289 syn region texDocZone matchgroup=texSection start='\\begin\s*{\s*document\s*}' end='\\end\s*{\s*document\s*}' contains=@texFoldGroup,@texDocGroup,@Spell
290 syn region texPartZone matchgroup=texSection start='\\part\>' end='\ze\s*\\\%(part\>\|end\s*{\s*document\s*}\)' contains=@texFoldGroup,@texPartGroup,@Spell
291 syn region texChapterZone matchgroup=texSection start='\\chapter\>' end='\ze\s*\\\%(chapter\>\|part\>\|end\s*{\s*document\s*}\)' contains=@texFoldGroup,@texChapterGroup,@Spell
292 syn region texSectionZone matchgroup=texSection start='\\section\>' end='\ze\s*\\\%(section\>\|chapter\>\|part\>\|end\s*{\s*document\s*}\)' contains=@texFoldGroup,@texSectionGroup,@Spell
293 syn region texSubSectionZone matchgroup=texSection start='\\subsection\>' end='\ze\s*\\\%(\%(sub\)\=section\>\|chapter\>\|part\>\|end\s*{\s*document\s*}\)' contains=@texFoldGroup,@texSubSectionGroup,@Spell
294 syn region texSubSubSectionZone matchgroup=texSection start='\\subsubsection\>' end='\ze\s*\\\%(\%(sub\)\{,2}section\>\|chapter\>\|part\>\|end\s*{\s*document\s*}\)' contains=@texFoldGroup,@texSubSubSectionGroup,@Spell
295 syn region texParaZone matchgroup=texSection start='\\paragraph\>' end='\ze\s*\\\%(paragraph\>\|\%(sub\)*section\>\|chapter\>\|part\>\|end\s*{\s*document\s*}\)' contains=@texFoldGroup,@texParaGroup,@Spell
296 syn region texSubParaZone matchgroup=texSection start='\\subparagraph\>' end='\ze\s*\\\%(\%(sub\)\=paragraph\>\|\%(sub\)*section\>\|chapter\>\|part\>\|end\s*{\s*document\s*}\)' contains=@texFoldGroup,@Spell
297 syn region texTitle matchgroup=texSection start='\\\%(author\|title\)\>\s*{' end='}' contains=@texFoldGroup,@Spell
298 syn region texAbstract matchgroup=texSection start='\\begin\s*{\s*abstract\s*}' end='\\end\s*{\s*abstract\s*}' contains=@texFoldGroup,@Spell
301 " Bad Math (mismatched): {{{1
302 if !exists("tex_no_math")
303 syn match texBadMath "\\end\s*{\s*\(array\|gathered\|bBpvV]matrix\|split\|subequations\|smallmatrix\|xxalignat\)\s*}"
304 syn match texBadMath "\\end\s*{\s*\(align\|alignat\|displaymath\|displaymath\|eqnarray\|equation\|flalign\|gather\|math\|multline\|xalignat\)\*\=\s*}"
305 syn match texBadMath "\\[\])]"
309 if !exists("tex_no_math")
310 " TexNewMathZone: function creates a mathzone with the given suffix and mathzone name. {{{2
311 " Starred forms are created if starform is true. Starred
312 " forms have syntax group and synchronization groups with a
313 " "S" appended. Handles: cluster, syntax, sync, and HiLink.
314 fun! TexNewMathZone(sfx,mathzone,starform)
315 let grpname = "texMathZone".a:sfx
316 let syncname = "texSyncMathZone".a:sfx
317 if g:tex_fold_enabled
322 exe "syn cluster texMathZones add=".grpname
323 exe 'syn region '.grpname.' start='."'".'\\begin\s*{\s*'.a:mathzone.'\s*}'."'".' end='."'".'\\end\s*{\s*'.a:mathzone.'\s*}'."'".' keepend contains=@texMathZoneGroup'.foldcmd
324 exe 'syn sync match '.syncname.' grouphere '.grpname.' "\\begin\s*{\s*'.a:mathzone.'\*\s*}"'
325 exe 'syn sync match '.syncname.' grouphere '.grpname.' "\\begin\s*{\s*'.a:mathzone.'\*\s*}"'
326 exe 'hi def link '.grpname.' texMath'
328 let grpname = "texMathZone".a:sfx.'S'
329 let syncname = "texSyncMathZone".a:sfx.'S'
330 exe "syn cluster texMathZones add=".grpname
331 exe 'syn region '.grpname.' start='."'".'\\begin\s*{\s*'.a:mathzone.'\*\s*}'."'".' end='."'".'\\end\s*{\s*'.a:mathzone.'\*\s*}'."'".' keepend contains=@texMathZoneGroup'.foldcmd
332 exe 'syn sync match '.syncname.' grouphere '.grpname.' "\\begin\s*{\s*'.a:mathzone.'\*\s*}"'
333 exe 'syn sync match '.syncname.' grouphere '.grpname.' "\\begin\s*{\s*'.a:mathzone.'\*\s*}"'
334 exe 'hi def link '.grpname.' texMath'
338 " Standard Math Zones: {{{2
339 call TexNewMathZone("A","align",1)
340 call TexNewMathZone("B","alignat",1)
341 call TexNewMathZone("C","displaymath",1)
342 call TexNewMathZone("D","eqnarray",1)
343 call TexNewMathZone("E","equation",1)
344 call TexNewMathZone("F","flalign",1)
345 call TexNewMathZone("G","gather",1)
346 call TexNewMathZone("H","math",1)
347 call TexNewMathZone("I","multline",1)
348 call TexNewMathZone("J","subequations",0)
349 call TexNewMathZone("K","xalignat",1)
350 call TexNewMathZone("L","xxalignat",0)
352 " Inline Math Zones: {{{2
353 if has("conceal") && &enc == 'utf-8' && s:tex_conceal =~ 'd'
354 syn region texMathZoneV matchgroup=Delimiter start="\\(" matchgroup=Delimiter end="\\)\|%stopzone\>" keepend concealends contains=@texMathZoneGroup
355 syn region texMathZoneW matchgroup=Delimiter start="\\\[" matchgroup=Delimiter end="\\]\|%stopzone\>" keepend concealends contains=@texMathZoneGroup
356 syn region texMathZoneX matchgroup=Delimiter start="\$" skip="\\\\\|\\\$" matchgroup=Delimiter end="\$" end="%stopzone\>" concealends contains=@texMathZoneGroup
357 syn region texMathZoneY matchgroup=Delimiter start="\$\$" matchgroup=Delimiter end="\$\$" end="%stopzone\>" concealends keepend contains=@texMathZoneGroup
359 syn region texMathZoneV matchgroup=Delimiter start="\\(" matchgroup=Delimiter end="\\)\|%stopzone\>" keepend contains=@texMathZoneGroup
360 syn region texMathZoneW matchgroup=Delimiter start="\\\[" matchgroup=Delimiter end="\\]\|%stopzone\>" keepend contains=@texMathZoneGroup
361 syn region texMathZoneX matchgroup=Delimiter start="\$" skip="\\\\\|\\\$" matchgroup=Delimiter end="\$" end="%stopzone\>" contains=@texMathZoneGroup
362 syn region texMathZoneY matchgroup=Delimiter start="\$\$" matchgroup=Delimiter end="\$\$" end="%stopzone\>" keepend contains=@texMathZoneGroup
364 syn region texMathZoneZ matchgroup=texStatement start="\\ensuremath\s*{" matchgroup=texStatement end="}" end="%stopzone\>" contains=@texMathZoneGroup
366 syn match texMathOper "[_^=]" contained
368 " Text Inside Math Zones: {{{2
369 syn region texMathText matchgroup=texStatement start='\\\(\(inter\)\=text\|mbox\)\s*{' end='}' contains=@texFoldGroup,@Spell
371 " \left..something.. and \right..something.. support: {{{2
372 syn match texMathDelimBad contained "\S"
373 if has("conceal") && &enc == 'utf-8' && s:tex_conceal =~ 'm'
374 syn match texMathDelim contained "\\left\\{\>" skipwhite nextgroup=texMathDelimSet1,texMathDelimSet2,texMathDelimBad contains=texMathSymbol cchar={
375 syn match texMathDelim contained "\\right\\}\>" skipwhite nextgroup=texMathDelimSet1,texMathDelimSet2,texMathDelimBad contains=texMathSymbol cchar=}
377 syn match texMathDelim contained "\\\(left\|right\)\>" skipwhite nextgroup=texMathDelimSet1,texMathDelimSet2,texMathDelimBad
379 syn match texMathDelim contained "\\\([bB]igg\=[lr]\)\>" skipwhite nextgroup=texMathDelimSet1,texMathDelimSet2,texMathDelimBad
380 syn match texMathDelim contained "\\\(left\|right\)arrow\>\|\<\([aA]rrow\|brace\)\=vert\>"
381 syn match texMathDelim contained "\\lefteqn\>"
382 syn match texMathDelimSet2 contained "\\" nextgroup=texMathDelimKey,texMathDelimBad
383 syn match texMathDelimSet1 contained "[<>()[\]|/.]\|\\[{}|]"
384 syn keyword texMathDelimKey contained backslash lceil lVert rgroup uparrow
385 syn keyword texMathDelimKey contained downarrow lfloor rangle rmoustache Uparrow
386 syn keyword texMathDelimKey contained Downarrow lgroup rbrace rvert updownarrow
387 syn keyword texMathDelimKey contained langle lmoustache rceil rVert Updownarrow
388 syn keyword texMathDelimKey contained lbrace lvert rfloor
391 " Special TeX characters ( \$ \& \% \# \{ \} \_ \S \P ) : {{{1
392 syn match texSpecialChar "\\[$&%#{}_]"
394 syn match texSpecialChar "\\[SP@][^a-zA-Z@]"me=e-1
396 syn match texSpecialChar "\\[SP@]\A"me=e-1
398 syn match texSpecialChar "\\\\"
399 if !exists("tex_no_math")
400 syn match texOnlyMath "[_^]"
402 syn match texSpecialChar "\^\^[0-9a-f]\{2}\|\^\^\S"
405 " Normal TeX LaTeX : %....
406 " Documented TeX Format: ^^A... -and- leading %s (only)
407 if !exists("g:tex_comment_nospell") || !g:tex_comment_nospell
408 syn cluster texCommentGroup contains=texTodo,@Spell
410 syn cluster texCommentGroup contains=texTodo,@NoSpell
413 syn keyword texTodo contained combak fixme todo xxx
415 if b:extfname == "dtx"
416 syn match texComment "\^\^A.*$" contains=@texCommentGroup
417 syn match texComment "^%\+" contains=@texCommentGroup
419 if g:tex_fold_enabled
420 " allows syntax-folding of 2 or more contiguous comment lines
421 " single-line comments are not folded
422 syn match texComment "%.*$" contains=@texCommentGroup
423 syn region texComment start="^\zs\s*%.*\_s*%" skip="^\s*%" end='^\ze\s*[^%]' fold
425 syn match texComment "%.*$" contains=@texCommentGroup
429 " Separate lines used for verb` and verb# so that the end conditions {{{1
430 " will appropriately terminate.
431 " If g:tex_verbspell exists, then verbatim texZones will permit spellchecking there.
432 if exists("g:tex_verbspell") && g:tex_verbspell
433 syn region texZone start="\\begin{[vV]erbatim}" end="\\end{[vV]erbatim}\|%stopzone\>" contains=@Spell
435 syn region texZone start="\\begin{lstlisting}" end="\\end{lstlisting}\|%stopzone\>" contains=@Spell
437 syn region texZone start="\\begin{verbatimtab}" end="\\end{verbatimtab}\|%stopzone\>" contains=@Spell
438 syn region texZone start="\\begin{verbatimwrite}" end="\\end{verbatimwrite}\|%stopzone\>" contains=@Spell
439 syn region texZone start="\\begin{boxedverbatim}" end="\\end{boxedverbatim}\|%stopzone\>" contains=@Spell
441 syn region texZone start="\\verb\*\=`" end="`\|%stopzone\>" contains=@Spell
442 syn region texZone start="\\verb\*\=#" end="#\|%stopzone\>" contains=@Spell
445 syn region texZone start="\\verb\*\=\z([^\ta-zA-Z@]\)" end="\z1\|%stopzone\>" contains=@Spell
447 syn region texZone start="\\verb\*\=\z([^\ta-zA-Z]\)" end="\z1\|%stopzone\>" contains=@Spell
451 syn region texZone start="\\begin{[vV]erbatim}" end="\\end{[vV]erbatim}\|%stopzone\>"
453 syn region texZone start="\\begin{lstlisting}" end="\\end{lstlisting}\|%stopzone\>"
455 syn region texZone start="\\begin{verbatimtab}" end="\\end{verbatimtab}\|%stopzone\>"
456 syn region texZone start="\\begin{verbatimwrite}" end="\\end{verbatimwrite}\|%stopzone\>"
457 syn region texZone start="\\begin{boxedverbatim}" end="\\end{boxedverbatim}\|%stopzone\>"
459 syn region texZone start="\\verb\*\=`" end="`\|%stopzone\>"
460 syn region texZone start="\\verb\*\=#" end="#\|%stopzone\>"
463 syn region texZone start="\\verb\*\=\z([^\ta-zA-Z@]\)" end="\z1\|%stopzone\>"
465 syn region texZone start="\\verb\*\=\z([^\ta-zA-Z]\)" end="\z1\|%stopzone\>"
470 " Tex Reference Zones: {{{1
471 syn region texZone matchgroup=texStatement start="@samp{" end="}\|%stopzone\>" contains=@texRefGroup
472 syn region texRefZone matchgroup=texStatement start="\\nocite{" end="}\|%stopzone\>" contains=@texRefGroup
473 syn region texRefZone matchgroup=texStatement start="\\bibliography{" end="}\|%stopzone\>" contains=@texRefGroup
474 syn region texRefZone matchgroup=texStatement start="\\label{" end="}\|%stopzone\>" contains=@texRefGroup
475 syn region texRefZone matchgroup=texStatement start="\\\(page\|eq\)ref{" end="}\|%stopzone\>" contains=@texRefGroup
476 syn region texRefZone matchgroup=texStatement start="\\v\=ref{" end="}\|%stopzone\>" contains=@texRefGroup
477 syn match texRefZone '\\cite\%([tp]\*\=\)\=' nextgroup=texRefOption,texCite
478 syn region texRefOption contained matchgroup=Delimiter start='\[' end=']' contains=@texRefGroup,texRefZone nextgroup=texRefOption,texCite
479 syn region texCite contained matchgroup=Delimiter start='{' end='}' contains=@texRefGroup,texRefZone,texCite
481 " Handle newcommand, newenvironment : {{{1
482 syn match texNewCmd "\\newcommand\>" nextgroup=texCmdName skipwhite skipnl
483 syn region texCmdName contained matchgroup=Delimiter start="{"rs=s+1 end="}" nextgroup=texCmdArgs,texCmdBody skipwhite skipnl
484 syn region texCmdArgs contained matchgroup=Delimiter start="\["rs=s+1 end="]" nextgroup=texCmdBody skipwhite skipnl
485 syn region texCmdBody contained matchgroup=Delimiter start="{"rs=s+1 skip="\\\\\|\\[{}]" matchgroup=Delimiter end="}" contains=@texCmdGroup
486 syn match texNewEnv "\\newenvironment\>" nextgroup=texEnvName skipwhite skipnl
487 syn region texEnvName contained matchgroup=Delimiter start="{"rs=s+1 end="}" nextgroup=texEnvBgn skipwhite skipnl
488 syn region texEnvBgn contained matchgroup=Delimiter start="{"rs=s+1 end="}" nextgroup=texEnvEnd skipwhite skipnl contains=@texEnvGroup
489 syn region texEnvEnd contained matchgroup=Delimiter start="{"rs=s+1 end="}" skipwhite skipnl contains=@texEnvGroup
491 " Definitions/Commands: {{{1
492 syn match texDefCmd "\\def\>" nextgroup=texDefName skipwhite skipnl
494 syn match texDefName contained "\\[a-zA-Z@]\+" nextgroup=texDefParms,texCmdBody skipwhite skipnl
495 syn match texDefName contained "\\[^a-zA-Z@]" nextgroup=texDefParms,texCmdBody skipwhite skipnl
497 syn match texDefName contained "\\\a\+" nextgroup=texDefParms,texCmdBody skipwhite skipnl
498 syn match texDefName contained "\\\A" nextgroup=texDefParms,texCmdBody skipwhite skipnl
500 syn match texDefParms contained "#[^{]*" contains=texDefParm nextgroup=texCmdBody skipwhite skipnl
501 syn match texDefParm contained "#\d\+"
504 syn match texLength "\<\d\+\([.,]\d\+\)\=\s*\(true\)\=\s*\(bp\|cc\|cm\|dd\|em\|ex\|in\|mm\|pc\|pt\|sp\)\>"
506 " TeX String Delimiters: {{{1
507 syn match texString "\(``\|''\|,,\)"
509 " makeatletter -- makeatother sections
510 if !exists("g:tex_no_error")
511 syn region texStyle matchgroup=texStatement start='\\makeatletter' end='\\makeatother' contains=@texStyleGroup contained
512 syn match texStyleStatement "\\[a-zA-Z@]\+" contained
513 syn region texStyleMatcher matchgroup=Delimiter start="{" skip="\\\\\|\\[{}]" end="}" contains=@texStyleGroup,texError contained
514 syn region texStyleMatcher matchgroup=Delimiter start="\[" end="]" contains=@texStyleGroup,texError contained
517 " Conceal mode support (supports set cole=2) {{{1
518 if has("conceal") && &enc == 'utf-8'
521 " (many of these symbols were contributed by Björn Winckler)
522 if s:tex_conceal =~ 'm'
528 \ ['backepsilon' , '∍'],
529 \ ['backsimeq' , '≃'],
530 \ ['barwedge' , '⊼'],
536 \ ['bigoplus' , '⊕'],
537 \ ['bigotimes' , '⊗'],
538 \ ['bigsqcup' , '⊔'],
539 \ ['bigtriangledown', '∇'],
541 \ ['bigwedge' , '⋀'],
542 \ ['blacksquare' , '∎'],
545 \ ['boxminus' , '⊟'],
547 \ ['boxtimes' , '⊠'],
556 \ ['circlearrowleft', '↺'],
557 \ ['circlearrowright', '↻'],
558 \ ['circledast' , '⊛'],
559 \ ['circledcirc' , '⊚'],
560 \ ['complement' , '∁'],
565 \ ['curlyeqprec' , '⋞'],
566 \ ['curlyeqsucc' , '⋟'],
567 \ ['curlyvee' , '⋎'],
568 \ ['curlywedge' , '⋏'],
573 \ ['doteqdot' , '≑'],
580 \ ['doublebarwedge' , '⩞'],
581 \ ['downarrow' , '↓'],
582 \ ['Downarrow' , '⇓'],
583 \ ['emptyset' , '∅'],
586 \ ['eqslantgtr' , '⪖'],
587 \ ['eqslantless' , '⪕'],
590 \ ['fallingdotseq' , '≒'],
598 \ ['gtreqless' , '⋛'],
601 \ ['hookleftarrow' , '↩'],
602 \ ['hookrightarrow' , '↪'],
612 \ ['leftarrow' , '⟵'],
613 \ ['Leftarrow' , '⟸'],
614 \ ['leftarrowtail' , '↢'],
618 \ ['Leftrightarrow' , '⇔'],
619 \ ['leftrightsquigarrow', '↭'],
620 \ ['leftthreetimes' , '⋋'],
624 \ ['lesseqgtr' , '⋚'],
630 \ ['measuredangle' , '∡'],
644 \ ['nleftarrow' , '↚'],
645 \ ['nLeftarrow' , '⇍'],
646 \ ['nLeftrightarrow', '⇎'],
653 \ ['nrightarrow' , '↛'],
654 \ ['nRightarrow' , '⇏'],
657 \ ['ntriangleleft' , '⋪'],
658 \ ['ntrianglelefteq', '⋬'],
659 \ ['ntriangleright' , '⋫'],
660 \ ['ntrianglerighteq', '⋭'],
674 \ ['pitchfork' , '⋔'],
676 \ ['precapprox' , '⪷'],
678 \ ['preccurlyeq' , '≼'],
680 \ ['precnapprox' , '⪹'],
681 \ ['precneqq' , '⪵'],
688 \ ['rightarrow' , '⟶'],
689 \ ['Rightarrow' , '⟹'],
690 \ ['rightarrowtail' , '↣'],
693 \ ['right\\}' , '}'],
694 \ ['rightsquigarrow', '↝'],
695 \ ['rightthreetimes', '⋌'],
696 \ ['risingdotseq' , '≓'],
699 \ ['setminus' , '∖'],
701 \ ['sphericalangle' , '∢'],
704 \ ['sqsubset' , '⊏'],
705 \ ['sqsubseteq' , '⊑'],
706 \ ['sqsupset' , '⊐'],
707 \ ['sqsupseteq' , '⊒'],
710 \ ['subseteq' , '⊆'],
711 \ ['subseteqq' , '⫅'],
712 \ ['subsetneq' , '⊊'],
713 \ ['subsetneqq' , '⫋'],
714 \ ['succapprox' , '⪸'],
716 \ ['succcurlyeq' , '≽'],
718 \ ['succnapprox' , '⪺'],
719 \ ['succneqq' , '⪶'],
723 \ ['supseteq' , '⊇'],
724 \ ['supseteqq' , '⫆'],
725 \ ['supsetneq' , '⊋'],
726 \ ['supsetneqq' , '⫌'],
729 \ ['therefore' , '∴'],
733 \ ['triangleleft' , '⊲'],
734 \ ['trianglelefteq' , '⊴'],
735 \ ['triangleq' , '≜'],
736 \ ['triangleright' , '⊳'],
737 \ ['trianglerighteq', '⊵'],
738 \ ['twoheadleftarrow', '↞'],
739 \ ['twoheadrightarrow', '↠'],
742 \ ['updownarrow' , '↕'],
743 \ ['Updownarrow' , '⇕'],
744 \ ['varnothing' , '∅'],
745 \ ['vartriangle' , '∆'],
755 for texmath in s:texMathList
756 exe "syn match texMathSymbol '\\\\".texmath[0]."\\>' contained conceal cchar=".texmath[1]
760 syn match texMathSymbol '\\gg\>' contained conceal cchar=≫
761 syn match texMathSymbol '\\ll\>' contained conceal cchar=≪
763 syn match texMathSymbol '\\gg\>' contained conceal cchar=⟫
764 syn match texMathSymbol '\\ll\>' contained conceal cchar=⟪
769 if s:tex_conceal =~ 'g'
770 fun! s:Greek(group,pat,cchar)
771 exe 'syn match '.a:group." '".a:pat."' contained conceal cchar=".a:cchar
773 call s:Greek('texGreek','\\alpha\>' ,'α')
774 call s:Greek('texGreek','\\beta\>' ,'β')
775 call s:Greek('texGreek','\\gamma\>' ,'γ')
776 call s:Greek('texGreek','\\delta\>' ,'δ')
777 call s:Greek('texGreek','\\epsilon\>' ,'ϵ')
778 call s:Greek('texGreek','\\varepsilon\>' ,'ε')
779 call s:Greek('texGreek','\\zeta\>' ,'ζ')
780 call s:Greek('texGreek','\\eta\>' ,'η')
781 call s:Greek('texGreek','\\theta\>' ,'θ')
782 call s:Greek('texGreek','\\vartheta\>' ,'ϑ')
783 call s:Greek('texGreek','\\kappa\>' ,'κ')
784 call s:Greek('texGreek','\\lambda\>' ,'λ')
785 call s:Greek('texGreek','\\mu\>' ,'μ')
786 call s:Greek('texGreek','\\nu\>' ,'ν')
787 call s:Greek('texGreek','\\xi\>' ,'ξ')
788 call s:Greek('texGreek','\\pi\>' ,'π')
789 call s:Greek('texGreek','\\varpi\>' ,'ϖ')
790 call s:Greek('texGreek','\\rho\>' ,'ρ')
791 call s:Greek('texGreek','\\varrho\>' ,'ϱ')
792 call s:Greek('texGreek','\\sigma\>' ,'σ')
793 call s:Greek('texGreek','\\varsigma\>' ,'ς')
794 call s:Greek('texGreek','\\tau\>' ,'τ')
795 call s:Greek('texGreek','\\upsilon\>' ,'υ')
796 call s:Greek('texGreek','\\phi\>' ,'φ')
797 call s:Greek('texGreek','\\varphi\>' ,'ϕ')
798 call s:Greek('texGreek','\\chi\>' ,'χ')
799 call s:Greek('texGreek','\\psi\>' ,'ψ')
800 call s:Greek('texGreek','\\omega\>' ,'ω')
801 call s:Greek('texGreek','\\Gamma\>' ,'Γ')
802 call s:Greek('texGreek','\\Delta\>' ,'Δ')
803 call s:Greek('texGreek','\\Theta\>' ,'Θ')
804 call s:Greek('texGreek','\\Lambda\>' ,'Λ')
805 call s:Greek('texGreek','\\Xi\>' ,'Χ')
806 call s:Greek('texGreek','\\Pi\>' ,'Π')
807 call s:Greek('texGreek','\\Sigma\>' ,'Σ')
808 call s:Greek('texGreek','\\Upsilon\>' ,'Υ')
809 call s:Greek('texGreek','\\Phi\>' ,'Φ')
810 call s:Greek('texGreek','\\Psi\>' ,'Ψ')
811 call s:Greek('texGreek','\\Omega\>' ,'Ω')
815 " Superscripts/Subscripts {{{2
816 if s:tex_conceal =~ 's'
817 syn region texSuperscript matchgroup=Delimiter start='\^{' end='}' contained concealends contains=texSuperscripts,texStatement,texSubscript,texSuperscript,texMathMatcher
818 syn region texSubscript matchgroup=Delimiter start='_{' end='}' contained concealends contains=texSubscripts,texStatement,texSubscript,texSuperscript,texMathMatcher
819 fun! s:SuperSub(group,leader,pat,cchar)
820 exe 'syn match '.a:group." '".a:leader.a:pat."' contained conceal cchar=".a:cchar
821 exe 'syn match '.a:group."s '".a:pat."' contained conceal cchar=".a:cchar.' nextgroup='.a:group.'s'
823 call s:SuperSub('texSuperscript','\^','0','⁰')
824 call s:SuperSub('texSuperscript','\^','1','¹')
825 call s:SuperSub('texSuperscript','\^','2','²')
826 call s:SuperSub('texSuperscript','\^','3','³')
827 call s:SuperSub('texSuperscript','\^','4','⁴')
828 call s:SuperSub('texSuperscript','\^','5','⁵')
829 call s:SuperSub('texSuperscript','\^','6','⁶')
830 call s:SuperSub('texSuperscript','\^','7','⁷')
831 call s:SuperSub('texSuperscript','\^','8','⁸')
832 call s:SuperSub('texSuperscript','\^','9','⁹')
833 call s:SuperSub('texSuperscript','\^','a','ᵃ')
834 call s:SuperSub('texSuperscript','\^','b','ᵇ')
835 call s:SuperSub('texSuperscript','\^','c','ᶜ')
836 call s:SuperSub('texSuperscript','\^','d','ᵈ')
837 call s:SuperSub('texSuperscript','\^','e','ᵉ')
838 call s:SuperSub('texSuperscript','\^','f','ᶠ')
839 call s:SuperSub('texSuperscript','\^','g','ᵍ')
840 call s:SuperSub('texSuperscript','\^','h','ʰ')
841 call s:SuperSub('texSuperscript','\^','i','ⁱ')
842 call s:SuperSub('texSuperscript','\^','j','ʲ')
843 call s:SuperSub('texSuperscript','\^','k','ᵏ')
844 call s:SuperSub('texSuperscript','\^','l','ˡ')
845 call s:SuperSub('texSuperscript','\^','m','ᵐ')
846 call s:SuperSub('texSuperscript','\^','n','ⁿ')
847 call s:SuperSub('texSuperscript','\^','o','ᵒ')
848 call s:SuperSub('texSuperscript','\^','p','ᵖ')
849 call s:SuperSub('texSuperscript','\^','r','ʳ')
850 call s:SuperSub('texSuperscript','\^','s','ˢ')
851 call s:SuperSub('texSuperscript','\^','t','ᵗ')
852 call s:SuperSub('texSuperscript','\^','u','ᵘ')
853 call s:SuperSub('texSuperscript','\^','v','ᵛ')
854 call s:SuperSub('texSuperscript','\^','w','ʷ')
855 call s:SuperSub('texSuperscript','\^','x','ˣ')
856 call s:SuperSub('texSuperscript','\^','y','ʸ')
857 call s:SuperSub('texSuperscript','\^','z','ᶻ')
858 call s:SuperSub('texSuperscript','\^','A','ᴬ')
859 call s:SuperSub('texSuperscript','\^','B','ᴮ')
860 call s:SuperSub('texSuperscript','\^','D','ᴰ')
861 call s:SuperSub('texSuperscript','\^','E','ᴱ')
862 call s:SuperSub('texSuperscript','\^','G','ᴳ')
863 call s:SuperSub('texSuperscript','\^','H','ᴴ')
864 call s:SuperSub('texSuperscript','\^','I','ᴵ')
865 call s:SuperSub('texSuperscript','\^','J','ᴶ')
866 call s:SuperSub('texSuperscript','\^','K','ᴷ')
867 call s:SuperSub('texSuperscript','\^','L','ᴸ')
868 call s:SuperSub('texSuperscript','\^','M','ᴹ')
869 call s:SuperSub('texSuperscript','\^','N','ᴺ')
870 call s:SuperSub('texSuperscript','\^','O','ᴼ')
871 call s:SuperSub('texSuperscript','\^','P','ᴾ')
872 call s:SuperSub('texSuperscript','\^','R','ᴿ')
873 call s:SuperSub('texSuperscript','\^','T','ᵀ')
874 call s:SuperSub('texSuperscript','\^','U','ᵁ')
875 call s:SuperSub('texSuperscript','\^','W','ᵂ')
876 call s:SuperSub('texSuperscript','\^','+','⁺')
877 call s:SuperSub('texSuperscript','\^','-','⁻')
878 call s:SuperSub('texSuperscript','\^','<','˂')
879 call s:SuperSub('texSuperscript','\^','>','˃')
880 call s:SuperSub('texSuperscript','\^','/','ˊ')
881 call s:SuperSub('texSuperscript','\^','(','⁽')
882 call s:SuperSub('texSuperscript','\^',')','⁾')
883 call s:SuperSub('texSuperscript','\^','\.','˙')
884 call s:SuperSub('texSuperscript','\^','=','˭')
885 call s:SuperSub('texSubscript','_','0','₀')
886 call s:SuperSub('texSubscript','_','1','₁')
887 call s:SuperSub('texSubscript','_','2','₂')
888 call s:SuperSub('texSubscript','_','3','₃')
889 call s:SuperSub('texSubscript','_','4','₄')
890 call s:SuperSub('texSubscript','_','5','₅')
891 call s:SuperSub('texSubscript','_','6','₆')
892 call s:SuperSub('texSubscript','_','7','₇')
893 call s:SuperSub('texSubscript','_','8','₈')
894 call s:SuperSub('texSubscript','_','9','₉')
895 call s:SuperSub('texSubscript','_','a','ₐ')
896 call s:SuperSub('texSubscript','_','e','ₑ')
897 call s:SuperSub('texSubscript','_','i','ᵢ')
898 call s:SuperSub('texSubscript','_','o','ₒ')
899 call s:SuperSub('texSubscript','_','u','ᵤ')
900 call s:SuperSub('texSubscript','_','+','₊')
901 call s:SuperSub('texSubscript','_','-','₋')
902 call s:SuperSub('texSubscript','_','/','ˏ')
903 call s:SuperSub('texSubscript','_','(','₍')
904 call s:SuperSub('texSubscript','_',')','₎')
905 call s:SuperSub('texSubscript','_','\.','‸')
906 call s:SuperSub('texSubscript','_','r','ᵣ')
907 call s:SuperSub('texSubscript','_','v','ᵥ')
908 call s:SuperSub('texSubscript','_','x','ₓ')
909 call s:SuperSub('texSubscript','_','\\beta\>' ,'ᵦ')
910 call s:SuperSub('texSubscript','_','\\delta\>','ᵨ')
911 call s:SuperSub('texSubscript','_','\\phi\>' ,'ᵩ')
912 call s:SuperSub('texSubscript','_','\\gamma\>','ᵧ')
913 call s:SuperSub('texSubscript','_','\\chi\>' ,'ᵪ')
917 " Accented characters: {{{2
918 if s:tex_conceal =~ 'a'
920 syn match texAccent "\\[bcdvuH][^a-zA-Z@]"me=e-1
921 syn match texLigature "\\\([ijolL]\|ae\|oe\|ss\|AA\|AE\|OE\)[^a-zA-Z@]"me=e-1
923 fun! s:Accents(chr,...)
925 for accent in ["`","\\'","^",'"','\~','\.',"c","H","k","r","u","v"]
929 if strlen(a:{i}) == 0 || a:{i} == ' ' || a:{i} == '?'
934 exe "syn match texAccent '".'\\'.accent.'\(\s*{'.a:chr.'}\|\s\+'.a:chr.'\)'."' conceal cchar=".a:{i}
936 exe "syn match texAccent '".'\\'.accent.'\s*\({'.a:chr.'}\|'.a:chr.'\)'."' conceal cchar=".a:{i}
941 " \` \' \^ \" \~ \. \c \H \k \r \u \v
942 call s:Accents('a','à','á','â','ä','ã',' ',' ',' ','ą','å','ă','ă')
943 call s:Accents('A','À','Á','Â','Ä','Ã',' ',' ',' ','Ą','Å','Ă','Ă')
944 call s:Accents('c',' ','ć','ĉ',' ',' ','ċ','ç',' ',' ',' ',' ','č')
945 call s:Accents('C',' ','Ć','Ĉ',' ',' ','Ċ','Ç',' ',' ',' ',' ','Č')
946 call s:Accents('d',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','ď')
947 call s:Accents('D',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','Ď')
948 call s:Accents('e','è','é','ê','ë','ẽ','ė','ȩ',' ','ę',' ','ĕ','ě')
949 call s:Accents('E','È','É','Ê','Ë','Ẽ','Ė','Ȩ',' ','Ę',' ','Ĕ','Ě')
950 call s:Accents('g',' ',' ',' ',' ',' ','ġ','ģ',' ',' ',' ','ğ',' ')
951 call s:Accents('G',' ',' ',' ',' ',' ','Ġ','Ģ',' ',' ',' ','Ğ',' ')
952 call s:Accents('i','ì','í','î','ï','ĩ','į',' ',' ',' ',' ','ĭ',' ')
953 call s:Accents('I','Ì','Í','Î','Ï','Ĩ','İ',' ',' ',' ',' ','Ĭ',' ')
954 call s:Accents('l',' ','ĺ','ľ',' ',' ',' ','ļ',' ',' ',' ',' ','ľ')
955 call s:Accents('L',' ','Ĺ','Ľ',' ',' ',' ','Ļ',' ',' ',' ',' ','Ľ')
956 call s:Accents('n',' ','ń',' ',' ','ñ',' ','ņ',' ',' ',' ',' ','ň')
957 call s:Accents('N',' ','Ń',' ',' ','Ñ',' ','Ņ',' ',' ',' ',' ','Ň')
958 call s:Accents('o','ò','ó','ô','ö','õ','ȯ',' ','ő','ǫ',' ','ŏ',' ')
959 call s:Accents('O','Ò','Ó','Ô','Ö','Õ','Ȯ',' ','Ő','Ǫ',' ','Ŏ',' ')
960 call s:Accents('r',' ','ŕ',' ',' ',' ',' ','ŗ',' ',' ',' ',' ','ř')
961 call s:Accents('R',' ','Ŕ',' ',' ',' ',' ','Ŗ',' ',' ',' ',' ','Ř')
962 call s:Accents('s',' ','ś','ŝ',' ',' ',' ','ş',' ',' ',' ',' ','š')
963 call s:Accents('S',' ','Ś','Ŝ',' ',' ',' ','Ş',' ',' ',' ',' ','Š')
964 call s:Accents('t',' ',' ',' ',' ',' ',' ','ţ',' ',' ',' ',' ','ť')
965 call s:Accents('T',' ',' ',' ',' ',' ',' ','Ţ',' ',' ',' ',' ','Ť')
966 call s:Accents('u','ù','ú','û','ü','ũ',' ',' ','ű',' ','ů','ŭ',' ')
967 call s:Accents('U','Ù','Ú','Û','Ü','Ũ',' ',' ','Ű',' ','Ů','Ŭ',' ')
968 call s:Accents('w',' ',' ','ŵ',' ',' ',' ',' ',' ',' ',' ',' ',' ')
969 call s:Accents('W',' ',' ','Ŵ',' ',' ',' ',' ',' ',' ',' ',' ',' ')
970 call s:Accents('y','ỳ','ý','ŷ','ÿ','ỹ',' ',' ',' ',' ',' ',' ',' ')
971 call s:Accents('Y','Ỳ','Ý','Ŷ','Ÿ','Ỹ',' ',' ',' ',' ',' ',' ',' ')
972 call s:Accents('z',' ','ź',' ',' ',' ','ż',' ',' ',' ',' ',' ','ž')
973 call s:Accents('Z',' ','Ź',' ',' ',' ','Ż',' ',' ',' ',' ',' ','Ž')
974 call s:Accents('\\i','ì','í','î','ï','ĩ','į',' ',' ',' ',' ','ĭ',' ')
975 " \` \' \^ \" \~ \. \c \H \k \r \u \v
977 syn match texAccent '\\aa\>' conceal cchar=å
978 syn match texAccent '\\AA\>' conceal cchar=Å
979 syn match texAccent '\\o\>' conceal cchar=ø
980 syn match texAccent '\\O\>' conceal cchar=Ø
981 syn match texLigature '\\AE\>' conceal cchar=Æ
982 syn match texLigature '\\ae\>' conceal cchar=æ
983 syn match texLigature '\\oe\>' conceal cchar=œ
984 syn match texLigature '\\OE\>' conceal cchar=Œ
985 syn match texLigature '\\ss\>' conceal cchar=ß
990 " ---------------------------------------------------------------------
991 " LaTeX synchronization: {{{1
992 syn sync maxlines=200
995 syn sync match texSyncStop groupthere NONE "%stopzone\>"
997 " Synchronization: {{{1
998 " The $..$ and $$..$$ make for impossible sync patterns
999 " (one can't tell if a "$$" starts or stops a math zone by itself)
1000 " The following grouptheres coupled with minlines above
1001 " help improve the odds of good syncing.
1002 if !exists("tex_no_math")
1003 syn sync match texSyncMathZoneA groupthere NONE "\\end{abstract}"
1004 syn sync match texSyncMathZoneA groupthere NONE "\\end{center}"
1005 syn sync match texSyncMathZoneA groupthere NONE "\\end{description}"
1006 syn sync match texSyncMathZoneA groupthere NONE "\\end{enumerate}"
1007 syn sync match texSyncMathZoneA groupthere NONE "\\end{itemize}"
1008 syn sync match texSyncMathZoneA groupthere NONE "\\end{table}"
1009 syn sync match texSyncMathZoneA groupthere NONE "\\end{tabular}"
1010 syn sync match texSyncMathZoneA groupthere NONE "\\\(sub\)*section\>"
1013 " ---------------------------------------------------------------------
1014 " Highlighting: {{{1
1015 if did_tex_syntax_inits == 1
1016 let did_tex_syntax_inits= 2
1017 " TeX highlighting groups which should share similar highlighting
1018 if !exists("g:tex_no_error")
1019 if !exists("tex_no_math")
1020 HiLink texBadMath texError
1021 HiLink texMathDelimBad texError
1022 HiLink texMathError texError
1024 HiLink texOnlyMath texError
1027 HiLink texError Error
1030 HiLink texCite texRefZone
1031 HiLink texDefCmd texDef
1032 HiLink texDefName texDef
1033 HiLink texDocType texCmdName
1034 HiLink texDocTypeArgs texCmdArgs
1035 HiLink texInputFileOpt texCmdArgs
1036 HiLink texInputCurlies texDelimiter
1037 HiLink texLigature texSpecialChar
1038 if !exists("tex_no_math")
1039 HiLink texMathDelimSet1 texMathDelim
1040 HiLink texMathDelimSet2 texMathDelim
1041 HiLink texMathDelimKey texMathDelim
1042 HiLink texMathMatcher texMath
1043 HiLink texAccent texStatement
1044 HiLink texGreek texStatement
1045 HiLink texSuperscript texStatement
1046 HiLink texSubscript texStatement
1047 HiLink texMathSymbol texStatement
1048 HiLink texMathZoneV texMath
1049 HiLink texMathZoneW texMath
1050 HiLink texMathZoneX texMath
1051 HiLink texMathZoneY texMath
1052 HiLink texMathZoneV texMath
1053 HiLink texMathZoneZ texMath
1055 HiLink texSectionMarker texCmdName
1056 HiLink texSectionName texSection
1057 HiLink texSpaceCode texStatement
1058 HiLink texStyleStatement texStatement
1059 HiLink texTypeSize texType
1060 HiLink texTypeStyle texType
1062 " Basic TeX highlighting groups
1063 HiLink texCmdArgs Number
1064 HiLink texCmdName Statement
1065 HiLink texComment Comment
1066 HiLink texDef Statement
1067 HiLink texDefParm Special
1068 HiLink texDelimiter Delimiter
1069 HiLink texInput Special
1070 HiLink texInputFile Special
1071 HiLink texLength Number
1072 HiLink texMath Special
1073 HiLink texMathDelim Statement
1074 HiLink texMathOper Operator
1075 HiLink texNewCmd Statement
1076 HiLink texNewEnv Statement
1077 HiLink texOption Number
1078 HiLink texRefZone Special
1079 HiLink texSection PreCondit
1080 HiLink texSpaceCodeChar Special
1081 HiLink texSpecialChar SpecialChar
1082 HiLink texStatement Statement
1083 HiLink texString String
1086 HiLink texZone PreCondit
1091 " Current Syntax: {{{1
1093 let b:current_syntax = "tex"
1094 " vim: ts=8 fdm=marker