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