tex.vim 64 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341
  1. " Vim syntax file
  2. " Language: TeX
  3. " Maintainer: Charles E. Campbell <NcampObell@SdrPchip.AorgM-NOSPAM>
  4. " Last Change: Jun 29, 2020
  5. " Version: 119
  6. " URL: http://www.drchip.org/astronaut/vim/index.html#SYNTAX_TEX
  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. " 6. Please see :help latex-syntax for information on
  33. " syntax folding :help tex-folding
  34. " spell checking :help tex-nospell
  35. " commands and mathzones :help tex-runon
  36. " new command highlighting :help tex-morecommands
  37. " error highlighting :help tex-error
  38. " new math groups :help tex-math
  39. " new styles :help tex-style
  40. " using conceal mode :help tex-conceal
  41. " Version Clears: {{{1
  42. " quit when a syntax file was already loaded
  43. if exists("b:current_syntax")
  44. finish
  45. endif
  46. let s:keepcpo= &cpo
  47. set cpo&vim
  48. scriptencoding utf-8
  49. " by default, enable all region-based highlighting
  50. let s:tex_fast= "bcmMprsSvV"
  51. if exists("g:tex_fast")
  52. if type(g:tex_fast) != 1
  53. " g:tex_fast exists and is not a string, so
  54. " turn off all optional region-based highighting
  55. let s:tex_fast= ""
  56. else
  57. let s:tex_fast= g:tex_fast
  58. endif
  59. endif
  60. " let user determine which classes of concealment will be supported
  61. " a=accents/ligatures d=delimiters m=math symbols g=Greek s=superscripts/subscripts
  62. if !exists("g:tex_conceal")
  63. let s:tex_conceal= 'abdmgsS'
  64. else
  65. let s:tex_conceal= g:tex_conceal
  66. endif
  67. if !exists("g:tex_superscripts")
  68. let s:tex_superscripts= '[0-9a-zA-W.,:;+-<>/()=]'
  69. else
  70. let s:tex_superscripts= g:tex_superscripts
  71. endif
  72. if !exists("g:tex_subscripts")
  73. let s:tex_subscripts= '[0-9aehijklmnoprstuvx,+-/().]'
  74. else
  75. let s:tex_subscripts= g:tex_subscripts
  76. endif
  77. " Determine whether or not to use "*.sty" mode {{{1
  78. " The user may override the normal determination by setting
  79. " g:tex_stylish to 1 (for "*.sty" mode)
  80. " or to 0 else (normal "*.tex" mode)
  81. " or on a buffer-by-buffer basis with b:tex_stylish
  82. let s:extfname=expand("%:e")
  83. if exists("g:tex_stylish")
  84. let b:tex_stylish= g:tex_stylish
  85. elseif !exists("b:tex_stylish")
  86. if s:extfname == "sty" || s:extfname == "cls" || s:extfname == "clo" || s:extfname == "dtx" || s:extfname == "ltx"
  87. let b:tex_stylish= 1
  88. else
  89. let b:tex_stylish= 0
  90. endif
  91. endif
  92. " handle folding {{{1
  93. if !exists("g:tex_fold_enabled")
  94. let s:tex_fold_enabled= 0
  95. elseif g:tex_fold_enabled && !has("folding")
  96. let s:tex_fold_enabled= 0
  97. echomsg "Ignoring g:tex_fold_enabled=".g:tex_fold_enabled."; need to re-compile vim for +fold support"
  98. else
  99. let s:tex_fold_enabled= 1
  100. endif
  101. if s:tex_fold_enabled && &fdm == "manual"
  102. setl fdm=syntax
  103. endif
  104. if s:tex_fold_enabled && has("folding")
  105. com! -nargs=* TexFold <args> fold
  106. else
  107. com! -nargs=* TexFold <args>
  108. endif
  109. " (La)TeX keywords: uses the characters 0-9,a-z,A-Z,192-255 only... {{{1
  110. " but _ is the only one that causes problems.
  111. " One may override this iskeyword setting by providing
  112. " g:tex_isk
  113. if exists("g:tex_isk")
  114. if b:tex_stylish && g:tex_isk !~ '@'
  115. let b:tex_isk= '@,'.g:tex_isk
  116. else
  117. let b:tex_isk= g:tex_isk
  118. endif
  119. elseif b:tex_stylish
  120. let b:tex_isk="@,48-57,a-z,A-Z,192-255"
  121. else
  122. let b:tex_isk="48-57,a-z,A-Z,192-255"
  123. endif
  124. if (v:version == 704 && has("patch-7.4.1142")) || v:version > 704
  125. exe "syn iskeyword ".b:tex_isk
  126. else
  127. exe "setl isk=".b:tex_isk
  128. endif
  129. if exists("g:tex_no_error") && g:tex_no_error
  130. let s:tex_no_error= 1
  131. else
  132. let s:tex_no_error= 0
  133. endif
  134. if exists("g:tex_comment_nospell") && g:tex_comment_nospell
  135. let s:tex_comment_nospell= 1
  136. else
  137. let s:tex_comment_nospell= 0
  138. endif
  139. if exists("g:tex_nospell") && g:tex_nospell
  140. let s:tex_nospell = 1
  141. else
  142. let s:tex_nospell = 0
  143. endif
  144. if exists("g:tex_matchcheck")
  145. let s:tex_matchcheck= g:tex_matchcheck
  146. else
  147. let s:tex_matchcheck= '[({[]'
  148. endif
  149. if exists("g:tex_excludematcher")
  150. let s:tex_excludematcher= g:tex_excludematcher
  151. else
  152. let s:tex_excludematcher= 0
  153. endif
  154. " Clusters: {{{1
  155. " --------
  156. syn cluster texCmdGroup contains=texCmdBody,texComment,texDefParm,texDelimiter,texDocType,texInput,texLength,texLigature,texMathDelim,texMathOper,texNewCmd,texNewEnv,texRefZone,texSection,texBeginEnd,texBeginEndName,texSpecialChar,texStatement,texString,texTypeSize,texTypeStyle,@texMathZones
  157. if !s:tex_no_error
  158. syn cluster texCmdGroup add=texMathError
  159. endif
  160. syn cluster texEnvGroup contains=texMatcher,texMathDelim,texSpecialChar,texStatement
  161. syn 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,texBeginEnd,texSectionZone,texSpaceCode,texSpecialChar,texStatement,texString,texTypeSize,texTypeStyle,texZone,@texMathZones,texTitle,texAbstract,texBoldStyle,texItalStyle,texEmphStyle,texNoSpell
  162. syn cluster texBoldGroup contains=texAccent,texBadMath,texComment,texDefCmd,texDelimiter,texDocType,texInput,texInputFile,texLength,texLigature,texMathZoneV,texMathZoneW,texMathZoneX,texMathZoneY,texMathZoneZ,texNewCmd,texNewEnv,texOnlyMath,texOption,texParen,texRefZone,texSection,texBeginEnd,texSectionZone,texSpaceCode,texSpecialChar,texStatement,texString,texTypeSize,texTypeStyle,texZone,@texMathZones,texTitle,texAbstract,texBoldStyle,texBoldItalStyle,texNoSpell
  163. syn cluster texItalGroup contains=texAccent,texBadMath,texComment,texDefCmd,texDelimiter,texDocType,texInput,texInputFile,texLength,texLigature,texMathZoneV,texMathZoneW,texMathZoneX,texMathZoneY,texMathZoneZ,texNewCmd,texNewEnv,texOnlyMath,texOption,texParen,texRefZone,texSection,texBeginEnd,texSectionZone,texSpaceCode,texSpecialChar,texStatement,texString,texTypeSize,texTypeStyle,texZone,@texMathZones,texTitle,texAbstract,texItalStyle,texEmphStyle,texItalBoldStyle,texNoSpell
  164. if !s:tex_excludematcher
  165. syn cluster texBoldGroup add=texMatcher
  166. syn cluster texItalGroup add=texMatcher
  167. endif
  168. if !s:tex_nospell
  169. syn cluster texMatchGroup contains=texAccent,texBadMath,texComment,texDefCmd,texDelimiter,texDocType,texInput,texLength,texLigature,texMatcher,texNewCmd,texNewEnv,texOnlyMath,texParen,texRefZone,texSection,texSpecialChar,texStatement,texString,texTypeSize,texTypeStyle,texBoldStyle,texBoldItalStyle,texItalStyle,texItalBoldStyle,texZone,texInputFile,texOption,@Spell
  170. syn cluster texMatchNMGroup contains=texAccent,texBadMath,texComment,texDefCmd,texDelimiter,texDocType,texInput,texLength,texLigature,texMatcherNM,texNewCmd,texNewEnv,texOnlyMath,texParen,texRefZone,texSection,texSpecialChar,texStatement,texString,texTypeSize,texTypeStyle,texBoldStyle,texBoldItalStyle,texItalStyle,texItalBoldStyle,texZone,texInputFile,texOption,@Spell
  171. syn cluster texStyleGroup contains=texAccent,texBadMath,texComment,texDefCmd,texDelimiter,texDocType,texInput,texLength,texLigature,texNewCmd,texNewEnv,texOnlyMath,texParen,texRefZone,texSection,texSpecialChar,texStatement,texString,texTypeSize,texTypeStyle,texBoldStyle,texBoldItalStyle,texItalStyle,texItalBoldStyle,texZone,texInputFile,texOption,texStyleStatement,texStyleMatcher,@Spell
  172. else
  173. syn cluster texMatchGroup contains=texAccent,texBadMath,texComment,texDefCmd,texDelimiter,texDocType,texInput,texLength,texLigature,texMatcher,texNewCmd,texNewEnv,texOnlyMath,texParen,texRefZone,texSection,texSpecialChar,texStatement,texString,texTypeSize,texTypeStyle,texZone,texInputFile,texOption
  174. syn cluster texMatchNMGroup contains=texAccent,texBadMath,texComment,texDefCmd,texDelimiter,texDocType,texInput,texLength,texLigature,texMatcherNM,texNewCmd,texNewEnv,texOnlyMath,texParen,texRefZone,texSection,texSpecialChar,texStatement,texString,texTypeSize,texTypeStyle,texZone,texInputFile,texOption
  175. syn 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,texStyleMatcher
  176. endif
  177. syn cluster texPreambleMatchGroup contains=texAccent,texBadMath,texComment,texDefCmd,texDelimiter,texDocType,texInput,texLength,texLigature,texMatcherNM,texNewCmd,texNewEnv,texOnlyMath,texParen,texRefZone,texSection,texSpecialChar,texStatement,texString,texTitle,texTypeSize,texTypeStyle,texZone,texInputFile,texOption,texMathZoneZ
  178. syn cluster texRefGroup contains=texMatcher,texComment,texDelimiter
  179. if !exists("g:tex_no_math")
  180. syn cluster texPreambleMatchGroup contains=texAccent,texBadMath,texComment,texDefCmd,texDelimiter,texDocType,texInput,texLength,texLigature,texMatcherNM,texNewCmd,texNewEnv,texOnlyMath,texParen,texRefZone,texSection,texSpecialChar,texStatement,texString,texTitle,texTypeSize,texTypeStyle,texZone,texInputFile,texOption,texMathZoneZ
  181. syn cluster texMathZones contains=texMathZoneV,texMathZoneW,texMathZoneX,texMathZoneY,texMathZoneZ
  182. syn cluster texMatchGroup add=@texMathZones
  183. syn cluster texMathDelimGroup contains=texMathDelimBad,texMathDelimKey,texMathDelimSet1,texMathDelimSet2
  184. 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
  185. syn cluster texMathZoneGroup contains=texComment,texDelimiter,texLength,texMathDelim,texMathMatcher,texMathOper,texMathSymbol,texMathText,texRefZone,texSpecialChar,texStatement,texTypeSize,texTypeStyle
  186. if !s:tex_no_error
  187. syn cluster texMathMatchGroup add=texMathError
  188. syn cluster texMathZoneGroup add=texMathError
  189. endif
  190. syn cluster texMathZoneGroup add=@NoSpell
  191. " following used in the \part \chapter \section \subsection \subsubsection
  192. " \paragraph \subparagraph \author \title highlighting
  193. syn cluster texDocGroup contains=texPartZone,@texPartGroup
  194. syn cluster texPartGroup contains=texChapterZone,texSectionZone,texParaZone
  195. syn cluster texChapterGroup contains=texSectionZone,texParaZone
  196. syn cluster texSectionGroup contains=texSubSectionZone,texParaZone
  197. syn cluster texSubSectionGroup contains=texSubSubSectionZone,texParaZone
  198. syn cluster texSubSubSectionGroup contains=texParaZone
  199. syn cluster texParaGroup contains=texSubParaZone
  200. if has("conceal") && &enc == 'utf-8'
  201. syn cluster texMathZoneGroup add=texGreek,texSuperscript,texSubscript,texMathSymbol
  202. syn cluster texMathMatchGroup add=texGreek,texSuperscript,texSubscript,texMathSymbol
  203. endif
  204. endif
  205. " Try to flag {}, [], and () mismatches: {{{1
  206. if s:tex_fast =~# 'm'
  207. if !s:tex_no_error
  208. if s:tex_matchcheck =~ '{'
  209. syn region texMatcher matchgroup=Delimiter start="{" skip="\\\\\|\\[{}]" end="}" transparent contains=@texMatchGroup,texError
  210. syn region texMatcherNM matchgroup=Delimiter start="{" skip="\\\\\|\\[{}]" end="}" transparent contains=@texMatchNMGroup,texError
  211. endif
  212. if s:tex_matchcheck =~ '\['
  213. syn region texMatcher matchgroup=Delimiter start="\[" end="]" transparent contains=@texMatchGroup,texError,@NoSpell
  214. syn region texMatcherNM matchgroup=Delimiter start="\[" end="]" transparent contains=@texMatchNMGroup,texError,@NoSpell
  215. endif
  216. else
  217. if s:tex_matchcheck =~ '{'
  218. syn region texMatcher matchgroup=Delimiter start="{" skip="\\\\\|\\[{}]" end="}" transparent contains=@texMatchGroup
  219. syn region texMatcherNM matchgroup=Delimiter start="{" skip="\\\\\|\\[{}]" end="}" transparent contains=@texMatchNMGroup
  220. endif
  221. if s:tex_matchcheck =~ '\['
  222. syn region texMatcher matchgroup=Delimiter start="\[" end="]" transparent contains=@texMatchGroup
  223. syn region texMatcherNM matchgroup=Delimiter start="\[" end="]" transparent contains=@texMatchNMGroup
  224. endif
  225. endif
  226. if s:tex_matchcheck =~ '('
  227. if !s:tex_nospell
  228. syn region texParen start="(" end=")" transparent contains=@texMatchGroup,@Spell
  229. else
  230. syn region texParen start="(" end=")" transparent contains=@texMatchGroup
  231. endif
  232. endif
  233. endif
  234. if !s:tex_no_error
  235. if s:tex_matchcheck =~ '('
  236. syn match texError "[}\]]"
  237. else
  238. syn match texError "[}\])]"
  239. endif
  240. endif
  241. if s:tex_fast =~# 'M'
  242. if !exists("g:tex_no_math")
  243. if !s:tex_no_error
  244. syn match texMathError "}" contained
  245. endif
  246. syn region texMathMatcher matchgroup=Delimiter start="{" skip="\%(\\\\\)*\\}" end="}" end="%stopzone\>" contained contains=@texMathMatchGroup
  247. endif
  248. endif
  249. " TeX/LaTeX keywords: {{{1
  250. " Instead of trying to be All Knowing, I just match \..alphameric..
  251. " Note that *.tex files may not have "@" in their \commands
  252. if exists("g:tex_tex") || b:tex_stylish
  253. syn match texStatement "\\[a-zA-Z@]\+"
  254. else
  255. syn match texStatement "\\\a\+"
  256. if !s:tex_no_error
  257. syn match texError "\\\a*@[a-zA-Z@]*"
  258. endif
  259. endif
  260. " TeX/LaTeX delimiters: {{{1
  261. syn match texDelimiter "&"
  262. syn match texDelimiter "\\\\"
  263. " Tex/Latex Options: {{{1
  264. syn match texOption "[^\\]\zs#\d\+\|^#\d\+"
  265. " texAccent (tnx to Karim Belabas) avoids annoying highlighting for accents: {{{1
  266. if b:tex_stylish
  267. syn match texAccent "\\[bcdvuH][^a-zA-Z@]"me=e-1
  268. syn match texLigature "\\\([ijolL]\|ae\|oe\|ss\|AA\|AE\|OE\)[^a-zA-Z@]"me=e-1
  269. else
  270. syn match texAccent "\\[bcdvuH]\A"me=e-1
  271. syn match texLigature "\\\([ijolL]\|ae\|oe\|ss\|AA\|AE\|OE\)\A"me=e-1
  272. endif
  273. syn match texAccent "\\[bcdvuH]$"
  274. syn match texAccent +\\[=^.\~"`']+
  275. syn match texAccent +\\['=t'.c^ud"vb~Hr]{\a}+
  276. syn match texLigature "\\\([ijolL]\|ae\|oe\|ss\|AA\|AE\|OE\)$"
  277. " \begin{}/\end{} section markers: {{{1
  278. syn match texBeginEnd "\\begin\>\|\\end\>" nextgroup=texBeginEndName
  279. if s:tex_fast =~# 'm'
  280. syn region texBeginEndName matchgroup=Delimiter start="{" end="}" contained nextgroup=texBeginEndModifier contains=texComment
  281. syn region texBeginEndModifier matchgroup=Delimiter start="\[" end="]" contained contains=texComment,@texMathZones,@NoSpell
  282. endif
  283. " \documentclass, \documentstyle, \usepackage: {{{1
  284. syn match texDocType "\\documentclass\>\|\\documentstyle\>\|\\usepackage\>" nextgroup=texBeginEndName,texDocTypeArgs
  285. if s:tex_fast =~# 'm'
  286. syn region texDocTypeArgs matchgroup=Delimiter start="\[" end="]" contained nextgroup=texBeginEndName contains=texComment,@NoSpell
  287. endif
  288. " Preamble syntax-based folding support: {{{1
  289. if s:tex_fold_enabled && has("folding")
  290. syn region texPreamble transparent fold start='\zs\\documentclass\>' end='\ze\\begin{document}' contains=texStyle,@texPreambleMatchGroup
  291. endif
  292. " TeX input: {{{1
  293. syn match texInput "\\input\s\+[a-zA-Z/.0-9_^]\+"hs=s+7 contains=texStatement
  294. syn match texInputFile "\\include\(graphics\|list\)\=\(\[.\{-}\]\)\=\s*{.\{-}}" contains=texStatement,texInputCurlies,texInputFileOpt
  295. syn match texInputFile "\\\(epsfig\|input\|usepackage\)\s*\(\[.*\]\)\={.\{-}}" contains=texStatement,texInputCurlies,texInputFileOpt
  296. syn match texInputCurlies "[{}]" contained
  297. if s:tex_fast =~# 'm'
  298. syn region texInputFileOpt matchgroup=Delimiter start="\[" end="\]" contained contains=texComment
  299. endif
  300. " Type Styles (LaTeX 2.09): {{{1
  301. syn match texTypeStyle "\\rm\>"
  302. syn match texTypeStyle "\\em\>"
  303. syn match texTypeStyle "\\bf\>"
  304. syn match texTypeStyle "\\it\>"
  305. syn match texTypeStyle "\\sl\>"
  306. syn match texTypeStyle "\\sf\>"
  307. syn match texTypeStyle "\\sc\>"
  308. syn match texTypeStyle "\\tt\>"
  309. " Type Styles: attributes, commands, families, etc (LaTeX2E): {{{1
  310. if s:tex_conceal !~# 'b'
  311. syn match texTypeStyle "\\textbf\>"
  312. syn match texTypeStyle "\\textit\>"
  313. syn match texTypeStyle "\\emph\>"
  314. endif
  315. syn match texTypeStyle "\\textmd\>"
  316. syn match texTypeStyle "\\textrm\>"
  317. syn match texTypeStyle "\\mathbb\>"
  318. syn match texTypeStyle "\\mathbf\>"
  319. syn match texTypeStyle "\\mathcal\>"
  320. syn match texTypeStyle "\\mathfrak\>"
  321. syn match texTypeStyle "\\mathit\>"
  322. syn match texTypeStyle "\\mathnormal\>"
  323. syn match texTypeStyle "\\mathrm\>"
  324. syn match texTypeStyle "\\mathsf\>"
  325. syn match texTypeStyle "\\mathtt\>"
  326. syn match texTypeStyle "\\rmfamily\>"
  327. syn match texTypeStyle "\\sffamily\>"
  328. syn match texTypeStyle "\\ttfamily\>"
  329. syn match texTypeStyle "\\itshape\>"
  330. syn match texTypeStyle "\\scshape\>"
  331. syn match texTypeStyle "\\slshape\>"
  332. syn match texTypeStyle "\\upshape\>"
  333. syn match texTypeStyle "\\bfseries\>"
  334. syn match texTypeStyle "\\mdseries\>"
  335. " Some type sizes: {{{1
  336. syn match texTypeSize "\\tiny\>"
  337. syn match texTypeSize "\\scriptsize\>"
  338. syn match texTypeSize "\\footnotesize\>"
  339. syn match texTypeSize "\\small\>"
  340. syn match texTypeSize "\\normalsize\>"
  341. syn match texTypeSize "\\large\>"
  342. syn match texTypeSize "\\Large\>"
  343. syn match texTypeSize "\\LARGE\>"
  344. syn match texTypeSize "\\huge\>"
  345. syn match texTypeSize "\\Huge\>"
  346. " Spacecodes (TeX'isms): {{{1
  347. " \mathcode`\^^@="2201 \delcode`\(="028300 \sfcode`\)=0 \uccode`X=`X \lccode`x=`x
  348. syn match texSpaceCode "\\\(math\|cat\|del\|lc\|sf\|uc\)code`"me=e-1 nextgroup=texSpaceCodeChar
  349. syn match texSpaceCodeChar "`\\\=.\(\^.\)\==\(\d\|\"\x\{1,6}\|`.\)" contained
  350. " Sections, subsections, etc: {{{1
  351. if s:tex_fast =~# 'p'
  352. if !s:tex_nospell
  353. TexFold syn region texDocZone matchgroup=texSection start='\\begin\s*{\s*document\s*}' end='\\end\s*{\s*document\s*}' contains=@texFoldGroup,@texDocGroup,@Spell
  354. TexFold syn region texPartZone matchgroup=texSection start='\\part\>' end='\ze\s*\\\%(part\>\|end\s*{\s*document\s*}\)' contains=@texFoldGroup,@texPartGroup,@Spell
  355. TexFold syn region texChapterZone matchgroup=texSection start='\\chapter\>' end='\ze\s*\\\%(chapter\>\|part\>\|end\s*{\s*document\s*}\)' contains=@texFoldGroup,@texChapterGroup,@Spell
  356. TexFold syn region texSectionZone matchgroup=texSection start='\\section\>' end='\ze\s*\\\%(section\>\|chapter\>\|part\>\|end\s*{\s*document\s*}\)' contains=@texFoldGroup,@texSectionGroup,@Spell
  357. TexFold syn region texSubSectionZone matchgroup=texSection start='\\subsection\>' end='\ze\s*\\\%(\%(sub\)\=section\>\|chapter\>\|part\>\|end\s*{\s*document\s*}\)' contains=@texFoldGroup,@texSubSectionGroup,@Spell
  358. TexFold syn region texSubSubSectionZone matchgroup=texSection start='\\subsubsection\>' end='\ze\s*\\\%(\%(sub\)\{,2}section\>\|chapter\>\|part\>\|end\s*{\s*document\s*}\)' contains=@texFoldGroup,@texSubSubSectionGroup,@Spell
  359. TexFold syn region texParaZone matchgroup=texSection start='\\paragraph\>' end='\ze\s*\\\%(paragraph\>\|\%(sub\)*section\>\|chapter\>\|part\>\|end\s*{\s*document\s*}\)' contains=@texFoldGroup,@texParaGroup,@Spell
  360. TexFold syn region texSubParaZone matchgroup=texSection start='\\subparagraph\>' end='\ze\s*\\\%(\%(sub\)\=paragraph\>\|\%(sub\)*section\>\|chapter\>\|part\>\|end\s*{\s*document\s*}\)' contains=@texFoldGroup,@Spell
  361. TexFold syn region texTitle matchgroup=texSection start='\\\%(author\|title\)\>\s*{' end='}' contains=@texFoldGroup,@Spell
  362. TexFold syn region texAbstract matchgroup=texSection start='\\begin\s*{\s*abstract\s*}' end='\\end\s*{\s*abstract\s*}' contains=@texFoldGroup,@Spell
  363. else
  364. TexFold syn region texDocZone matchgroup=texSection start='\\begin\s*{\s*document\s*}' end='\\end\s*{\s*document\s*}' contains=@texFoldGroup,@texDocGroup
  365. TexFold syn region texPartZone matchgroup=texSection start='\\part\>' end='\ze\s*\\\%(part\>\|end\s*{\s*document\s*}\)' contains=@texFoldGroup,@texPartGroup
  366. TexFold syn region texChapterZone matchgroup=texSection start='\\chapter\>' end='\ze\s*\\\%(chapter\>\|part\>\|end\s*{\s*document\s*}\)' contains=@texFoldGroup,@texChapterGroup
  367. TexFold syn region texSectionZone matchgroup=texSection start='\\section\>' end='\ze\s*\\\%(section\>\|chapter\>\|part\>\|end\s*{\s*document\s*}\)' contains=@texFoldGroup,@texSectionGroup
  368. TexFold syn region texSubSectionZone matchgroup=texSection start='\\subsection\>' end='\ze\s*\\\%(\%(sub\)\=section\>\|chapter\>\|part\>\|end\s*{\s*document\s*}\)' contains=@texFoldGroup,@texSubSectionGroup
  369. TexFold syn region texSubSubSectionZone matchgroup=texSection start='\\subsubsection\>' end='\ze\s*\\\%(\%(sub\)\{,2}section\>\|chapter\>\|part\>\|end\s*{\s*document\s*}\)' contains=@texFoldGroup,@texSubSubSectionGroup
  370. TexFold syn region texParaZone matchgroup=texSection start='\\paragraph\>' end='\ze\s*\\\%(paragraph\>\|\%(sub\)*section\>\|chapter\>\|part\>\|end\s*{\s*document\s*}\)' contains=@texFoldGroup,@texParaGroup
  371. TexFold syn region texSubParaZone matchgroup=texSection start='\\subparagraph\>' end='\ze\s*\\\%(\%(sub\)\=paragraph\>\|\%(sub\)*section\>\|chapter\>\|part\>\|end\s*{\s*document\s*}\)' contains=@texFoldGroup
  372. TexFold syn region texTitle matchgroup=texSection start='\\\%(author\|title\)\>\s*{' end='}' contains=@texFoldGroup
  373. TexFold syn region texAbstract matchgroup=texSection start='\\begin\s*{\s*abstract\s*}' end='\\end\s*{\s*abstract\s*}' contains=@texFoldGroup
  374. endif
  375. endif
  376. " particular support for bold and italic {{{1
  377. if s:tex_fast =~# 'b'
  378. if s:tex_conceal =~# 'b'
  379. if !exists("g:tex_nospell") || !g:tex_nospell
  380. syn region texBoldStyle matchgroup=texTypeStyle start="\\textbf\s*{" matchgroup=texTypeStyle end="}" concealends contains=@texBoldGroup,@Spell
  381. syn region texBoldItalStyle matchgroup=texTypeStyle start="\\textit\s*{" matchgroup=texTypeStyle end="}" concealends contains=@texItalGroup,@Spell
  382. syn region texItalStyle matchgroup=texTypeStyle start="\\textit\s*{" matchgroup=texTypeStyle end="}" concealends contains=@texItalGroup,@Spell
  383. syn region texItalBoldStyle matchgroup=texTypeStyle start="\\textbf\s*{" matchgroup=texTypeStyle end="}" concealends contains=@texBoldGroup,@Spell
  384. syn region texEmphStyle matchgroup=texTypeStyle start="\\emph\s*{" matchgroup=texTypeStyle end="}" concealends contains=@texItalGroup,@Spell
  385. syn region texEmphStyle matchgroup=texTypeStyle start="\\texts[cfl]\s*{" matchgroup=texTypeStyle end="}" concealends contains=@texBoldGroup,@Spell
  386. syn region texEmphStyle matchgroup=texTypeStyle start="\\textup\s*{" matchgroup=texTypeStyle end="}" concealends contains=@texBoldGroup,@Spell
  387. syn region texEmphStyle matchgroup=texTypeStyle start="\\texttt\s*{" matchgroup=texTypeStyle end="}" concealends contains=@texBoldGroup,@Spell
  388. else
  389. syn region texBoldStyle matchgroup=texTypeStyle start="\\textbf\s*{" matchgroup=texTypeStyle end="}" concealends contains=@texBoldGroup
  390. syn region texBoldItalStyle matchgroup=texTypeStyle start="\\textit\s*{" matchgroup=texTypeStyle end="}" concealends contains=@texItalGroup
  391. syn region texItalStyle matchgroup=texTypeStyle start="\\textit\s*{" matchgroup=texTypeStyle end="}" concealends contains=@texItalGroup
  392. syn region texItalBoldStyle matchgroup=texTypeStyle start="\\textbf\s*{" matchgroup=texTypeStyle end="}" concealends contains=@texBoldGroup
  393. syn region texEmphStyle matchgroup=texTypeStyle start="\\emph\s*{" matchgroup=texTypeStyle end="}" concealends contains=@texItalGroup
  394. syn region texEmphStyle matchgroup=texTypeStyle start="\\texts[cfl]\s*{" matchgroup=texTypeStyle end="}" concealends contains=@texEmphGroup
  395. syn region texEmphStyle matchgroup=texTypeStyle start="\\textup\s*{" matchgroup=texTypeStyle end="}" concealends contains=@texEmphGroup
  396. syn region texEmphStyle matchgroup=texTypeStyle start="\\texttt\s*{" matchgroup=texTypeStyle end="}" concealends contains=@texEmphGroup
  397. endif
  398. endif
  399. endif
  400. " Bad Math (mismatched): {{{1
  401. if !exists("g:tex_no_math") && !s:tex_no_error
  402. syn match texBadMath "\\end\s*{\s*\(array\|[bBpvV]matrix\|split\|smallmatrix\)\s*}"
  403. syn match texBadMath "\\end\s*{\s*\(displaymath\|equation\|eqnarray\|math\)\*\=\s*}"
  404. syn match texBadMath "\\[\])]"
  405. endif
  406. " Math Zones: {{{1
  407. if !exists("g:tex_no_math")
  408. " TexNewMathZone: function creates a mathzone with the given suffix and mathzone name. {{{2
  409. " Starred forms are created if starform is true. Starred
  410. " forms have syntax group and synchronization groups with a
  411. " "S" appended. Handles: cluster, syntax, sync, and highlighting.
  412. fun! TexNewMathZone(sfx,mathzone,starform)
  413. let grpname = "texMathZone".a:sfx
  414. let syncname = "texSyncMathZone".a:sfx
  415. if s:tex_fold_enabled
  416. let foldcmd= " fold"
  417. else
  418. let foldcmd= ""
  419. endif
  420. exe "syn cluster texMathZones add=".grpname
  421. if s:tex_fast =~# 'M'
  422. exe 'syn region '.grpname.' start='."'".'\\begin\s*{\s*'.a:mathzone.'\s*}'."'".' end='."'".'\\end\s*{\s*'.a:mathzone.'\s*}'."'".' keepend contains=@texMathZoneGroup'.foldcmd
  423. exe 'syn sync match '.syncname.' grouphere '.grpname.' "\\begin\s*{\s*'.a:mathzone.'\*\s*}"'
  424. exe 'syn sync match '.syncname.' grouphere '.grpname.' "\\begin\s*{\s*'.a:mathzone.'\*\s*}"'
  425. endif
  426. exe 'hi def link '.grpname.' texMath'
  427. if a:starform
  428. let grpname = "texMathZone".a:sfx.'S'
  429. let syncname = "texSyncMathZone".a:sfx.'S'
  430. exe "syn cluster texMathZones add=".grpname
  431. if s:tex_fast =~# 'M'
  432. exe 'syn region '.grpname.' start='."'".'\\begin\s*{\s*'.a:mathzone.'\*\s*}'."'".' end='."'".'\\end\s*{\s*'.a:mathzone.'\*\s*}'."'".' keepend contains=@texMathZoneGroup'.foldcmd
  433. exe 'syn sync match '.syncname.' grouphere '.grpname.' "\\begin\s*{\s*'.a:mathzone.'\*\s*}"'
  434. exe 'syn sync match '.syncname.' grouphere '.grpname.' "\\begin\s*{\s*'.a:mathzone.'\*\s*}"'
  435. endif
  436. exe 'hi def link '.grpname.' texMath'
  437. endif
  438. endfun
  439. " Standard Math Zones: {{{2
  440. call TexNewMathZone("A","displaymath",1)
  441. call TexNewMathZone("B","eqnarray",1)
  442. call TexNewMathZone("C","equation",1)
  443. call TexNewMathZone("D","math",1)
  444. " Inline Math Zones: {{{2
  445. if s:tex_fast =~# 'M'
  446. if has("conceal") && &enc == 'utf-8' && s:tex_conceal =~# 'd'
  447. syn region texMathZoneV matchgroup=Delimiter start="\\(" matchgroup=Delimiter end="\\)\|%stopzone\>" keepend concealends contains=@texMathZoneGroup
  448. syn region texMathZoneW matchgroup=Delimiter start="\\\[" matchgroup=Delimiter end="\\]\|%stopzone\>" keepend concealends contains=@texMathZoneGroup
  449. syn region texMathZoneX matchgroup=Delimiter start="\$" skip="\\\\\|\\\$" matchgroup=Delimiter end="\$" end="%stopzone\>" concealends contains=@texMathZoneGroup
  450. syn region texMathZoneY matchgroup=Delimiter start="\$\$" matchgroup=Delimiter end="\$\$" end="%stopzone\>" keepend concealends contains=@texMathZoneGroup
  451. else
  452. syn region texMathZoneV matchgroup=Delimiter start="\\(" matchgroup=Delimiter end="\\)\|%stopzone\>" keepend contains=@texMathZoneGroup
  453. syn region texMathZoneW matchgroup=Delimiter start="\\\[" matchgroup=Delimiter end="\\]\|%stopzone\>" keepend contains=@texMathZoneGroup
  454. syn region texMathZoneX matchgroup=Delimiter start="\$" skip="\%(\\\\\)*\\\$" matchgroup=Delimiter end="\$" end="%stopzone\>" contains=@texMathZoneGroup
  455. syn region texMathZoneY matchgroup=Delimiter start="\$\$" matchgroup=Delimiter end="\$\$" end="%stopzone\>" keepend contains=@texMathZoneGroup
  456. endif
  457. syn region texMathZoneZ matchgroup=texStatement start="\\ensuremath\s*{" matchgroup=texStatement end="}" end="%stopzone\>" contains=@texMathZoneGroup
  458. endif
  459. syn match texMathOper "[_^=]" contained
  460. " Text Inside Math Zones: {{{2
  461. if s:tex_fast =~# 'M'
  462. if !exists("g:tex_nospell") || !g:tex_nospell
  463. syn region texMathText matchgroup=texStatement start='\\\(\(inter\)\=text\|mbox\)\s*{' end='}' contains=@texFoldGroup,@Spell
  464. else
  465. syn region texMathText matchgroup=texStatement start='\\\(\(inter\)\=text\|mbox\)\s*{' end='}' contains=@texFoldGroup
  466. endif
  467. endif
  468. " \left..something.. and \right..something.. support: {{{2
  469. syn match texMathDelimBad contained "\S"
  470. if has("conceal") && &enc == 'utf-8' && s:tex_conceal =~# 'm'
  471. syn match texMathDelim contained "\\left\["
  472. syn match texMathDelim contained "\\left\\{" skipwhite nextgroup=texMathDelimSet1,texMathDelimSet2,texMathDelimBad contains=texMathSymbol cchar={
  473. syn match texMathDelim contained "\\right\\}" skipwhite nextgroup=texMathDelimSet1,texMathDelimSet2,texMathDelimBad contains=texMathSymbol cchar=}
  474. let s:texMathDelimList=[
  475. \ ['<' , '<'] ,
  476. \ ['>' , '>'] ,
  477. \ ['(' , '('] ,
  478. \ [')' , ')'] ,
  479. \ ['\[' , '['] ,
  480. \ [']' , ']'] ,
  481. \ ['\\{' , '{'] ,
  482. \ ['\\}' , '}'] ,
  483. \ ['|' , '|'] ,
  484. \ ['\\|' , '‖'] ,
  485. \ ['\\backslash' , '\'] ,
  486. \ ['\\downarrow' , '↓'] ,
  487. \ ['\\Downarrow' , '⇓'] ,
  488. \ ['\\lbrace' , '['] ,
  489. \ ['\\lceil' , '⌈'] ,
  490. \ ['\\lfloor' , '⌊'] ,
  491. \ ['\\lgroup' , '⌊'] ,
  492. \ ['\\lmoustache' , '⎛'] ,
  493. \ ['\\rbrace' , ']'] ,
  494. \ ['\\rceil' , '⌉'] ,
  495. \ ['\\rfloor' , '⌋'] ,
  496. \ ['\\rgroup' , '⌋'] ,
  497. \ ['\\rmoustache' , '⎞'] ,
  498. \ ['\\uparrow' , '↑'] ,
  499. \ ['\\Uparrow' , '↑'] ,
  500. \ ['\\updownarrow', '↕'] ,
  501. \ ['\\Updownarrow', '⇕']]
  502. if &ambw == "double" || exists("g:tex_usedblwidth")
  503. let s:texMathDelimList= s:texMathDelimList + [
  504. \ ['\\langle' , '〈'] ,
  505. \ ['\\rangle' , '〉']]
  506. else
  507. let s:texMathDelimList= s:texMathDelimList + [
  508. \ ['\\langle' , '<'] ,
  509. \ ['\\rangle' , '>']]
  510. endif
  511. syn match texMathDelim '\\[bB]igg\=[lr]' contained nextgroup=texMathDelimBad
  512. for texmath in s:texMathDelimList
  513. exe "syn match texMathDelim '\\\\[bB]igg\\=[lr]\\=".texmath[0]."' contained conceal cchar=".texmath[1]
  514. endfor
  515. else
  516. syn match texMathDelim contained "\\\(left\|right\)\>" skipwhite nextgroup=texMathDelimSet1,texMathDelimSet2,texMathDelimBad
  517. syn match texMathDelim contained "\\[bB]igg\=[lr]\=\>" skipwhite nextgroup=texMathDelimSet1,texMathDelimSet2,texMathDelimBad
  518. syn match texMathDelimSet2 contained "\\" nextgroup=texMathDelimKey,texMathDelimBad
  519. syn match texMathDelimSet1 contained "[<>()[\]|/.]\|\\[{}|]"
  520. syn keyword texMathDelimKey contained backslash lceil lVert rgroup uparrow
  521. syn keyword texMathDelimKey contained downarrow lfloor rangle rmoustache Uparrow
  522. syn keyword texMathDelimKey contained Downarrow lgroup rbrace rvert updownarrow
  523. syn keyword texMathDelimKey contained langle lmoustache rceil rVert Updownarrow
  524. syn keyword texMathDelimKey contained lbrace lvert rfloor
  525. endif
  526. syn match texMathDelim contained "\\\(left\|right\)arrow\>\|\<\([aA]rrow\|brace\)\=vert\>"
  527. syn match texMathDelim contained "\\lefteqn\>"
  528. endif
  529. " Special TeX characters ( \$ \& \% \# \{ \} \_ \S \P ) : {{{1
  530. syn match texSpecialChar "\\[$&%#{}_]"
  531. if b:tex_stylish
  532. syn match texSpecialChar "\\[SP@][^a-zA-Z@]"me=e-1
  533. else
  534. syn match texSpecialChar "\\[SP@]\A"me=e-1
  535. endif
  536. syn match texSpecialChar "\\\\"
  537. if !exists("g:tex_no_math")
  538. syn match texOnlyMath "[_^]"
  539. endif
  540. syn match texSpecialChar "\^\^[0-9a-f]\{2}\|\^\^\S"
  541. if s:tex_conceal !~# 'S'
  542. syn match texSpecialChar '\\glq\>' contained conceal cchar=‚
  543. syn match texSpecialChar '\\grq\>' contained conceal cchar=‘
  544. syn match texSpecialChar '\\glqq\>' contained conceal cchar=„
  545. syn match texSpecialChar '\\grqq\>' contained conceal cchar=“
  546. syn match texSpecialChar '\\hyp\>' contained conceal cchar=-
  547. endif
  548. " Comments: {{{1
  549. " Normal TeX LaTeX : %....
  550. " Documented TeX Format: ^^A... -and- leading %s (only)
  551. if !s:tex_comment_nospell
  552. syn cluster texCommentGroup contains=texTodo,@Spell
  553. else
  554. syn cluster texCommentGroup contains=texTodo,@NoSpell
  555. endif
  556. syn case ignore
  557. syn keyword texTodo contained combak fixme todo xxx
  558. syn case match
  559. if s:extfname == "dtx"
  560. syn match texComment "\^\^A.*$" contains=@texCommentGroup
  561. syn match texComment "^%\+" contains=@texCommentGroup
  562. else
  563. if s:tex_fold_enabled
  564. " allows syntax-folding of 2 or more contiguous comment lines
  565. " single-line comments are not folded
  566. syn match texComment "%.*$" contains=@texCommentGroup
  567. if s:tex_fast =~# 'c'
  568. TexFold syn region texComment start="^\zs\s*%.*\_s*%" skip="^\s*%" end='^\ze\s*[^%]' contains=@texCommentGroup
  569. TexFold syn region texNoSpell contained matchgroup=texComment start="%\s*nospell\s*{" end="%\s*nospell\s*}" contains=@texFoldGroup,@NoSpell
  570. endif
  571. else
  572. syn match texComment "%.*$" contains=@texCommentGroup
  573. if s:tex_fast =~# 'c'
  574. syn region texNoSpell contained matchgroup=texComment start="%\s*nospell\s*{" end="%\s*nospell\s*}" contains=@texFoldGroup,@NoSpell
  575. endif
  576. endif
  577. endif
  578. " %begin-include ... %end-include acts like a texDocZone for \include'd files. Permits spell checking, for example, in such files.
  579. if !s:tex_nospell
  580. TexFold syn region texDocZone matchgroup=texSection start='^\s*%begin-include\>' end='^\s*%end-include\>' contains=@texFoldGroup,@texDocGroup,@Spell
  581. else
  582. TexFold syn region texDocZone matchgroup=texSection start='^\s*%begin-include\>' end='^\s*%end-include\>' contains=@texFoldGroup,@texDocGroup
  583. endif
  584. " Separate lines used for verb` and verb# so that the end conditions {{{1
  585. " will appropriately terminate.
  586. " If g:tex_verbspell exists, then verbatim texZones will permit spellchecking there.
  587. if s:tex_fast =~# 'v'
  588. if exists("g:tex_verbspell") && g:tex_verbspell
  589. syn region texZone start="\\begin{[vV]erbatim}" end="\\end{[vV]erbatim}\|%stopzone\>" contains=@Spell
  590. " listings package:
  591. if b:tex_stylish
  592. syn region texZone start="\\verb\*\=\z([^\ta-zA-Z@]\)" end="\z1\|%stopzone\>" contains=@Spell
  593. else
  594. syn region texZone start="\\verb\*\=\z([^\ta-zA-Z]\)" end="\z1\|%stopzone\>" contains=@Spell
  595. endif
  596. else
  597. syn region texZone start="\\begin{[vV]erbatim}" end="\\end{[vV]erbatim}\|%stopzone\>"
  598. if b:tex_stylish
  599. syn region texZone start="\\verb\*\=\z([^\ta-zA-Z@]\)" end="\z1\|%stopzone\>"
  600. else
  601. syn region texZone start="\\verb\*\=\z([^\ta-zA-Z]\)" end="\z1\|%stopzone\>"
  602. endif
  603. endif
  604. endif
  605. " Tex Reference Zones: {{{1
  606. if s:tex_fast =~# 'r'
  607. syn region texZone matchgroup=texStatement start="@samp{" end="}\|%stopzone\>" contains=@texRefGroup
  608. syn region texRefZone matchgroup=texStatement start="\\nocite{" end="}\|%stopzone\>" contains=@texRefGroup
  609. syn region texRefZone matchgroup=texStatement start="\\bibliography{" end="}\|%stopzone\>" contains=@texRefGroup
  610. syn region texRefZone matchgroup=texStatement start="\\label{" end="}\|%stopzone\>" contains=@texRefGroup
  611. syn region texRefZone matchgroup=texStatement start="\\\(page\|eq\)ref{" end="}\|%stopzone\>" contains=@texRefGroup
  612. syn region texRefZone matchgroup=texStatement start="\\v\=ref{" end="}\|%stopzone\>" contains=@texRefGroup
  613. syn region texRefOption contained matchgroup=Delimiter start='\[' end=']' contains=@texRefGroup,texRefZone nextgroup=texRefOption,texCite
  614. syn region texCite contained matchgroup=Delimiter start='{' end='}' contains=@texRefGroup,texRefZone,texCite
  615. endif
  616. syn match texRefZone '\\cite\%([tp]\*\=\)\=\>' nextgroup=texRefOption,texCite
  617. " Handle newcommand, newenvironment : {{{1
  618. syn match texNewCmd "\\newcommand\>" nextgroup=texCmdName skipwhite skipnl
  619. if s:tex_fast =~# 'V'
  620. syn region texCmdName contained matchgroup=Delimiter start="{"rs=s+1 end="}" nextgroup=texCmdArgs,texCmdBody skipwhite skipnl
  621. syn region texCmdArgs contained matchgroup=Delimiter start="\["rs=s+1 end="]" nextgroup=texCmdBody skipwhite skipnl
  622. syn region texCmdBody contained matchgroup=Delimiter start="{"rs=s+1 skip="\\\\\|\\[{}]" matchgroup=Delimiter end="}" contains=@texCmdGroup
  623. endif
  624. syn match texNewEnv "\\newenvironment\>" nextgroup=texEnvName skipwhite skipnl
  625. if s:tex_fast =~# 'V'
  626. syn region texEnvName contained matchgroup=Delimiter start="{"rs=s+1 end="}" nextgroup=texEnvBgn skipwhite skipnl
  627. syn region texEnvBgn contained matchgroup=Delimiter start="{"rs=s+1 end="}" nextgroup=texEnvEnd skipwhite skipnl contains=@texEnvGroup
  628. syn region texEnvEnd contained matchgroup=Delimiter start="{"rs=s+1 end="}" skipwhite skipnl contains=@texEnvGroup
  629. endif
  630. " Definitions/Commands: {{{1
  631. syn match texDefCmd "\\def\>" nextgroup=texDefName skipwhite skipnl
  632. if b:tex_stylish
  633. syn match texDefName contained "\\[a-zA-Z@]\+" nextgroup=texDefParms,texCmdBody skipwhite skipnl
  634. syn match texDefName contained "\\[^a-zA-Z@]" nextgroup=texDefParms,texCmdBody skipwhite skipnl
  635. else
  636. syn match texDefName contained "\\\a\+" nextgroup=texDefParms,texCmdBody skipwhite skipnl
  637. syn match texDefName contained "\\\A" nextgroup=texDefParms,texCmdBody skipwhite skipnl
  638. endif
  639. syn match texDefParms contained "#[^{]*" contains=texDefParm nextgroup=texCmdBody skipwhite skipnl
  640. syn match texDefParm contained "#\d\+"
  641. " TeX Lengths: {{{1
  642. syn match texLength "\<\d\+\([.,]\d\+\)\=\s*\(true\)\=\s*\(bp\|cc\|cm\|dd\|em\|ex\|in\|mm\|pc\|pt\|sp\)\>"
  643. " TeX String Delimiters: {{{1
  644. syn match texString "\(``\|''\|,,\)"
  645. " makeatletter -- makeatother sections
  646. if !s:tex_no_error
  647. if s:tex_fast =~# 'S'
  648. syn region texStyle matchgroup=texStatement start='\\makeatletter' end='\\makeatother' contains=@texStyleGroup contained
  649. endif
  650. syn match texStyleStatement "\\[a-zA-Z@]\+" contained
  651. if s:tex_fast =~# 'S'
  652. syn region texStyleMatcher matchgroup=Delimiter start="{" skip="\\\\\|\\[{}]" end="}" contains=@texStyleGroup,texError contained
  653. syn region texStyleMatcher matchgroup=Delimiter start="\[" end="]" contains=@texStyleGroup,texError contained
  654. endif
  655. endif
  656. " Conceal mode support (supports set cole=2) {{{1
  657. if has("conceal") && &enc == 'utf-8'
  658. " Math Symbols {{{2
  659. " (many of these symbols were contributed by Björn Winckler)
  660. if s:tex_conceal =~# 'm'
  661. let s:texMathList=[
  662. \ ['|' , '‖'],
  663. \ ['aleph' , 'ℵ'],
  664. \ ['amalg' , '∐'],
  665. \ ['angle' , '∠'],
  666. \ ['approx' , '≈'],
  667. \ ['ast' , '∗'],
  668. \ ['asymp' , '≍'],
  669. \ ['backslash' , '∖'],
  670. \ ['bigcap' , '∩'],
  671. \ ['bigcirc' , '○'],
  672. \ ['bigcup' , '∪'],
  673. \ ['bigodot' , '⊙'],
  674. \ ['bigoplus' , '⊕'],
  675. \ ['bigotimes' , '⊗'],
  676. \ ['bigsqcup' , '⊔'],
  677. \ ['bigtriangledown', '∇'],
  678. \ ['bigtriangleup' , '∆'],
  679. \ ['bigvee' , '⋁'],
  680. \ ['bigwedge' , '⋀'],
  681. \ ['bot' , '⊥'],
  682. \ ['bowtie' , '⋈'],
  683. \ ['bullet' , '•'],
  684. \ ['cap' , '∩'],
  685. \ ['cdot' , '·'],
  686. \ ['cdots' , '⋯'],
  687. \ ['circ' , '∘'],
  688. \ ['clubsuit' , '♣'],
  689. \ ['cong' , '≅'],
  690. \ ['coprod' , '∐'],
  691. \ ['copyright' , '©'],
  692. \ ['cup' , '∪'],
  693. \ ['dagger' , '†'],
  694. \ ['dashv' , '⊣'],
  695. \ ['ddagger' , '‡'],
  696. \ ['ddots' , '⋱'],
  697. \ ['diamond' , '⋄'],
  698. \ ['diamondsuit' , '♢'],
  699. \ ['div' , '÷'],
  700. \ ['doteq' , '≐'],
  701. \ ['dots' , '…'],
  702. \ ['downarrow' , '↓'],
  703. \ ['Downarrow' , '⇓'],
  704. \ ['ell' , 'ℓ'],
  705. \ ['emptyset' , '∅'],
  706. \ ['equiv' , '≡'],
  707. \ ['exists' , '∃'],
  708. \ ['flat' , '♭'],
  709. \ ['forall' , '∀'],
  710. \ ['frown' , '⁔'],
  711. \ ['ge' , '≥'],
  712. \ ['geq' , '≥'],
  713. \ ['gets' , '←'],
  714. \ ['gg' , '⟫'],
  715. \ ['hbar' , 'ℏ'],
  716. \ ['heartsuit' , '♡'],
  717. \ ['hookleftarrow' , '↩'],
  718. \ ['hookrightarrow' , '↪'],
  719. \ ['iff' , '⇔'],
  720. \ ['Im' , 'ℑ'],
  721. \ ['imath' , 'ɩ'],
  722. \ ['in' , '∈'],
  723. \ ['infty' , '∞'],
  724. \ ['int' , '∫'],
  725. \ ['jmath' , '𝚥'],
  726. \ ['land' , '∧'],
  727. \ ['lceil' , '⌈'],
  728. \ ['ldots' , '…'],
  729. \ ['le' , '≤'],
  730. \ ['left|' , '|'],
  731. \ ['left\\|' , '‖'],
  732. \ ['left(' , '('],
  733. \ ['left\[' , '['],
  734. \ ['left\\{' , '{'],
  735. \ ['leftarrow' , '←'],
  736. \ ['Leftarrow' , '⇐'],
  737. \ ['leftharpoondown', '↽'],
  738. \ ['leftharpoonup' , '↼'],
  739. \ ['leftrightarrow' , '↔'],
  740. \ ['Leftrightarrow' , '⇔'],
  741. \ ['leq' , '≤'],
  742. \ ['leq' , '≤'],
  743. \ ['lfloor' , '⌊'],
  744. \ ['ll' , '≪'],
  745. \ ['lmoustache' , '╭'],
  746. \ ['lor' , '∨'],
  747. \ ['mapsto' , '↦'],
  748. \ ['mid' , '∣'],
  749. \ ['models' , '╞'],
  750. \ ['mp' , '∓'],
  751. \ ['nabla' , '∇'],
  752. \ ['natural' , '♮'],
  753. \ ['ne' , '≠'],
  754. \ ['nearrow' , '↗'],
  755. \ ['neg' , '¬'],
  756. \ ['neq' , '≠'],
  757. \ ['ni' , '∋'],
  758. \ ['notin' , '∉'],
  759. \ ['nwarrow' , '↖'],
  760. \ ['odot' , '⊙'],
  761. \ ['oint' , '∮'],
  762. \ ['ominus' , '⊖'],
  763. \ ['oplus' , '⊕'],
  764. \ ['oslash' , '⊘'],
  765. \ ['otimes' , '⊗'],
  766. \ ['owns' , '∋'],
  767. \ ['P' , '¶'],
  768. \ ['parallel' , '║'],
  769. \ ['partial' , '∂'],
  770. \ ['perp' , '⊥'],
  771. \ ['pm' , '±'],
  772. \ ['prec' , '≺'],
  773. \ ['preceq' , '⪯'],
  774. \ ['prime' , '′'],
  775. \ ['prod' , '∏'],
  776. \ ['propto' , '∝'],
  777. \ ['rceil' , '⌉'],
  778. \ ['Re' , 'ℜ'],
  779. \ ['quad' , ' '],
  780. \ ['qquad' , ' '],
  781. \ ['rfloor' , '⌋'],
  782. \ ['right|' , '|'],
  783. \ ['right\\|' , '‖'],
  784. \ ['right)' , ')'],
  785. \ ['right]' , ']'],
  786. \ ['right\\}' , '}'],
  787. \ ['rightarrow' , '→'],
  788. \ ['Rightarrow' , '⇒'],
  789. \ ['rightleftharpoons', '⇌'],
  790. \ ['rmoustache' , '╮'],
  791. \ ['S' , '§'],
  792. \ ['searrow' , '↘'],
  793. \ ['setminus' , '∖'],
  794. \ ['sharp' , '♯'],
  795. \ ['sim' , '∼'],
  796. \ ['simeq' , '⋍'],
  797. \ ['smile' , '‿'],
  798. \ ['spadesuit' , '♠'],
  799. \ ['sqcap' , '⊓'],
  800. \ ['sqcup' , '⊔'],
  801. \ ['sqsubset' , '⊏'],
  802. \ ['sqsubseteq' , '⊑'],
  803. \ ['sqsupset' , '⊐'],
  804. \ ['sqsupseteq' , '⊒'],
  805. \ ['star' , '✫'],
  806. \ ['subset' , '⊂'],
  807. \ ['subseteq' , '⊆'],
  808. \ ['succ' , '≻'],
  809. \ ['succeq' , '⪰'],
  810. \ ['sum' , '∑'],
  811. \ ['supset' , '⊃'],
  812. \ ['supseteq' , '⊇'],
  813. \ ['surd' , '√'],
  814. \ ['swarrow' , '↙'],
  815. \ ['times' , '×'],
  816. \ ['to' , '→'],
  817. \ ['top' , '⊤'],
  818. \ ['triangle' , '∆'],
  819. \ ['triangleleft' , '⊲'],
  820. \ ['triangleright' , '⊳'],
  821. \ ['uparrow' , '↑'],
  822. \ ['Uparrow' , '⇑'],
  823. \ ['updownarrow' , '↕'],
  824. \ ['Updownarrow' , '⇕'],
  825. \ ['vdash' , '⊢'],
  826. \ ['vdots' , '⋮'],
  827. \ ['vee' , '∨'],
  828. \ ['wedge' , '∧'],
  829. \ ['wp' , '℘'],
  830. \ ['wr' , '≀']]
  831. if &ambw == "double" || exists("g:tex_usedblwidth")
  832. let s:texMathList= s:texMathList + [
  833. \ ['right\\rangle' , '〉'],
  834. \ ['left\\langle' , '〈']]
  835. else
  836. let s:texMathList= s:texMathList + [
  837. \ ['right\\rangle' , '>'],
  838. \ ['left\\langle' , '<']]
  839. endif
  840. for texmath in s:texMathList
  841. if texmath[0] =~# '\w$'
  842. exe "syn match texMathSymbol '\\\\".texmath[0]."\\>' contained conceal cchar=".texmath[1]
  843. else
  844. exe "syn match texMathSymbol '\\\\".texmath[0]."' contained conceal cchar=".texmath[1]
  845. endif
  846. endfor
  847. if &ambw == "double"
  848. syn match texMathSymbol '\\gg\>' contained conceal cchar=≫
  849. syn match texMathSymbol '\\ll\>' contained conceal cchar=≪
  850. else
  851. syn match texMathSymbol '\\gg\>' contained conceal cchar=⟫
  852. syn match texMathSymbol '\\ll\>' contained conceal cchar=⟪
  853. endif
  854. syn match texMathSymbol '\\hat{a}' contained conceal cchar=â
  855. syn match texMathSymbol '\\hat{A}' contained conceal cchar=Â
  856. syn match texMathSymbol '\\hat{c}' contained conceal cchar=ĉ
  857. syn match texMathSymbol '\\hat{C}' contained conceal cchar=Ĉ
  858. syn match texMathSymbol '\\hat{e}' contained conceal cchar=ê
  859. syn match texMathSymbol '\\hat{E}' contained conceal cchar=Ê
  860. syn match texMathSymbol '\\hat{g}' contained conceal cchar=ĝ
  861. syn match texMathSymbol '\\hat{G}' contained conceal cchar=Ĝ
  862. syn match texMathSymbol '\\hat{i}' contained conceal cchar=î
  863. syn match texMathSymbol '\\hat{I}' contained conceal cchar=Î
  864. syn match texMathSymbol '\\hat{o}' contained conceal cchar=ô
  865. syn match texMathSymbol '\\hat{O}' contained conceal cchar=Ô
  866. syn match texMathSymbol '\\hat{s}' contained conceal cchar=ŝ
  867. syn match texMathSymbol '\\hat{S}' contained conceal cchar=Ŝ
  868. syn match texMathSymbol '\\hat{u}' contained conceal cchar=û
  869. syn match texMathSymbol '\\hat{U}' contained conceal cchar=Û
  870. syn match texMathSymbol '\\hat{w}' contained conceal cchar=ŵ
  871. syn match texMathSymbol '\\hat{W}' contained conceal cchar=Ŵ
  872. syn match texMathSymbol '\\hat{y}' contained conceal cchar=ŷ
  873. syn match texMathSymbol '\\hat{Y}' contained conceal cchar=Ŷ
  874. " syn match texMathSymbol '\\bar{a}' contained conceal cchar=a̅
  875. syn match texMathSymbol '\\dot{B}' contained conceal cchar=Ḃ
  876. syn match texMathSymbol '\\dot{b}' contained conceal cchar=ḃ
  877. syn match texMathSymbol '\\dot{D}' contained conceal cchar=Ḋ
  878. syn match texMathSymbol '\\dot{d}' contained conceal cchar=ḋ
  879. syn match texMathSymbol '\\dot{F}' contained conceal cchar=Ḟ
  880. syn match texMathSymbol '\\dot{f}' contained conceal cchar=ḟ
  881. syn match texMathSymbol '\\dot{H}' contained conceal cchar=Ḣ
  882. syn match texMathSymbol '\\dot{h}' contained conceal cchar=ḣ
  883. syn match texMathSymbol '\\dot{M}' contained conceal cchar=Ṁ
  884. syn match texMathSymbol '\\dot{m}' contained conceal cchar=ṁ
  885. syn match texMathSymbol '\\dot{N}' contained conceal cchar=Ṅ
  886. syn match texMathSymbol '\\dot{n}' contained conceal cchar=ṅ
  887. syn match texMathSymbol '\\dot{P}' contained conceal cchar=Ṗ
  888. syn match texMathSymbol '\\dot{p}' contained conceal cchar=ṗ
  889. syn match texMathSymbol '\\dot{R}' contained conceal cchar=Ṙ
  890. syn match texMathSymbol '\\dot{r}' contained conceal cchar=ṙ
  891. syn match texMathSymbol '\\dot{S}' contained conceal cchar=Ṡ
  892. syn match texMathSymbol '\\dot{s}' contained conceal cchar=ṡ
  893. syn match texMathSymbol '\\dot{T}' contained conceal cchar=Ṫ
  894. syn match texMathSymbol '\\dot{t}' contained conceal cchar=ṫ
  895. syn match texMathSymbol '\\dot{W}' contained conceal cchar=Ẇ
  896. syn match texMathSymbol '\\dot{w}' contained conceal cchar=ẇ
  897. syn match texMathSymbol '\\dot{X}' contained conceal cchar=Ẋ
  898. syn match texMathSymbol '\\dot{x}' contained conceal cchar=ẋ
  899. syn match texMathSymbol '\\dot{Y}' contained conceal cchar=Ẏ
  900. syn match texMathSymbol '\\dot{y}' contained conceal cchar=ẏ
  901. syn match texMathSymbol '\\dot{Z}' contained conceal cchar=Ż
  902. syn match texMathSymbol '\\dot{z}' contained conceal cchar=ż
  903. syn match texMathSymbol '\\dot{C}' contained conceal cchar=Ċ
  904. syn match texMathSymbol '\\dot{c}' contained conceal cchar=ċ
  905. syn match texMathSymbol '\\dot{E}' contained conceal cchar=Ė
  906. syn match texMathSymbol '\\dot{e}' contained conceal cchar=ė
  907. syn match texMathSymbol '\\dot{G}' contained conceal cchar=Ġ
  908. syn match texMathSymbol '\\dot{g}' contained conceal cchar=ġ
  909. syn match texMathSymbol '\\dot{I}' contained conceal cchar=İ
  910. syn match texMathSymbol '\\dot{A}' contained conceal cchar=Ȧ
  911. syn match texMathSymbol '\\dot{a}' contained conceal cchar=ȧ
  912. syn match texMathSymbol '\\dot{O}' contained conceal cchar=Ȯ
  913. syn match texMathSymbol '\\dot{o}' contained conceal cchar=ȯ
  914. endif
  915. " Greek {{{2
  916. if s:tex_conceal =~# 'g'
  917. fun! s:Greek(group,pat,cchar)
  918. exe 'syn match '.a:group." '".a:pat."' contained conceal cchar=".a:cchar
  919. endfun
  920. call s:Greek('texGreek','\\alpha\>' ,'α')
  921. call s:Greek('texGreek','\\beta\>' ,'β')
  922. call s:Greek('texGreek','\\gamma\>' ,'γ')
  923. call s:Greek('texGreek','\\delta\>' ,'δ')
  924. call s:Greek('texGreek','\\epsilon\>' ,'ϵ')
  925. call s:Greek('texGreek','\\varepsilon\>' ,'ε')
  926. call s:Greek('texGreek','\\zeta\>' ,'ζ')
  927. call s:Greek('texGreek','\\eta\>' ,'η')
  928. call s:Greek('texGreek','\\theta\>' ,'θ')
  929. call s:Greek('texGreek','\\vartheta\>' ,'ϑ')
  930. call s:Greek('texGreek','\\iota\>' ,'ι')
  931. call s:Greek('texGreek','\\kappa\>' ,'κ')
  932. call s:Greek('texGreek','\\lambda\>' ,'λ')
  933. call s:Greek('texGreek','\\mu\>' ,'μ')
  934. call s:Greek('texGreek','\\nu\>' ,'ν')
  935. call s:Greek('texGreek','\\xi\>' ,'ξ')
  936. call s:Greek('texGreek','\\pi\>' ,'π')
  937. call s:Greek('texGreek','\\varpi\>' ,'ϖ')
  938. call s:Greek('texGreek','\\rho\>' ,'ρ')
  939. call s:Greek('texGreek','\\varrho\>' ,'ϱ')
  940. call s:Greek('texGreek','\\sigma\>' ,'σ')
  941. call s:Greek('texGreek','\\varsigma\>' ,'ς')
  942. call s:Greek('texGreek','\\tau\>' ,'τ')
  943. call s:Greek('texGreek','\\upsilon\>' ,'υ')
  944. call s:Greek('texGreek','\\phi\>' ,'ϕ')
  945. call s:Greek('texGreek','\\varphi\>' ,'φ')
  946. call s:Greek('texGreek','\\chi\>' ,'χ')
  947. call s:Greek('texGreek','\\psi\>' ,'ψ')
  948. call s:Greek('texGreek','\\omega\>' ,'ω')
  949. call s:Greek('texGreek','\\Gamma\>' ,'Γ')
  950. call s:Greek('texGreek','\\Delta\>' ,'Δ')
  951. call s:Greek('texGreek','\\Theta\>' ,'Θ')
  952. call s:Greek('texGreek','\\Lambda\>' ,'Λ')
  953. call s:Greek('texGreek','\\Xi\>' ,'Ξ')
  954. call s:Greek('texGreek','\\Pi\>' ,'Π')
  955. call s:Greek('texGreek','\\Sigma\>' ,'Σ')
  956. call s:Greek('texGreek','\\Upsilon\>' ,'Υ')
  957. call s:Greek('texGreek','\\Phi\>' ,'Φ')
  958. call s:Greek('texGreek','\\Chi\>' ,'Χ')
  959. call s:Greek('texGreek','\\Psi\>' ,'Ψ')
  960. call s:Greek('texGreek','\\Omega\>' ,'Ω')
  961. delfun s:Greek
  962. endif
  963. " Superscripts/Subscripts {{{2
  964. if s:tex_conceal =~# 's'
  965. if s:tex_fast =~# 's'
  966. syn region texSuperscript matchgroup=Delimiter start='\^{' skip="\\\\\|\\[{}]" end='}' contained concealends contains=texSpecialChar,texSuperscripts,texStatement,texSubscript,texSuperscript,texMathMatcher
  967. syn region texSubscript matchgroup=Delimiter start='_{' skip="\\\\\|\\[{}]" end='}' contained concealends contains=texSpecialChar,texSubscripts,texStatement,texSubscript,texSuperscript,texMathMatcher
  968. endif
  969. " s:SuperSub:
  970. fun! s:SuperSub(group,leader,pat,cchar)
  971. if a:pat =~# '^\\' || (a:leader == '\^' && a:pat =~# s:tex_superscripts) || (a:leader == '_' && a:pat =~# s:tex_subscripts)
  972. " call Decho("SuperSub: group<".a:group."> leader<".a:leader."> pat<".a:pat."> cchar<".a:cchar.">")
  973. exe 'syn match '.a:group." '".a:leader.a:pat."' contained conceal cchar=".a:cchar
  974. exe 'syn match '.a:group."s '".a:pat ."' contained conceal cchar=".a:cchar.' nextgroup='.a:group.'s'
  975. endif
  976. endfun
  977. call s:SuperSub('texSuperscript','\^','0','⁰')
  978. call s:SuperSub('texSuperscript','\^','1','¹')
  979. call s:SuperSub('texSuperscript','\^','2','²')
  980. call s:SuperSub('texSuperscript','\^','3','³')
  981. call s:SuperSub('texSuperscript','\^','4','⁴')
  982. call s:SuperSub('texSuperscript','\^','5','⁵')
  983. call s:SuperSub('texSuperscript','\^','6','⁶')
  984. call s:SuperSub('texSuperscript','\^','7','⁷')
  985. call s:SuperSub('texSuperscript','\^','8','⁸')
  986. call s:SuperSub('texSuperscript','\^','9','⁹')
  987. call s:SuperSub('texSuperscript','\^','a','ᵃ')
  988. call s:SuperSub('texSuperscript','\^','b','ᵇ')
  989. call s:SuperSub('texSuperscript','\^','c','ᶜ')
  990. call s:SuperSub('texSuperscript','\^','d','ᵈ')
  991. call s:SuperSub('texSuperscript','\^','e','ᵉ')
  992. call s:SuperSub('texSuperscript','\^','f','ᶠ')
  993. call s:SuperSub('texSuperscript','\^','g','ᵍ')
  994. call s:SuperSub('texSuperscript','\^','h','ʰ')
  995. call s:SuperSub('texSuperscript','\^','i','ⁱ')
  996. call s:SuperSub('texSuperscript','\^','j','ʲ')
  997. call s:SuperSub('texSuperscript','\^','k','ᵏ')
  998. call s:SuperSub('texSuperscript','\^','l','ˡ')
  999. call s:SuperSub('texSuperscript','\^','m','ᵐ')
  1000. call s:SuperSub('texSuperscript','\^','n','ⁿ')
  1001. call s:SuperSub('texSuperscript','\^','o','ᵒ')
  1002. call s:SuperSub('texSuperscript','\^','p','ᵖ')
  1003. call s:SuperSub('texSuperscript','\^','r','ʳ')
  1004. call s:SuperSub('texSuperscript','\^','s','ˢ')
  1005. call s:SuperSub('texSuperscript','\^','t','ᵗ')
  1006. call s:SuperSub('texSuperscript','\^','u','ᵘ')
  1007. call s:SuperSub('texSuperscript','\^','v','ᵛ')
  1008. call s:SuperSub('texSuperscript','\^','w','ʷ')
  1009. call s:SuperSub('texSuperscript','\^','x','ˣ')
  1010. call s:SuperSub('texSuperscript','\^','y','ʸ')
  1011. call s:SuperSub('texSuperscript','\^','z','ᶻ')
  1012. call s:SuperSub('texSuperscript','\^','A','ᴬ')
  1013. call s:SuperSub('texSuperscript','\^','B','ᴮ')
  1014. call s:SuperSub('texSuperscript','\^','D','ᴰ')
  1015. call s:SuperSub('texSuperscript','\^','E','ᴱ')
  1016. call s:SuperSub('texSuperscript','\^','G','ᴳ')
  1017. call s:SuperSub('texSuperscript','\^','H','ᴴ')
  1018. call s:SuperSub('texSuperscript','\^','I','ᴵ')
  1019. call s:SuperSub('texSuperscript','\^','J','ᴶ')
  1020. call s:SuperSub('texSuperscript','\^','K','ᴷ')
  1021. call s:SuperSub('texSuperscript','\^','L','ᴸ')
  1022. call s:SuperSub('texSuperscript','\^','M','ᴹ')
  1023. call s:SuperSub('texSuperscript','\^','N','ᴺ')
  1024. call s:SuperSub('texSuperscript','\^','O','ᴼ')
  1025. call s:SuperSub('texSuperscript','\^','P','ᴾ')
  1026. call s:SuperSub('texSuperscript','\^','R','ᴿ')
  1027. call s:SuperSub('texSuperscript','\^','T','ᵀ')
  1028. call s:SuperSub('texSuperscript','\^','U','ᵁ')
  1029. call s:SuperSub('texSuperscript','\^','V','ⱽ')
  1030. call s:SuperSub('texSuperscript','\^','W','ᵂ')
  1031. call s:SuperSub('texSuperscript','\^',',','︐')
  1032. call s:SuperSub('texSuperscript','\^',':','︓')
  1033. call s:SuperSub('texSuperscript','\^',';','︔')
  1034. call s:SuperSub('texSuperscript','\^','+','⁺')
  1035. call s:SuperSub('texSuperscript','\^','-','⁻')
  1036. call s:SuperSub('texSuperscript','\^','<','˂')
  1037. call s:SuperSub('texSuperscript','\^','>','˃')
  1038. call s:SuperSub('texSuperscript','\^','/','ˊ')
  1039. call s:SuperSub('texSuperscript','\^','(','⁽')
  1040. call s:SuperSub('texSuperscript','\^',')','⁾')
  1041. call s:SuperSub('texSuperscript','\^','\.','˙')
  1042. call s:SuperSub('texSuperscript','\^','=','˭')
  1043. call s:SuperSub('texSubscript','_','0','₀')
  1044. call s:SuperSub('texSubscript','_','1','₁')
  1045. call s:SuperSub('texSubscript','_','2','₂')
  1046. call s:SuperSub('texSubscript','_','3','₃')
  1047. call s:SuperSub('texSubscript','_','4','₄')
  1048. call s:SuperSub('texSubscript','_','5','₅')
  1049. call s:SuperSub('texSubscript','_','6','₆')
  1050. call s:SuperSub('texSubscript','_','7','₇')
  1051. call s:SuperSub('texSubscript','_','8','₈')
  1052. call s:SuperSub('texSubscript','_','9','₉')
  1053. call s:SuperSub('texSubscript','_','a','ₐ')
  1054. call s:SuperSub('texSubscript','_','e','ₑ')
  1055. call s:SuperSub('texSubscript','_','h','ₕ')
  1056. call s:SuperSub('texSubscript','_','i','ᵢ')
  1057. call s:SuperSub('texSubscript','_','j','ⱼ')
  1058. call s:SuperSub('texSubscript','_','k','ₖ')
  1059. call s:SuperSub('texSubscript','_','l','ₗ')
  1060. call s:SuperSub('texSubscript','_','m','ₘ')
  1061. call s:SuperSub('texSubscript','_','n','ₙ')
  1062. call s:SuperSub('texSubscript','_','o','ₒ')
  1063. call s:SuperSub('texSubscript','_','p','ₚ')
  1064. call s:SuperSub('texSubscript','_','r','ᵣ')
  1065. call s:SuperSub('texSubscript','_','s','ₛ')
  1066. call s:SuperSub('texSubscript','_','t','ₜ')
  1067. call s:SuperSub('texSubscript','_','u','ᵤ')
  1068. call s:SuperSub('texSubscript','_','v','ᵥ')
  1069. call s:SuperSub('texSubscript','_','x','ₓ')
  1070. call s:SuperSub('texSubscript','_',',','︐')
  1071. call s:SuperSub('texSubscript','_','+','₊')
  1072. call s:SuperSub('texSubscript','_','-','₋')
  1073. call s:SuperSub('texSubscript','_','/','ˏ')
  1074. call s:SuperSub('texSubscript','_','(','₍')
  1075. call s:SuperSub('texSubscript','_',')','₎')
  1076. call s:SuperSub('texSubscript','_','\.','‸')
  1077. call s:SuperSub('texSubscript','_','r','ᵣ')
  1078. call s:SuperSub('texSubscript','_','v','ᵥ')
  1079. call s:SuperSub('texSubscript','_','x','ₓ')
  1080. call s:SuperSub('texSubscript','_','\\beta\>' ,'ᵦ')
  1081. call s:SuperSub('texSubscript','_','\\delta\>','ᵨ')
  1082. call s:SuperSub('texSubscript','_','\\phi\>' ,'ᵩ')
  1083. call s:SuperSub('texSubscript','_','\\gamma\>','ᵧ')
  1084. call s:SuperSub('texSubscript','_','\\chi\>' ,'ᵪ')
  1085. delfun s:SuperSub
  1086. endif
  1087. " Accented characters and Ligatures: {{{2
  1088. if s:tex_conceal =~# 'a'
  1089. if b:tex_stylish
  1090. syn match texAccent "\\[bcdvuH][^a-zA-Z@]"me=e-1
  1091. syn match texLigature "\\\([ijolL]\|ae\|oe\|ss\|AA\|AE\|OE\)[^a-zA-Z@]"me=e-1
  1092. syn match texLigature '--'
  1093. syn match texLigature '---'
  1094. else
  1095. fun! s:Accents(chr,...)
  1096. let i= 1
  1097. for accent in ["`","\\'","^",'"','\~','\.','=',"c","H","k","r","u","v"]
  1098. if i > a:0
  1099. break
  1100. endif
  1101. if strlen(a:{i}) == 0 || a:{i} == ' ' || a:{i} == '?'
  1102. let i= i + 1
  1103. continue
  1104. endif
  1105. if accent =~# '\a'
  1106. exe "syn match texAccent '".'\\'.accent.'\(\s*{'.a:chr.'}\|\s\+'.a:chr.'\)'."' conceal cchar=".a:{i}
  1107. else
  1108. exe "syn match texAccent '".'\\'.accent.'\s*\({'.a:chr.'}\|'.a:chr.'\)'."' conceal cchar=".a:{i}
  1109. endif
  1110. let i= i + 1
  1111. endfor
  1112. endfun
  1113. " \` \' \^ \" \~ \. \= \c \H \k \r \u \v
  1114. call s:Accents('a','à','á','â','ä','ã','ȧ','ā',' ',' ','ą','å','ă','ǎ')
  1115. call s:Accents('A','À','Á','Â','Ä','Ã','Ȧ','Ā',' ',' ','Ą','Å','Ă','Ǎ')
  1116. call s:Accents('c',' ','ć','ĉ',' ',' ','ċ',' ','ç',' ',' ',' ',' ','č')
  1117. call s:Accents('C',' ','Ć','Ĉ',' ',' ','Ċ',' ','Ç',' ',' ',' ',' ','Č')
  1118. call s:Accents('d',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','ď')
  1119. call s:Accents('D',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','Ď')
  1120. call s:Accents('e','è','é','ê','ë','ẽ','ė','ē','ȩ',' ','ę',' ','ĕ','ě')
  1121. call s:Accents('E','È','É','Ê','Ë','Ẽ','Ė','Ē','Ȩ',' ','Ę',' ','Ĕ','Ě')
  1122. call s:Accents('g',' ','ǵ','ĝ',' ',' ','ġ',' ','ģ',' ',' ',' ','ğ','ǧ')
  1123. call s:Accents('G',' ','Ǵ','Ĝ',' ',' ','Ġ',' ','Ģ',' ',' ',' ','Ğ','Ǧ')
  1124. call s:Accents('h',' ',' ','ĥ',' ',' ',' ',' ',' ',' ',' ',' ',' ','ȟ')
  1125. call s:Accents('H',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','Ȟ')
  1126. call s:Accents('i','ì','í','î','ï','ĩ','į','ī',' ',' ','į',' ','ĭ','ǐ')
  1127. call s:Accents('I','Ì','Í','Î','Ï','Ĩ','İ','Ī',' ',' ','Į',' ','Ĭ','Ǐ')
  1128. call s:Accents('J',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','ǰ')
  1129. call s:Accents('k',' ',' ',' ',' ',' ',' ',' ','ķ',' ',' ',' ',' ','ǩ')
  1130. call s:Accents('K',' ',' ',' ',' ',' ',' ',' ','Ķ',' ',' ',' ',' ','Ǩ')
  1131. call s:Accents('l',' ','ĺ','ľ',' ',' ',' ',' ','ļ',' ',' ',' ',' ','ľ')
  1132. call s:Accents('L',' ','Ĺ','Ľ',' ',' ',' ',' ','Ļ',' ',' ',' ',' ','Ľ')
  1133. call s:Accents('n',' ','ń',' ',' ','ñ',' ',' ','ņ',' ',' ',' ',' ','ň')
  1134. call s:Accents('N',' ','Ń',' ',' ','Ñ',' ',' ','Ņ',' ',' ',' ',' ','Ň')
  1135. call s:Accents('o','ò','ó','ô','ö','õ','ȯ','ō',' ','ő','ǫ',' ','ŏ','ǒ')
  1136. call s:Accents('O','Ò','Ó','Ô','Ö','Õ','Ȯ','Ō',' ','Ő','Ǫ',' ','Ŏ','Ǒ')
  1137. call s:Accents('r',' ','ŕ',' ',' ',' ',' ',' ','ŗ',' ',' ',' ',' ','ř')
  1138. call s:Accents('R',' ','Ŕ',' ',' ',' ',' ',' ','Ŗ',' ',' ',' ',' ','Ř')
  1139. call s:Accents('s',' ','ś','ŝ',' ',' ',' ',' ','ş',' ','ȿ',' ',' ','š')
  1140. call s:Accents('S',' ','Ś','Ŝ',' ',' ',' ',' ','Ş',' ',' ',' ',' ','Š')
  1141. call s:Accents('t',' ',' ',' ',' ',' ',' ',' ','ţ',' ',' ',' ',' ','ť')
  1142. call s:Accents('T',' ',' ',' ',' ',' ',' ',' ','Ţ',' ',' ',' ',' ','Ť')
  1143. call s:Accents('u','ù','ú','û','ü','ũ',' ','ū',' ','ű','ų','ů','ŭ','ǔ')
  1144. call s:Accents('U','Ù','Ú','Û','Ü','Ũ',' ','Ū',' ','Ű','Ų','Ů','Ŭ','Ǔ')
  1145. call s:Accents('w',' ',' ','ŵ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ')
  1146. call s:Accents('W',' ',' ','Ŵ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ')
  1147. call s:Accents('y','ỳ','ý','ŷ','ÿ','ỹ',' ',' ',' ',' ',' ',' ',' ',' ')
  1148. call s:Accents('Y','Ỳ','Ý','Ŷ','Ÿ','Ỹ',' ',' ',' ',' ',' ',' ',' ',' ')
  1149. call s:Accents('z',' ','ź',' ',' ',' ','ż',' ',' ',' ',' ',' ',' ','ž')
  1150. call s:Accents('Z',' ','Ź',' ',' ',' ','Ż',' ',' ',' ',' ',' ',' ','Ž')
  1151. call s:Accents('\\i','ì','í','î','ï','ĩ','į',' ',' ',' ',' ',' ','ĭ',' ')
  1152. " \` \' \^ \" \~ \. \= \c \H \k \r \u \v
  1153. delfun s:Accents
  1154. syn match texAccent '\\aa\>' conceal cchar=å
  1155. syn match texAccent '\\AA\>' conceal cchar=Å
  1156. syn match texAccent '\\o\>' conceal cchar=ø
  1157. syn match texAccent '\\O\>' conceal cchar=Ø
  1158. syn match texLigature '\\AE\>' conceal cchar=Æ
  1159. syn match texLigature '\\ae\>' conceal cchar=æ
  1160. syn match texLigature '\\oe\>' conceal cchar=œ
  1161. syn match texLigature '\\OE\>' conceal cchar=Œ
  1162. syn match texLigature '\\ss\>' conceal cchar=ß
  1163. syn match texLigature '--' conceal cchar=–
  1164. syn match texLigature '---' conceal cchar=—
  1165. endif
  1166. endif
  1167. endif
  1168. " ---------------------------------------------------------------------
  1169. " LaTeX synchronization: {{{1
  1170. syn sync maxlines=200
  1171. syn sync minlines=50
  1172. syn sync match texSyncStop groupthere NONE "%stopzone\>"
  1173. " Synchronization: {{{1
  1174. " The $..$ and $$..$$ make for impossible sync patterns
  1175. " (one can't tell if a "$$" starts or stops a math zone by itself)
  1176. " The following grouptheres coupled with minlines above
  1177. " help improve the odds of good syncing.
  1178. if !exists("g:tex_no_math")
  1179. syn sync match texSyncMathZoneA groupthere NONE "\\end{abstract}"
  1180. syn sync match texSyncMathZoneA groupthere NONE "\\end{center}"
  1181. syn sync match texSyncMathZoneA groupthere NONE "\\end{description}"
  1182. syn sync match texSyncMathZoneA groupthere NONE "\\end{enumerate}"
  1183. syn sync match texSyncMathZoneA groupthere NONE "\\end{itemize}"
  1184. syn sync match texSyncMathZoneA groupthere NONE "\\end{table}"
  1185. syn sync match texSyncMathZoneA groupthere NONE "\\end{tabular}"
  1186. syn sync match texSyncMathZoneA groupthere NONE "\\\(sub\)*section\>"
  1187. endif
  1188. " ---------------------------------------------------------------------
  1189. " Highlighting: {{{1
  1190. " Define the default highlighting. {{{1
  1191. if !exists("skip_tex_syntax_inits")
  1192. " TeX highlighting groups which should share similar highlighting
  1193. if !exists("g:tex_no_error")
  1194. if !exists("g:tex_no_math")
  1195. hi def link texBadMath texError
  1196. hi def link texMathDelimBad texError
  1197. hi def link texMathError texError
  1198. if !b:tex_stylish
  1199. hi def link texOnlyMath texError
  1200. endif
  1201. endif
  1202. hi def link texError Error
  1203. endif
  1204. hi texBoldStyle gui=bold cterm=bold
  1205. hi texItalStyle gui=italic cterm=italic
  1206. hi texBoldItalStyle gui=bold,italic cterm=bold,italic
  1207. hi texItalBoldStyle gui=bold,italic cterm=bold,italic
  1208. hi def link texEmphStyle texItalStyle
  1209. hi def link texCite texRefZone
  1210. hi def link texDefCmd texDef
  1211. hi def link texDefName texDef
  1212. hi def link texDocType texCmdName
  1213. hi def link texDocTypeArgs texCmdArgs
  1214. hi def link texInputFileOpt texCmdArgs
  1215. hi def link texInputCurlies texDelimiter
  1216. hi def link texLigature texSpecialChar
  1217. if !exists("g:tex_no_math")
  1218. hi def link texMathDelimSet1 texMathDelim
  1219. hi def link texMathDelimSet2 texMathDelim
  1220. hi def link texMathDelimKey texMathDelim
  1221. hi def link texMathMatcher texMath
  1222. hi def link texAccent texStatement
  1223. hi def link texGreek texStatement
  1224. hi def link texSuperscript texStatement
  1225. hi def link texSubscript texStatement
  1226. hi def link texSuperscripts texSuperscript
  1227. hi def link texSubscripts texSubscript
  1228. hi def link texMathSymbol texStatement
  1229. hi def link texMathZoneV texMath
  1230. hi def link texMathZoneW texMath
  1231. hi def link texMathZoneX texMath
  1232. hi def link texMathZoneY texMath
  1233. hi def link texMathZoneV texMath
  1234. hi def link texMathZoneZ texMath
  1235. endif
  1236. hi def link texBeginEnd texCmdName
  1237. hi def link texBeginEndName texSection
  1238. hi def link texSpaceCode texStatement
  1239. hi def link texStyleStatement texStatement
  1240. hi def link texTypeSize texType
  1241. hi def link texTypeStyle texType
  1242. " Basic TeX highlighting groups
  1243. hi def link texCmdArgs Number
  1244. hi def link texCmdName Statement
  1245. hi def link texComment Comment
  1246. hi def link texDef Statement
  1247. hi def link texDefParm Special
  1248. hi def link texDelimiter Delimiter
  1249. hi def link texInput Special
  1250. hi def link texInputFile Special
  1251. hi def link texLength Number
  1252. hi def link texMath Special
  1253. hi def link texMathDelim Statement
  1254. hi def link texMathOper Operator
  1255. hi def link texNewCmd Statement
  1256. hi def link texNewEnv Statement
  1257. hi def link texOption Number
  1258. hi def link texRefZone Special
  1259. hi def link texSection PreCondit
  1260. hi def link texSpaceCodeChar Special
  1261. hi def link texSpecialChar SpecialChar
  1262. hi def link texStatement Statement
  1263. hi def link texString String
  1264. hi def link texTodo Todo
  1265. hi def link texType Type
  1266. hi def link texZone PreCondit
  1267. endif
  1268. " Cleanup: {{{1
  1269. delc TexFold
  1270. unlet s:extfname
  1271. let b:current_syntax = "tex"
  1272. let &cpo = s:keepcpo
  1273. unlet s:keepcpo
  1274. " vim: ts=8 fdm=marker