blob: fb7a7e41d1080c9ff8ce5b7049b7197fda718f49 [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>
4" Last Change: Aug 11, 2005
5" Version: 28
6" 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")
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
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 Moolenaar071d4272004-06-13 20:20:40 +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
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")
Bram Moolenaar488c6512005-08-11 20:09:58 +0000249 syn cluster texDocGroup contains=texPartZone,@texPartGroup
250 syn cluster texPartGroup contains=texChapterZone,texSectionZone,texParaZone
251 syn cluster texChapterGroup contains=texSectionZone,texParaZone
252 syn cluster texSectionGroup contains=texSubSectionZone,texParaZone
253 syn cluster texSubSectionGroup contains=texSubSubSectionZone,texParaZone
254 syn cluster texSubSubSectionGroup contains=texParaZone
255 syn cluster texParaGroup contains=texSubParaZone
256
257 syn region texDocZone matchgroup=texSection start='\\begin\s*{\s*document\s*}' end='\\end\s*{\s*document\s*}' fold keepend contains=@texFoldGroup,@texDocGroup
258 syn region texPartZone matchgroup=texSection start='\\part\>' end='\n\ze\s*\\part\>' fold keepend contains=@texFoldGroup,@texPartGroup
259 syn region texChapterZone matchgroup=texSection start='\\chapter\>' end='\n\ze\s*\\chapter\>' fold keepend contains=@texFoldGroup,@texChapterGroup
260 syn region texSectionZone matchgroup=texSection start='\\section\>' end='\n\ze\s*\\section\>' fold keepend contains=@texFoldGroup,@texSectionGroup
261 syn region texSubSectionZone matchgroup=texSection start='\\subsection\>' end='\n\ze\s*\\subsection\>' fold keepend contains=@texFoldGroup,@texSubSectionGroup
262 syn region texSubSubSectionZone matchgroup=texSection start='\\subsubsection\>' end='\n\ze\s*\\subsubsection\>' fold keepend contains=@texFoldGroup,@texSubSubSectionGroup
263 syn region texParaZone matchgroup=texSection start='\\paragraph\>' end='\n\ze\s*\\paragraph\>' fold keepend contains=@texFoldGroup,@texParaGroup
264 syn region texSubParaZone matchgroup=texSection start='\\subparagraph\>' end='\n\ze\s*\\subparagraph\>' fold keepend contains=@texFoldGroup
265 syn region texTitle matchgroup=texSection start='\\\%(author\|title\)\>\s*{' end='}' fold contains=@texFoldGroup
266 syn region texAbstract matchgroup=texSection start='\\begin\s*{\s*abstract\s*}' end='\\end\s*{\s*abstract\s*}' fold contains=@texFoldGroup
Bram Moolenaar293ee4d2004-12-09 21:34:53 +0000267else
Bram Moolenaar488c6512005-08-11 20:09:58 +0000268 syn match texSection "\\\(sub\)*section\*\=\>"
269 syn match texSection "\\\(part\|chapter\|paragraph\|subparagraph\)\>"
270 syn region texTitle matchgroup=texSection start='\\\%(author\|title\)\>\s*\ze{' end='}' contains=@texFoldGroup
271 syn match texSection "\\begin\s*{\s*abstract\s*}\|\\end\s*{\s*abstract\s*}"
Bram Moolenaar293ee4d2004-12-09 21:34:53 +0000272endif
Bram Moolenaar071d4272004-06-13 20:20:40 +0000273
274" Bad Math (mismatched): {{{1
275if !exists("tex_no_math")
276 syn match texBadMath "\\end\s*{\s*\(array\|gathered\|bBpvV]matrix\|split\|subequations\|smallmatrix\|xxalignat\)\s*}"
277 syn match texBadMath "\\end\s*{\s*\(align\|alignat\|displaymath\|displaymath\|eqnarray\|equation\|flalign\|gather\|math\|multline\|xalignat\)\*\=\s*}"
278 syn match texBadMath "\\[\])]"
279endif
280
281" Math Zones: {{{1
282if !exists("tex_no_math")
Bram Moolenaar488c6512005-08-11 20:09:58 +0000283 " TexNewMathZone: function creates a mathzone with the given suffix and mathzone name. {{{2
Bram Moolenaar071d4272004-06-13 20:20:40 +0000284 " Starred forms are created if starform is true. Starred
285 " forms have syntax group and synchronization groups with a
286 " "S" appended. Handles: cluster, syntax, sync, and HiLink.
287 fun! TexNewMathZone(sfx,mathzone,starform)
288 let grpname = "texMathZone".a:sfx
289 let syncname = "texSyncMathZone".a:sfx
290 exe "syn cluster texMathZones add=".grpname
291 exe 'syn region '.grpname.' start='."'".'\\begin\s*{\s*'.a:mathzone.'\s*}'."'".' end='."'".'\\end\s*{\s*'.a:mathzone.'\s*}'."'".' keepend contains=@texMathZoneGroup'
292 exe 'syn sync match '.syncname.' grouphere '.grpname.' "\\begin\s*{\s*'.a:mathzone.'\*\s*}"'
293 exe 'syn sync match '.syncname.' grouphere '.grpname.' "\\begin\s*{\s*'.a:mathzone.'\*\s*}"'
294 exe 'HiLink '.grpname.' texMath'
295 if a:starform
296 let grpname = "texMathZone".a:sfx.'S'
297 let syncname = "texSyncMathZone".a:sfx.'S'
298 exe "syn cluster texMathZones add=".grpname
299 exe 'syn region '.grpname.' start='."'".'\\begin\s*{\s*'.a:mathzone.'\*\s*}'."'".' end='."'".'\\end\s*{\s*'.a:mathzone.'\*\s*}'."'".' keepend contains=@texMathZoneGroup'
300 exe 'syn sync match '.syncname.' grouphere '.grpname.' "\\begin\s*{\s*'.a:mathzone.'\*\s*}"'
301 exe 'syn sync match '.syncname.' grouphere '.grpname.' "\\begin\s*{\s*'.a:mathzone.'\*\s*}"'
302 exe 'HiLink '.grpname.' texMath'
303 endif
304 endfun
305
306 " Standard Math Zones: {{{2
307 call TexNewMathZone("A","align",1)
308 call TexNewMathZone("B","alignat",1)
309 call TexNewMathZone("C","displaymath",1)
310 call TexNewMathZone("D","eqnarray",1)
311 call TexNewMathZone("E","equation",1)
312 call TexNewMathZone("F","flalign",1)
313 call TexNewMathZone("G","gather",1)
314 call TexNewMathZone("H","math",1)
315 call TexNewMathZone("I","multline",1)
316 call TexNewMathZone("J","subequations",0)
317 call TexNewMathZone("K","xalignat",1)
318 call TexNewMathZone("L","xxalignat",0)
319
320 " Inline Math Zones: {{{2
321 syn region texMathZoneV matchgroup=Delimiter start="\\(" matchgroup=Delimiter end="\\)\|%stopzone\>" keepend contains=@texMathZoneGroup
322 syn region texMathZoneW matchgroup=Delimiter start="\\\[" matchgroup=Delimiter end="\\]\|%stopzone\>" keepend contains=@texMathZoneGroup
323 syn region texMathZoneX matchgroup=Delimiter start="\$" skip="\\\\\|\\\$" matchgroup=Delimiter end="\$" end="%stopzone\>" contains=@texMathZoneGroup
324 syn region texMathZoneY matchgroup=Delimiter start="\$\$" matchgroup=Delimiter end="\$\$" end="%stopzone\>" keepend contains=@texMathZoneGroup
325 syn region texMathZoneZ matchgroup=texStatement start="\\ensuremath\s*{" matchgroup=texStatement end="}" end="%stopzone\>" contains=@texMathZoneGroup
326
327 syn match texMathOper "[_^=]" contained
328
329 " \left..something.. and \right..something.. support: {{{2
330 syn match texMathDelimBad contained "\S"
331 syn match texMathDelim contained "\\\(left\|right\|[bB]igg\=[lr]\)\>" skipwhite nextgroup=texMathDelimSet1,texMathDelimSet2,texMathDelimBad
332 syn match texMathDelim contained "\\\(left\|right\)arrow\>\|\<\([aA]rrow\|brace\)\=vert\>"
333 syn match texMathDelim contained "\\lefteqn\>"
334 syn match texMathDelimSet2 contained "\\" nextgroup=texMathDelimKey,texMathDelimBad
335 syn match texMathDelimSet1 contained "[<>()[\]|/.]\|\\[{}|]"
336 syn keyword texMathDelimKey contained backslash lceil lVert rgroup uparrow
337 syn keyword texMathDelimKey contained downarrow lfloor rangle rmoustache Uparrow
338 syn keyword texMathDelimKey contained Downarrow lgroup rbrace rvert updownarrow
339 syn keyword texMathDelimKey contained langle lmoustache rceil rVert Updownarrow
340 syn keyword texMathDelimKey contained lbrace lvert rfloor
341endif
342
343" Special TeX characters ( \$ \& \% \# \{ \} \_ \S \P ) : {{{1
344syn match texSpecialChar "\\[$&%#{}_]"
345if b:tex_stylish
346 syn match texSpecialChar "\\[SP@][^a-zA-Z@]"me=e-1
347else
348 syn match texSpecialChar "\\[SP@]\A"me=e-1
349endif
350syn match texSpecialChar "\\\\"
351if !exists("tex_no_math")
352 syn match texOnlyMath "[_^]"
353endif
354syn match texSpecialChar "\^\^[0-9a-f]\{2}\|\^\^\S"
355
356" Comments: {{{1
357" Normal TeX LaTeX : %....
358" Documented TeX Format: ^^A... -and- leading %s (only)
359syn cluster texCommentGroup contains=texTodo,@Spell
360syn case ignore
361syn keyword texTodo contained combak fixme todo
362syn case match
363if b:extfname == "dtx"
364 syn match texComment "\^\^A.*$" contains=@texCommentGroup
365 syn match texComment "^%\+" contains=@texCommentGroup
366else
367 syn match texComment "%.*$" contains=@texCommentGroup
368endif
369
370" Separate lines used for verb` and verb# so that the end conditions {{{1
371" will appropriately terminate. Ideally vim would let me save a
372" character from the start pattern and re-use it in the end-pattern.
373syn region texZone start="\\begin{verbatim}" end="\\end{verbatim}\|%stopzone\>"
374if version < 600
375 syn region texZone start="\\verb\*\=`" end="`\|%stopzone\>"
376 syn region texZone start="\\verb\*\=#" end="#\|%stopzone\>"
377else
378 if b:tex_stylish
379 syn region texZone start="\\verb\*\=\z([^\ta-zA-Z@]\)" end="\z1\|%stopzone\>"
380 else
381 syn region texZone start="\\verb\*\=\z([^\ta-zA-Z]\)" end="\z1\|%stopzone\>"
382 endif
383endif
384
385" Tex Reference Zones: {{{1
Bram Moolenaarcfbc5ee2004-07-02 15:38:35 +0000386syn region texZone matchgroup=texStatement start="@samp{" end="}\|%stopzone\>" contains=@texRefGroup
387syn region texRefZone matchgroup=texStatement start="\\nocite{" end="}\|%stopzone\>" contains=@texRefGroup
388syn region texRefZone matchgroup=texStatement start="\\bibliography{" end="}\|%stopzone\>" contains=@texRefGroup
389syn region texRefZone matchgroup=texStatement start="\\cite\([tp]\*\=\)\={" end="}\|%stopzone\>" contains=@texRefGroup
390syn region texRefZone matchgroup=texStatement start="\\label{" end="}\|%stopzone\>" contains=@texRefGroup
391syn region texRefZone matchgroup=texStatement start="\\\(page\|eq\)ref{" end="}\|%stopzone\>" contains=@texRefGroup
392syn region texRefZone matchgroup=texStatement start="\\v\=ref{" end="}\|%stopzone\>" contains=@texRefGroup
Bram Moolenaar071d4272004-06-13 20:20:40 +0000393
394" Handle newcommand, newenvironment : {{{1
395syn match texNewCmd "\\newcommand\>" nextgroup=texCmdName skipwhite skipnl
396syn region texCmdName contained matchgroup=Delimiter start="{"rs=s+1 end="}" nextgroup=texCmdArgs,texCmdBody skipwhite skipnl
397syn region texCmdArgs contained matchgroup=Delimiter start="\["rs=s+1 end="]" nextgroup=texCmdBody skipwhite skipnl
398syn region texCmdBody contained matchgroup=Delimiter start="{"rs=s+1 skip="\\\\\|\\[{}]" matchgroup=Delimiter end="}" contains=@texCmdGroup
399syn match texNewEnv "\\newenvironment\>" nextgroup=texEnvName skipwhite skipnl
400syn region texEnvName contained matchgroup=Delimiter start="{"rs=s+1 end="}" nextgroup=texEnvBgn skipwhite skipnl
401syn region texEnvBgn contained matchgroup=Delimiter start="{"rs=s+1 end="}" nextgroup=texEnvEnd skipwhite skipnl contains=@texEnvGroup
402syn region texEnvEnd contained matchgroup=Delimiter start="{"rs=s+1 end="}" skipwhite skipnl contains=@texEnvGroup
403
404" Definitions/Commands: {{{1
405syn match texDefCmd "\\def\>" nextgroup=texDefName skipwhite skipnl
406if b:tex_stylish
407 syn match texDefName contained "\\[a-zA-Z@]\+" nextgroup=texDefParms,texCmdBody skipwhite skipnl
408 syn match texDefName contained "\\[^a-zA-Z@]" nextgroup=texDefParms,texCmdBody skipwhite skipnl
409else
410 syn match texDefName contained "\\\a\+" nextgroup=texDefParms,texCmdBody skipwhite skipnl
411 syn match texDefName contained "\\\A" nextgroup=texDefParms,texCmdBody skipwhite skipnl
412endif
413syn match texDefParms contained "#[^{]*" contains=texDefParm nextgroup=texCmdBody skipwhite skipnl
414syn match texDefParm contained "#\d\+"
415
416" TeX Lengths: {{{1
417syn match texLength "\<\d\+\(\.\d\+\)\=\s*\(true\)\=\s*\(bp\|cc\|cm\|dd\|em\|ex\|in\|mm\|pc\|pt\|sp\)\>"
418
419" TeX String Delimiters: {{{1
420syn match texString "\(``\|''\|,,\)"
421
422" LaTeX synchronization: {{{1
423syn sync maxlines=200
424syn sync minlines=50
425
426syn sync match texSyncStop groupthere NONE "%stopzone\>"
427
428" Synchronization: {{{1
429" The $..$ and $$..$$ make for impossible sync patterns
430" (one can't tell if a "$$" starts or stops a math zone by itself)
431" The following grouptheres coupled with minlines above
432" help improve the odds of good syncing.
433if !exists("tex_no_math")
434 syn sync match texSyncMathZoneA groupthere NONE "\\end{abstract}"
435 syn sync match texSyncMathZoneA groupthere NONE "\\end{center}"
436 syn sync match texSyncMathZoneA groupthere NONE "\\end{description}"
437 syn sync match texSyncMathZoneA groupthere NONE "\\end{enumerate}"
438 syn sync match texSyncMathZoneA groupthere NONE "\\end{itemize}"
439 syn sync match texSyncMathZoneA groupthere NONE "\\end{table}"
440 syn sync match texSyncMathZoneA groupthere NONE "\\end{tabular}"
441 syn sync match texSyncMathZoneA groupthere NONE "\\\(sub\)*section\>"
442endif
443
444" Highlighting: {{{1
445if did_tex_syntax_inits == 1
446 let did_tex_syntax_inits= 2
447 " TeX highlighting groups which should share similar highlighting
448 if !exists("g:tex_no_error")
449 if !exists("tex_no_math")
450 HiLink texBadMath texError
451 HiLink texMathDelimBad texError
452 HiLink texMathError texError
453 if !b:tex_stylish
454 HiLink texOnlyMath texError
455 endif
456 endif
457 HiLink texError Error
458 endif
459
460 HiLink texDefCmd texDef
461 HiLink texDefName texDef
462 HiLink texDocType texCmdName
463 HiLink texDocTypeArgs texCmdArgs
464 HiLink texInputFileOpt texCmdArgs
465 HiLink texInputCurlies texDelimiter
466 HiLink texLigature texSpecialChar
467 if !exists("tex_no_math")
468 HiLink texMathDelimSet1 texMathDelim
469 HiLink texMathDelimSet2 texMathDelim
470 HiLink texMathDelimKey texMathDelim
471 HiLink texMathMatcher texMath
472 HiLink texMathZoneW texMath
473 HiLink texMathZoneX texMath
474 HiLink texMathZoneY texMath
475 HiLink texMathZoneZ texMath
476 endif
477 HiLink texSectionMarker texCmdName
478 HiLink texSectionName texSection
479 HiLink texSpaceCode texStatement
480 HiLink texTypeSize texType
481 HiLink texTypeStyle texType
482
483 " Basic TeX highlighting groups
484 HiLink texCmdArgs Number
485 HiLink texCmdName Statement
486 HiLink texComment Comment
487 HiLink texDef Statement
488 HiLink texDefParm Special
489 HiLink texDelimiter Delimiter
490 HiLink texInput Special
491 HiLink texInputFile Special
492 HiLink texLength Number
493 HiLink texMath Special
494 HiLink texMathDelim Statement
495 HiLink texMathOper Operator
496 HiLink texNewCmd Statement
497 HiLink texNewEnv Statement
498 HiLink texOption Number
499 HiLink texRefZone Special
500 HiLink texSection PreCondit
501 HiLink texSpaceCodeChar Special
502 HiLink texSpecialChar SpecialChar
503 HiLink texStatement Statement
504 HiLink texString String
505 HiLink texTodo Todo
506 HiLink texType Type
507 HiLink texZone PreCondit
508
509 delcommand HiLink
510endif
511
512" Current Syntax: {{{1
513unlet b:extfname
514let b:current_syntax = "tex"
515" vim: ts=8 fdm=marker