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