blob: e1753d820502edabe58d29952c960d68f81cef1d [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
Bram Moolenaar4b22cdb2010-08-02 22:12:46 +02005" Version: 52
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
Bram Moolenaar4b22cdb2010-08-02 22:12:46 +020040scriptencoding utf-8
Bram Moolenaar071d4272004-06-13 20:20:40 +000041
42" Define the default highlighting. {{{1
43" For version 5.7 and earlier: only when not done already
44" For version 5.8 and later: only when an item doesn't have highlighting yet
45if version >= 508 || !exists("did_tex_syntax_inits")
46 let did_tex_syntax_inits = 1
47 if version < 508
48 command -nargs=+ HiLink hi link <args>
49 else
50 command -nargs=+ HiLink hi def link <args>
51 endif
52endif
53if exists("g:tex_tex") && !exists("g:tex_no_error")
54 let g:tex_no_error= 1
55endif
56
Bram Moolenaar4b22cdb2010-08-02 22:12:46 +020057" let user determine which classes of concealment will be supported
58" a=accents/ligatures m=math symbols g=Greek s=superscripts/subscripts
59if !exists("g:tex_conceal")
60 let s:tex_conceal= 'amgs'
61else
62 let s:tex_conceal= g:tex_conceal
63endif
64
Bram Moolenaarf1f8bc52005-03-07 23:20:08 +000065" Determine whether or not to use "*.sty" mode {{{1
Bram Moolenaar071d4272004-06-13 20:20:40 +000066" The user may override the normal determination by setting
67" g:tex_stylish to 1 (for "*.sty" mode)
68" or to 0 else (normal "*.tex" mode)
69" or on a buffer-by-buffer basis with b:tex_stylish
70let b:extfname=expand("%:e")
71if exists("g:tex_stylish")
72 let b:tex_stylish= g:tex_stylish
73elseif !exists("b:tex_stylish")
74 if b:extfname == "sty" || b:extfname == "cls" || b:extfname == "clo" || b:extfname == "dtx" || b:extfname == "ltx"
75 let b:tex_stylish= 1
76 else
77 let b:tex_stylish= 0
78 endif
79endif
80
Bram Moolenaarf1f8bc52005-03-07 23:20:08 +000081" handle folding {{{1
82if !exists("g:tex_fold_enabled")
83 let g:tex_fold_enabled= 0
84elseif g:tex_fold_enabled && !has("folding")
Bram Moolenaarab194812005-09-14 21:40:12 +000085 let g:tex_fold_enabled= 0
Bram Moolenaarf1f8bc52005-03-07 23:20:08 +000086 echomsg "Ignoring g:tex_fold_enabled=".g:tex_fold_enabled."; need to re-compile vim for +fold support"
87endif
88if g:tex_fold_enabled && &fdm == "manual"
Bram Moolenaar00a927d2010-05-14 23:24:24 +020089 setl fdm=syntax
Bram Moolenaarf1f8bc52005-03-07 23:20:08 +000090endif
91
Bram Moolenaar071d4272004-06-13 20:20:40 +000092" (La)TeX keywords: only use the letters a-zA-Z {{{1
93" but _ is the only one that causes problems.
94if version < 600
95 set isk-=_
96 if b:tex_stylish
97 set isk+=@
98 endif
99else
100 setlocal isk-=_
101 if b:tex_stylish
102 setlocal isk+=@
103 endif
104endif
105
106" Clusters: {{{1
107" --------
108syn cluster texCmdGroup contains=texCmdBody,texComment,texDefParm,texDelimiter,texDocType,texInput,texLength,texLigature,texMathDelim,texMathOper,texNewCmd,texNewEnv,texRefZone,texSection,texSectionMarker,texSectionName,texSpecialChar,texStatement,texString,texTypeSize,texTypeStyle
109if !exists("g:tex_no_error")
110 syn cluster texCmdGroup add=texMathError
111endif
112syn cluster texEnvGroup contains=texMatcher,texMathDelim,texSpecialChar,texStatement
Bram Moolenaar488c6512005-08-11 20:09:58 +0000113syn 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 +0000114syn 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 +0100115syn 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 +0000116syn cluster texRefGroup contains=texMatcher,texComment,texDelimiter
Bram Moolenaar071d4272004-06-13 20:20:40 +0000117if !exists("tex_no_math")
118 syn cluster texMathZones contains=texMathZoneV,texMathZoneW,texMathZoneX,texMathZoneY,texMathZoneZ
119 syn cluster texMatchGroup add=@texMathZones
120 syn cluster texMathDelimGroup contains=texMathDelimBad,texMathDelimKey,texMathDelimSet1,texMathDelimSet2
121 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 +0200122 syn cluster texMathZoneGroup contains=texComment,texDelimiter,texLength,texMathDelim,texMathMatcher,texMathOper,texMathSymbol,texRefZone,texSpecialChar,texStatement,texTypeSize,texTypeStyle
Bram Moolenaar071d4272004-06-13 20:20:40 +0000123 if !exists("g:tex_no_error")
124 syn cluster texMathMatchGroup add=texMathError
125 syn cluster texMathZoneGroup add=texMathError
126 endif
Bram Moolenaar5b8d8fd2005-08-16 23:01:50 +0000127 syn cluster texMathZoneGroup add=@NoSpell
128 " following used in the \part \chapter \section \subsection \subsubsection
129 " \paragraph \subparagraph \author \title highlighting
130 syn cluster texDocGroup contains=texPartZone,@texPartGroup
131 syn cluster texPartGroup contains=texChapterZone,texSectionZone,texParaZone
132 syn cluster texChapterGroup contains=texSectionZone,texParaZone
133 syn cluster texSectionGroup contains=texSubSectionZone,texParaZone
134 syn cluster texSubSectionGroup contains=texSubSubSectionZone,texParaZone
135 syn cluster texSubSubSectionGroup contains=texParaZone
136 syn cluster texParaGroup contains=texSubParaZone
Bram Moolenaarb2c03502010-07-02 20:20:09 +0200137 if has("conceal") && &enc == 'utf-8'
Bram Moolenaare0021c72010-07-28 17:25:21 +0200138 syn cluster texMathZoneGroup add=texGreek,texSuperscript,texSubscript,texMathSymbol
139 syn cluster texMathMatchGroup add=texGreek,texSuperscript,texSubscript,texMathSymbol
Bram Moolenaarb2c03502010-07-02 20:20:09 +0200140 endif
Bram Moolenaar071d4272004-06-13 20:20:40 +0000141endif
142
143" Try to flag {} and () mismatches: {{{1
144if !exists("g:tex_no_error")
145 syn region texMatcher matchgroup=Delimiter start="{" skip="\\\\\|\\[{}]" end="}" contains=@texMatchGroup,texError
146 syn region texMatcher matchgroup=Delimiter start="\[" end="]" contains=@texMatchGroup,texError
147else
148 syn region texMatcher matchgroup=Delimiter start="{" skip="\\\\\|\\[{}]" end="}" contains=@texMatchGroup
149 syn region texMatcher matchgroup=Delimiter start="\[" end="]" contains=@texMatchGroup
150endif
Bram Moolenaar293ee4d2004-12-09 21:34:53 +0000151syn region texParen start="(" end=")" contains=@texMatchGroup,@Spell
Bram Moolenaar071d4272004-06-13 20:20:40 +0000152if !exists("g:tex_no_error")
153 syn match texError "[}\])]"
154endif
155if !exists("tex_no_math")
156 if !exists("g:tex_no_error")
157 syn match texMathError "}" contained
158 endif
159 syn region texMathMatcher matchgroup=Delimiter start="{" skip="\\\\\|\\}" end="}" end="%stopzone\>" contained contains=@texMathMatchGroup
160endif
161
162" TeX/LaTeX keywords: {{{1
163" Instead of trying to be All Knowing, I just match \..alphameric..
164" Note that *.tex files may not have "@" in their \commands
165if exists("g:tex_tex") || b:tex_stylish
166 syn match texStatement "\\[a-zA-Z@]\+"
167else
168 syn match texStatement "\\\a\+"
169 if !exists("g:tex_no_error")
170 syn match texError "\\\a*@[a-zA-Z@]*"
171 endif
172endif
173
174" TeX/LaTeX delimiters: {{{1
175syn match texDelimiter "&"
176syn match texDelimiter "\\\\"
177
178" Tex/Latex Options: {{{1
179syn match texOption "[^\\]\zs#\d\+\|^#\d\+"
180
181" texAccent (tnx to Karim Belabas) avoids annoying highlighting for accents: {{{1
182if b:tex_stylish
183 syn match texAccent "\\[bcdvuH][^a-zA-Z@]"me=e-1
184 syn match texLigature "\\\([ijolL]\|ae\|oe\|ss\|AA\|AE\|OE\)[^a-zA-Z@]"me=e-1
185else
186 syn match texAccent "\\[bcdvuH]\A"me=e-1
187 syn match texLigature "\\\([ijolL]\|ae\|oe\|ss\|AA\|AE\|OE\)\A"me=e-1
188endif
189syn match texAccent "\\[bcdvuH]$"
190syn match texAccent +\\[=^.\~"`']+
191syn match texAccent +\\['=t'.c^ud"vb~Hr]{\a}+
192syn match texLigature "\\\([ijolL]\|ae\|oe\|ss\|AA\|AE\|OE\)$"
193
194" \begin{}/\end{} section markers: {{{1
195syn match texSectionMarker "\\begin\>\|\\end\>" nextgroup=texSectionName
Bram Moolenaar5c736222010-01-06 20:54:52 +0100196syn region texSectionName matchgroup=Delimiter start="{" end="}" contained nextgroup=texSectionModifier contains=texComment
197syn region texSectionModifier matchgroup=Delimiter start="\[" end="]" contained contains=texComment
Bram Moolenaar071d4272004-06-13 20:20:40 +0000198
199" \documentclass, \documentstyle, \usepackage: {{{1
200syn match texDocType "\\documentclass\>\|\\documentstyle\>\|\\usepackage\>" nextgroup=texSectionName,texDocTypeArgs
Bram Moolenaar5c736222010-01-06 20:54:52 +0100201syn region texDocTypeArgs matchgroup=Delimiter start="\[" end="]" contained nextgroup=texSectionName contains=texComment
Bram Moolenaar071d4272004-06-13 20:20:40 +0000202
Bram Moolenaara9a568c2006-03-14 23:04:27 +0000203" Preamble syntax-based folding support: {{{1
204if g:tex_fold_enabled && has("folding")
Bram Moolenaar5c736222010-01-06 20:54:52 +0100205 syn region texPreamble transparent fold start='\zs\\documentclass\>' end='\ze\\begin{document}' contains=texStyle,@texMatchGroup
Bram Moolenaara9a568c2006-03-14 23:04:27 +0000206endif
207
Bram Moolenaar071d4272004-06-13 20:20:40 +0000208" TeX input: {{{1
209syn match texInput "\\input\s\+[a-zA-Z/.0-9_^]\+"hs=s+7 contains=texStatement
Bram Moolenaar5c736222010-01-06 20:54:52 +0100210syn match texInputFile "\\include\(graphics\|list\)\=\(\[.\{-}\]\)\=\s*{.\{-}}" contains=texStatement,texInputCurlies,texInputFileOpt
Bram Moolenaar071d4272004-06-13 20:20:40 +0000211syn match texInputFile "\\\(epsfig\|input\|usepackage\)\s*\(\[.*\]\)\={.\{-}}" contains=texStatement,texInputCurlies,texInputFileOpt
212syn match texInputCurlies "[{}]" contained
Bram Moolenaar5c736222010-01-06 20:54:52 +0100213syn region texInputFileOpt matchgroup=Delimiter start="\[" end="\]" contained contains=texComment
Bram Moolenaar071d4272004-06-13 20:20:40 +0000214
215" Type Styles (LaTeX 2.09): {{{1
216syn match texTypeStyle "\\rm\>"
217syn match texTypeStyle "\\em\>"
218syn match texTypeStyle "\\bf\>"
219syn match texTypeStyle "\\it\>"
220syn match texTypeStyle "\\sl\>"
221syn match texTypeStyle "\\sf\>"
222syn match texTypeStyle "\\sc\>"
223syn match texTypeStyle "\\tt\>"
224
225" Type Styles: attributes, commands, families, etc (LaTeX2E): {{{1
226syn match texTypeStyle "\\textbf\>"
227syn match texTypeStyle "\\textit\>"
228syn match texTypeStyle "\\textmd\>"
229syn match texTypeStyle "\\textrm\>"
230syn match texTypeStyle "\\textsc\>"
231syn match texTypeStyle "\\textsf\>"
232syn match texTypeStyle "\\textsl\>"
233syn match texTypeStyle "\\texttt\>"
234syn match texTypeStyle "\\textup\>"
235syn match texTypeStyle "\\emph\>"
236
237syn match texTypeStyle "\\mathbb\>"
238syn match texTypeStyle "\\mathbf\>"
239syn match texTypeStyle "\\mathcal\>"
240syn match texTypeStyle "\\mathfrak\>"
241syn match texTypeStyle "\\mathit\>"
242syn match texTypeStyle "\\mathnormal\>"
243syn match texTypeStyle "\\mathrm\>"
244syn match texTypeStyle "\\mathsf\>"
245syn match texTypeStyle "\\mathtt\>"
246
247syn match texTypeStyle "\\rmfamily\>"
248syn match texTypeStyle "\\sffamily\>"
249syn match texTypeStyle "\\ttfamily\>"
250
251syn match texTypeStyle "\\itshape\>"
252syn match texTypeStyle "\\scshape\>"
253syn match texTypeStyle "\\slshape\>"
254syn match texTypeStyle "\\upshape\>"
255
256syn match texTypeStyle "\\bfseries\>"
257syn match texTypeStyle "\\mdseries\>"
258
259" Some type sizes: {{{1
260syn match texTypeSize "\\tiny\>"
261syn match texTypeSize "\\scriptsize\>"
262syn match texTypeSize "\\footnotesize\>"
263syn match texTypeSize "\\small\>"
264syn match texTypeSize "\\normalsize\>"
265syn match texTypeSize "\\large\>"
266syn match texTypeSize "\\Large\>"
267syn match texTypeSize "\\LARGE\>"
268syn match texTypeSize "\\huge\>"
269syn match texTypeSize "\\Huge\>"
270
271" Spacecodes (TeX'isms): {{{1
272" \mathcode`\^^@="2201 \delcode`\(="028300 \sfcode`\)=0 \uccode`X=`X \lccode`x=`x
273syn match texSpaceCode "\\\(math\|cat\|del\|lc\|sf\|uc\)code`"me=e-1 nextgroup=texSpaceCodeChar
274syn match texSpaceCodeChar "`\\\=.\(\^.\)\==\(\d\|\"\x\{1,6}\|`.\)" contained
275
276" Sections, subsections, etc: {{{1
Bram Moolenaarf1f8bc52005-03-07 23:20:08 +0000277if g:tex_fold_enabled && has("folding")
Bram Moolenaar3577c6f2008-06-24 21:16:56 +0000278 syn region texDocZone matchgroup=texSection start='\\begin\s*{\s*document\s*}' end='\\end\s*{\s*document\s*}' fold contains=@texFoldGroup,@texDocGroup,@Spell
279 syn region texPartZone matchgroup=texSection start='\\part\>' end='\ze\s*\\\%(part\>\|end\s*{\s*document\s*}\)' fold contains=@texFoldGroup,@texPartGroup,@Spell
280 syn region texChapterZone matchgroup=texSection start='\\chapter\>' end='\ze\s*\\\%(chapter\>\|part\>\|end\s*{\s*document\s*}\)' fold contains=@texFoldGroup,@texChapterGroup,@Spell
281 syn region texSectionZone matchgroup=texSection start='\\section\>' end='\ze\s*\\\%(section\>\|chapter\>\|part\>\|end\s*{\s*document\s*}\)' fold contains=@texFoldGroup,@texSectionGroup,@Spell
282 syn region texSubSectionZone matchgroup=texSection start='\\subsection\>' end='\ze\s*\\\%(\%(sub\)\=section\>\|chapter\>\|part\>\|end\s*{\s*document\s*}\)' fold contains=@texFoldGroup,@texSubSectionGroup,@Spell
283 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
284 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
285 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
286 syn region texTitle matchgroup=texSection start='\\\%(author\|title\)\>\s*{' end='}' fold contains=@texFoldGroup,@Spell
287 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 +0000288else
Bram Moolenaar3577c6f2008-06-24 21:16:56 +0000289 syn region texDocZone matchgroup=texSection start='\\begin\s*{\s*document\s*}' end='\\end\s*{\s*document\s*}' contains=@texFoldGroup,@texDocGroup,@Spell
290 syn region texPartZone matchgroup=texSection start='\\part\>' end='\ze\s*\\\%(part\>\|end\s*{\s*document\s*}\)' contains=@texFoldGroup,@texPartGroup,@Spell
291 syn region texChapterZone matchgroup=texSection start='\\chapter\>' end='\ze\s*\\\%(chapter\>\|part\>\|end\s*{\s*document\s*}\)' contains=@texFoldGroup,@texChapterGroup,@Spell
292 syn region texSectionZone matchgroup=texSection start='\\section\>' end='\ze\s*\\\%(section\>\|chapter\>\|part\>\|end\s*{\s*document\s*}\)' contains=@texFoldGroup,@texSectionGroup,@Spell
293 syn region texSubSectionZone matchgroup=texSection start='\\subsection\>' end='\ze\s*\\\%(\%(sub\)\=section\>\|chapter\>\|part\>\|end\s*{\s*document\s*}\)' contains=@texFoldGroup,@texSubSectionGroup,@Spell
294 syn region texSubSubSectionZone matchgroup=texSection start='\\subsubsection\>' end='\ze\s*\\\%(\%(sub\)\{,2}section\>\|chapter\>\|part\>\|end\s*{\s*document\s*}\)' contains=@texFoldGroup,@texSubSubSectionGroup,@Spell
295 syn region texParaZone matchgroup=texSection start='\\paragraph\>' end='\ze\s*\\\%(paragraph\>\|\%(sub\)*section\>\|chapter\>\|part\>\|end\s*{\s*document\s*}\)' contains=@texFoldGroup,@texParaGroup,@Spell
296 syn region texSubParaZone matchgroup=texSection start='\\subparagraph\>' end='\ze\s*\\\%(\%(sub\)\=paragraph\>\|\%(sub\)*section\>\|chapter\>\|part\>\|end\s*{\s*document\s*}\)' contains=@texFoldGroup,@Spell
297 syn region texTitle matchgroup=texSection start='\\\%(author\|title\)\>\s*{' end='}' contains=@texFoldGroup,@Spell
298 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 +0000299endif
Bram Moolenaar071d4272004-06-13 20:20:40 +0000300
301" Bad Math (mismatched): {{{1
302if !exists("tex_no_math")
303 syn match texBadMath "\\end\s*{\s*\(array\|gathered\|bBpvV]matrix\|split\|subequations\|smallmatrix\|xxalignat\)\s*}"
304 syn match texBadMath "\\end\s*{\s*\(align\|alignat\|displaymath\|displaymath\|eqnarray\|equation\|flalign\|gather\|math\|multline\|xalignat\)\*\=\s*}"
305 syn match texBadMath "\\[\])]"
306endif
307
308" Math Zones: {{{1
309if !exists("tex_no_math")
Bram Moolenaar488c6512005-08-11 20:09:58 +0000310 " TexNewMathZone: function creates a mathzone with the given suffix and mathzone name. {{{2
Bram Moolenaar071d4272004-06-13 20:20:40 +0000311 " Starred forms are created if starform is true. Starred
312 " forms have syntax group and synchronization groups with a
313 " "S" appended. Handles: cluster, syntax, sync, and HiLink.
314 fun! TexNewMathZone(sfx,mathzone,starform)
315 let grpname = "texMathZone".a:sfx
316 let syncname = "texSyncMathZone".a:sfx
Bram Moolenaar3577c6f2008-06-24 21:16:56 +0000317 if g:tex_fold_enabled
318 let foldcmd= " fold"
319 else
320 let foldcmd= ""
321 endif
Bram Moolenaar071d4272004-06-13 20:20:40 +0000322 exe "syn cluster texMathZones add=".grpname
Bram Moolenaar3577c6f2008-06-24 21:16:56 +0000323 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 +0000324 exe 'syn sync match '.syncname.' grouphere '.grpname.' "\\begin\s*{\s*'.a:mathzone.'\*\s*}"'
325 exe 'syn sync match '.syncname.' grouphere '.grpname.' "\\begin\s*{\s*'.a:mathzone.'\*\s*}"'
Bram Moolenaar5c736222010-01-06 20:54:52 +0100326 exe 'hi def link '.grpname.' texMath'
Bram Moolenaar071d4272004-06-13 20:20:40 +0000327 if a:starform
328 let grpname = "texMathZone".a:sfx.'S'
329 let syncname = "texSyncMathZone".a:sfx.'S'
330 exe "syn cluster texMathZones add=".grpname
Bram Moolenaar3577c6f2008-06-24 21:16:56 +0000331 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 +0000332 exe 'syn sync match '.syncname.' grouphere '.grpname.' "\\begin\s*{\s*'.a:mathzone.'\*\s*}"'
333 exe 'syn sync match '.syncname.' grouphere '.grpname.' "\\begin\s*{\s*'.a:mathzone.'\*\s*}"'
Bram Moolenaar5c736222010-01-06 20:54:52 +0100334 exe 'hi def link '.grpname.' texMath'
Bram Moolenaar071d4272004-06-13 20:20:40 +0000335 endif
336 endfun
337
338 " Standard Math Zones: {{{2
339 call TexNewMathZone("A","align",1)
340 call TexNewMathZone("B","alignat",1)
341 call TexNewMathZone("C","displaymath",1)
342 call TexNewMathZone("D","eqnarray",1)
343 call TexNewMathZone("E","equation",1)
344 call TexNewMathZone("F","flalign",1)
345 call TexNewMathZone("G","gather",1)
346 call TexNewMathZone("H","math",1)
347 call TexNewMathZone("I","multline",1)
348 call TexNewMathZone("J","subequations",0)
349 call TexNewMathZone("K","xalignat",1)
350 call TexNewMathZone("L","xxalignat",0)
351
352 " Inline Math Zones: {{{2
Bram Moolenaare0021c72010-07-28 17:25:21 +0200353 if has("conceal") && &enc == 'utf-8'
354 syn region texMathZoneV matchgroup=Delimiter start="\\(" matchgroup=Delimiter end="\\)\|%stopzone\>" keepend concealends contains=@texMathZoneGroup
355 syn region texMathZoneW matchgroup=Delimiter start="\\\[" matchgroup=Delimiter end="\\]\|%stopzone\>" keepend concealends contains=@texMathZoneGroup
356 syn region texMathZoneX matchgroup=Delimiter start="\$" skip="\\\\\|\\\$" matchgroup=Delimiter end="\$" end="%stopzone\>" concealends contains=@texMathZoneGroup
357 syn region texMathZoneY matchgroup=Delimiter start="\$\$" matchgroup=Delimiter end="\$\$" end="%stopzone\>" concealends keepend contains=@texMathZoneGroup
358 else
359 syn region texMathZoneV matchgroup=Delimiter start="\\(" matchgroup=Delimiter end="\\)\|%stopzone\>" keepend contains=@texMathZoneGroup
360 syn region texMathZoneW matchgroup=Delimiter start="\\\[" matchgroup=Delimiter end="\\]\|%stopzone\>" keepend contains=@texMathZoneGroup
361 syn region texMathZoneX matchgroup=Delimiter start="\$" skip="\\\\\|\\\$" matchgroup=Delimiter end="\$" end="%stopzone\>" contains=@texMathZoneGroup
362 syn region texMathZoneY matchgroup=Delimiter start="\$\$" matchgroup=Delimiter end="\$\$" end="%stopzone\>" keepend contains=@texMathZoneGroup
363 endif
Bram Moolenaarb2c03502010-07-02 20:20:09 +0200364 syn region texMathZoneZ matchgroup=texStatement start="\\ensuremath\s*{" matchgroup=texStatement end="}" end="%stopzone\>" contains=@texMathZoneGroup
Bram Moolenaar071d4272004-06-13 20:20:40 +0000365
366 syn match texMathOper "[_^=]" contained
367
368 " \left..something.. and \right..something.. support: {{{2
369 syn match texMathDelimBad contained "\S"
Bram Moolenaar4b22cdb2010-08-02 22:12:46 +0200370 if has("conceal") && &enc == 'utf-8' && s:tex_conceal =~ 'm'
371 syn match texMathDelim contained "\\left\\{\>" skipwhite nextgroup=texMathDelimSet1,texMathDelimSet2,texMathDelimBad contains=texMathSymbol cchar={
372 syn match texMathDelim contained "\\right\\}\>" skipwhite nextgroup=texMathDelimSet1,texMathDelimSet2,texMathDelimBad contains=texMathSymbol cchar=}
373 else
374 syn match texMathDelim contained "\\\(left\|right\)\>" skipwhite nextgroup=texMathDelimSet1,texMathDelimSet2,texMathDelimBad
375 endif
376 syn match texMathDelim contained "\\\([bB]igg\=[lr]\)\>" skipwhite nextgroup=texMathDelimSet1,texMathDelimSet2,texMathDelimBad
Bram Moolenaar071d4272004-06-13 20:20:40 +0000377 syn match texMathDelim contained "\\\(left\|right\)arrow\>\|\<\([aA]rrow\|brace\)\=vert\>"
378 syn match texMathDelim contained "\\lefteqn\>"
379 syn match texMathDelimSet2 contained "\\" nextgroup=texMathDelimKey,texMathDelimBad
380 syn match texMathDelimSet1 contained "[<>()[\]|/.]\|\\[{}|]"
381 syn keyword texMathDelimKey contained backslash lceil lVert rgroup uparrow
382 syn keyword texMathDelimKey contained downarrow lfloor rangle rmoustache Uparrow
383 syn keyword texMathDelimKey contained Downarrow lgroup rbrace rvert updownarrow
384 syn keyword texMathDelimKey contained langle lmoustache rceil rVert Updownarrow
385 syn keyword texMathDelimKey contained lbrace lvert rfloor
386endif
387
388" Special TeX characters ( \$ \& \% \# \{ \} \_ \S \P ) : {{{1
389syn match texSpecialChar "\\[$&%#{}_]"
390if b:tex_stylish
391 syn match texSpecialChar "\\[SP@][^a-zA-Z@]"me=e-1
392else
393 syn match texSpecialChar "\\[SP@]\A"me=e-1
394endif
395syn match texSpecialChar "\\\\"
396if !exists("tex_no_math")
397 syn match texOnlyMath "[_^]"
398endif
399syn match texSpecialChar "\^\^[0-9a-f]\{2}\|\^\^\S"
400
401" Comments: {{{1
402" Normal TeX LaTeX : %....
403" Documented TeX Format: ^^A... -and- leading %s (only)
Bram Moolenaar3577c6f2008-06-24 21:16:56 +0000404if !exists("g:tex_comment_nospell") || !g:tex_comment_nospell
405 syn cluster texCommentGroup contains=texTodo,@Spell
406else
407 syn cluster texCommentGroup contains=texTodo,@NoSpell
408endif
Bram Moolenaar071d4272004-06-13 20:20:40 +0000409syn case ignore
Bram Moolenaar18144c82006-04-12 21:52:12 +0000410syn keyword texTodo contained combak fixme todo xxx
Bram Moolenaar071d4272004-06-13 20:20:40 +0000411syn case match
412if b:extfname == "dtx"
413 syn match texComment "\^\^A.*$" contains=@texCommentGroup
414 syn match texComment "^%\+" contains=@texCommentGroup
415else
Bram Moolenaarfd2ac762006-03-01 22:09:21 +0000416 if g:tex_fold_enabled
417 " allows syntax-folding of 2 or more contiguous comment lines
418 " single-line comments are not folded
419 syn match texComment "%.*$" contains=@texCommentGroup
420 syn region texComment start="^\zs\s*%.*\_s*%" skip="^\s*%" end='^\ze\s*[^%]' fold
421 else
422 syn match texComment "%.*$" contains=@texCommentGroup
423 endif
Bram Moolenaar071d4272004-06-13 20:20:40 +0000424endif
425
426" Separate lines used for verb` and verb# so that the end conditions {{{1
427" will appropriately terminate. Ideally vim would let me save a
428" character from the start pattern and re-use it in the end-pattern.
Bram Moolenaar5c736222010-01-06 20:54:52 +0100429syn region texZone start="\\begin{[vV]erbatim}" end="\\end{[vV]erbatim}\|%stopzone\>" contains=@Spell
Bram Moolenaarc1e37902006-04-18 21:55:01 +0000430" listings package:
431syn region texZone start="\\begin{lstlisting}" end="\\end{lstlisting}\|%stopzone\>" contains=@Spell
432" moreverb package:
433syn region texZone start="\\begin{verbatimtab}" end="\\end{verbatimtab}\|%stopzone\>" contains=@Spell
434syn region texZone start="\\begin{verbatimwrite}" end="\\end{verbatimwrite}\|%stopzone\>" contains=@Spell
435syn region texZone start="\\begin{boxedverbatim}" end="\\end{boxedverbatim}\|%stopzone\>" contains=@Spell
Bram Moolenaar071d4272004-06-13 20:20:40 +0000436if version < 600
437 syn region texZone start="\\verb\*\=`" end="`\|%stopzone\>"
438 syn region texZone start="\\verb\*\=#" end="#\|%stopzone\>"
439else
440 if b:tex_stylish
441 syn region texZone start="\\verb\*\=\z([^\ta-zA-Z@]\)" end="\z1\|%stopzone\>"
442 else
443 syn region texZone start="\\verb\*\=\z([^\ta-zA-Z]\)" end="\z1\|%stopzone\>"
444 endif
445endif
446
447" Tex Reference Zones: {{{1
Bram Moolenaarcfbc5ee2004-07-02 15:38:35 +0000448syn region texZone matchgroup=texStatement start="@samp{" end="}\|%stopzone\>" contains=@texRefGroup
449syn region texRefZone matchgroup=texStatement start="\\nocite{" end="}\|%stopzone\>" contains=@texRefGroup
450syn region texRefZone matchgroup=texStatement start="\\bibliography{" end="}\|%stopzone\>" contains=@texRefGroup
Bram Moolenaarcfbc5ee2004-07-02 15:38:35 +0000451syn region texRefZone matchgroup=texStatement start="\\label{" end="}\|%stopzone\>" contains=@texRefGroup
452syn region texRefZone matchgroup=texStatement start="\\\(page\|eq\)ref{" end="}\|%stopzone\>" contains=@texRefGroup
453syn region texRefZone matchgroup=texStatement start="\\v\=ref{" end="}\|%stopzone\>" contains=@texRefGroup
Bram Moolenaarcc016f52005-12-10 20:23:46 +0000454syn match texRefZone '\\cite\%([tp]\*\=\)\=' nextgroup=texRefOption,texCite
455syn region texRefOption contained matchgroup=Delimiter start='\[' end=']' contains=@texRefGroup nextgroup=texRefOption,texCite
456syn region texCite contained matchgroup=Delimiter start='{' end='}' contains=@texRefGroup
Bram Moolenaar071d4272004-06-13 20:20:40 +0000457
458" Handle newcommand, newenvironment : {{{1
459syn match texNewCmd "\\newcommand\>" nextgroup=texCmdName skipwhite skipnl
460syn region texCmdName contained matchgroup=Delimiter start="{"rs=s+1 end="}" nextgroup=texCmdArgs,texCmdBody skipwhite skipnl
461syn region texCmdArgs contained matchgroup=Delimiter start="\["rs=s+1 end="]" nextgroup=texCmdBody skipwhite skipnl
462syn region texCmdBody contained matchgroup=Delimiter start="{"rs=s+1 skip="\\\\\|\\[{}]" matchgroup=Delimiter end="}" contains=@texCmdGroup
463syn match texNewEnv "\\newenvironment\>" nextgroup=texEnvName skipwhite skipnl
464syn region texEnvName contained matchgroup=Delimiter start="{"rs=s+1 end="}" nextgroup=texEnvBgn skipwhite skipnl
465syn region texEnvBgn contained matchgroup=Delimiter start="{"rs=s+1 end="}" nextgroup=texEnvEnd skipwhite skipnl contains=@texEnvGroup
466syn region texEnvEnd contained matchgroup=Delimiter start="{"rs=s+1 end="}" skipwhite skipnl contains=@texEnvGroup
467
468" Definitions/Commands: {{{1
469syn match texDefCmd "\\def\>" nextgroup=texDefName skipwhite skipnl
470if b:tex_stylish
471 syn match texDefName contained "\\[a-zA-Z@]\+" nextgroup=texDefParms,texCmdBody skipwhite skipnl
472 syn match texDefName contained "\\[^a-zA-Z@]" nextgroup=texDefParms,texCmdBody skipwhite skipnl
473else
474 syn match texDefName contained "\\\a\+" nextgroup=texDefParms,texCmdBody skipwhite skipnl
475 syn match texDefName contained "\\\A" nextgroup=texDefParms,texCmdBody skipwhite skipnl
476endif
477syn match texDefParms contained "#[^{]*" contains=texDefParm nextgroup=texCmdBody skipwhite skipnl
478syn match texDefParm contained "#\d\+"
479
480" TeX Lengths: {{{1
Bram Moolenaar9964e462007-05-05 17:54:07 +0000481syn 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 +0000482
483" TeX String Delimiters: {{{1
484syn match texString "\(``\|''\|,,\)"
485
Bram Moolenaar5c736222010-01-06 20:54:52 +0100486" makeatletter -- makeatother sections
487if !exists("g:tex_no_error")
488 syn region texStyle matchgroup=texStatement start='\\makeatletter' end='\\makeatother' contains=@texStyleGroup contained
489 syn match texStyleStatement "\\[a-zA-Z@]\+" contained
490 syn region texStyleMatcher matchgroup=Delimiter start="{" skip="\\\\\|\\[{}]" end="}" contains=@texStyleGroup,texError contained
491 syn region texStyleMatcher matchgroup=Delimiter start="\[" end="]" contains=@texStyleGroup,texError contained
492endif
493
Bram Moolenaar611df5b2010-07-26 22:51:56 +0200494" Conceal mode support (supports set cole=1) {{{1
Bram Moolenaarb2c03502010-07-02 20:20:09 +0200495if has("conceal") && &enc == 'utf-8'
Bram Moolenaar611df5b2010-07-26 22:51:56 +0200496
497 " Math Symbols {{{2
Bram Moolenaar4b22cdb2010-08-02 22:12:46 +0200498 if s:tex_conceal =~ 'm'
499 syn match texMathSymbol '\\approx\>' contained conceal cchar=≈
500 syn match texMathSymbol '\\ast\>' contained conceal cchar=∗
501 syn match texMathSymbol '\\bigtriangledown\>' contained conceal cchar=∇
502 syn match texMathSymbol '\\bigvee\>' contained conceal cchar=⋁
503 syn match texMathSymbol '\\bigwedge\>' contained conceal cchar=⋀
504 syn match texMathSymbol '\\blacksquare\>' contained conceal cchar=∎
505 syn match texMathSymbol '\\cap\>' contained conceal cchar=∩
506 syn match texMathSymbol '\\cdot\>' contained conceal cchar=·
507 syn match texMathSymbol '\\circ\>' contained conceal cchar=∘
508 syn match texMathSymbol '\\circledcirc\>' contained conceal cchar=⊚
509 syn match texMathSymbol '\\cong\>' contained conceal cchar=≅
510 syn match texMathSymbol '\\cup\>' contained conceal cchar=∪
511 syn match texMathSymbol '\\diamond\>' contained conceal cchar=⋄
512 syn match texMathSymbol '\\div\>' contained conceal cchar=÷
513 syn match texMathSymbol '\\doteq\>' contained conceal cchar=≐
514 syn match texMathSymbol '\\dotsb\>' contained conceal cchar=⋯
515 syn match texMathSymbol '\\emptyset\>' contained conceal cchar=∅
516 syn match texMathSymbol '\\equiv\>' contained conceal cchar=≡
517 syn match texMathSymbol '\\forall\>' contained conceal cchar=∀
518 syn match texMathSymbol '\\geq\>' contained conceal cchar=≥
519 syn match texMathSymbol '\\geq\>' contained conceal cchar=≥
520 syn match texMathSymbol '\\gg\>' contained conceal cchar=⟫
521 syn match texMathSymbol '\\gtreqless\>' contained conceal cchar=⋛
522 syn match texMathSymbol '\\gtrless\>' contained conceal cchar=≷
523 syn match texMathSymbol '\\Im\>' contained conceal cchar=ℑ
524 syn match texMathSymbol '\\in\>' contained conceal cchar=∈
525 syn match texMathSymbol '\\infty\>' contained conceal cchar=∞
526 syn match texMathSymbol '\\lceil\>' contained conceal cchar=⌈
527 syn match texMathSymbol '\\leftarrow\>' contained conceal cchar=⟶
528 syn match texMathSymbol '\\Leftarrow\>' contained conceal cchar=⟹
529 syn match texMathSymbol '\\left(' contained conceal cchar=(
530 syn match texMathSymbol '\\left\[' contained conceal cchar=[
531 syn match texMathSymbol '\\left\\{' contained conceal cchar={
532 syn match texMathSymbol '\\leq\>' contained conceal cchar=≤
533 syn match texMathSymbol '\\leq\>' contained conceal cchar=≤
534 syn match texMathSymbol '\\lesseqgtr\>' contained conceal cchar=⋚
535 syn match texMathSymbol '\\lfloor\>' contained conceal cchar=⌊
536 syn match texMathSymbol '\\ll\>' contained conceal cchar=⟪
537 syn match texMathSymbol '\\mapsto\>' contained conceal cchar=↦
538 syn match texMathSymbol '\\mp\>' contained conceal cchar=∓
539 syn match texMathSymbol '\\neq\>' contained conceal cchar=≠
540 syn match texMathSymbol '\\ngeq\>' contained conceal cchar=≱
541 syn match texMathSymbol '\\ngtr\>' contained conceal cchar=≯
542 syn match texMathSymbol '\\nleq\>' contained conceal cchar=≰
543 syn match texMathSymbol '\\nless\>' contained conceal cchar=≮
544 syn match texMathSymbol '\\notin\>' contained conceal cchar=∉
545 syn match texMathSymbol '\\odot\>' contained conceal cchar=⊙
546 syn match texMathSymbol '\\oint\>' contained conceal cchar=∮
547 syn match texMathSymbol '\\oplus\>' contained conceal cchar=⊕
548 syn match texMathSymbol '\\oslash\>' contained conceal cchar=⊘
549 syn match texMathSymbol '\\otimes\>' contained conceal cchar=⊗
550 syn match texMathSymbol '\\partial\>' contained conceal cchar=∂
551 syn match texMathSymbol '\\perp\>' contained conceal cchar=⊥
552 syn match texMathSymbol '\\pm\>' contained conceal cchar=±
553 syn match texMathSymbol '\\prec\>' contained conceal cchar=≺
554 syn match texMathSymbol '\\prod\>' contained conceal cchar=∏
555 syn match texMathSymbol '\\propto\>' contained conceal cchar=∝
556 syn match texMathSymbol '\\rceil\>' contained conceal cchar=⌉
557 syn match texMathSymbol '\\Re\>' contained conceal cchar=ℜ
558 syn match texMathSymbol '\\rfloor\>' contained conceal cchar=⌋
559 syn match texMathSymbol '\\rightarrow\>' contained conceal cchar=⟵
560 syn match texMathSymbol '\\Rightarrow\>' contained conceal cchar=⟸
561 syn match texMathSymbol '\\right)' contained conceal cchar=)
562 syn match texMathSymbol '\\right]' contained conceal cchar=]
563 syn match texMathSymbol '\\right\\}' contained conceal cchar=}
564 syn match texMathSymbol '\\sqcap\>' contained conceal cchar=⊓
565 syn match texMathSymbol '\\sqcup\>' contained conceal cchar=⊔
566 syn match texMathSymbol '\\subset\>' contained conceal cchar=⊂
567 syn match texMathSymbol '\\subseteq\>' contained conceal cchar=⊆
568 syn match texMathSymbol '\\subsetneq\>' contained conceal cchar=⊊
569 syn match texMathSymbol '\\succ\>' contained conceal cchar=≻
570 syn match texMathSymbol '\\sum\>' contained conceal cchar=∑
571 syn match texMathSymbol '\\supseteq\>' contained conceal cchar=⊇
572 syn match texMathSymbol '\\supsetneq\>' contained conceal cchar=⊋
573 syn match texMathSymbol '\\surd\>' contained conceal cchar=√
574 syn match texMathSymbol '\\therefore\>' contained conceal cchar=∴
575 syn match texMathSymbol '\\times\>' contained conceal cchar=×
576 syn match texMathSymbol '\\to\>' contained conceal cchar=→
577 syn match texMathSymbol '\\trianglelefteq\>' contained conceal cchar=⊴
578 syn match texMathSymbol '\\trianglerighteq\>' contained conceal cchar=⊵
579 syn match texMathSymbol '\\vartriangle\>' contained conceal cchar=∆
580 syn match texMathSymbol '\\vdots\>' contained conceal cchar=⋮
581 endif
Bram Moolenaar611df5b2010-07-26 22:51:56 +0200582
583 " Greek {{{2
Bram Moolenaar4b22cdb2010-08-02 22:12:46 +0200584 if s:tex_conceal =~ 'g'
585 fun! s:Greek(group,pat,cchar)
586 exe 'syn match '.a:group." '".a:pat."' contained conceal cchar=".a:cchar
587 endfun
588 call s:Greek('texGreek','\\alpha\>' ,'α')
589 call s:Greek('texGreek','\\beta\>' ,'β')
590 call s:Greek('texGreek','\\gamma\>' ,'γ')
591 call s:Greek('texGreek','\\delta\>' ,'δ')
592 call s:Greek('texGreek','\\epsilon\>' ,'ϵ')
593 call s:Greek('texGreek','\\varepsilon\>' ,'ε')
594 call s:Greek('texGreek','\\zeta\>' ,'ζ')
595 call s:Greek('texGreek','\\eta\>' ,'η')
596 call s:Greek('texGreek','\\theta\>' ,'θ')
597 call s:Greek('texGreek','\\vartheta\>' ,'ϑ')
598 call s:Greek('texGreek','\\kappa\>' ,'κ')
599 call s:Greek('texGreek','\\lambda\>' ,'λ')
600 call s:Greek('texGreek','\\mu\>' ,'μ')
601 call s:Greek('texGreek','\\nu\>' ,'ν')
602 call s:Greek('texGreek','\\xi\>' ,'ξ')
603 call s:Greek('texGreek','\\pi\>' ,'π')
604 call s:Greek('texGreek','\\varpi\>' ,'ϖ')
605 call s:Greek('texGreek','\\rho\>' ,'ρ')
606 call s:Greek('texGreek','\\varrho\>' ,'ϱ')
607 call s:Greek('texGreek','\\sigma\>' ,'σ')
608 call s:Greek('texGreek','\\varsigma\>' ,'ς')
609 call s:Greek('texGreek','\\tau\>' ,'τ')
610 call s:Greek('texGreek','\\upsilon\>' ,'υ')
611 call s:Greek('texGreek','\\phi\>' ,'φ')
612 call s:Greek('texGreek','\\varphi\>' ,'ϕ')
613 call s:Greek('texGreek','\\chi\>' ,'χ')
614 call s:Greek('texGreek','\\psi\>' ,'ψ')
615 call s:Greek('texGreek','\\omega\>' ,'ω')
616 call s:Greek('texGreek','\\Gamma\>' ,'Γ')
617 call s:Greek('texGreek','\\Delta\>' ,'Δ')
618 call s:Greek('texGreek','\\Theta\>' ,'Θ')
619 call s:Greek('texGreek','\\Lambda\>' ,'Λ')
620 call s:Greek('texGreek','\\Xi\>' ,'Χ')
621 call s:Greek('texGreek','\\Pi\>' ,'Π')
622 call s:Greek('texGreek','\\Sigma\>' ,'Σ')
623 call s:Greek('texGreek','\\Upsilon\>' ,'Υ')
624 call s:Greek('texGreek','\\Phi\>' ,'Φ')
625 call s:Greek('texGreek','\\Psi\>' ,'Ψ')
626 call s:Greek('texGreek','\\Omega\>' ,'Ω')
627 delfun s:Greek
628 endif
Bram Moolenaar611df5b2010-07-26 22:51:56 +0200629
630 " Superscripts/Subscripts {{{2
Bram Moolenaar4b22cdb2010-08-02 22:12:46 +0200631 if s:tex_conceal =~ 's'
632 syn region texSuperscript matchgroup=Delimiter start='\^{' end='}' contained concealends contains=texSuperscripts,texStatement
633 syn region texSubscript matchgroup=Delimiter start='_{' end='}' contained concealends contains=texSubscripts,texStatement
634 fun! s:SuperSub(group,leader,pat,cchar)
635 exe 'syn match '.a:group." '".a:leader.a:pat."' contained conceal cchar=".a:cchar
636 exe 'syn match '.a:group."s '".a:pat."' contained conceal cchar=".a:cchar.' nextgroup='.a:group.'s'
637 endfun
638 call s:SuperSub('texSuperscript','\^','0','⁰')
639 call s:SuperSub('texSuperscript','\^','1','¹')
640 call s:SuperSub('texSuperscript','\^','2','²')
641 call s:SuperSub('texSuperscript','\^','3','³')
642 call s:SuperSub('texSuperscript','\^','4','⁴')
643 call s:SuperSub('texSuperscript','\^','5','⁵')
644 call s:SuperSub('texSuperscript','\^','6','⁶')
645 call s:SuperSub('texSuperscript','\^','7','⁷')
646 call s:SuperSub('texSuperscript','\^','8','⁸')
647 call s:SuperSub('texSuperscript','\^','9','⁹')
648 call s:SuperSub('texSuperscript','\^','a','ᵃ')
649 call s:SuperSub('texSuperscript','\^','b','ᵇ')
650 call s:SuperSub('texSuperscript','\^','c','ᶜ')
651 call s:SuperSub('texSuperscript','\^','d','ᵈ')
652 call s:SuperSub('texSuperscript','\^','e','ᵉ')
653 call s:SuperSub('texSuperscript','\^','f','ᶠ')
654 call s:SuperSub('texSuperscript','\^','g','ᵍ')
655 call s:SuperSub('texSuperscript','\^','h','ʰ')
656 call s:SuperSub('texSuperscript','\^','i','ⁱ')
657 call s:SuperSub('texSuperscript','\^','j','ʲ')
658 call s:SuperSub('texSuperscript','\^','k','ᵏ')
659 call s:SuperSub('texSuperscript','\^','l','ˡ')
660 call s:SuperSub('texSuperscript','\^','m','ᵐ')
661 call s:SuperSub('texSuperscript','\^','n','ⁿ')
662 call s:SuperSub('texSuperscript','\^','o','ᵒ')
663 call s:SuperSub('texSuperscript','\^','p','ᵖ')
664 call s:SuperSub('texSuperscript','\^','r','ʳ')
665 call s:SuperSub('texSuperscript','\^','s','ˢ')
666 call s:SuperSub('texSuperscript','\^','t','ᵗ')
667 call s:SuperSub('texSuperscript','\^','u','ᵘ')
668 call s:SuperSub('texSuperscript','\^','v','ᵛ')
669 call s:SuperSub('texSuperscript','\^','w','ʷ')
670 call s:SuperSub('texSuperscript','\^','x','ˣ')
671 call s:SuperSub('texSuperscript','\^','y','ʸ')
672 call s:SuperSub('texSuperscript','\^','z','ᶻ')
673 call s:SuperSub('texSuperscript','\^','A','ᴬ')
674 call s:SuperSub('texSuperscript','\^','B','ᴮ')
675 call s:SuperSub('texSuperscript','\^','D','ᴰ')
676 call s:SuperSub('texSuperscript','\^','E','ᴱ')
677 call s:SuperSub('texSuperscript','\^','G','ᴳ')
678 call s:SuperSub('texSuperscript','\^','H','ᴴ')
679 call s:SuperSub('texSuperscript','\^','I','ᴵ')
680 call s:SuperSub('texSuperscript','\^','J','ᴶ')
681 call s:SuperSub('texSuperscript','\^','K','ᴷ')
682 call s:SuperSub('texSuperscript','\^','L','ᴸ')
683 call s:SuperSub('texSuperscript','\^','M','ᴹ')
684 call s:SuperSub('texSuperscript','\^','N','ᴺ')
685 call s:SuperSub('texSuperscript','\^','O','ᴼ')
686 call s:SuperSub('texSuperscript','\^','P','ᴾ')
687 call s:SuperSub('texSuperscript','\^','R','ᴿ')
688 call s:SuperSub('texSuperscript','\^','T','ᵀ')
689 call s:SuperSub('texSuperscript','\^','U','ᵁ')
690 call s:SuperSub('texSuperscript','\^','W','ᵂ')
691 call s:SuperSub('texSuperscript','\^','+','⁺')
692 call s:SuperSub('texSuperscript','\^','-','⁻')
693 call s:SuperSub('texSuperscript','\^','<','˂')
694 call s:SuperSub('texSuperscript','\^','>','˃')
695 call s:SuperSub('texSuperscript','\^','/','ˊ')
696 call s:SuperSub('texSuperscript','\^','(','⁽')
697 call s:SuperSub('texSuperscript','\^',')','⁾')
698 call s:SuperSub('texSuperscript','\^','\.','˙')
699 call s:SuperSub('texSuperscript','\^','=','˭')
700 call s:SuperSub('texSubscript','_','0','₀')
701 call s:SuperSub('texSubscript','_','1','₁')
702 call s:SuperSub('texSubscript','_','2','₂')
703 call s:SuperSub('texSubscript','_','3','₃')
704 call s:SuperSub('texSubscript','_','4','₄')
705 call s:SuperSub('texSubscript','_','5','₅')
706 call s:SuperSub('texSubscript','_','6','₆')
707 call s:SuperSub('texSubscript','_','7','₇')
708 call s:SuperSub('texSubscript','_','8','₈')
709 call s:SuperSub('texSubscript','_','9','₉')
710 call s:SuperSub('texSubscript','_','a','ₐ')
711 call s:SuperSub('texSubscript','_','e','ₑ')
712 call s:SuperSub('texSubscript','_','i','ᵢ')
713 call s:SuperSub('texSubscript','_','o','ₒ')
714 call s:SuperSub('texSubscript','_','u','ᵤ')
715 call s:SuperSub('texSubscript','_','+','₊')
716 call s:SuperSub('texSubscript','_','-','₋')
717 call s:SuperSub('texSubscript','_','/','ˏ')
718 call s:SuperSub('texSubscript','_','(','₍')
719 call s:SuperSub('texSubscript','_',')','₎')
720 call s:SuperSub('texSubscript','_','\.','‸')
721 call s:SuperSub('texSubscript','_','r','ᵣ')
722 call s:SuperSub('texSubscript','_','v','ᵥ')
723 call s:SuperSub('texSubscript','_','x','ₓ')
724 call s:SuperSub('texSubscript','_','\\beta\>' ,'ᵦ')
725 call s:SuperSub('texSubscript','_','\\delta\>','ᵨ')
726 call s:SuperSub('texSubscript','_','\\phi\>' ,'ᵩ')
727 call s:SuperSub('texSubscript','_','\\gamma\>','ᵧ')
728 call s:SuperSub('texSubscript','_','\\chi\>' ,'ᵪ')
729 delfun s:SuperSub
730 endif
Bram Moolenaar611df5b2010-07-26 22:51:56 +0200731
732 " Accented characters: {{{2
Bram Moolenaar4b22cdb2010-08-02 22:12:46 +0200733 if s:tex_conceal =~ 'a'
734 if b:tex_stylish
735 syn match texAccent "\\[bcdvuH][^a-zA-Z@]"me=e-1
736 syn match texLigature "\\\([ijolL]\|ae\|oe\|ss\|AA\|AE\|OE\)[^a-zA-Z@]"me=e-1
737 else
738 fun! s:Accents(chr,...)
739 let i= 1
740 for accent in ["`","\\'","^",'"','\~',"r","v"]
741 if i > a:0
742 break
743 endif
744 if strlen(a:{i}) == 0
745 let i= i + 1
746 continue
747 endif
748 exe "syn match texAccent '\\\\".accent."{".a:chr."}' conceal cchar=".a:{i}
Bram Moolenaare0021c72010-07-28 17:25:21 +0200749 let i= i + 1
Bram Moolenaar4b22cdb2010-08-02 22:12:46 +0200750 endfor
751 endfun
752 call s:Accents('a','à','á','â','ä','ã','å','ă')
753 call s:Accents('A','À','Á','Â','Ä','Ã','Å','Ă')
754 call s:Accents('C',"" ,'Ć','Ĉ',"" ,"" ,"" ,'Ć')
755 call s:Accents('e','è','é','ê','ë','ẽ',"" ,'ĕ')
756 call s:Accents('E','È','É','Ê','Ë','Ẽ',"" ,'Ė')
757 call s:Accents('i','ì','í','î','ï','ĩ',"" ,"ĭ")
758 call s:Accents('I','Ì','Í','Î','Ï','Ĩ',"" ,'Ĭ')
759 call s:Accents('o','ò','ó','ô','ö','õ',"" ,'ŏ')
760 call s:Accents('O','Ò','Ó','Ô','Ö','Õ',"" ,'Ŏ')
761 call s:Accents('r',"" ,'ŕ',"" ,"" ,"" ,"" ,'ř')
762 call s:Accents('R',"" ,'Ŕ',"" ,"" ,"" ,"" ,'Ř')
763 call s:Accents('s',"" ,'ś','ŝ',"" ,"" ,"" ,'š')
764 call s:Accents('S',"" ,'Ś','Ŝ',"" ,"" ,"" ,'Š')
765 call s:Accents('u','ù','ú','û','ü','ũ',"" ,'ŭ')
766 call s:Accents('U','Ù','Ú','Û','Ü','Ũ',"" ,'Ŭ')
767 call s:Accents('y','ỳ','ý','ŷ','ÿ','ỹ',"" ,"" )
768 call s:Accents('Y','Ỳ','Ý','Ŷ','Ÿ','Ỹ',"" ,"" )
769 delfun s:Accents
770 syn match texAccent '\\aa\>' conceal cchar=å
771 syn match texAccent '\\AA\>' conceal cchar=Å
772 syn match texAccent '\\k{a}' conceal cchar=ą
773 syn match texAccent '\\k{A}' conceal cchar=Ą
774 syn match texAccent '\\c{C}' conceal cchar=Ç
775 syn match texAccent '\\c{c}' conceal cchar=ç
776 syn match texAccent '\\\~{n}' conceal cchar=ñ
777 syn match texAccent '\\\~{N}' conceal cchar=Ñ
778 syn match texAccent '\\o\>' conceal cchar=ø
779 syn match texAccent '\\O\>' conceal cchar=Ø
780 syn match texAccent '\\H{o}' conceal cchar=ő
781 syn match texAccent '\\H{O}' conceal cchar=Ő
782 syn match texAccent '\\c{r}' conceal cchar=ŗ
783 syn match texLigature '\\AE\>' conceal cchar=Æ
784 syn match texLigature '\\ae\>' conceal cchar=æ
785 syn match texLigature '\\oe\>' conceal cchar=œ
786 syn match texLigature '\\OE\>' conceal cchar=Œ
787 syn match texLigature '\\ss\>' conceal cchar=ß
788 endif
Bram Moolenaar611df5b2010-07-26 22:51:56 +0200789 endif
Bram Moolenaarb2c03502010-07-02 20:20:09 +0200790endif
791
792" ---------------------------------------------------------------------
Bram Moolenaar071d4272004-06-13 20:20:40 +0000793" LaTeX synchronization: {{{1
794syn sync maxlines=200
795syn sync minlines=50
796
797syn sync match texSyncStop groupthere NONE "%stopzone\>"
798
799" Synchronization: {{{1
800" The $..$ and $$..$$ make for impossible sync patterns
801" (one can't tell if a "$$" starts or stops a math zone by itself)
802" The following grouptheres coupled with minlines above
803" help improve the odds of good syncing.
804if !exists("tex_no_math")
805 syn sync match texSyncMathZoneA groupthere NONE "\\end{abstract}"
806 syn sync match texSyncMathZoneA groupthere NONE "\\end{center}"
807 syn sync match texSyncMathZoneA groupthere NONE "\\end{description}"
808 syn sync match texSyncMathZoneA groupthere NONE "\\end{enumerate}"
809 syn sync match texSyncMathZoneA groupthere NONE "\\end{itemize}"
810 syn sync match texSyncMathZoneA groupthere NONE "\\end{table}"
811 syn sync match texSyncMathZoneA groupthere NONE "\\end{tabular}"
812 syn sync match texSyncMathZoneA groupthere NONE "\\\(sub\)*section\>"
813endif
814
Bram Moolenaarb2c03502010-07-02 20:20:09 +0200815" ---------------------------------------------------------------------
Bram Moolenaar071d4272004-06-13 20:20:40 +0000816" Highlighting: {{{1
817if did_tex_syntax_inits == 1
818 let did_tex_syntax_inits= 2
819 " TeX highlighting groups which should share similar highlighting
820 if !exists("g:tex_no_error")
821 if !exists("tex_no_math")
822 HiLink texBadMath texError
823 HiLink texMathDelimBad texError
824 HiLink texMathError texError
825 if !b:tex_stylish
826 HiLink texOnlyMath texError
827 endif
828 endif
829 HiLink texError Error
830 endif
831
Bram Moolenaarcc016f52005-12-10 20:23:46 +0000832 HiLink texCite texRefZone
Bram Moolenaar071d4272004-06-13 20:20:40 +0000833 HiLink texDefCmd texDef
834 HiLink texDefName texDef
835 HiLink texDocType texCmdName
836 HiLink texDocTypeArgs texCmdArgs
837 HiLink texInputFileOpt texCmdArgs
838 HiLink texInputCurlies texDelimiter
839 HiLink texLigature texSpecialChar
840 if !exists("tex_no_math")
841 HiLink texMathDelimSet1 texMathDelim
842 HiLink texMathDelimSet2 texMathDelim
843 HiLink texMathDelimKey texMathDelim
844 HiLink texMathMatcher texMath
Bram Moolenaar5c736222010-01-06 20:54:52 +0100845 HiLink texMathZoneV texMath
Bram Moolenaar071d4272004-06-13 20:20:40 +0000846 HiLink texMathZoneW texMath
847 HiLink texMathZoneX texMath
848 HiLink texMathZoneY texMath
Bram Moolenaar3577c6f2008-06-24 21:16:56 +0000849 HiLink texMathZoneV texMath
Bram Moolenaar071d4272004-06-13 20:20:40 +0000850 HiLink texMathZoneZ texMath
851 endif
852 HiLink texSectionMarker texCmdName
853 HiLink texSectionName texSection
854 HiLink texSpaceCode texStatement
Bram Moolenaar5c736222010-01-06 20:54:52 +0100855 HiLink texStyleStatement texStatement
Bram Moolenaar071d4272004-06-13 20:20:40 +0000856 HiLink texTypeSize texType
857 HiLink texTypeStyle texType
858
859 " Basic TeX highlighting groups
860 HiLink texCmdArgs Number
861 HiLink texCmdName Statement
862 HiLink texComment Comment
863 HiLink texDef Statement
864 HiLink texDefParm Special
865 HiLink texDelimiter Delimiter
866 HiLink texInput Special
867 HiLink texInputFile Special
868 HiLink texLength Number
869 HiLink texMath Special
870 HiLink texMathDelim Statement
871 HiLink texMathOper Operator
872 HiLink texNewCmd Statement
873 HiLink texNewEnv Statement
874 HiLink texOption Number
875 HiLink texRefZone Special
876 HiLink texSection PreCondit
877 HiLink texSpaceCodeChar Special
878 HiLink texSpecialChar SpecialChar
879 HiLink texStatement Statement
880 HiLink texString String
881 HiLink texTodo Todo
882 HiLink texType Type
883 HiLink texZone PreCondit
884
885 delcommand HiLink
886endif
887
888" Current Syntax: {{{1
889unlet b:extfname
890let b:current_syntax = "tex"
891" vim: ts=8 fdm=marker