blob: 218f9cbfde19e6fccc301a01c2963b603613fa15 [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>
Bram Moolenaare0021c72010-07-28 17:25:21 +02004" Last Change: Jul 28, 2010
5" Version: 51
Bram Moolenaar488c6512005-08-11 20:09:58 +00006" 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")
Bram Moolenaarab194812005-09-14 21:40:12 +000076 let g:tex_fold_enabled= 0
Bram Moolenaarf1f8bc52005-03-07 23:20:08 +000077 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"
Bram Moolenaar00a927d2010-05-14 23:24:24 +020080 setl fdm=syntax
Bram Moolenaarf1f8bc52005-03-07 23:20:08 +000081endif
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 Moolenaar5b8d8fd2005-08-16 23:01:50 +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,@Spell
Bram Moolenaar5c736222010-01-06 20:54:52 +0100106syn cluster texStyleGroup contains=texAccent,texBadMath,texComment,texDefCmd,texDelimiter,texDocType,texInput,texLength,texLigature,texNewCmd,texNewEnv,texOnlyMath,texParen,texRefZone,texSection,texSpecialChar,texStatement,texString,texTypeSize,texTypeStyle,texZone,texInputFile,texOption,texStyleStatement,@Spell,texStyleMatcher
Bram Moolenaarcfbc5ee2004-07-02 15:38:35 +0000107syn cluster texRefGroup contains=texMatcher,texComment,texDelimiter
Bram Moolenaar071d4272004-06-13 20:20:40 +0000108if !exists("tex_no_math")
109 syn cluster texMathZones contains=texMathZoneV,texMathZoneW,texMathZoneX,texMathZoneY,texMathZoneZ
110 syn cluster texMatchGroup add=@texMathZones
111 syn cluster texMathDelimGroup contains=texMathDelimBad,texMathDelimKey,texMathDelimSet1,texMathDelimSet2
112 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
Bram Moolenaar611df5b2010-07-26 22:51:56 +0200113 syn cluster texMathZoneGroup contains=texComment,texDelimiter,texLength,texMathDelim,texMathMatcher,texMathOper,texMathSymbol,texRefZone,texSpecialChar,texStatement,texTypeSize,texTypeStyle
Bram Moolenaar071d4272004-06-13 20:20:40 +0000114 if !exists("g:tex_no_error")
115 syn cluster texMathMatchGroup add=texMathError
116 syn cluster texMathZoneGroup add=texMathError
117 endif
Bram Moolenaar5b8d8fd2005-08-16 23:01:50 +0000118 syn cluster texMathZoneGroup add=@NoSpell
119 " following used in the \part \chapter \section \subsection \subsubsection
120 " \paragraph \subparagraph \author \title highlighting
121 syn cluster texDocGroup contains=texPartZone,@texPartGroup
122 syn cluster texPartGroup contains=texChapterZone,texSectionZone,texParaZone
123 syn cluster texChapterGroup contains=texSectionZone,texParaZone
124 syn cluster texSectionGroup contains=texSubSectionZone,texParaZone
125 syn cluster texSubSectionGroup contains=texSubSubSectionZone,texParaZone
126 syn cluster texSubSubSectionGroup contains=texParaZone
127 syn cluster texParaGroup contains=texSubParaZone
Bram Moolenaarb2c03502010-07-02 20:20:09 +0200128 if has("conceal") && &enc == 'utf-8'
Bram Moolenaare0021c72010-07-28 17:25:21 +0200129 syn cluster texMathZoneGroup add=texGreek,texSuperscript,texSubscript,texMathSymbol
130 syn cluster texMathMatchGroup add=texGreek,texSuperscript,texSubscript,texMathSymbol
Bram Moolenaarb2c03502010-07-02 20:20:09 +0200131 endif
Bram Moolenaar071d4272004-06-13 20:20:40 +0000132endif
133
134" Try to flag {} and () mismatches: {{{1
135if !exists("g:tex_no_error")
136 syn region texMatcher matchgroup=Delimiter start="{" skip="\\\\\|\\[{}]" end="}" contains=@texMatchGroup,texError
137 syn region texMatcher matchgroup=Delimiter start="\[" end="]" contains=@texMatchGroup,texError
138else
139 syn region texMatcher matchgroup=Delimiter start="{" skip="\\\\\|\\[{}]" end="}" contains=@texMatchGroup
140 syn region texMatcher matchgroup=Delimiter start="\[" end="]" contains=@texMatchGroup
141endif
Bram Moolenaar293ee4d2004-12-09 21:34:53 +0000142syn region texParen start="(" end=")" contains=@texMatchGroup,@Spell
Bram Moolenaar071d4272004-06-13 20:20:40 +0000143if !exists("g:tex_no_error")
144 syn match texError "[}\])]"
145endif
146if !exists("tex_no_math")
147 if !exists("g:tex_no_error")
148 syn match texMathError "}" contained
149 endif
150 syn region texMathMatcher matchgroup=Delimiter start="{" skip="\\\\\|\\}" end="}" end="%stopzone\>" contained contains=@texMathMatchGroup
151endif
152
153" TeX/LaTeX keywords: {{{1
154" Instead of trying to be All Knowing, I just match \..alphameric..
155" Note that *.tex files may not have "@" in their \commands
156if exists("g:tex_tex") || b:tex_stylish
157 syn match texStatement "\\[a-zA-Z@]\+"
158else
159 syn match texStatement "\\\a\+"
160 if !exists("g:tex_no_error")
161 syn match texError "\\\a*@[a-zA-Z@]*"
162 endif
163endif
164
165" TeX/LaTeX delimiters: {{{1
166syn match texDelimiter "&"
167syn match texDelimiter "\\\\"
168
169" Tex/Latex Options: {{{1
170syn match texOption "[^\\]\zs#\d\+\|^#\d\+"
171
172" texAccent (tnx to Karim Belabas) avoids annoying highlighting for accents: {{{1
173if b:tex_stylish
174 syn match texAccent "\\[bcdvuH][^a-zA-Z@]"me=e-1
175 syn match texLigature "\\\([ijolL]\|ae\|oe\|ss\|AA\|AE\|OE\)[^a-zA-Z@]"me=e-1
176else
177 syn match texAccent "\\[bcdvuH]\A"me=e-1
178 syn match texLigature "\\\([ijolL]\|ae\|oe\|ss\|AA\|AE\|OE\)\A"me=e-1
179endif
180syn match texAccent "\\[bcdvuH]$"
181syn match texAccent +\\[=^.\~"`']+
182syn match texAccent +\\['=t'.c^ud"vb~Hr]{\a}+
183syn match texLigature "\\\([ijolL]\|ae\|oe\|ss\|AA\|AE\|OE\)$"
184
185" \begin{}/\end{} section markers: {{{1
186syn match texSectionMarker "\\begin\>\|\\end\>" nextgroup=texSectionName
Bram Moolenaar5c736222010-01-06 20:54:52 +0100187syn region texSectionName matchgroup=Delimiter start="{" end="}" contained nextgroup=texSectionModifier contains=texComment
188syn region texSectionModifier matchgroup=Delimiter start="\[" end="]" contained contains=texComment
Bram Moolenaar071d4272004-06-13 20:20:40 +0000189
190" \documentclass, \documentstyle, \usepackage: {{{1
191syn match texDocType "\\documentclass\>\|\\documentstyle\>\|\\usepackage\>" nextgroup=texSectionName,texDocTypeArgs
Bram Moolenaar5c736222010-01-06 20:54:52 +0100192syn region texDocTypeArgs matchgroup=Delimiter start="\[" end="]" contained nextgroup=texSectionName contains=texComment
Bram Moolenaar071d4272004-06-13 20:20:40 +0000193
Bram Moolenaara9a568c2006-03-14 23:04:27 +0000194" Preamble syntax-based folding support: {{{1
195if g:tex_fold_enabled && has("folding")
Bram Moolenaar5c736222010-01-06 20:54:52 +0100196 syn region texPreamble transparent fold start='\zs\\documentclass\>' end='\ze\\begin{document}' contains=texStyle,@texMatchGroup
Bram Moolenaara9a568c2006-03-14 23:04:27 +0000197endif
198
Bram Moolenaar071d4272004-06-13 20:20:40 +0000199" TeX input: {{{1
200syn match texInput "\\input\s\+[a-zA-Z/.0-9_^]\+"hs=s+7 contains=texStatement
Bram Moolenaar5c736222010-01-06 20:54:52 +0100201syn match texInputFile "\\include\(graphics\|list\)\=\(\[.\{-}\]\)\=\s*{.\{-}}" contains=texStatement,texInputCurlies,texInputFileOpt
Bram Moolenaar071d4272004-06-13 20:20:40 +0000202syn match texInputFile "\\\(epsfig\|input\|usepackage\)\s*\(\[.*\]\)\={.\{-}}" contains=texStatement,texInputCurlies,texInputFileOpt
203syn match texInputCurlies "[{}]" contained
Bram Moolenaar5c736222010-01-06 20:54:52 +0100204syn region texInputFileOpt matchgroup=Delimiter start="\[" end="\]" contained contains=texComment
Bram Moolenaar071d4272004-06-13 20:20:40 +0000205
206" Type Styles (LaTeX 2.09): {{{1
207syn match texTypeStyle "\\rm\>"
208syn match texTypeStyle "\\em\>"
209syn match texTypeStyle "\\bf\>"
210syn match texTypeStyle "\\it\>"
211syn match texTypeStyle "\\sl\>"
212syn match texTypeStyle "\\sf\>"
213syn match texTypeStyle "\\sc\>"
214syn match texTypeStyle "\\tt\>"
215
216" Type Styles: attributes, commands, families, etc (LaTeX2E): {{{1
217syn match texTypeStyle "\\textbf\>"
218syn match texTypeStyle "\\textit\>"
219syn match texTypeStyle "\\textmd\>"
220syn match texTypeStyle "\\textrm\>"
221syn match texTypeStyle "\\textsc\>"
222syn match texTypeStyle "\\textsf\>"
223syn match texTypeStyle "\\textsl\>"
224syn match texTypeStyle "\\texttt\>"
225syn match texTypeStyle "\\textup\>"
226syn match texTypeStyle "\\emph\>"
227
228syn match texTypeStyle "\\mathbb\>"
229syn match texTypeStyle "\\mathbf\>"
230syn match texTypeStyle "\\mathcal\>"
231syn match texTypeStyle "\\mathfrak\>"
232syn match texTypeStyle "\\mathit\>"
233syn match texTypeStyle "\\mathnormal\>"
234syn match texTypeStyle "\\mathrm\>"
235syn match texTypeStyle "\\mathsf\>"
236syn match texTypeStyle "\\mathtt\>"
237
238syn match texTypeStyle "\\rmfamily\>"
239syn match texTypeStyle "\\sffamily\>"
240syn match texTypeStyle "\\ttfamily\>"
241
242syn match texTypeStyle "\\itshape\>"
243syn match texTypeStyle "\\scshape\>"
244syn match texTypeStyle "\\slshape\>"
245syn match texTypeStyle "\\upshape\>"
246
247syn match texTypeStyle "\\bfseries\>"
248syn match texTypeStyle "\\mdseries\>"
249
250" Some type sizes: {{{1
251syn match texTypeSize "\\tiny\>"
252syn match texTypeSize "\\scriptsize\>"
253syn match texTypeSize "\\footnotesize\>"
254syn match texTypeSize "\\small\>"
255syn match texTypeSize "\\normalsize\>"
256syn match texTypeSize "\\large\>"
257syn match texTypeSize "\\Large\>"
258syn match texTypeSize "\\LARGE\>"
259syn match texTypeSize "\\huge\>"
260syn match texTypeSize "\\Huge\>"
261
262" Spacecodes (TeX'isms): {{{1
263" \mathcode`\^^@="2201 \delcode`\(="028300 \sfcode`\)=0 \uccode`X=`X \lccode`x=`x
264syn match texSpaceCode "\\\(math\|cat\|del\|lc\|sf\|uc\)code`"me=e-1 nextgroup=texSpaceCodeChar
265syn match texSpaceCodeChar "`\\\=.\(\^.\)\==\(\d\|\"\x\{1,6}\|`.\)" contained
266
267" Sections, subsections, etc: {{{1
Bram Moolenaarf1f8bc52005-03-07 23:20:08 +0000268if g:tex_fold_enabled && has("folding")
Bram Moolenaar3577c6f2008-06-24 21:16:56 +0000269 syn region texDocZone matchgroup=texSection start='\\begin\s*{\s*document\s*}' end='\\end\s*{\s*document\s*}' fold contains=@texFoldGroup,@texDocGroup,@Spell
270 syn region texPartZone matchgroup=texSection start='\\part\>' end='\ze\s*\\\%(part\>\|end\s*{\s*document\s*}\)' fold contains=@texFoldGroup,@texPartGroup,@Spell
271 syn region texChapterZone matchgroup=texSection start='\\chapter\>' end='\ze\s*\\\%(chapter\>\|part\>\|end\s*{\s*document\s*}\)' fold contains=@texFoldGroup,@texChapterGroup,@Spell
272 syn region texSectionZone matchgroup=texSection start='\\section\>' end='\ze\s*\\\%(section\>\|chapter\>\|part\>\|end\s*{\s*document\s*}\)' fold contains=@texFoldGroup,@texSectionGroup,@Spell
273 syn region texSubSectionZone matchgroup=texSection start='\\subsection\>' end='\ze\s*\\\%(\%(sub\)\=section\>\|chapter\>\|part\>\|end\s*{\s*document\s*}\)' fold contains=@texFoldGroup,@texSubSectionGroup,@Spell
274 syn region texSubSubSectionZone matchgroup=texSection start='\\subsubsection\>' end='\ze\s*\\\%(\%(sub\)\{,2}section\>\|chapter\>\|part\>\|end\s*{\s*document\s*}\)' fold contains=@texFoldGroup,@texSubSubSectionGroup,@Spell
275 syn region texParaZone matchgroup=texSection start='\\paragraph\>' end='\ze\s*\\\%(paragraph\>\|\%(sub\)*section\>\|chapter\>\|part\>\|end\s*{\s*document\s*}\)' fold contains=@texFoldGroup,@texParaGroup,@Spell
276 syn region texSubParaZone matchgroup=texSection start='\\subparagraph\>' end='\ze\s*\\\%(\%(sub\)\=paragraph\>\|\%(sub\)*section\>\|chapter\>\|part\>\|end\s*{\s*document\s*}\)' fold contains=@texFoldGroup,@Spell
277 syn region texTitle matchgroup=texSection start='\\\%(author\|title\)\>\s*{' end='}' fold contains=@texFoldGroup,@Spell
278 syn region texAbstract matchgroup=texSection start='\\begin\s*{\s*abstract\s*}' end='\\end\s*{\s*abstract\s*}' fold contains=@texFoldGroup,@Spell
Bram Moolenaar293ee4d2004-12-09 21:34:53 +0000279else
Bram Moolenaar3577c6f2008-06-24 21:16:56 +0000280 syn region texDocZone matchgroup=texSection start='\\begin\s*{\s*document\s*}' end='\\end\s*{\s*document\s*}' contains=@texFoldGroup,@texDocGroup,@Spell
281 syn region texPartZone matchgroup=texSection start='\\part\>' end='\ze\s*\\\%(part\>\|end\s*{\s*document\s*}\)' contains=@texFoldGroup,@texPartGroup,@Spell
282 syn region texChapterZone matchgroup=texSection start='\\chapter\>' end='\ze\s*\\\%(chapter\>\|part\>\|end\s*{\s*document\s*}\)' contains=@texFoldGroup,@texChapterGroup,@Spell
283 syn region texSectionZone matchgroup=texSection start='\\section\>' end='\ze\s*\\\%(section\>\|chapter\>\|part\>\|end\s*{\s*document\s*}\)' contains=@texFoldGroup,@texSectionGroup,@Spell
284 syn region texSubSectionZone matchgroup=texSection start='\\subsection\>' end='\ze\s*\\\%(\%(sub\)\=section\>\|chapter\>\|part\>\|end\s*{\s*document\s*}\)' contains=@texFoldGroup,@texSubSectionGroup,@Spell
285 syn region texSubSubSectionZone matchgroup=texSection start='\\subsubsection\>' end='\ze\s*\\\%(\%(sub\)\{,2}section\>\|chapter\>\|part\>\|end\s*{\s*document\s*}\)' contains=@texFoldGroup,@texSubSubSectionGroup,@Spell
286 syn region texParaZone matchgroup=texSection start='\\paragraph\>' end='\ze\s*\\\%(paragraph\>\|\%(sub\)*section\>\|chapter\>\|part\>\|end\s*{\s*document\s*}\)' contains=@texFoldGroup,@texParaGroup,@Spell
287 syn region texSubParaZone matchgroup=texSection start='\\subparagraph\>' end='\ze\s*\\\%(\%(sub\)\=paragraph\>\|\%(sub\)*section\>\|chapter\>\|part\>\|end\s*{\s*document\s*}\)' contains=@texFoldGroup,@Spell
288 syn region texTitle matchgroup=texSection start='\\\%(author\|title\)\>\s*{' end='}' contains=@texFoldGroup,@Spell
289 syn region texAbstract matchgroup=texSection start='\\begin\s*{\s*abstract\s*}' end='\\end\s*{\s*abstract\s*}' contains=@texFoldGroup,@Spell
Bram Moolenaar293ee4d2004-12-09 21:34:53 +0000290endif
Bram Moolenaar071d4272004-06-13 20:20:40 +0000291
292" Bad Math (mismatched): {{{1
293if !exists("tex_no_math")
294 syn match texBadMath "\\end\s*{\s*\(array\|gathered\|bBpvV]matrix\|split\|subequations\|smallmatrix\|xxalignat\)\s*}"
295 syn match texBadMath "\\end\s*{\s*\(align\|alignat\|displaymath\|displaymath\|eqnarray\|equation\|flalign\|gather\|math\|multline\|xalignat\)\*\=\s*}"
296 syn match texBadMath "\\[\])]"
297endif
298
299" Math Zones: {{{1
300if !exists("tex_no_math")
Bram Moolenaar488c6512005-08-11 20:09:58 +0000301 " TexNewMathZone: function creates a mathzone with the given suffix and mathzone name. {{{2
Bram Moolenaar071d4272004-06-13 20:20:40 +0000302 " Starred forms are created if starform is true. Starred
303 " forms have syntax group and synchronization groups with a
304 " "S" appended. Handles: cluster, syntax, sync, and HiLink.
305 fun! TexNewMathZone(sfx,mathzone,starform)
306 let grpname = "texMathZone".a:sfx
307 let syncname = "texSyncMathZone".a:sfx
Bram Moolenaar3577c6f2008-06-24 21:16:56 +0000308 if g:tex_fold_enabled
309 let foldcmd= " fold"
310 else
311 let foldcmd= ""
312 endif
Bram Moolenaar071d4272004-06-13 20:20:40 +0000313 exe "syn cluster texMathZones add=".grpname
Bram Moolenaar3577c6f2008-06-24 21:16:56 +0000314 exe 'syn region '.grpname.' start='."'".'\\begin\s*{\s*'.a:mathzone.'\s*}'."'".' end='."'".'\\end\s*{\s*'.a:mathzone.'\s*}'."'".' keepend contains=@texMathZoneGroup'.foldcmd
Bram Moolenaar071d4272004-06-13 20:20:40 +0000315 exe 'syn sync match '.syncname.' grouphere '.grpname.' "\\begin\s*{\s*'.a:mathzone.'\*\s*}"'
316 exe 'syn sync match '.syncname.' grouphere '.grpname.' "\\begin\s*{\s*'.a:mathzone.'\*\s*}"'
Bram Moolenaar5c736222010-01-06 20:54:52 +0100317 exe 'hi def link '.grpname.' texMath'
Bram Moolenaar071d4272004-06-13 20:20:40 +0000318 if a:starform
319 let grpname = "texMathZone".a:sfx.'S'
320 let syncname = "texSyncMathZone".a:sfx.'S'
321 exe "syn cluster texMathZones add=".grpname
Bram Moolenaar3577c6f2008-06-24 21:16:56 +0000322 exe 'syn region '.grpname.' start='."'".'\\begin\s*{\s*'.a:mathzone.'\*\s*}'."'".' end='."'".'\\end\s*{\s*'.a:mathzone.'\*\s*}'."'".' keepend contains=@texMathZoneGroup'.foldcmd
Bram Moolenaar071d4272004-06-13 20:20:40 +0000323 exe 'syn sync match '.syncname.' grouphere '.grpname.' "\\begin\s*{\s*'.a:mathzone.'\*\s*}"'
324 exe 'syn sync match '.syncname.' grouphere '.grpname.' "\\begin\s*{\s*'.a:mathzone.'\*\s*}"'
Bram Moolenaar5c736222010-01-06 20:54:52 +0100325 exe 'hi def link '.grpname.' texMath'
Bram Moolenaar071d4272004-06-13 20:20:40 +0000326 endif
327 endfun
328
329 " Standard Math Zones: {{{2
330 call TexNewMathZone("A","align",1)
331 call TexNewMathZone("B","alignat",1)
332 call TexNewMathZone("C","displaymath",1)
333 call TexNewMathZone("D","eqnarray",1)
334 call TexNewMathZone("E","equation",1)
335 call TexNewMathZone("F","flalign",1)
336 call TexNewMathZone("G","gather",1)
337 call TexNewMathZone("H","math",1)
338 call TexNewMathZone("I","multline",1)
339 call TexNewMathZone("J","subequations",0)
340 call TexNewMathZone("K","xalignat",1)
341 call TexNewMathZone("L","xxalignat",0)
342
343 " Inline Math Zones: {{{2
Bram Moolenaare0021c72010-07-28 17:25:21 +0200344 if has("conceal") && &enc == 'utf-8'
345 syn region texMathZoneV matchgroup=Delimiter start="\\(" matchgroup=Delimiter end="\\)\|%stopzone\>" keepend concealends contains=@texMathZoneGroup
346 syn region texMathZoneW matchgroup=Delimiter start="\\\[" matchgroup=Delimiter end="\\]\|%stopzone\>" keepend concealends contains=@texMathZoneGroup
347 syn region texMathZoneX matchgroup=Delimiter start="\$" skip="\\\\\|\\\$" matchgroup=Delimiter end="\$" end="%stopzone\>" concealends contains=@texMathZoneGroup
348 syn region texMathZoneY matchgroup=Delimiter start="\$\$" matchgroup=Delimiter end="\$\$" end="%stopzone\>" concealends keepend contains=@texMathZoneGroup
349 else
350 syn region texMathZoneV matchgroup=Delimiter start="\\(" matchgroup=Delimiter end="\\)\|%stopzone\>" keepend contains=@texMathZoneGroup
351 syn region texMathZoneW matchgroup=Delimiter start="\\\[" matchgroup=Delimiter end="\\]\|%stopzone\>" keepend contains=@texMathZoneGroup
352 syn region texMathZoneX matchgroup=Delimiter start="\$" skip="\\\\\|\\\$" matchgroup=Delimiter end="\$" end="%stopzone\>" contains=@texMathZoneGroup
353 syn region texMathZoneY matchgroup=Delimiter start="\$\$" matchgroup=Delimiter end="\$\$" end="%stopzone\>" keepend contains=@texMathZoneGroup
354 endif
Bram Moolenaarb2c03502010-07-02 20:20:09 +0200355 syn region texMathZoneZ matchgroup=texStatement start="\\ensuremath\s*{" matchgroup=texStatement end="}" end="%stopzone\>" contains=@texMathZoneGroup
Bram Moolenaar071d4272004-06-13 20:20:40 +0000356
357 syn match texMathOper "[_^=]" contained
358
359 " \left..something.. and \right..something.. support: {{{2
360 syn match texMathDelimBad contained "\S"
361 syn match texMathDelim contained "\\\(left\|right\|[bB]igg\=[lr]\)\>" skipwhite nextgroup=texMathDelimSet1,texMathDelimSet2,texMathDelimBad
362 syn match texMathDelim contained "\\\(left\|right\)arrow\>\|\<\([aA]rrow\|brace\)\=vert\>"
363 syn match texMathDelim contained "\\lefteqn\>"
364 syn match texMathDelimSet2 contained "\\" nextgroup=texMathDelimKey,texMathDelimBad
365 syn match texMathDelimSet1 contained "[<>()[\]|/.]\|\\[{}|]"
366 syn keyword texMathDelimKey contained backslash lceil lVert rgroup uparrow
367 syn keyword texMathDelimKey contained downarrow lfloor rangle rmoustache Uparrow
368 syn keyword texMathDelimKey contained Downarrow lgroup rbrace rvert updownarrow
369 syn keyword texMathDelimKey contained langle lmoustache rceil rVert Updownarrow
370 syn keyword texMathDelimKey contained lbrace lvert rfloor
371endif
372
373" Special TeX characters ( \$ \& \% \# \{ \} \_ \S \P ) : {{{1
374syn match texSpecialChar "\\[$&%#{}_]"
375if b:tex_stylish
376 syn match texSpecialChar "\\[SP@][^a-zA-Z@]"me=e-1
377else
378 syn match texSpecialChar "\\[SP@]\A"me=e-1
379endif
380syn match texSpecialChar "\\\\"
381if !exists("tex_no_math")
382 syn match texOnlyMath "[_^]"
383endif
384syn match texSpecialChar "\^\^[0-9a-f]\{2}\|\^\^\S"
385
386" Comments: {{{1
387" Normal TeX LaTeX : %....
388" Documented TeX Format: ^^A... -and- leading %s (only)
Bram Moolenaar3577c6f2008-06-24 21:16:56 +0000389if !exists("g:tex_comment_nospell") || !g:tex_comment_nospell
390 syn cluster texCommentGroup contains=texTodo,@Spell
391else
392 syn cluster texCommentGroup contains=texTodo,@NoSpell
393endif
Bram Moolenaar071d4272004-06-13 20:20:40 +0000394syn case ignore
Bram Moolenaar18144c82006-04-12 21:52:12 +0000395syn keyword texTodo contained combak fixme todo xxx
Bram Moolenaar071d4272004-06-13 20:20:40 +0000396syn case match
397if b:extfname == "dtx"
398 syn match texComment "\^\^A.*$" contains=@texCommentGroup
399 syn match texComment "^%\+" contains=@texCommentGroup
400else
Bram Moolenaarfd2ac762006-03-01 22:09:21 +0000401 if g:tex_fold_enabled
402 " allows syntax-folding of 2 or more contiguous comment lines
403 " single-line comments are not folded
404 syn match texComment "%.*$" contains=@texCommentGroup
405 syn region texComment start="^\zs\s*%.*\_s*%" skip="^\s*%" end='^\ze\s*[^%]' fold
406 else
407 syn match texComment "%.*$" contains=@texCommentGroup
408 endif
Bram Moolenaar071d4272004-06-13 20:20:40 +0000409endif
410
411" Separate lines used for verb` and verb# so that the end conditions {{{1
412" will appropriately terminate. Ideally vim would let me save a
413" character from the start pattern and re-use it in the end-pattern.
Bram Moolenaar5c736222010-01-06 20:54:52 +0100414syn region texZone start="\\begin{[vV]erbatim}" end="\\end{[vV]erbatim}\|%stopzone\>" contains=@Spell
Bram Moolenaarc1e37902006-04-18 21:55:01 +0000415" listings package:
416syn region texZone start="\\begin{lstlisting}" end="\\end{lstlisting}\|%stopzone\>" contains=@Spell
417" moreverb package:
418syn region texZone start="\\begin{verbatimtab}" end="\\end{verbatimtab}\|%stopzone\>" contains=@Spell
419syn region texZone start="\\begin{verbatimwrite}" end="\\end{verbatimwrite}\|%stopzone\>" contains=@Spell
420syn region texZone start="\\begin{boxedverbatim}" end="\\end{boxedverbatim}\|%stopzone\>" contains=@Spell
Bram Moolenaar071d4272004-06-13 20:20:40 +0000421if version < 600
422 syn region texZone start="\\verb\*\=`" end="`\|%stopzone\>"
423 syn region texZone start="\\verb\*\=#" end="#\|%stopzone\>"
424else
425 if b:tex_stylish
426 syn region texZone start="\\verb\*\=\z([^\ta-zA-Z@]\)" end="\z1\|%stopzone\>"
427 else
428 syn region texZone start="\\verb\*\=\z([^\ta-zA-Z]\)" end="\z1\|%stopzone\>"
429 endif
430endif
431
432" Tex Reference Zones: {{{1
Bram Moolenaarcfbc5ee2004-07-02 15:38:35 +0000433syn region texZone matchgroup=texStatement start="@samp{" end="}\|%stopzone\>" contains=@texRefGroup
434syn region texRefZone matchgroup=texStatement start="\\nocite{" end="}\|%stopzone\>" contains=@texRefGroup
435syn region texRefZone matchgroup=texStatement start="\\bibliography{" end="}\|%stopzone\>" contains=@texRefGroup
Bram Moolenaarcfbc5ee2004-07-02 15:38:35 +0000436syn region texRefZone matchgroup=texStatement start="\\label{" end="}\|%stopzone\>" contains=@texRefGroup
437syn region texRefZone matchgroup=texStatement start="\\\(page\|eq\)ref{" end="}\|%stopzone\>" contains=@texRefGroup
438syn region texRefZone matchgroup=texStatement start="\\v\=ref{" end="}\|%stopzone\>" contains=@texRefGroup
Bram Moolenaarcc016f52005-12-10 20:23:46 +0000439syn match texRefZone '\\cite\%([tp]\*\=\)\=' nextgroup=texRefOption,texCite
440syn region texRefOption contained matchgroup=Delimiter start='\[' end=']' contains=@texRefGroup nextgroup=texRefOption,texCite
441syn region texCite contained matchgroup=Delimiter start='{' end='}' contains=@texRefGroup
Bram Moolenaar071d4272004-06-13 20:20:40 +0000442
443" Handle newcommand, newenvironment : {{{1
444syn match texNewCmd "\\newcommand\>" nextgroup=texCmdName skipwhite skipnl
445syn region texCmdName contained matchgroup=Delimiter start="{"rs=s+1 end="}" nextgroup=texCmdArgs,texCmdBody skipwhite skipnl
446syn region texCmdArgs contained matchgroup=Delimiter start="\["rs=s+1 end="]" nextgroup=texCmdBody skipwhite skipnl
447syn region texCmdBody contained matchgroup=Delimiter start="{"rs=s+1 skip="\\\\\|\\[{}]" matchgroup=Delimiter end="}" contains=@texCmdGroup
448syn match texNewEnv "\\newenvironment\>" nextgroup=texEnvName skipwhite skipnl
449syn region texEnvName contained matchgroup=Delimiter start="{"rs=s+1 end="}" nextgroup=texEnvBgn skipwhite skipnl
450syn region texEnvBgn contained matchgroup=Delimiter start="{"rs=s+1 end="}" nextgroup=texEnvEnd skipwhite skipnl contains=@texEnvGroup
451syn region texEnvEnd contained matchgroup=Delimiter start="{"rs=s+1 end="}" skipwhite skipnl contains=@texEnvGroup
452
453" Definitions/Commands: {{{1
454syn match texDefCmd "\\def\>" nextgroup=texDefName skipwhite skipnl
455if b:tex_stylish
456 syn match texDefName contained "\\[a-zA-Z@]\+" nextgroup=texDefParms,texCmdBody skipwhite skipnl
457 syn match texDefName contained "\\[^a-zA-Z@]" nextgroup=texDefParms,texCmdBody skipwhite skipnl
458else
459 syn match texDefName contained "\\\a\+" nextgroup=texDefParms,texCmdBody skipwhite skipnl
460 syn match texDefName contained "\\\A" nextgroup=texDefParms,texCmdBody skipwhite skipnl
461endif
462syn match texDefParms contained "#[^{]*" contains=texDefParm nextgroup=texCmdBody skipwhite skipnl
463syn match texDefParm contained "#\d\+"
464
465" TeX Lengths: {{{1
Bram Moolenaar9964e462007-05-05 17:54:07 +0000466syn match texLength "\<\d\+\([.,]\d\+\)\=\s*\(true\)\=\s*\(bp\|cc\|cm\|dd\|em\|ex\|in\|mm\|pc\|pt\|sp\)\>"
Bram Moolenaar071d4272004-06-13 20:20:40 +0000467
468" TeX String Delimiters: {{{1
469syn match texString "\(``\|''\|,,\)"
470
Bram Moolenaar5c736222010-01-06 20:54:52 +0100471" makeatletter -- makeatother sections
472if !exists("g:tex_no_error")
473 syn region texStyle matchgroup=texStatement start='\\makeatletter' end='\\makeatother' contains=@texStyleGroup contained
474 syn match texStyleStatement "\\[a-zA-Z@]\+" contained
475 syn region texStyleMatcher matchgroup=Delimiter start="{" skip="\\\\\|\\[{}]" end="}" contains=@texStyleGroup,texError contained
476 syn region texStyleMatcher matchgroup=Delimiter start="\[" end="]" contains=@texStyleGroup,texError contained
477endif
478
Bram Moolenaar611df5b2010-07-26 22:51:56 +0200479" Conceal mode support (supports set cole=1) {{{1
Bram Moolenaarb2c03502010-07-02 20:20:09 +0200480if has("conceal") && &enc == 'utf-8'
Bram Moolenaar611df5b2010-07-26 22:51:56 +0200481
482 " Math Symbols {{{2
483 syn match texMathSymbol '\\left(' contained conceal cchar=(
484 syn match texMathSymbol '\\right)' contained conceal cchar=)
485 syn match texMathSymbol '\\left{' contained conceal cchar={
486 syn match texMathSymbol '\\right}' contained conceal cchar=}
487 syn match texMathSymbol '\\cdot\>' contained conceal cchar=·
488 syn match texMathSymbol '\\leq\>' contained conceal cchar=≤
489 syn match texMathSymbol '\\geq\>' contained conceal cchar=≥
490 syn match texMathSymbol '\\cdot\>' contained conceal cchar=·
491 syn match texMathSymbol '\\times\>' contained conceal cchar=×
492 syn match texMathSymbol '\\div\>' contained conceal cchar=÷
493 syn match texMathSymbol '\\pm\>' contained conceal cchar=±
494 syn match texMathSymbol '\\neq\>' contained conceal cchar=≠
495 syn match texMathSymbol '\\cong\>' contained conceal cchar=≅
496
497 " Greek {{{2
498 fun! s:Greek(group,pat,cchar)
499 exe 'syn match '.a:group." '".a:pat."' contained conceal cchar=".a:cchar
500 endfun
501 call s:Greek('texGreek','\\alpha\>' ,'α')
502 call s:Greek('texGreek','\\beta\>' ,'β')
503 call s:Greek('texGreek','\\gamma\>' ,'γ')
504 call s:Greek('texGreek','\\delta\>' ,'δ')
505 call s:Greek('texGreek','\\epsilon\>' ,'ϵ')
506 call s:Greek('texGreek','\\varepsilon\>' ,'ε')
507 call s:Greek('texGreek','\\zeta\>' ,'ζ')
508 call s:Greek('texGreek','\\eta\>' ,'η')
509 call s:Greek('texGreek','\\theta\>' ,'θ')
510 call s:Greek('texGreek','\\vartheta\>' ,'ϑ')
511 call s:Greek('texGreek','\\kappa\>' ,'κ')
512 call s:Greek('texGreek','\\lambda\>' ,'λ')
513 call s:Greek('texGreek','\\mu\>' ,'μ')
514 call s:Greek('texGreek','\\nu\>' ,'ν')
515 call s:Greek('texGreek','\\xi\>' ,'ξ')
516 call s:Greek('texGreek','\\pi\>' ,'π')
517 call s:Greek('texGreek','\\varpi\>' ,'ϖ')
518 call s:Greek('texGreek','\\rho\>' ,'ρ')
519 call s:Greek('texGreek','\\varrho\>' ,'ϱ')
520 call s:Greek('texGreek','\\sigma\>' ,'σ')
521 call s:Greek('texGreek','\\varsigma\>' ,'ς')
522 call s:Greek('texGreek','\\tau\>' ,'τ')
523 call s:Greek('texGreek','\\upsilon\>' ,'υ')
524 call s:Greek('texGreek','\\phi\>' ,'φ')
525 call s:Greek('texGreek','\\varphi\>' ,'ϕ')
526 call s:Greek('texGreek','\\chi\>' ,'χ')
527 call s:Greek('texGreek','\\psi\>' ,'ψ')
528 call s:Greek('texGreek','\\omega\>' ,'ω')
529 call s:Greek('texGreek','\\Gamma\>' ,'Γ')
530 call s:Greek('texGreek','\\Delta\>' ,'Δ')
531 call s:Greek('texGreek','\\Theta\>' ,'Θ')
532 call s:Greek('texGreek','\\Lambda\>' ,'Λ')
533 call s:Greek('texGreek','\\Xi\>' ,'Χ')
534 call s:Greek('texGreek','\\Pi\>' ,'Π')
535 call s:Greek('texGreek','\\Sigma\>' ,'Σ')
536 call s:Greek('texGreek','\\Upsilon\>' ,'Υ')
537 call s:Greek('texGreek','\\Phi\>' ,'Φ')
538 call s:Greek('texGreek','\\Psi\>' ,'Ψ')
539 call s:Greek('texGreek','\\Omega\>' ,'Ω')
Bram Moolenaare0021c72010-07-28 17:25:21 +0200540 delfun s:Greek
Bram Moolenaar611df5b2010-07-26 22:51:56 +0200541
542 " Superscripts/Subscripts {{{2
Bram Moolenaare0021c72010-07-28 17:25:21 +0200543 syn region texSuperscript matchgroup=Delimiter start='\^{' end='}' contained concealends contains=texSuperscripts
544 syn region texSubscript matchgroup=Delimiter start='_{' end='}' contained concealends contains=texSubscripts
Bram Moolenaar611df5b2010-07-26 22:51:56 +0200545 fun! s:SuperSub(group,leader,pat,cchar)
546 exe 'syn match '.a:group." '".a:leader.a:pat."' contained conceal cchar=".a:cchar
547 exe 'syn match '.a:group."s '".a:pat."' contained conceal cchar=".a:cchar.' nextgroup='.a:group.'s'
548 endfun
549 call s:SuperSub('texSuperscript','\^','0','⁰')
550 call s:SuperSub('texSuperscript','\^','1','¹')
551 call s:SuperSub('texSuperscript','\^','2','²')
552 call s:SuperSub('texSuperscript','\^','3','³')
553 call s:SuperSub('texSuperscript','\^','4','⁴')
554 call s:SuperSub('texSuperscript','\^','5','⁵')
555 call s:SuperSub('texSuperscript','\^','6','⁶')
556 call s:SuperSub('texSuperscript','\^','7','⁷')
557 call s:SuperSub('texSuperscript','\^','8','⁸')
558 call s:SuperSub('texSuperscript','\^','9','⁹')
559 call s:SuperSub('texSuperscript','\^','a','ᵃ')
560 call s:SuperSub('texSuperscript','\^','b','ᵇ')
561 call s:SuperSub('texSuperscript','\^','c','ᶜ')
562 call s:SuperSub('texSuperscript','\^','d','ᵈ')
563 call s:SuperSub('texSuperscript','\^','e','ᵉ')
564 call s:SuperSub('texSuperscript','\^','f','ᶠ')
565 call s:SuperSub('texSuperscript','\^','g','ᵍ')
566 call s:SuperSub('texSuperscript','\^','h','ʰ')
567 call s:SuperSub('texSuperscript','\^','i','ⁱ')
568 call s:SuperSub('texSuperscript','\^','j','ʲ')
569 call s:SuperSub('texSuperscript','\^','k','ᵏ')
570 call s:SuperSub('texSuperscript','\^','l','ˡ')
571 call s:SuperSub('texSuperscript','\^','m','ᵐ')
572 call s:SuperSub('texSuperscript','\^','n','ⁿ')
573 call s:SuperSub('texSuperscript','\^','o','ᵒ')
574 call s:SuperSub('texSuperscript','\^','p','ᵖ')
575 call s:SuperSub('texSuperscript','\^','r','ʳ')
576 call s:SuperSub('texSuperscript','\^','s','ˢ')
577 call s:SuperSub('texSuperscript','\^','t','ᵗ')
578 call s:SuperSub('texSuperscript','\^','u','ᵘ')
579 call s:SuperSub('texSuperscript','\^','v','ᵛ')
580 call s:SuperSub('texSuperscript','\^','w','ʷ')
581 call s:SuperSub('texSuperscript','\^','x','ˣ')
582 call s:SuperSub('texSuperscript','\^','y','ʸ')
583 call s:SuperSub('texSuperscript','\^','z','ᶻ')
584 call s:SuperSub('texSuperscript','\^','A','ᴬ')
585 call s:SuperSub('texSuperscript','\^','B','ᴮ')
586 call s:SuperSub('texSuperscript','\^','D','ᴰ')
587 call s:SuperSub('texSuperscript','\^','E','ᴱ')
588 call s:SuperSub('texSuperscript','\^','G','ᴳ')
589 call s:SuperSub('texSuperscript','\^','H','ᴴ')
590 call s:SuperSub('texSuperscript','\^','I','ᴵ')
591 call s:SuperSub('texSuperscript','\^','J','ᴶ')
592 call s:SuperSub('texSuperscript','\^','K','ᴷ')
593 call s:SuperSub('texSuperscript','\^','L','ᴸ')
594 call s:SuperSub('texSuperscript','\^','M','ᴹ')
595 call s:SuperSub('texSuperscript','\^','N','ᴺ')
596 call s:SuperSub('texSuperscript','\^','O','ᴼ')
597 call s:SuperSub('texSuperscript','\^','P','ᴾ')
598 call s:SuperSub('texSuperscript','\^','R','ᴿ')
599 call s:SuperSub('texSuperscript','\^','T','ᵀ')
600 call s:SuperSub('texSuperscript','\^','U','ᵁ')
601 call s:SuperSub('texSuperscript','\^','W','ᵂ')
602 call s:SuperSub('texSuperscript','\^','+','⁺')
603 call s:SuperSub('texSuperscript','\^','-','⁻')
604 call s:SuperSub('texSuperscript','\^','<','˂')
605 call s:SuperSub('texSuperscript','\^','>','˃')
606 call s:SuperSub('texSuperscript','\^','/','ˊ')
607 call s:SuperSub('texSuperscript','\^','(','⁽')
608 call s:SuperSub('texSuperscript','\^',')','⁾')
609 call s:SuperSub('texSuperscript','\^','\.','˙')
610 call s:SuperSub('texSuperscript','\^','=','˭')
611 call s:SuperSub('texSubscript','_','0','₀')
612 call s:SuperSub('texSubscript','_','1','₁')
613 call s:SuperSub('texSubscript','_','2','₂')
614 call s:SuperSub('texSubscript','_','3','₃')
615 call s:SuperSub('texSubscript','_','4','₄')
616 call s:SuperSub('texSubscript','_','5','₅')
617 call s:SuperSub('texSubscript','_','6','₆')
618 call s:SuperSub('texSubscript','_','7','₇')
619 call s:SuperSub('texSubscript','_','8','₈')
620 call s:SuperSub('texSubscript','_','9','₉')
621 call s:SuperSub('texSubscript','_','a','ₐ')
622 call s:SuperSub('texSubscript','_','e','ₑ')
623 call s:SuperSub('texSubscript','_','i','ᵢ')
624 call s:SuperSub('texSubscript','_','o','ₒ')
625 call s:SuperSub('texSubscript','_','u','ᵤ')
626 call s:SuperSub('texSubscript','_','+','₊')
627 call s:SuperSub('texSubscript','_','-','₋')
628 call s:SuperSub('texSubscript','_','/','ˏ')
629 call s:SuperSub('texSubscript','_','(','₍')
630 call s:SuperSub('texSubscript','_',')','₎')
631 call s:SuperSub('texSubscript','_','\.','‸')
632 call s:SuperSub('texSubscript','_','r','ᵣ')
633 call s:SuperSub('texSubscript','_','v','ᵥ')
634 call s:SuperSub('texSubscript','_','x','ₓ')
635 call s:SuperSub('texSubscript','_','\\beta\>' ,'ᵦ')
636 call s:SuperSub('texSubscript','_','\\delta\>','ᵨ')
637 call s:SuperSub('texSubscript','_','\\phi\>' ,'ᵩ')
638 call s:SuperSub('texSubscript','_','\\gamma\>','ᵧ')
639 call s:SuperSub('texSubscript','_','\\chi\>' ,'ᵪ')
Bram Moolenaare0021c72010-07-28 17:25:21 +0200640 delfun s:SuperSub
Bram Moolenaar611df5b2010-07-26 22:51:56 +0200641
642 " Accented characters: {{{2
643 if b:tex_stylish
644 syn match texAccent "\\[bcdvuH][^a-zA-Z@]"me=e-1
645 syn match texLigature "\\\([ijolL]\|ae\|oe\|ss\|AA\|AE\|OE\)[^a-zA-Z@]"me=e-1
646 else
Bram Moolenaare0021c72010-07-28 17:25:21 +0200647 fun! s:Accents(chr,...)
648 let i= 1
649 for accent in ["`","\\'","^",'"','\~',"r","v"]
650 if i > a:0
651 break
652 endif
653 if strlen(a:{i}) == 0
654 let i= i + 1
655 continue
656 endif
657 exe "syn match texAccent '\\\\".accent."{".a:chr."}' conceal cchar=".a:{i}
658 let i= i + 1
659 endfor
660 endfun
661 call s:Accents('a','à','á','â','ä','ã','å','ă')
662 call s:Accents('A','À','Á','Â','Ä','Ã','Å','Ă')
663 call s:Accents('C',"" ,'Ć','Ĉ',"" ,"" ,"" ,'Ć')
664 call s:Accents('e','è','é','ê','ë','ẽ',"" ,'ĕ')
665 call s:Accents('E','È','É','Ê','Ë','Ẽ',"" ,'Ė')
666 call s:Accents('i','ì','í','î','ï','ĩ',"" ,"ĭ")
667 call s:Accents('I','Ì','Í','Î','Ï','Ĩ',"" ,'Ĭ')
668 call s:Accents('o','ò','ó','ô','ö','õ',"" ,'ŏ')
669 call s:Accents('O','Ò','Ó','Ô','Ö','Õ',"" ,'Ŏ')
670 call s:Accents('r',"" ,'ŕ',"" ,"" ,"" ,"" ,'ř')
671 call s:Accents('R',"" ,'Ŕ',"" ,"" ,"" ,"" ,'Ř')
672 call s:Accents('s',"" ,'ś','ŝ',"" ,"" ,"" ,'š')
673 call s:Accents('S',"" ,'Ś','Ŝ',"" ,"" ,"" ,'Š')
674 call s:Accents('u','ù','ú','û','ü','ũ',"" ,'ŭ')
675 call s:Accents('U','Ù','Ú','Û','Ü','Ũ',"" ,'Ŭ')
676 call s:Accents('y','ỳ','ý','ŷ','ÿ','ỹ',"" ,"" )
677 call s:Accents('Y','Ỳ','Ý','Ŷ','Ÿ','Ỹ',"" ,"" )
678 delfun s:Accents
679 syn match texAccent '\\aa\>' conceal cchar=å
680 syn match texAccent '\\AA\>' conceal cchar=Å
681 syn match texAccent '\\k{a}' conceal cchar=ą
682 syn match texAccent '\\k{A}' conceal cchar=Ą
683 syn match texAccent '\\c{C}' conceal cchar=Ç
Bram Moolenaar611df5b2010-07-26 22:51:56 +0200684 syn match texAccent '\\c{c}' conceal cchar=ç
Bram Moolenaare0021c72010-07-28 17:25:21 +0200685 syn match texAccent '\\\~{n}' conceal cchar=ñ
686 syn match texAccent '\\\~{N}' conceal cchar=Ñ
687 syn match texAccent '\\o\>' conceal cchar=ø
688 syn match texAccent '\\O\>' conceal cchar=Ø
689 syn match texAccent '\\H{o}' conceal cchar=ő
690 syn match texAccent '\\H{O}' conceal cchar=Ő
691 syn match texAccent '\\c{r}' conceal cchar=ŗ
692 syn match texLigature '\\AE\>' conceal cchar=Æ
693 syn match texLigature '\\ae\>' conceal cchar=æ
694 syn match texLigature '\\oe\>' conceal cchar=œ
695 syn match texLigature '\\OE\>' conceal cchar=Œ
696 syn match texLigature '\\ss\>' conceal cchar=ß
Bram Moolenaar611df5b2010-07-26 22:51:56 +0200697 endif
Bram Moolenaarb2c03502010-07-02 20:20:09 +0200698endif
699
700" ---------------------------------------------------------------------
Bram Moolenaar071d4272004-06-13 20:20:40 +0000701" LaTeX synchronization: {{{1
702syn sync maxlines=200
703syn sync minlines=50
704
705syn sync match texSyncStop groupthere NONE "%stopzone\>"
706
707" Synchronization: {{{1
708" The $..$ and $$..$$ make for impossible sync patterns
709" (one can't tell if a "$$" starts or stops a math zone by itself)
710" The following grouptheres coupled with minlines above
711" help improve the odds of good syncing.
712if !exists("tex_no_math")
713 syn sync match texSyncMathZoneA groupthere NONE "\\end{abstract}"
714 syn sync match texSyncMathZoneA groupthere NONE "\\end{center}"
715 syn sync match texSyncMathZoneA groupthere NONE "\\end{description}"
716 syn sync match texSyncMathZoneA groupthere NONE "\\end{enumerate}"
717 syn sync match texSyncMathZoneA groupthere NONE "\\end{itemize}"
718 syn sync match texSyncMathZoneA groupthere NONE "\\end{table}"
719 syn sync match texSyncMathZoneA groupthere NONE "\\end{tabular}"
720 syn sync match texSyncMathZoneA groupthere NONE "\\\(sub\)*section\>"
721endif
722
Bram Moolenaarb2c03502010-07-02 20:20:09 +0200723" ---------------------------------------------------------------------
Bram Moolenaar071d4272004-06-13 20:20:40 +0000724" Highlighting: {{{1
725if did_tex_syntax_inits == 1
726 let did_tex_syntax_inits= 2
727 " TeX highlighting groups which should share similar highlighting
728 if !exists("g:tex_no_error")
729 if !exists("tex_no_math")
730 HiLink texBadMath texError
731 HiLink texMathDelimBad texError
732 HiLink texMathError texError
733 if !b:tex_stylish
734 HiLink texOnlyMath texError
735 endif
736 endif
737 HiLink texError Error
738 endif
739
Bram Moolenaarcc016f52005-12-10 20:23:46 +0000740 HiLink texCite texRefZone
Bram Moolenaar071d4272004-06-13 20:20:40 +0000741 HiLink texDefCmd texDef
742 HiLink texDefName texDef
743 HiLink texDocType texCmdName
744 HiLink texDocTypeArgs texCmdArgs
745 HiLink texInputFileOpt texCmdArgs
746 HiLink texInputCurlies texDelimiter
747 HiLink texLigature texSpecialChar
748 if !exists("tex_no_math")
749 HiLink texMathDelimSet1 texMathDelim
750 HiLink texMathDelimSet2 texMathDelim
751 HiLink texMathDelimKey texMathDelim
752 HiLink texMathMatcher texMath
Bram Moolenaar5c736222010-01-06 20:54:52 +0100753 HiLink texMathZoneV texMath
Bram Moolenaar071d4272004-06-13 20:20:40 +0000754 HiLink texMathZoneW texMath
755 HiLink texMathZoneX texMath
756 HiLink texMathZoneY texMath
Bram Moolenaar3577c6f2008-06-24 21:16:56 +0000757 HiLink texMathZoneV texMath
Bram Moolenaar071d4272004-06-13 20:20:40 +0000758 HiLink texMathZoneZ texMath
759 endif
760 HiLink texSectionMarker texCmdName
761 HiLink texSectionName texSection
762 HiLink texSpaceCode texStatement
Bram Moolenaar5c736222010-01-06 20:54:52 +0100763 HiLink texStyleStatement texStatement
Bram Moolenaar071d4272004-06-13 20:20:40 +0000764 HiLink texTypeSize texType
765 HiLink texTypeStyle texType
766
767 " Basic TeX highlighting groups
768 HiLink texCmdArgs Number
769 HiLink texCmdName Statement
770 HiLink texComment Comment
771 HiLink texDef Statement
772 HiLink texDefParm Special
773 HiLink texDelimiter Delimiter
774 HiLink texInput Special
775 HiLink texInputFile Special
776 HiLink texLength Number
777 HiLink texMath Special
778 HiLink texMathDelim Statement
779 HiLink texMathOper Operator
780 HiLink texNewCmd Statement
781 HiLink texNewEnv Statement
782 HiLink texOption Number
783 HiLink texRefZone Special
784 HiLink texSection PreCondit
785 HiLink texSpaceCodeChar Special
786 HiLink texSpecialChar SpecialChar
787 HiLink texStatement Statement
788 HiLink texString String
789 HiLink texTodo Todo
790 HiLink texType Type
791 HiLink texZone PreCondit
792
793 delcommand HiLink
794endif
795
796" Current Syntax: {{{1
797unlet b:extfname
798let b:current_syntax = "tex"
799" vim: ts=8 fdm=marker