blob: b6a0450d373c5dad656b2b8540f1f52873cefd6a [file] [log] [blame]
Bram Moolenaar071d4272004-06-13 20:20:40 +00001" Vim syntax file
2" Language: TeX
3" Maintainer: Dr. Charles E. Campbell, Jr. <NdrOchipS@PcampbellAfamily.Mbiz>
Bram Moolenaarf1f8bc52005-03-07 23:20:08 +00004" Last Change: Mar 02, 2005
5" Version: 27
Bram Moolenaar071d4272004-06-13 20:20:40 +00006" URL: http://www.erols.com/astronaut/vim/index.html#vimlinks_syntax
7"
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")
76 let g:sh_fold_enabled= 0;
77 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"
80 set fdm=syntax
81endif
82
83
Bram Moolenaar071d4272004-06-13 20:20:40 +000084" (La)TeX keywords: only use the letters a-zA-Z {{{1
85" but _ is the only one that causes problems.
86if version < 600
87 set isk-=_
88 if b:tex_stylish
89 set isk+=@
90 endif
91else
92 setlocal isk-=_
93 if b:tex_stylish
94 setlocal isk+=@
95 endif
96endif
97
98" Clusters: {{{1
99" --------
100syn cluster texCmdGroup contains=texCmdBody,texComment,texDefParm,texDelimiter,texDocType,texInput,texLength,texLigature,texMathDelim,texMathOper,texNewCmd,texNewEnv,texRefZone,texSection,texSectionMarker,texSectionName,texSpecialChar,texStatement,texString,texTypeSize,texTypeStyle
101if !exists("g:tex_no_error")
102 syn cluster texCmdGroup add=texMathError
103endif
104syn cluster texEnvGroup contains=texMatcher,texMathDelim,texSpecialChar,texStatement
105syn 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
Bram Moolenaarcfbc5ee2004-07-02 15:38:35 +0000106syn cluster texRefGroup contains=texMatcher,texComment,texDelimiter
Bram Moolenaar071d4272004-06-13 20:20:40 +0000107if !exists("tex_no_math")
108 syn cluster texMathZones contains=texMathZoneV,texMathZoneW,texMathZoneX,texMathZoneY,texMathZoneZ
109 syn cluster texMatchGroup add=@texMathZones
110 syn cluster texMathDelimGroup contains=texMathDelimBad,texMathDelimKey,texMathDelimSet1,texMathDelimSet2
111 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
112 syn cluster texMathZoneGroup contains=texComment,texDelimiter,texLength,texMathDelim,texMathMatcher,texMathOper,texRefZone,texSpecialChar,texStatement,texTypeSize,texTypeStyle
113 if !exists("g:tex_no_error")
114 syn cluster texMathMatchGroup add=texMathError
115 syn cluster texMathZoneGroup add=texMathError
116 endif
117endif
118
119" Try to flag {} and () mismatches: {{{1
120if !exists("g:tex_no_error")
121 syn region texMatcher matchgroup=Delimiter start="{" skip="\\\\\|\\[{}]" end="}" contains=@texMatchGroup,texError
122 syn region texMatcher matchgroup=Delimiter start="\[" end="]" contains=@texMatchGroup,texError
123else
124 syn region texMatcher matchgroup=Delimiter start="{" skip="\\\\\|\\[{}]" end="}" contains=@texMatchGroup
125 syn region texMatcher matchgroup=Delimiter start="\[" end="]" contains=@texMatchGroup
126endif
Bram Moolenaar293ee4d2004-12-09 21:34:53 +0000127syn region texParen start="(" end=")" contains=@texMatchGroup,@Spell
Bram Moolenaar071d4272004-06-13 20:20:40 +0000128if !exists("g:tex_no_error")
129 syn match texError "[}\])]"
130endif
131if !exists("tex_no_math")
132 if !exists("g:tex_no_error")
133 syn match texMathError "}" contained
134 endif
135 syn region texMathMatcher matchgroup=Delimiter start="{" skip="\\\\\|\\}" end="}" end="%stopzone\>" contained contains=@texMathMatchGroup
136endif
137
138" TeX/LaTeX keywords: {{{1
139" Instead of trying to be All Knowing, I just match \..alphameric..
140" Note that *.tex files may not have "@" in their \commands
141if exists("g:tex_tex") || b:tex_stylish
142 syn match texStatement "\\[a-zA-Z@]\+"
143else
144 syn match texStatement "\\\a\+"
145 if !exists("g:tex_no_error")
146 syn match texError "\\\a*@[a-zA-Z@]*"
147 endif
148endif
149
150" TeX/LaTeX delimiters: {{{1
151syn match texDelimiter "&"
152syn match texDelimiter "\\\\"
153
154" Tex/Latex Options: {{{1
155syn match texOption "[^\\]\zs#\d\+\|^#\d\+"
156
157" texAccent (tnx to Karim Belabas) avoids annoying highlighting for accents: {{{1
158if b:tex_stylish
159 syn match texAccent "\\[bcdvuH][^a-zA-Z@]"me=e-1
160 syn match texLigature "\\\([ijolL]\|ae\|oe\|ss\|AA\|AE\|OE\)[^a-zA-Z@]"me=e-1
161else
162 syn match texAccent "\\[bcdvuH]\A"me=e-1
163 syn match texLigature "\\\([ijolL]\|ae\|oe\|ss\|AA\|AE\|OE\)\A"me=e-1
164endif
165syn match texAccent "\\[bcdvuH]$"
166syn match texAccent +\\[=^.\~"`']+
167syn match texAccent +\\['=t'.c^ud"vb~Hr]{\a}+
168syn match texLigature "\\\([ijolL]\|ae\|oe\|ss\|AA\|AE\|OE\)$"
169
170" \begin{}/\end{} section markers: {{{1
171syn match texSectionMarker "\\begin\>\|\\end\>" nextgroup=texSectionName
172syn region texSectionName matchgroup=Delimiter start="{" end="}" contained nextgroup=texSectionModifier
173syn region texSectionModifier matchgroup=Delimiter start="\[" end="]" contained
174
175" \documentclass, \documentstyle, \usepackage: {{{1
176syn match texDocType "\\documentclass\>\|\\documentstyle\>\|\\usepackage\>" nextgroup=texSectionName,texDocTypeArgs
177syn region texDocTypeArgs matchgroup=Delimiter start="\[" end="]" contained nextgroup=texSectionName
178
179" TeX input: {{{1
180syn match texInput "\\input\s\+[a-zA-Z/.0-9_^]\+"hs=s+7 contains=texStatement
181syn match texInputFile "\\include\(graphics\|list\)\=\(\[.\{-}\]\)\=\s*{.\{-}}" contains=texStatement,texInputCurlies
182syn match texInputFile "\\\(epsfig\|input\|usepackage\)\s*\(\[.*\]\)\={.\{-}}" contains=texStatement,texInputCurlies,texInputFileOpt
183syn match texInputCurlies "[{}]" contained
184syn region texInputFileOpt matchgroup=Delimiter start="\[" end="\]" contained
185
186" Type Styles (LaTeX 2.09): {{{1
187syn match texTypeStyle "\\rm\>"
188syn match texTypeStyle "\\em\>"
189syn match texTypeStyle "\\bf\>"
190syn match texTypeStyle "\\it\>"
191syn match texTypeStyle "\\sl\>"
192syn match texTypeStyle "\\sf\>"
193syn match texTypeStyle "\\sc\>"
194syn match texTypeStyle "\\tt\>"
195
196" Type Styles: attributes, commands, families, etc (LaTeX2E): {{{1
197syn match texTypeStyle "\\textbf\>"
198syn match texTypeStyle "\\textit\>"
199syn match texTypeStyle "\\textmd\>"
200syn match texTypeStyle "\\textrm\>"
201syn match texTypeStyle "\\textsc\>"
202syn match texTypeStyle "\\textsf\>"
203syn match texTypeStyle "\\textsl\>"
204syn match texTypeStyle "\\texttt\>"
205syn match texTypeStyle "\\textup\>"
206syn match texTypeStyle "\\emph\>"
207
208syn match texTypeStyle "\\mathbb\>"
209syn match texTypeStyle "\\mathbf\>"
210syn match texTypeStyle "\\mathcal\>"
211syn match texTypeStyle "\\mathfrak\>"
212syn match texTypeStyle "\\mathit\>"
213syn match texTypeStyle "\\mathnormal\>"
214syn match texTypeStyle "\\mathrm\>"
215syn match texTypeStyle "\\mathsf\>"
216syn match texTypeStyle "\\mathtt\>"
217
218syn match texTypeStyle "\\rmfamily\>"
219syn match texTypeStyle "\\sffamily\>"
220syn match texTypeStyle "\\ttfamily\>"
221
222syn match texTypeStyle "\\itshape\>"
223syn match texTypeStyle "\\scshape\>"
224syn match texTypeStyle "\\slshape\>"
225syn match texTypeStyle "\\upshape\>"
226
227syn match texTypeStyle "\\bfseries\>"
228syn match texTypeStyle "\\mdseries\>"
229
230" Some type sizes: {{{1
231syn match texTypeSize "\\tiny\>"
232syn match texTypeSize "\\scriptsize\>"
233syn match texTypeSize "\\footnotesize\>"
234syn match texTypeSize "\\small\>"
235syn match texTypeSize "\\normalsize\>"
236syn match texTypeSize "\\large\>"
237syn match texTypeSize "\\Large\>"
238syn match texTypeSize "\\LARGE\>"
239syn match texTypeSize "\\huge\>"
240syn match texTypeSize "\\Huge\>"
241
242" Spacecodes (TeX'isms): {{{1
243" \mathcode`\^^@="2201 \delcode`\(="028300 \sfcode`\)=0 \uccode`X=`X \lccode`x=`x
244syn match texSpaceCode "\\\(math\|cat\|del\|lc\|sf\|uc\)code`"me=e-1 nextgroup=texSpaceCodeChar
245syn match texSpaceCodeChar "`\\\=.\(\^.\)\==\(\d\|\"\x\{1,6}\|`.\)" contained
246
247" Sections, subsections, etc: {{{1
Bram Moolenaarf1f8bc52005-03-07 23:20:08 +0000248if g:tex_fold_enabled && has("folding")
249 syn region texSectionZone matchgroup=texSection start="\\\(sub\)*\(section\|author\|part\|chapter\|paragraph\)\*\=\>" end="\ze\\\(sub\)*\(section\|author\|part\|chapter\|paragraph\)\*\=\>" end="%\s*stopzone\>" contains=TOP fold
250 syn region texSectionZone matchgroup=texSection start="\\begin\s*{\s*abstract\s*}" end="\\end\s*{\s*abstract\s*}" contains=TOP fold
Bram Moolenaar293ee4d2004-12-09 21:34:53 +0000251else
252 syn match texSection "\\\(sub\)*section\*\=\>"
253 syn match texSection "\\\(title\|author\|part\|chapter\|paragraph\|subparagraph\)\>"
254 syn match texSection "\\begin\s*{\s*abstract\s*}\|\\end\s*{\s*abstract\s*}"
255endif
Bram Moolenaar071d4272004-06-13 20:20:40 +0000256
257" Bad Math (mismatched): {{{1
258if !exists("tex_no_math")
259 syn match texBadMath "\\end\s*{\s*\(array\|gathered\|bBpvV]matrix\|split\|subequations\|smallmatrix\|xxalignat\)\s*}"
260 syn match texBadMath "\\end\s*{\s*\(align\|alignat\|displaymath\|displaymath\|eqnarray\|equation\|flalign\|gather\|math\|multline\|xalignat\)\*\=\s*}"
261 syn match texBadMath "\\[\])]"
262endif
263
264" Math Zones: {{{1
265if !exists("tex_no_math")
266 " TexNewMathZone: creates a mathzone with the given suffix and mathzone name. {{{2
267 " Starred forms are created if starform is true. Starred
268 " forms have syntax group and synchronization groups with a
269 " "S" appended. Handles: cluster, syntax, sync, and HiLink.
270 fun! TexNewMathZone(sfx,mathzone,starform)
271 let grpname = "texMathZone".a:sfx
272 let syncname = "texSyncMathZone".a:sfx
273 exe "syn cluster texMathZones add=".grpname
274 exe 'syn region '.grpname.' start='."'".'\\begin\s*{\s*'.a:mathzone.'\s*}'."'".' end='."'".'\\end\s*{\s*'.a:mathzone.'\s*}'."'".' keepend contains=@texMathZoneGroup'
275 exe 'syn sync match '.syncname.' grouphere '.grpname.' "\\begin\s*{\s*'.a:mathzone.'\*\s*}"'
276 exe 'syn sync match '.syncname.' grouphere '.grpname.' "\\begin\s*{\s*'.a:mathzone.'\*\s*}"'
277 exe 'HiLink '.grpname.' texMath'
278 if a:starform
279 let grpname = "texMathZone".a:sfx.'S'
280 let syncname = "texSyncMathZone".a:sfx.'S'
281 exe "syn cluster texMathZones add=".grpname
282 exe 'syn region '.grpname.' start='."'".'\\begin\s*{\s*'.a:mathzone.'\*\s*}'."'".' end='."'".'\\end\s*{\s*'.a:mathzone.'\*\s*}'."'".' keepend contains=@texMathZoneGroup'
283 exe 'syn sync match '.syncname.' grouphere '.grpname.' "\\begin\s*{\s*'.a:mathzone.'\*\s*}"'
284 exe 'syn sync match '.syncname.' grouphere '.grpname.' "\\begin\s*{\s*'.a:mathzone.'\*\s*}"'
285 exe 'HiLink '.grpname.' texMath'
286 endif
287 endfun
288
289 " Standard Math Zones: {{{2
290 call TexNewMathZone("A","align",1)
291 call TexNewMathZone("B","alignat",1)
292 call TexNewMathZone("C","displaymath",1)
293 call TexNewMathZone("D","eqnarray",1)
294 call TexNewMathZone("E","equation",1)
295 call TexNewMathZone("F","flalign",1)
296 call TexNewMathZone("G","gather",1)
297 call TexNewMathZone("H","math",1)
298 call TexNewMathZone("I","multline",1)
299 call TexNewMathZone("J","subequations",0)
300 call TexNewMathZone("K","xalignat",1)
301 call TexNewMathZone("L","xxalignat",0)
302
303 " Inline Math Zones: {{{2
304 syn region texMathZoneV matchgroup=Delimiter start="\\(" matchgroup=Delimiter end="\\)\|%stopzone\>" keepend contains=@texMathZoneGroup
305 syn region texMathZoneW matchgroup=Delimiter start="\\\[" matchgroup=Delimiter end="\\]\|%stopzone\>" keepend contains=@texMathZoneGroup
306 syn region texMathZoneX matchgroup=Delimiter start="\$" skip="\\\\\|\\\$" matchgroup=Delimiter end="\$" end="%stopzone\>" contains=@texMathZoneGroup
307 syn region texMathZoneY matchgroup=Delimiter start="\$\$" matchgroup=Delimiter end="\$\$" end="%stopzone\>" keepend contains=@texMathZoneGroup
308 syn region texMathZoneZ matchgroup=texStatement start="\\ensuremath\s*{" matchgroup=texStatement end="}" end="%stopzone\>" contains=@texMathZoneGroup
309
310 syn match texMathOper "[_^=]" contained
311
312 " \left..something.. and \right..something.. support: {{{2
313 syn match texMathDelimBad contained "\S"
314 syn match texMathDelim contained "\\\(left\|right\|[bB]igg\=[lr]\)\>" skipwhite nextgroup=texMathDelimSet1,texMathDelimSet2,texMathDelimBad
315 syn match texMathDelim contained "\\\(left\|right\)arrow\>\|\<\([aA]rrow\|brace\)\=vert\>"
316 syn match texMathDelim contained "\\lefteqn\>"
317 syn match texMathDelimSet2 contained "\\" nextgroup=texMathDelimKey,texMathDelimBad
318 syn match texMathDelimSet1 contained "[<>()[\]|/.]\|\\[{}|]"
319 syn keyword texMathDelimKey contained backslash lceil lVert rgroup uparrow
320 syn keyword texMathDelimKey contained downarrow lfloor rangle rmoustache Uparrow
321 syn keyword texMathDelimKey contained Downarrow lgroup rbrace rvert updownarrow
322 syn keyword texMathDelimKey contained langle lmoustache rceil rVert Updownarrow
323 syn keyword texMathDelimKey contained lbrace lvert rfloor
324endif
325
326" Special TeX characters ( \$ \& \% \# \{ \} \_ \S \P ) : {{{1
327syn match texSpecialChar "\\[$&%#{}_]"
328if b:tex_stylish
329 syn match texSpecialChar "\\[SP@][^a-zA-Z@]"me=e-1
330else
331 syn match texSpecialChar "\\[SP@]\A"me=e-1
332endif
333syn match texSpecialChar "\\\\"
334if !exists("tex_no_math")
335 syn match texOnlyMath "[_^]"
336endif
337syn match texSpecialChar "\^\^[0-9a-f]\{2}\|\^\^\S"
338
339" Comments: {{{1
340" Normal TeX LaTeX : %....
341" Documented TeX Format: ^^A... -and- leading %s (only)
342syn cluster texCommentGroup contains=texTodo,@Spell
343syn case ignore
344syn keyword texTodo contained combak fixme todo
345syn case match
346if b:extfname == "dtx"
347 syn match texComment "\^\^A.*$" contains=@texCommentGroup
348 syn match texComment "^%\+" contains=@texCommentGroup
349else
350 syn match texComment "%.*$" contains=@texCommentGroup
351endif
352
353" Separate lines used for verb` and verb# so that the end conditions {{{1
354" will appropriately terminate. Ideally vim would let me save a
355" character from the start pattern and re-use it in the end-pattern.
356syn region texZone start="\\begin{verbatim}" end="\\end{verbatim}\|%stopzone\>"
357if version < 600
358 syn region texZone start="\\verb\*\=`" end="`\|%stopzone\>"
359 syn region texZone start="\\verb\*\=#" end="#\|%stopzone\>"
360else
361 if b:tex_stylish
362 syn region texZone start="\\verb\*\=\z([^\ta-zA-Z@]\)" end="\z1\|%stopzone\>"
363 else
364 syn region texZone start="\\verb\*\=\z([^\ta-zA-Z]\)" end="\z1\|%stopzone\>"
365 endif
366endif
367
368" Tex Reference Zones: {{{1
Bram Moolenaarcfbc5ee2004-07-02 15:38:35 +0000369syn region texZone matchgroup=texStatement start="@samp{" end="}\|%stopzone\>" contains=@texRefGroup
370syn region texRefZone matchgroup=texStatement start="\\nocite{" end="}\|%stopzone\>" contains=@texRefGroup
371syn region texRefZone matchgroup=texStatement start="\\bibliography{" end="}\|%stopzone\>" contains=@texRefGroup
372syn region texRefZone matchgroup=texStatement start="\\cite\([tp]\*\=\)\={" end="}\|%stopzone\>" contains=@texRefGroup
373syn region texRefZone matchgroup=texStatement start="\\label{" end="}\|%stopzone\>" contains=@texRefGroup
374syn region texRefZone matchgroup=texStatement start="\\\(page\|eq\)ref{" end="}\|%stopzone\>" contains=@texRefGroup
375syn region texRefZone matchgroup=texStatement start="\\v\=ref{" end="}\|%stopzone\>" contains=@texRefGroup
Bram Moolenaar071d4272004-06-13 20:20:40 +0000376
377" Handle newcommand, newenvironment : {{{1
378syn match texNewCmd "\\newcommand\>" nextgroup=texCmdName skipwhite skipnl
379syn region texCmdName contained matchgroup=Delimiter start="{"rs=s+1 end="}" nextgroup=texCmdArgs,texCmdBody skipwhite skipnl
380syn region texCmdArgs contained matchgroup=Delimiter start="\["rs=s+1 end="]" nextgroup=texCmdBody skipwhite skipnl
381syn region texCmdBody contained matchgroup=Delimiter start="{"rs=s+1 skip="\\\\\|\\[{}]" matchgroup=Delimiter end="}" contains=@texCmdGroup
382syn match texNewEnv "\\newenvironment\>" nextgroup=texEnvName skipwhite skipnl
383syn region texEnvName contained matchgroup=Delimiter start="{"rs=s+1 end="}" nextgroup=texEnvBgn skipwhite skipnl
384syn region texEnvBgn contained matchgroup=Delimiter start="{"rs=s+1 end="}" nextgroup=texEnvEnd skipwhite skipnl contains=@texEnvGroup
385syn region texEnvEnd contained matchgroup=Delimiter start="{"rs=s+1 end="}" skipwhite skipnl contains=@texEnvGroup
386
387" Definitions/Commands: {{{1
388syn match texDefCmd "\\def\>" nextgroup=texDefName skipwhite skipnl
389if b:tex_stylish
390 syn match texDefName contained "\\[a-zA-Z@]\+" nextgroup=texDefParms,texCmdBody skipwhite skipnl
391 syn match texDefName contained "\\[^a-zA-Z@]" nextgroup=texDefParms,texCmdBody skipwhite skipnl
392else
393 syn match texDefName contained "\\\a\+" nextgroup=texDefParms,texCmdBody skipwhite skipnl
394 syn match texDefName contained "\\\A" nextgroup=texDefParms,texCmdBody skipwhite skipnl
395endif
396syn match texDefParms contained "#[^{]*" contains=texDefParm nextgroup=texCmdBody skipwhite skipnl
397syn match texDefParm contained "#\d\+"
398
399" TeX Lengths: {{{1
400syn match texLength "\<\d\+\(\.\d\+\)\=\s*\(true\)\=\s*\(bp\|cc\|cm\|dd\|em\|ex\|in\|mm\|pc\|pt\|sp\)\>"
401
402" TeX String Delimiters: {{{1
403syn match texString "\(``\|''\|,,\)"
404
405" LaTeX synchronization: {{{1
406syn sync maxlines=200
407syn sync minlines=50
408
409syn sync match texSyncStop groupthere NONE "%stopzone\>"
410
411" Synchronization: {{{1
412" The $..$ and $$..$$ make for impossible sync patterns
413" (one can't tell if a "$$" starts or stops a math zone by itself)
414" The following grouptheres coupled with minlines above
415" help improve the odds of good syncing.
416if !exists("tex_no_math")
417 syn sync match texSyncMathZoneA groupthere NONE "\\end{abstract}"
418 syn sync match texSyncMathZoneA groupthere NONE "\\end{center}"
419 syn sync match texSyncMathZoneA groupthere NONE "\\end{description}"
420 syn sync match texSyncMathZoneA groupthere NONE "\\end{enumerate}"
421 syn sync match texSyncMathZoneA groupthere NONE "\\end{itemize}"
422 syn sync match texSyncMathZoneA groupthere NONE "\\end{table}"
423 syn sync match texSyncMathZoneA groupthere NONE "\\end{tabular}"
424 syn sync match texSyncMathZoneA groupthere NONE "\\\(sub\)*section\>"
425endif
426
427" Highlighting: {{{1
428if did_tex_syntax_inits == 1
429 let did_tex_syntax_inits= 2
430 " TeX highlighting groups which should share similar highlighting
431 if !exists("g:tex_no_error")
432 if !exists("tex_no_math")
433 HiLink texBadMath texError
434 HiLink texMathDelimBad texError
435 HiLink texMathError texError
436 if !b:tex_stylish
437 HiLink texOnlyMath texError
438 endif
439 endif
440 HiLink texError Error
441 endif
442
443 HiLink texDefCmd texDef
444 HiLink texDefName texDef
445 HiLink texDocType texCmdName
446 HiLink texDocTypeArgs texCmdArgs
447 HiLink texInputFileOpt texCmdArgs
448 HiLink texInputCurlies texDelimiter
449 HiLink texLigature texSpecialChar
450 if !exists("tex_no_math")
451 HiLink texMathDelimSet1 texMathDelim
452 HiLink texMathDelimSet2 texMathDelim
453 HiLink texMathDelimKey texMathDelim
454 HiLink texMathMatcher texMath
455 HiLink texMathZoneW texMath
456 HiLink texMathZoneX texMath
457 HiLink texMathZoneY texMath
458 HiLink texMathZoneZ texMath
459 endif
460 HiLink texSectionMarker texCmdName
461 HiLink texSectionName texSection
462 HiLink texSpaceCode texStatement
463 HiLink texTypeSize texType
464 HiLink texTypeStyle texType
465
466 " Basic TeX highlighting groups
467 HiLink texCmdArgs Number
468 HiLink texCmdName Statement
469 HiLink texComment Comment
470 HiLink texDef Statement
471 HiLink texDefParm Special
472 HiLink texDelimiter Delimiter
473 HiLink texInput Special
474 HiLink texInputFile Special
475 HiLink texLength Number
476 HiLink texMath Special
477 HiLink texMathDelim Statement
478 HiLink texMathOper Operator
479 HiLink texNewCmd Statement
480 HiLink texNewEnv Statement
481 HiLink texOption Number
482 HiLink texRefZone Special
483 HiLink texSection PreCondit
484 HiLink texSpaceCodeChar Special
485 HiLink texSpecialChar SpecialChar
486 HiLink texStatement Statement
487 HiLink texString String
488 HiLink texTodo Todo
489 HiLink texType Type
490 HiLink texZone PreCondit
491
492 delcommand HiLink
493endif
494
495" Current Syntax: {{{1
496unlet b:extfname
497let b:current_syntax = "tex"
498" vim: ts=8 fdm=marker