1" Vim syntax file 2" Language: TeX 3" Maintainer: Dr. Charles E. Campbell, Jr. <NdrchipO@ScampbellPfamily.AbizM> 4" Last Change: Aug 12, 2010 5" Version: 57 6" URL: http://mysite.verizon.net/astronaut/vim/index.html#vimlinks_syntax 7" 8" Notes: {{{1 9" 10" 1. If you have a \begin{verbatim} that appears to overrun its boundaries, 11" use %stopzone. 12" 13" 2. Run-on equations ($..$ and $$..$$, particularly) can also be stopped 14" by suitable use of %stopzone. 15" 16" 3. If you have a slow computer, you may wish to modify 17" 18" syn sync maxlines=200 19" syn sync minlines=50 20" 21" to values that are more to your liking. 22" 23" 4. There is no match-syncing for $...$ and $$...$$; hence large 24" equation blocks constructed that way may exhibit syncing problems. 25" (there's no difference between begin/end patterns) 26" 27" 5. If you have the variable "g:tex_no_error" defined then none of the 28" lexical error-checking will be done. 29" 30" ie. let g:tex_no_error=1 31 32" Version Clears: {{{1 33" For version 5.x: Clear all syntax items 34" For version 6.x: Quit when a syntax file was already loaded 35if version < 600 36 syntax clear 37elseif exists("b:current_syntax") 38 finish 39endif 40scriptencoding utf-8 41 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 57" let user determine which classes of concealment will be supported 58" a=accents/ligatures d=delimiters m=math symbols g=Greek s=superscripts/subscripts 59if !exists("g:tex_conceal") 60 let s:tex_conceal= 'admgs' 61else 62 let s:tex_conceal= g:tex_conceal 63endif 64 65" Determine whether or not to use "*.sty" mode {{{1 66" 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 81" handle folding {{{1 82if !exists("g:tex_fold_enabled") 83 let g:tex_fold_enabled= 0 84elseif g:tex_fold_enabled && !has("folding") 85 let g:tex_fold_enabled= 0 86 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" 89 setl fdm=syntax 90endif 91 92" (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 113syn 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 114syn 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 115syn 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 116syn cluster texRefGroup contains=texMatcher,texComment,texDelimiter 117if !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 122 syn cluster texMathZoneGroup contains=texComment,texDelimiter,texLength,texMathDelim,texMathMatcher,texMathOper,texMathSymbol,texMathText,texRefZone,texSpecialChar,texStatement,texTypeSize,texTypeStyle 123 if !exists("g:tex_no_error") 124 syn cluster texMathMatchGroup add=texMathError 125 syn cluster texMathZoneGroup add=texMathError 126 endif 127 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 137 if has("conceal") && &enc == 'utf-8' 138 syn cluster texMathZoneGroup add=texGreek,texSuperscript,texSubscript,texMathSymbol 139 syn cluster texMathMatchGroup add=texGreek,texSuperscript,texSubscript,texMathSymbol 140 endif 141endif 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 151syn region texParen start="(" end=")" contains=@texMatchGroup,@Spell 152if !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 196syn region texSectionName matchgroup=Delimiter start="{" end="}" contained nextgroup=texSectionModifier contains=texComment 197syn region texSectionModifier matchgroup=Delimiter start="\[" end="]" contained contains=texComment 198 199" \documentclass, \documentstyle, \usepackage: {{{1 200syn match texDocType "\\documentclass\>\|\\documentstyle\>\|\\usepackage\>" nextgroup=texSectionName,texDocTypeArgs 201syn region texDocTypeArgs matchgroup=Delimiter start="\[" end="]" contained nextgroup=texSectionName contains=texComment 202 203" Preamble syntax-based folding support: {{{1 204if g:tex_fold_enabled && has("folding") 205 syn region texPreamble transparent fold start='\zs\\documentclass\>' end='\ze\\begin{document}' contains=texStyle,@texMatchGroup 206endif 207 208" TeX input: {{{1 209syn match texInput "\\input\s\+[a-zA-Z/.0-9_^]\+"hs=s+7 contains=texStatement 210syn match texInputFile "\\include\(graphics\|list\)\=\(\[.\{-}\]\)\=\s*{.\{-}}" contains=texStatement,texInputCurlies,texInputFileOpt 211syn match texInputFile "\\\(epsfig\|input\|usepackage\)\s*\(\[.*\]\)\={.\{-}}" contains=texStatement,texInputCurlies,texInputFileOpt 212syn match texInputCurlies "[{}]" contained 213syn region texInputFileOpt matchgroup=Delimiter start="\[" end="\]" contained contains=texComment 214 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 277if g:tex_fold_enabled && has("folding") 278 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 288else 289 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 299endif 300 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") 310 " TexNewMathZone: function creates a mathzone with the given suffix and mathzone name. {{{2 311 " 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 317 if g:tex_fold_enabled 318 let foldcmd= " fold" 319 else 320 let foldcmd= "" 321 endif 322 exe "syn cluster texMathZones add=".grpname 323 exe 'syn region '.grpname.' start='."'".'\\begin\s*{\s*'.a:mathzone.'\s*}'."'".' end='."'".'\\end\s*{\s*'.a:mathzone.'\s*}'."'".' keepend contains=@texMathZoneGroup'.foldcmd 324 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*}"' 326 exe 'hi def link '.grpname.' texMath' 327 if a:starform 328 let grpname = "texMathZone".a:sfx.'S' 329 let syncname = "texSyncMathZone".a:sfx.'S' 330 exe "syn cluster texMathZones add=".grpname 331 exe 'syn region '.grpname.' start='."'".'\\begin\s*{\s*'.a:mathzone.'\*\s*}'."'".' end='."'".'\\end\s*{\s*'.a:mathzone.'\*\s*}'."'".' keepend contains=@texMathZoneGroup'.foldcmd 332 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*}"' 334 exe 'hi def link '.grpname.' texMath' 335 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 353 if has("conceal") && &enc == 'utf-8' && s:tex_conceal =~ 'd' 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 364 syn region texMathZoneZ matchgroup=texStatement start="\\ensuremath\s*{" matchgroup=texStatement end="}" end="%stopzone\>" contains=@texMathZoneGroup 365 366 syn match texMathOper "[_^=]" contained 367 368 " Text Inside Math Zones: {{{2 369 syn region texMathText matchgroup=texStatement start='\\\(\(inter\)\=text\|mbox\)\s*{' end='}' contains=@texFoldGroup,@Spell 370 371 " \left..something.. and \right..something.. support: {{{2 372 syn match texMathDelimBad contained "\S" 373 if has("conceal") && &enc == 'utf-8' && s:tex_conceal =~ 'm' 374 syn match texMathDelim contained "\\left\\{\>" skipwhite nextgroup=texMathDelimSet1,texMathDelimSet2,texMathDelimBad contains=texMathSymbol cchar={ 375 syn match texMathDelim contained "\\right\\}\>" skipwhite nextgroup=texMathDelimSet1,texMathDelimSet2,texMathDelimBad contains=texMathSymbol cchar=} 376 else 377 syn match texMathDelim contained "\\\(left\|right\)\>" skipwhite nextgroup=texMathDelimSet1,texMathDelimSet2,texMathDelimBad 378 endif 379 syn match texMathDelim contained "\\\([bB]igg\=[lr]\)\>" skipwhite nextgroup=texMathDelimSet1,texMathDelimSet2,texMathDelimBad 380 syn match texMathDelim contained "\\\(left\|right\)arrow\>\|\<\([aA]rrow\|brace\)\=vert\>" 381 syn match texMathDelim contained "\\lefteqn\>" 382 syn match texMathDelimSet2 contained "\\" nextgroup=texMathDelimKey,texMathDelimBad 383 syn match texMathDelimSet1 contained "[<>()[\]|/.]\|\\[{}|]" 384 syn keyword texMathDelimKey contained backslash lceil lVert rgroup uparrow 385 syn keyword texMathDelimKey contained downarrow lfloor rangle rmoustache Uparrow 386 syn keyword texMathDelimKey contained Downarrow lgroup rbrace rvert updownarrow 387 syn keyword texMathDelimKey contained langle lmoustache rceil rVert Updownarrow 388 syn keyword texMathDelimKey contained lbrace lvert rfloor 389endif 390 391" Special TeX characters ( \$ \& \% \# \{ \} \_ \S \P ) : {{{1 392syn match texSpecialChar "\\[$&%#{}_]" 393if b:tex_stylish 394 syn match texSpecialChar "\\[SP@][^a-zA-Z@]"me=e-1 395else 396 syn match texSpecialChar "\\[SP@]\A"me=e-1 397endif 398syn match texSpecialChar "\\\\" 399if !exists("tex_no_math") 400 syn match texOnlyMath "[_^]" 401endif 402syn match texSpecialChar "\^\^[0-9a-f]\{2}\|\^\^\S" 403 404" Comments: {{{1 405" Normal TeX LaTeX : %.... 406" Documented TeX Format: ^^A... -and- leading %s (only) 407if !exists("g:tex_comment_nospell") || !g:tex_comment_nospell 408 syn cluster texCommentGroup contains=texTodo,@Spell 409else 410 syn cluster texCommentGroup contains=texTodo,@NoSpell 411endif 412syn case ignore 413syn keyword texTodo contained combak fixme todo xxx 414syn case match 415if b:extfname == "dtx" 416 syn match texComment "\^\^A.*$" contains=@texCommentGroup 417 syn match texComment "^%\+" contains=@texCommentGroup 418else 419 if g:tex_fold_enabled 420 " allows syntax-folding of 2 or more contiguous comment lines 421 " single-line comments are not folded 422 syn match texComment "%.*$" contains=@texCommentGroup 423 syn region texComment start="^\zs\s*%.*\_s*%" skip="^\s*%" end='^\ze\s*[^%]' fold 424 else 425 syn match texComment "%.*$" contains=@texCommentGroup 426 endif 427endif 428 429" Separate lines used for verb` and verb# so that the end conditions {{{1 430" will appropriately terminate. 431" If g:tex_verbspell exists, then verbatim texZones will permit spellchecking there. 432if exists("g:tex_verbspell") && g:tex_verbspell 433 syn region texZone start="\\begin{[vV]erbatim}" end="\\end{[vV]erbatim}\|%stopzone\>" contains=@Spell 434 " listings package: 435 syn region texZone start="\\begin{lstlisting}" end="\\end{lstlisting}\|%stopzone\>" contains=@Spell 436 " moreverb package: 437 syn region texZone start="\\begin{verbatimtab}" end="\\end{verbatimtab}\|%stopzone\>" contains=@Spell 438 syn region texZone start="\\begin{verbatimwrite}" end="\\end{verbatimwrite}\|%stopzone\>" contains=@Spell 439 syn region texZone start="\\begin{boxedverbatim}" end="\\end{boxedverbatim}\|%stopzone\>" contains=@Spell 440 if version < 600 441 syn region texZone start="\\verb\*\=`" end="`\|%stopzone\>" contains=@Spell 442 syn region texZone start="\\verb\*\=#" end="#\|%stopzone\>" contains=@Spell 443 else 444 if b:tex_stylish 445 syn region texZone start="\\verb\*\=\z([^\ta-zA-Z@]\)" end="\z1\|%stopzone\>" contains=@Spell 446 else 447 syn region texZone start="\\verb\*\=\z([^\ta-zA-Z]\)" end="\z1\|%stopzone\>" contains=@Spell 448 endif 449 endif 450else 451 syn region texZone start="\\begin{[vV]erbatim}" end="\\end{[vV]erbatim}\|%stopzone\>" 452 " listings package: 453 syn region texZone start="\\begin{lstlisting}" end="\\end{lstlisting}\|%stopzone\>" 454 " moreverb package: 455 syn region texZone start="\\begin{verbatimtab}" end="\\end{verbatimtab}\|%stopzone\>" 456 syn region texZone start="\\begin{verbatimwrite}" end="\\end{verbatimwrite}\|%stopzone\>" 457 syn region texZone start="\\begin{boxedverbatim}" end="\\end{boxedverbatim}\|%stopzone\>" 458 if version < 600 459 syn region texZone start="\\verb\*\=`" end="`\|%stopzone\>" 460 syn region texZone start="\\verb\*\=#" end="#\|%stopzone\>" 461 else 462 if b:tex_stylish 463 syn region texZone start="\\verb\*\=\z([^\ta-zA-Z@]\)" end="\z1\|%stopzone\>" 464 else 465 syn region texZone start="\\verb\*\=\z([^\ta-zA-Z]\)" end="\z1\|%stopzone\>" 466 endif 467 endif 468endif 469 470" Tex Reference Zones: {{{1 471syn region texZone matchgroup=texStatement start="@samp{" end="}\|%stopzone\>" contains=@texRefGroup 472syn region texRefZone matchgroup=texStatement start="\\nocite{" end="}\|%stopzone\>" contains=@texRefGroup 473syn region texRefZone matchgroup=texStatement start="\\bibliography{" end="}\|%stopzone\>" contains=@texRefGroup 474syn region texRefZone matchgroup=texStatement start="\\label{" end="}\|%stopzone\>" contains=@texRefGroup 475syn region texRefZone matchgroup=texStatement start="\\\(page\|eq\)ref{" end="}\|%stopzone\>" contains=@texRefGroup 476syn region texRefZone matchgroup=texStatement start="\\v\=ref{" end="}\|%stopzone\>" contains=@texRefGroup 477syn match texRefZone '\\cite\%([tp]\*\=\)\=' nextgroup=texRefOption,texCite 478syn region texRefOption contained matchgroup=Delimiter start='\[' end=']' contains=@texRefGroup,texRefZone nextgroup=texRefOption,texCite 479syn region texCite contained matchgroup=Delimiter start='{' end='}' contains=@texRefGroup,texRefZone,texCite 480 481" Handle newcommand, newenvironment : {{{1 482syn match texNewCmd "\\newcommand\>" nextgroup=texCmdName skipwhite skipnl 483syn region texCmdName contained matchgroup=Delimiter start="{"rs=s+1 end="}" nextgroup=texCmdArgs,texCmdBody skipwhite skipnl 484syn region texCmdArgs contained matchgroup=Delimiter start="\["rs=s+1 end="]" nextgroup=texCmdBody skipwhite skipnl 485syn region texCmdBody contained matchgroup=Delimiter start="{"rs=s+1 skip="\\\\\|\\[{}]" matchgroup=Delimiter end="}" contains=@texCmdGroup 486syn match texNewEnv "\\newenvironment\>" nextgroup=texEnvName skipwhite skipnl 487syn region texEnvName contained matchgroup=Delimiter start="{"rs=s+1 end="}" nextgroup=texEnvBgn skipwhite skipnl 488syn region texEnvBgn contained matchgroup=Delimiter start="{"rs=s+1 end="}" nextgroup=texEnvEnd skipwhite skipnl contains=@texEnvGroup 489syn region texEnvEnd contained matchgroup=Delimiter start="{"rs=s+1 end="}" skipwhite skipnl contains=@texEnvGroup 490 491" Definitions/Commands: {{{1 492syn match texDefCmd "\\def\>" nextgroup=texDefName skipwhite skipnl 493if b:tex_stylish 494 syn match texDefName contained "\\[a-zA-Z@]\+" nextgroup=texDefParms,texCmdBody skipwhite skipnl 495 syn match texDefName contained "\\[^a-zA-Z@]" nextgroup=texDefParms,texCmdBody skipwhite skipnl 496else 497 syn match texDefName contained "\\\a\+" nextgroup=texDefParms,texCmdBody skipwhite skipnl 498 syn match texDefName contained "\\\A" nextgroup=texDefParms,texCmdBody skipwhite skipnl 499endif 500syn match texDefParms contained "#[^{]*" contains=texDefParm nextgroup=texCmdBody skipwhite skipnl 501syn match texDefParm contained "#\d\+" 502 503" TeX Lengths: {{{1 504syn match texLength "\<\d\+\([.,]\d\+\)\=\s*\(true\)\=\s*\(bp\|cc\|cm\|dd\|em\|ex\|in\|mm\|pc\|pt\|sp\)\>" 505 506" TeX String Delimiters: {{{1 507syn match texString "\(``\|''\|,,\)" 508 509" makeatletter -- makeatother sections 510if !exists("g:tex_no_error") 511 syn region texStyle matchgroup=texStatement start='\\makeatletter' end='\\makeatother' contains=@texStyleGroup contained 512 syn match texStyleStatement "\\[a-zA-Z@]\+" contained 513 syn region texStyleMatcher matchgroup=Delimiter start="{" skip="\\\\\|\\[{}]" end="}" contains=@texStyleGroup,texError contained 514 syn region texStyleMatcher matchgroup=Delimiter start="\[" end="]" contains=@texStyleGroup,texError contained 515endif 516 517" Conceal mode support (supports set cole=2) {{{1 518if has("conceal") && &enc == 'utf-8' 519 520 " Math Symbols {{{2 521 " (many of these symbols were contributed by Björn Winckler) 522 if s:tex_conceal =~ 'm' 523 let s:texMathList=[ 524 \ ['angle' , '∠'], 525 \ ['approx' , '≈'], 526 \ ['ast' , '∗'], 527 \ ['asymp' , '≍'], 528 \ ['backepsilon' , '∍'], 529 \ ['backsimeq' , '≃'], 530 \ ['barwedge' , '⊼'], 531 \ ['because' , '∵'], 532 \ ['between' , '≬'], 533 \ ['bigcap' , '∩'], 534 \ ['bigcup' , '∪'], 535 \ ['bigodot' , '⊙'], 536 \ ['bigoplus' , '⊕'], 537 \ ['bigotimes' , '⊗'], 538 \ ['bigsqcup' , '⊔'], 539 \ ['bigtriangledown', '∇'], 540 \ ['bigvee' , '⋁'], 541 \ ['bigwedge' , '⋀'], 542 \ ['blacksquare' , '∎'], 543 \ ['bot' , '⊥'], 544 \ ['boxdot' , '⊡'], 545 \ ['boxminus' , '⊟'], 546 \ ['boxplus' , '⊞'], 547 \ ['boxtimes' , '⊠'], 548 \ ['bumpeq' , '≏'], 549 \ ['Bumpeq' , '≎'], 550 \ ['cap' , '∩'], 551 \ ['Cap' , '⋒'], 552 \ ['cdot' , '·'], 553 \ ['cdots' , '⋯'], 554 \ ['circ' , '∘'], 555 \ ['circeq' , '≗'], 556 \ ['circlearrowleft', '↺'], 557 \ ['circlearrowright', '↻'], 558 \ ['circledast' , '⊛'], 559 \ ['circledcirc' , '⊚'], 560 \ ['complement' , '∁'], 561 \ ['cong' , '≅'], 562 \ ['coprod' , '∐'], 563 \ ['cup' , '∪'], 564 \ ['Cup' , '⋓'], 565 \ ['curlyeqprec' , '⋞'], 566 \ ['curlyeqsucc' , '⋟'], 567 \ ['curlyvee' , '⋎'], 568 \ ['curlywedge' , '⋏'], 569 \ ['dashv' , '⊣'], 570 \ ['diamond' , '⋄'], 571 \ ['div' , '÷'], 572 \ ['doteq' , '≐'], 573 \ ['doteqdot' , '≑'], 574 \ ['dotplus' , '∔'], 575 \ ['dotsb' , '⋯'], 576 \ ['dotsc' , '…'], 577 \ ['dots' , '…'], 578 \ ['dotsi' , '⋯'], 579 \ ['dotso' , '…'], 580 \ ['doublebarwedge' , '⩞'], 581 \ ['downarrow' , '↓'], 582 \ ['Downarrow' , '⇓'], 583 \ ['emptyset' , '∅'], 584 \ ['eqcirc' , '≖'], 585 \ ['eqsim' , '≂'], 586 \ ['eqslantgtr' , '⪖'], 587 \ ['eqslantless' , '⪕'], 588 \ ['equiv' , '≡'], 589 \ ['exists' , '∃'], 590 \ ['fallingdotseq' , '≒'], 591 \ ['forall' , '∀'], 592 \ ['ge' , '≥'], 593 \ ['geq' , '≥'], 594 \ ['geqq' , '≧'], 595 \ ['gets' , '←'], 596 \ ['gneqq' , '≩'], 597 \ ['gtrdot' , '⋗'], 598 \ ['gtreqless' , '⋛'], 599 \ ['gtrless' , '≷'], 600 \ ['gtrsim' , '≳'], 601 \ ['hookleftarrow' , '↩'], 602 \ ['hookrightarrow' , '↪'], 603 \ ['iiint' , '∭'], 604 \ ['iint' , '∬'], 605 \ ['Im' , 'ℑ'], 606 \ ['in' , '∈'], 607 \ ['infty' , '∞'], 608 \ ['int' , '∫'], 609 \ ['lceil' , '⌈'], 610 \ ['ldots' , '…'], 611 \ ['le' , '≤'], 612 \ ['leftarrow' , '⟵'], 613 \ ['Leftarrow' , '⟸'], 614 \ ['leftarrowtail' , '↢'], 615 \ ['left(' , '('], 616 \ ['left\[' , '['], 617 \ ['left\\{' , '{'], 618 \ ['Leftrightarrow' , '⇔'], 619 \ ['leftrightsquigarrow', '↭'], 620 \ ['leftthreetimes' , '⋋'], 621 \ ['leq' , '≤'], 622 \ ['leqq' , '≦'], 623 \ ['lessdot' , '⋖'], 624 \ ['lesseqgtr' , '⋚'], 625 \ ['lesssim' , '≲'], 626 \ ['lfloor' , '⌊'], 627 \ ['lneqq' , '≨'], 628 \ ['ltimes' , '⋉'], 629 \ ['mapsto' , '↦'], 630 \ ['measuredangle' , '∡'], 631 \ ['mid' , '∣'], 632 \ ['mp' , '∓'], 633 \ ['nabla' , '∇'], 634 \ ['ncong' , '≇'], 635 \ ['nearrow' , '↗'], 636 \ ['ne' , '≠'], 637 \ ['neg' , '¬'], 638 \ ['neq' , '≠'], 639 \ ['nexists' , '∄'], 640 \ ['ngeq' , '≱'], 641 \ ['ngeqq' , '≱'], 642 \ ['ngtr' , '≯'], 643 \ ['ni' , '∋'], 644 \ ['nleftarrow' , '↚'], 645 \ ['nLeftarrow' , '⇍'], 646 \ ['nLeftrightarrow', '⇎'], 647 \ ['nleq' , '≰'], 648 \ ['nleqq' , '≰'], 649 \ ['nless' , '≮'], 650 \ ['nmid' , '∤'], 651 \ ['notin' , '∉'], 652 \ ['nprec' , '⊀'], 653 \ ['nrightarrow' , '↛'], 654 \ ['nRightarrow' , '⇏'], 655 \ ['nsim' , '≁'], 656 \ ['nsucc' , '⊁'], 657 \ ['ntriangleleft' , '⋪'], 658 \ ['ntrianglelefteq', '⋬'], 659 \ ['ntriangleright' , '⋫'], 660 \ ['ntrianglerighteq', '⋭'], 661 \ ['nvdash' , '⊬'], 662 \ ['nvDash' , '⊭'], 663 \ ['nVdash' , '⊮'], 664 \ ['nwarrow' , '↖'], 665 \ ['odot' , '⊙'], 666 \ ['oint' , '∮'], 667 \ ['ominus' , '⊖'], 668 \ ['oplus' , '⊕'], 669 \ ['oslash' , '⊘'], 670 \ ['otimes' , '⊗'], 671 \ ['owns' , '∋'], 672 \ ['partial' , '∂'], 673 \ ['perp' , '⊥'], 674 \ ['pitchfork' , '⋔'], 675 \ ['pm' , '±'], 676 \ ['precapprox' , '⪷'], 677 \ ['prec' , '≺'], 678 \ ['preccurlyeq' , '≼'], 679 \ ['preceq' , '⪯'], 680 \ ['precnapprox' , '⪹'], 681 \ ['precneqq' , '⪵'], 682 \ ['precsim' , '≾'], 683 \ ['prod' , '∏'], 684 \ ['propto' , '∝'], 685 \ ['rceil' , '⌉'], 686 \ ['Re' , 'ℜ'], 687 \ ['rfloor' , '⌋'], 688 \ ['rightarrow' , '⟶'], 689 \ ['Rightarrow' , '⟹'], 690 \ ['rightarrowtail' , '↣'], 691 \ ['right)' , ')'], 692 \ ['right]' , ']'], 693 \ ['right\\}' , '}'], 694 \ ['rightsquigarrow', '↝'], 695 \ ['rightthreetimes', '⋌'], 696 \ ['risingdotseq' , '≓'], 697 \ ['rtimes' , '⋊'], 698 \ ['searrow' , '↘'], 699 \ ['setminus' , '∖'], 700 \ ['sim' , '∼'], 701 \ ['sphericalangle' , '∢'], 702 \ ['sqcap' , '⊓'], 703 \ ['sqcup' , '⊔'], 704 \ ['sqsubset' , '⊏'], 705 \ ['sqsubseteq' , '⊑'], 706 \ ['sqsupset' , '⊐'], 707 \ ['sqsupseteq' , '⊒'], 708 \ ['subset' , '⊂'], 709 \ ['Subset' , '⋐'], 710 \ ['subseteq' , '⊆'], 711 \ ['subseteqq' , '⫅'], 712 \ ['subsetneq' , '⊊'], 713 \ ['subsetneqq' , '⫋'], 714 \ ['succapprox' , '⪸'], 715 \ ['succ' , '≻'], 716 \ ['succcurlyeq' , '≽'], 717 \ ['succeq' , '⪰'], 718 \ ['succnapprox' , '⪺'], 719 \ ['succneqq' , '⪶'], 720 \ ['succsim' , '≿'], 721 \ ['sum' , '∑'], 722 \ ['Supset' , '⋑'], 723 \ ['supseteq' , '⊇'], 724 \ ['supseteqq' , '⫆'], 725 \ ['supsetneq' , '⊋'], 726 \ ['supsetneqq' , '⫌'], 727 \ ['surd' , '√'], 728 \ ['swarrow' , '↙'], 729 \ ['therefore' , '∴'], 730 \ ['times' , '×'], 731 \ ['to' , '→'], 732 \ ['top' , '⊤'], 733 \ ['triangleleft' , '⊲'], 734 \ ['trianglelefteq' , '⊴'], 735 \ ['triangleq' , '≜'], 736 \ ['triangleright' , '⊳'], 737 \ ['trianglerighteq', '⊵'], 738 \ ['twoheadleftarrow', '↞'], 739 \ ['twoheadrightarrow', '↠'], 740 \ ['uparrow' , '↑'], 741 \ ['Uparrow' , '⇑'], 742 \ ['updownarrow' , '↕'], 743 \ ['Updownarrow' , '⇕'], 744 \ ['varnothing' , '∅'], 745 \ ['vartriangle' , '∆'], 746 \ ['vdash' , '⊢'], 747 \ ['vDash' , '⊨'], 748 \ ['Vdash' , '⊩'], 749 \ ['vdots' , '⋮'], 750 \ ['veebar' , '⊻'], 751 \ ['vee' , '∨'], 752 \ ['Vvdash' , '⊪'], 753 \ ['wedge' , '∧'], 754 \ ['wr' , '≀']] 755 for texmath in s:texMathList 756 exe "syn match texMathSymbol '\\\\".texmath[0]."\\>' contained conceal cchar=".texmath[1] 757 endfor 758 759 if &ambw == "double" 760 syn match texMathSymbol '\\gg\>' contained conceal cchar=≫ 761 syn match texMathSymbol '\\ll\>' contained conceal cchar=≪ 762 else 763 syn match texMathSymbol '\\gg\>' contained conceal cchar=⟫ 764 syn match texMathSymbol '\\ll\>' contained conceal cchar=⟪ 765 endif 766 endif 767 768 " Greek {{{2 769 if s:tex_conceal =~ 'g' 770 fun! s:Greek(group,pat,cchar) 771 exe 'syn match '.a:group." '".a:pat."' contained conceal cchar=".a:cchar 772 endfun 773 call s:Greek('texGreek','\\alpha\>' ,'α') 774 call s:Greek('texGreek','\\beta\>' ,'β') 775 call s:Greek('texGreek','\\gamma\>' ,'γ') 776 call s:Greek('texGreek','\\delta\>' ,'δ') 777 call s:Greek('texGreek','\\epsilon\>' ,'ϵ') 778 call s:Greek('texGreek','\\varepsilon\>' ,'ε') 779 call s:Greek('texGreek','\\zeta\>' ,'ζ') 780 call s:Greek('texGreek','\\eta\>' ,'η') 781 call s:Greek('texGreek','\\theta\>' ,'θ') 782 call s:Greek('texGreek','\\vartheta\>' ,'ϑ') 783 call s:Greek('texGreek','\\kappa\>' ,'κ') 784 call s:Greek('texGreek','\\lambda\>' ,'λ') 785 call s:Greek('texGreek','\\mu\>' ,'μ') 786 call s:Greek('texGreek','\\nu\>' ,'ν') 787 call s:Greek('texGreek','\\xi\>' ,'ξ') 788 call s:Greek('texGreek','\\pi\>' ,'π') 789 call s:Greek('texGreek','\\varpi\>' ,'ϖ') 790 call s:Greek('texGreek','\\rho\>' ,'ρ') 791 call s:Greek('texGreek','\\varrho\>' ,'ϱ') 792 call s:Greek('texGreek','\\sigma\>' ,'σ') 793 call s:Greek('texGreek','\\varsigma\>' ,'ς') 794 call s:Greek('texGreek','\\tau\>' ,'τ') 795 call s:Greek('texGreek','\\upsilon\>' ,'υ') 796 call s:Greek('texGreek','\\phi\>' ,'φ') 797 call s:Greek('texGreek','\\varphi\>' ,'ϕ') 798 call s:Greek('texGreek','\\chi\>' ,'χ') 799 call s:Greek('texGreek','\\psi\>' ,'ψ') 800 call s:Greek('texGreek','\\omega\>' ,'ω') 801 call s:Greek('texGreek','\\Gamma\>' ,'Γ') 802 call s:Greek('texGreek','\\Delta\>' ,'Δ') 803 call s:Greek('texGreek','\\Theta\>' ,'Θ') 804 call s:Greek('texGreek','\\Lambda\>' ,'Λ') 805 call s:Greek('texGreek','\\Xi\>' ,'Χ') 806 call s:Greek('texGreek','\\Pi\>' ,'Π') 807 call s:Greek('texGreek','\\Sigma\>' ,'Σ') 808 call s:Greek('texGreek','\\Upsilon\>' ,'Υ') 809 call s:Greek('texGreek','\\Phi\>' ,'Φ') 810 call s:Greek('texGreek','\\Psi\>' ,'Ψ') 811 call s:Greek('texGreek','\\Omega\>' ,'Ω') 812 delfun s:Greek 813 endif 814 815 " Superscripts/Subscripts {{{2 816 if s:tex_conceal =~ 's' 817 syn region texSuperscript matchgroup=Delimiter start='\^{' end='}' contained concealends contains=texSuperscripts,texStatement,texSubscript,texSuperscript,texMathMatcher 818 syn region texSubscript matchgroup=Delimiter start='_{' end='}' contained concealends contains=texSubscripts,texStatement,texSubscript,texSuperscript,texMathMatcher 819 fun! s:SuperSub(group,leader,pat,cchar) 820 exe 'syn match '.a:group." '".a:leader.a:pat."' contained conceal cchar=".a:cchar 821 exe 'syn match '.a:group."s '".a:pat."' contained conceal cchar=".a:cchar.' nextgroup='.a:group.'s' 822 endfun 823 call s:SuperSub('texSuperscript','\^','0','⁰') 824 call s:SuperSub('texSuperscript','\^','1','¹') 825 call s:SuperSub('texSuperscript','\^','2','²') 826 call s:SuperSub('texSuperscript','\^','3','³') 827 call s:SuperSub('texSuperscript','\^','4','⁴') 828 call s:SuperSub('texSuperscript','\^','5','⁵') 829 call s:SuperSub('texSuperscript','\^','6','⁶') 830 call s:SuperSub('texSuperscript','\^','7','⁷') 831 call s:SuperSub('texSuperscript','\^','8','⁸') 832 call s:SuperSub('texSuperscript','\^','9','⁹') 833 call s:SuperSub('texSuperscript','\^','a','ᵃ') 834 call s:SuperSub('texSuperscript','\^','b','ᵇ') 835 call s:SuperSub('texSuperscript','\^','c','ᶜ') 836 call s:SuperSub('texSuperscript','\^','d','ᵈ') 837 call s:SuperSub('texSuperscript','\^','e','ᵉ') 838 call s:SuperSub('texSuperscript','\^','f','ᶠ') 839 call s:SuperSub('texSuperscript','\^','g','ᵍ') 840 call s:SuperSub('texSuperscript','\^','h','ʰ') 841 call s:SuperSub('texSuperscript','\^','i','ⁱ') 842 call s:SuperSub('texSuperscript','\^','j','ʲ') 843 call s:SuperSub('texSuperscript','\^','k','ᵏ') 844 call s:SuperSub('texSuperscript','\^','l','ˡ') 845 call s:SuperSub('texSuperscript','\^','m','ᵐ') 846 call s:SuperSub('texSuperscript','\^','n','ⁿ') 847 call s:SuperSub('texSuperscript','\^','o','ᵒ') 848 call s:SuperSub('texSuperscript','\^','p','ᵖ') 849 call s:SuperSub('texSuperscript','\^','r','ʳ') 850 call s:SuperSub('texSuperscript','\^','s','ˢ') 851 call s:SuperSub('texSuperscript','\^','t','ᵗ') 852 call s:SuperSub('texSuperscript','\^','u','ᵘ') 853 call s:SuperSub('texSuperscript','\^','v','ᵛ') 854 call s:SuperSub('texSuperscript','\^','w','ʷ') 855 call s:SuperSub('texSuperscript','\^','x','ˣ') 856 call s:SuperSub('texSuperscript','\^','y','ʸ') 857 call s:SuperSub('texSuperscript','\^','z','ᶻ') 858 call s:SuperSub('texSuperscript','\^','A','ᴬ') 859 call s:SuperSub('texSuperscript','\^','B','ᴮ') 860 call s:SuperSub('texSuperscript','\^','D','ᴰ') 861 call s:SuperSub('texSuperscript','\^','E','ᴱ') 862 call s:SuperSub('texSuperscript','\^','G','ᴳ') 863 call s:SuperSub('texSuperscript','\^','H','ᴴ') 864 call s:SuperSub('texSuperscript','\^','I','ᴵ') 865 call s:SuperSub('texSuperscript','\^','J','ᴶ') 866 call s:SuperSub('texSuperscript','\^','K','ᴷ') 867 call s:SuperSub('texSuperscript','\^','L','ᴸ') 868 call s:SuperSub('texSuperscript','\^','M','ᴹ') 869 call s:SuperSub('texSuperscript','\^','N','ᴺ') 870 call s:SuperSub('texSuperscript','\^','O','ᴼ') 871 call s:SuperSub('texSuperscript','\^','P','ᴾ') 872 call s:SuperSub('texSuperscript','\^','R','ᴿ') 873 call s:SuperSub('texSuperscript','\^','T','ᵀ') 874 call s:SuperSub('texSuperscript','\^','U','ᵁ') 875 call s:SuperSub('texSuperscript','\^','W','ᵂ') 876 call s:SuperSub('texSuperscript','\^','+','⁺') 877 call s:SuperSub('texSuperscript','\^','-','⁻') 878 call s:SuperSub('texSuperscript','\^','<','˂') 879 call s:SuperSub('texSuperscript','\^','>','˃') 880 call s:SuperSub('texSuperscript','\^','/','ˊ') 881 call s:SuperSub('texSuperscript','\^','(','⁽') 882 call s:SuperSub('texSuperscript','\^',')','⁾') 883 call s:SuperSub('texSuperscript','\^','\.','˙') 884 call s:SuperSub('texSuperscript','\^','=','˭') 885 call s:SuperSub('texSubscript','_','0','₀') 886 call s:SuperSub('texSubscript','_','1','₁') 887 call s:SuperSub('texSubscript','_','2','₂') 888 call s:SuperSub('texSubscript','_','3','₃') 889 call s:SuperSub('texSubscript','_','4','₄') 890 call s:SuperSub('texSubscript','_','5','₅') 891 call s:SuperSub('texSubscript','_','6','₆') 892 call s:SuperSub('texSubscript','_','7','₇') 893 call s:SuperSub('texSubscript','_','8','₈') 894 call s:SuperSub('texSubscript','_','9','₉') 895 call s:SuperSub('texSubscript','_','a','ₐ') 896 call s:SuperSub('texSubscript','_','e','ₑ') 897 call s:SuperSub('texSubscript','_','i','ᵢ') 898 call s:SuperSub('texSubscript','_','o','ₒ') 899 call s:SuperSub('texSubscript','_','u','ᵤ') 900 call s:SuperSub('texSubscript','_','+','₊') 901 call s:SuperSub('texSubscript','_','-','₋') 902 call s:SuperSub('texSubscript','_','/','ˏ') 903 call s:SuperSub('texSubscript','_','(','₍') 904 call s:SuperSub('texSubscript','_',')','₎') 905 call s:SuperSub('texSubscript','_','\.','‸') 906 call s:SuperSub('texSubscript','_','r','ᵣ') 907 call s:SuperSub('texSubscript','_','v','ᵥ') 908 call s:SuperSub('texSubscript','_','x','ₓ') 909 call s:SuperSub('texSubscript','_','\\beta\>' ,'ᵦ') 910 call s:SuperSub('texSubscript','_','\\delta\>','ᵨ') 911 call s:SuperSub('texSubscript','_','\\phi\>' ,'ᵩ') 912 call s:SuperSub('texSubscript','_','\\gamma\>','ᵧ') 913 call s:SuperSub('texSubscript','_','\\chi\>' ,'ᵪ') 914 delfun s:SuperSub 915 endif 916 917 " Accented characters: {{{2 918 if s:tex_conceal =~ 'a' 919 if b:tex_stylish 920 syn match texAccent "\\[bcdvuH][^a-zA-Z@]"me=e-1 921 syn match texLigature "\\\([ijolL]\|ae\|oe\|ss\|AA\|AE\|OE\)[^a-zA-Z@]"me=e-1 922 else 923 fun! s:Accents(chr,...) 924 let i= 1 925 for accent in ["`","\\'","^",'"','\~','\.',"c","H","k","r","u","v"] 926 if i > a:0 927 break 928 endif 929 if strlen(a:{i}) == 0 || a:{i} == ' ' || a:{i} == '?' 930 let i= i + 1 931 continue 932 endif 933 if accent =~ '\a' 934 exe "syn match texAccent '".'\\'.accent.'\(\s*{'.a:chr.'}\|\s\+'.a:chr.'\)'."' conceal cchar=".a:{i} 935 else 936 exe "syn match texAccent '".'\\'.accent.'\s*\({'.a:chr.'}\|'.a:chr.'\)'."' conceal cchar=".a:{i} 937 endif 938 let i= i + 1 939 endfor 940 endfun 941 " \` \' \^ \" \~ \. \c \H \k \r \u \v 942 call s:Accents('a','à','á','â','ä','ã',' ',' ',' ','ą','å','ă','ă') 943 call s:Accents('A','À','Á','Â','Ä','Ã',' ',' ',' ','Ą','Å','Ă','Ă') 944 call s:Accents('c',' ','ć','ĉ',' ',' ','ċ','ç',' ',' ',' ',' ','č') 945 call s:Accents('C',' ','Ć','Ĉ',' ',' ','Ċ','Ç',' ',' ',' ',' ','Č') 946 call s:Accents('d',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','ď') 947 call s:Accents('D',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','Ď') 948 call s:Accents('e','è','é','ê','ë','ẽ','ė','ȩ',' ','ę',' ','ĕ','ě') 949 call s:Accents('E','È','É','Ê','Ë','Ẽ','Ė','Ȩ',' ','Ę',' ','Ĕ','Ě') 950 call s:Accents('g',' ',' ',' ',' ',' ','ġ','ģ',' ',' ',' ','ğ',' ') 951 call s:Accents('G',' ',' ',' ',' ',' ','Ġ','Ģ',' ',' ',' ','Ğ',' ') 952 call s:Accents('i','ì','í','î','ï','ĩ','į',' ',' ',' ',' ','ĭ',' ') 953 call s:Accents('I','Ì','Í','Î','Ï','Ĩ','İ',' ',' ',' ',' ','Ĭ',' ') 954 call s:Accents('l',' ','ĺ','ľ',' ',' ',' ','ļ',' ',' ',' ',' ','ľ') 955 call s:Accents('L',' ','Ĺ','Ľ',' ',' ',' ','Ļ',' ',' ',' ',' ','Ľ') 956 call s:Accents('n',' ','ń',' ',' ','ñ',' ','ņ',' ',' ',' ',' ','ň') 957 call s:Accents('N',' ','Ń',' ',' ','Ñ',' ','Ņ',' ',' ',' ',' ','Ň') 958 call s:Accents('o','ò','ó','ô','ö','õ','ȯ',' ','ő','ǫ',' ','ŏ',' ') 959 call s:Accents('O','Ò','Ó','Ô','Ö','Õ','Ȯ',' ','Ő','Ǫ',' ','Ŏ',' ') 960 call s:Accents('r',' ','ŕ',' ',' ',' ',' ','ŗ',' ',' ',' ',' ','ř') 961 call s:Accents('R',' ','Ŕ',' ',' ',' ',' ','Ŗ',' ',' ',' ',' ','Ř') 962 call s:Accents('s',' ','ś','ŝ',' ',' ',' ','ş',' ',' ',' ',' ','š') 963 call s:Accents('S',' ','Ś','Ŝ',' ',' ',' ','Ş',' ',' ',' ',' ','Š') 964 call s:Accents('t',' ',' ',' ',' ',' ',' ','ţ',' ',' ',' ',' ','ť') 965 call s:Accents('T',' ',' ',' ',' ',' ',' ','Ţ',' ',' ',' ',' ','Ť') 966 call s:Accents('u','ù','ú','û','ü','ũ',' ',' ','ű',' ','ů','ŭ',' ') 967 call s:Accents('U','Ù','Ú','Û','Ü','Ũ',' ',' ','Ű',' ','Ů','Ŭ',' ') 968 call s:Accents('w',' ',' ','ŵ',' ',' ',' ',' ',' ',' ',' ',' ',' ') 969 call s:Accents('W',' ',' ','Ŵ',' ',' ',' ',' ',' ',' ',' ',' ',' ') 970 call s:Accents('y','ỳ','ý','ŷ','ÿ','ỹ',' ',' ',' ',' ',' ',' ',' ') 971 call s:Accents('Y','Ỳ','Ý','Ŷ','Ÿ','Ỹ',' ',' ',' ',' ',' ',' ',' ') 972 call s:Accents('z',' ','ź',' ',' ',' ','ż',' ',' ',' ',' ',' ','ž') 973 call s:Accents('Z',' ','Ź',' ',' ',' ','Ż',' ',' ',' ',' ',' ','Ž') 974 call s:Accents('\\i','ì','í','î','ï','ĩ','į',' ',' ',' ',' ','ĭ',' ') 975 " \` \' \^ \" \~ \. \c \H \k \r \u \v 976 delfun s:Accents 977 syn match texAccent '\\aa\>' conceal cchar=å 978 syn match texAccent '\\AA\>' conceal cchar=Å 979 syn match texAccent '\\o\>' conceal cchar=ø 980 syn match texAccent '\\O\>' conceal cchar=Ø 981 syn match texLigature '\\AE\>' conceal cchar=Æ 982 syn match texLigature '\\ae\>' conceal cchar=æ 983 syn match texLigature '\\oe\>' conceal cchar=œ 984 syn match texLigature '\\OE\>' conceal cchar=Œ 985 syn match texLigature '\\ss\>' conceal cchar=ß 986 endif 987 endif 988endif 989 990" --------------------------------------------------------------------- 991" LaTeX synchronization: {{{1 992syn sync maxlines=200 993syn sync minlines=50 994 995syn sync match texSyncStop groupthere NONE "%stopzone\>" 996 997" Synchronization: {{{1 998" The $..$ and $$..$$ make for impossible sync patterns 999" (one can't tell if a "$$" starts or stops a math zone by itself) 1000" The following grouptheres coupled with minlines above 1001" help improve the odds of good syncing. 1002if !exists("tex_no_math") 1003 syn sync match texSyncMathZoneA groupthere NONE "\\end{abstract}" 1004 syn sync match texSyncMathZoneA groupthere NONE "\\end{center}" 1005 syn sync match texSyncMathZoneA groupthere NONE "\\end{description}" 1006 syn sync match texSyncMathZoneA groupthere NONE "\\end{enumerate}" 1007 syn sync match texSyncMathZoneA groupthere NONE "\\end{itemize}" 1008 syn sync match texSyncMathZoneA groupthere NONE "\\end{table}" 1009 syn sync match texSyncMathZoneA groupthere NONE "\\end{tabular}" 1010 syn sync match texSyncMathZoneA groupthere NONE "\\\(sub\)*section\>" 1011endif 1012 1013" --------------------------------------------------------------------- 1014" Highlighting: {{{1 1015if did_tex_syntax_inits == 1 1016 let did_tex_syntax_inits= 2 1017 " TeX highlighting groups which should share similar highlighting 1018 if !exists("g:tex_no_error") 1019 if !exists("tex_no_math") 1020 HiLink texBadMath texError 1021 HiLink texMathDelimBad texError 1022 HiLink texMathError texError 1023 if !b:tex_stylish 1024 HiLink texOnlyMath texError 1025 endif 1026 endif 1027 HiLink texError Error 1028 endif 1029 1030 HiLink texCite texRefZone 1031 HiLink texDefCmd texDef 1032 HiLink texDefName texDef 1033 HiLink texDocType texCmdName 1034 HiLink texDocTypeArgs texCmdArgs 1035 HiLink texInputFileOpt texCmdArgs 1036 HiLink texInputCurlies texDelimiter 1037 HiLink texLigature texSpecialChar 1038 if !exists("tex_no_math") 1039 HiLink texMathDelimSet1 texMathDelim 1040 HiLink texMathDelimSet2 texMathDelim 1041 HiLink texMathDelimKey texMathDelim 1042 HiLink texMathMatcher texMath 1043 HiLink texAccent texStatement 1044 HiLink texGreek texStatement 1045 HiLink texSuperscript texStatement 1046 HiLink texSubscript texStatement 1047 HiLink texMathSymbol texStatement 1048 HiLink texMathZoneV texMath 1049 HiLink texMathZoneW texMath 1050 HiLink texMathZoneX texMath 1051 HiLink texMathZoneY texMath 1052 HiLink texMathZoneV texMath 1053 HiLink texMathZoneZ texMath 1054 endif 1055 HiLink texSectionMarker texCmdName 1056 HiLink texSectionName texSection 1057 HiLink texSpaceCode texStatement 1058 HiLink texStyleStatement texStatement 1059 HiLink texTypeSize texType 1060 HiLink texTypeStyle texType 1061 1062 " Basic TeX highlighting groups 1063 HiLink texCmdArgs Number 1064 HiLink texCmdName Statement 1065 HiLink texComment Comment 1066 HiLink texDef Statement 1067 HiLink texDefParm Special 1068 HiLink texDelimiter Delimiter 1069 HiLink texInput Special 1070 HiLink texInputFile Special 1071 HiLink texLength Number 1072 HiLink texMath Special 1073 HiLink texMathDelim Statement 1074 HiLink texMathOper Operator 1075 HiLink texNewCmd Statement 1076 HiLink texNewEnv Statement 1077 HiLink texOption Number 1078 HiLink texRefZone Special 1079 HiLink texSection PreCondit 1080 HiLink texSpaceCodeChar Special 1081 HiLink texSpecialChar SpecialChar 1082 HiLink texStatement Statement 1083 HiLink texString String 1084 HiLink texTodo Todo 1085 HiLink texType Type 1086 HiLink texZone PreCondit 1087 1088 delcommand HiLink 1089endif 1090 1091" Current Syntax: {{{1 1092unlet b:extfname 1093let b:current_syntax = "tex" 1094" vim: ts=8 fdm=marker 1095