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