blob: f4a0875da0d6f609191f068db33ec091f98cbc7e [file] [log] [blame]
Bram Moolenaar071d4272004-06-13 20:20:40 +00001" Vim syntax file
2" Language: TeX
Bram Moolenaar97d62492012-11-15 21:28:22 +01003" Maintainer: Charles E. Campbell <NdrchipO@ScampbellPfamily.AbizM>
Bram Moolenaarf37506f2016-08-31 22:22:10 +02004" Last Change: Aug 31, 2016
5" Version: 100
Bram Moolenaarac7bd632013-03-19 11:35:58 +01006" URL: http://www.drchip.org/astronaut/vim/index.html#SYNTAX_TEX
Bram Moolenaar071d4272004-06-13 20:20:40 +00007"
8" Notes: {{{1
9"
10" 1. If you have a \begin{verbatim} that appears to overrun its boundaries,
11" use %stopzone.
12"
13" 2. Run-on equations ($..$ and $$..$$, particularly) can also be stopped
14" by suitable use of %stopzone.
15"
16" 3. If you have a slow computer, you may wish to modify
17"
18" syn sync maxlines=200
19" syn sync minlines=50
20"
21" to values that are more to your liking.
22"
23" 4. There is no match-syncing for $...$ and $$...$$; hence large
24" equation blocks constructed that way may exhibit syncing problems.
25" (there's no difference between begin/end patterns)
26"
27" 5. If you have the variable "g:tex_no_error" defined then none of the
28" lexical error-checking will be done.
29"
30" ie. let g:tex_no_error=1
Bram Moolenaara6878372014-03-22 21:02:50 +010031"
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
Bram Moolenaar071d4272004-06-13 20:20:40 +000041
42" Version Clears: {{{1
Bram Moolenaar89bcfda2016-08-30 23:26:57 +020043" quit when a syntax file was already loaded
44if exists("b:current_syntax")
Bram Moolenaar071d4272004-06-13 20:20:40 +000045 finish
46endif
Bram Moolenaar15146672011-10-20 22:22:38 +020047let s:keepcpo= &cpo
48set cpo&vim
Bram Moolenaar4b22cdb2010-08-02 22:12:46 +020049scriptencoding utf-8
Bram Moolenaar071d4272004-06-13 20:20:40 +000050
Bram Moolenaar543b7ef2013-06-01 14:50:56 +020051" by default, enable all region-based highlighting
52let s:tex_fast= "bcmMprsSvV"
53if exists("g:tex_fast")
54 if type(g:tex_fast) != 1
55 " g:tex_fast exists and is not a string, so
56 " turn off all optional region-based highighting
57 let s:tex_fast= ""
58 else
59 let s:tex_fast= g:tex_fast
60 endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000061endif
62
Bram Moolenaar4b22cdb2010-08-02 22:12:46 +020063" let user determine which classes of concealment will be supported
Bram Moolenaar7fc0c062010-08-10 21:43:35 +020064" a=accents/ligatures d=delimiters m=math symbols g=Greek s=superscripts/subscripts
Bram Moolenaar4b22cdb2010-08-02 22:12:46 +020065if !exists("g:tex_conceal")
Bram Moolenaarbc488a72013-07-05 21:01:22 +020066 let s:tex_conceal= 'abdmgsS'
Bram Moolenaar4b22cdb2010-08-02 22:12:46 +020067else
68 let s:tex_conceal= g:tex_conceal
69endif
Bram Moolenaar6e932462014-09-09 18:48:09 +020070if !exists("g:tex_superscripts")
Bram Moolenaar802a0d92016-06-26 16:17:58 +020071 let s:tex_superscripts= '[0-9a-zA-W.,:;+-<>/()=]'
Bram Moolenaar03413f42016-04-12 21:07:15 +020072else
73 let s:tex_superscripts= g:tex_superscripts
Bram Moolenaar6e932462014-09-09 18:48:09 +020074endif
75if !exists("g:tex_subscripts")
Bram Moolenaar802a0d92016-06-26 16:17:58 +020076 let s:tex_subscripts= '[0-9aehijklmnoprstuvx,+-/().]'
Bram Moolenaar03413f42016-04-12 21:07:15 +020077else
78 let s:tex_subscripts= g:tex_subscripts
Bram Moolenaar6e932462014-09-09 18:48:09 +020079endif
Bram Moolenaar4b22cdb2010-08-02 22:12:46 +020080
Bram Moolenaarf1f8bc52005-03-07 23:20:08 +000081" Determine whether or not to use "*.sty" mode {{{1
Bram Moolenaar071d4272004-06-13 20:20:40 +000082" The user may override the normal determination by setting
83" g:tex_stylish to 1 (for "*.sty" mode)
84" or to 0 else (normal "*.tex" mode)
85" or on a buffer-by-buffer basis with b:tex_stylish
Bram Moolenaar81af9252010-12-10 20:35:50 +010086let s:extfname=expand("%:e")
Bram Moolenaar071d4272004-06-13 20:20:40 +000087if exists("g:tex_stylish")
88 let b:tex_stylish= g:tex_stylish
89elseif !exists("b:tex_stylish")
Bram Moolenaar81af9252010-12-10 20:35:50 +010090 if s:extfname == "sty" || s:extfname == "cls" || s:extfname == "clo" || s:extfname == "dtx" || s:extfname == "ltx"
Bram Moolenaar071d4272004-06-13 20:20:40 +000091 let b:tex_stylish= 1
92 else
93 let b:tex_stylish= 0
94 endif
95endif
96
Bram Moolenaarf1f8bc52005-03-07 23:20:08 +000097" handle folding {{{1
98if !exists("g:tex_fold_enabled")
Bram Moolenaarb4ff5182015-11-10 21:15:48 +010099 let s:tex_fold_enabled= 0
Bram Moolenaarf1f8bc52005-03-07 23:20:08 +0000100elseif g:tex_fold_enabled && !has("folding")
Bram Moolenaarb4ff5182015-11-10 21:15:48 +0100101 let s:tex_fold_enabled= 0
Bram Moolenaarf1f8bc52005-03-07 23:20:08 +0000102 echomsg "Ignoring g:tex_fold_enabled=".g:tex_fold_enabled."; need to re-compile vim for +fold support"
Bram Moolenaarb4ff5182015-11-10 21:15:48 +0100103else
104 let s:tex_fold_enabled= 1
Bram Moolenaarf1f8bc52005-03-07 23:20:08 +0000105endif
Bram Moolenaarb4ff5182015-11-10 21:15:48 +0100106if s:tex_fold_enabled && &fdm == "manual"
Bram Moolenaar00a927d2010-05-14 23:24:24 +0200107 setl fdm=syntax
Bram Moolenaarf1f8bc52005-03-07 23:20:08 +0000108endif
Bram Moolenaarb4ff5182015-11-10 21:15:48 +0100109if s:tex_fold_enabled && has("folding")
Bram Moolenaara0f849e2015-10-30 14:37:44 +0100110 com! -nargs=* TexFold <args> fold
111else
112 com! -nargs=* TexFold <args>
113endif
Bram Moolenaarf1f8bc52005-03-07 23:20:08 +0000114
Bram Moolenaaradc21822011-04-01 18:03:16 +0200115" (La)TeX keywords: uses the characters 0-9,a-z,A-Z,192-255 only... {{{1
Bram Moolenaar071d4272004-06-13 20:20:40 +0000116" but _ is the only one that causes problems.
Bram Moolenaaradc21822011-04-01 18:03:16 +0200117" One may override this iskeyword setting by providing
118" g:tex_isk
119if exists("g:tex_isk")
Bram Moolenaarbc8801c2016-08-02 21:04:33 +0200120 if b:tex_stylish && g:tex_isk !~ '@'
121 let b:tex_isk= '@,'.g:tex_isk
122 else
123 let b:tex_isk= g:tex_isk
124 endif
125elseif b:tex_stylish
126 let b:tex_isk="@,48-57,a-z,A-Z,192-255"
Bram Moolenaar071d4272004-06-13 20:20:40 +0000127else
Bram Moolenaarbc8801c2016-08-02 21:04:33 +0200128 let b:tex_isk="48-57,a-z,A-Z,192-255"
Bram Moolenaaradc21822011-04-01 18:03:16 +0200129endif
Bram Moolenaarbc8801c2016-08-02 21:04:33 +0200130if v:version > 704 || (v:version == 704 && has("patch-7.4.1142"))
131 exe "syn iskeyword ".b:tex_isk
132else
133 exe "setl isk=".b:tex_isk
Bram Moolenaar071d4272004-06-13 20:20:40 +0000134endif
Bram Moolenaarb4ff5182015-11-10 21:15:48 +0100135if exists("g:tex_no_error") && g:tex_no_error
136 let s:tex_no_error= 1
137else
138 let s:tex_no_error= 0
139endif
140if exists("g:tex_comment_nospell") && g:tex_comment_nospell
141 let s:tex_comment_nospell= 1
142else
143 let s:tex_comment_nospell= 0
144endif
145if exists("g:tex_nospell") && g:tex_nospell
146 let s:tex_nospell = 1
147else
148 let s:tex_nospell = 0
Bram Moolenaard960d762011-09-21 19:22:10 +0200149endif
Bram Moolenaar071d4272004-06-13 20:20:40 +0000150
151" Clusters: {{{1
152" --------
Bram Moolenaarbc8801c2016-08-02 21:04:33 +0200153syn 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
Bram Moolenaara0f849e2015-10-30 14:37:44 +0100154if !s:tex_no_error
Bram Moolenaarb4ff5182015-11-10 21:15:48 +0100155 syn cluster texCmdGroup add=texMathError
Bram Moolenaar071d4272004-06-13 20:20:40 +0000156endif
Bram Moolenaarb4ff5182015-11-10 21:15:48 +0100157syn cluster texEnvGroup contains=texMatcher,texMathDelim,texSpecialChar,texStatement
158syn 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,texNoSpell
159syn cluster texBoldGroup 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,texBoldItalStyle,texNoSpell
160syn cluster texItalGroup 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,texItalStyle,texItalBoldStyle,texNoSpell
161if !s:tex_nospell
162 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,@Spell
163 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,@Spell,texStyleMatcher
Bram Moolenaard960d762011-09-21 19:22:10 +0200164else
Bram Moolenaarb4ff5182015-11-10 21:15:48 +0100165 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
166 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
Bram Moolenaard960d762011-09-21 19:22:10 +0200167endif
Bram Moolenaara0f849e2015-10-30 14:37:44 +0100168syn cluster texPreambleMatchGroup contains=texAccent,texBadMath,texComment,texDefCmd,texDelimiter,texDocType,texInput,texLength,texLigature,texMatcher,texNewCmd,texNewEnv,texOnlyMath,texParen,texRefZone,texSection,texSpecialChar,texStatement,texString,texTitle,texTypeSize,texTypeStyle,texZone,texInputFile,texOption,texMathZoneZ
Bram Moolenaarb4ff5182015-11-10 21:15:48 +0100169syn cluster texRefGroup contains=texMatcher,texComment,texDelimiter
Bram Moolenaare2719092015-01-10 15:09:25 +0100170if !exists("g:tex_no_math")
Bram Moolenaarb4ff5182015-11-10 21:15:48 +0100171 syn cluster texPreambleMatchGroup contains=texAccent,texBadMath,texComment,texDefCmd,texDelimiter,texDocType,texInput,texLength,texLigature,texMatcher,texNewCmd,texNewEnv,texOnlyMath,texParen,texRefZone,texSection,texSpecialChar,texStatement,texString,texTitle,texTypeSize,texTypeStyle,texZone,texInputFile,texOption,texMathZoneZ
172 syn cluster texMathZones contains=texMathZoneV,texMathZoneW,texMathZoneX,texMathZoneY,texMathZoneZ
173 syn cluster texMatchGroup add=@texMathZones
174 syn cluster texMathDelimGroup contains=texMathDelimBad,texMathDelimKey,texMathDelimSet1,texMathDelimSet2
175 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
176 syn cluster texMathZoneGroup contains=texComment,texDelimiter,texLength,texMathDelim,texMathMatcher,texMathOper,texMathSymbol,texMathText,texRefZone,texSpecialChar,texStatement,texTypeSize,texTypeStyle
Bram Moolenaara0f849e2015-10-30 14:37:44 +0100177 if !s:tex_no_error
Bram Moolenaarb4ff5182015-11-10 21:15:48 +0100178 syn cluster texMathMatchGroup add=texMathError
179 syn cluster texMathZoneGroup add=texMathError
Bram Moolenaar071d4272004-06-13 20:20:40 +0000180 endif
Bram Moolenaarb4ff5182015-11-10 21:15:48 +0100181 syn cluster texMathZoneGroup add=@NoSpell
Bram Moolenaar5b8d8fd2005-08-16 23:01:50 +0000182 " following used in the \part \chapter \section \subsection \subsubsection
183 " \paragraph \subparagraph \author \title highlighting
184 syn cluster texDocGroup contains=texPartZone,@texPartGroup
185 syn cluster texPartGroup contains=texChapterZone,texSectionZone,texParaZone
186 syn cluster texChapterGroup contains=texSectionZone,texParaZone
187 syn cluster texSectionGroup contains=texSubSectionZone,texParaZone
188 syn cluster texSubSectionGroup contains=texSubSubSectionZone,texParaZone
189 syn cluster texSubSubSectionGroup contains=texParaZone
190 syn cluster texParaGroup contains=texSubParaZone
Bram Moolenaarb2c03502010-07-02 20:20:09 +0200191 if has("conceal") && &enc == 'utf-8'
Bram Moolenaarb4ff5182015-11-10 21:15:48 +0100192 syn cluster texMathZoneGroup add=texGreek,texSuperscript,texSubscript,texMathSymbol
193 syn cluster texMathMatchGroup add=texGreek,texSuperscript,texSubscript,texMathSymbol
Bram Moolenaarb2c03502010-07-02 20:20:09 +0200194 endif
Bram Moolenaar071d4272004-06-13 20:20:40 +0000195endif
196
197" Try to flag {} and () mismatches: {{{1
Bram Moolenaarf3913272016-02-25 00:00:01 +0100198if s:tex_fast =~# 'm'
Bram Moolenaara0f849e2015-10-30 14:37:44 +0100199 if !s:tex_no_error
Bram Moolenaar802a0d92016-06-26 16:17:58 +0200200 syn region texMatcher matchgroup=Delimiter start="{" skip="\\\\\|\\[{}]" end="}" transparent contains=@texMatchGroup,texError
201 syn region texMatcher matchgroup=Delimiter start="\[" end="]" transparent contains=@texMatchGroup,texError,@NoSpell
Bram Moolenaarac7bd632013-03-19 11:35:58 +0100202 else
Bram Moolenaar802a0d92016-06-26 16:17:58 +0200203 syn region texMatcher matchgroup=Delimiter start="{" skip="\\\\\|\\[{}]" end="}" transparent contains=@texMatchGroup
204 syn region texMatcher matchgroup=Delimiter start="\[" end="]" transparent contains=@texMatchGroup
Bram Moolenaarac7bd632013-03-19 11:35:58 +0100205 endif
Bram Moolenaarb4ff5182015-11-10 21:15:48 +0100206 if !s:tex_nospell
Bram Moolenaar802a0d92016-06-26 16:17:58 +0200207 syn region texParen start="(" end=")" transparent contains=@texMatchGroup,@Spell
Bram Moolenaarac7bd632013-03-19 11:35:58 +0100208 else
Bram Moolenaar802a0d92016-06-26 16:17:58 +0200209 syn region texParen start="(" end=")" transparent contains=@texMatchGroup
Bram Moolenaarac7bd632013-03-19 11:35:58 +0100210 endif
Bram Moolenaar071d4272004-06-13 20:20:40 +0000211endif
Bram Moolenaara0f849e2015-10-30 14:37:44 +0100212if !s:tex_no_error
Bram Moolenaar071d4272004-06-13 20:20:40 +0000213 syn match texError "[}\])]"
214endif
Bram Moolenaarf3913272016-02-25 00:00:01 +0100215if s:tex_fast =~# 'M'
Bram Moolenaare2719092015-01-10 15:09:25 +0100216 if !exists("g:tex_no_math")
Bram Moolenaara0f849e2015-10-30 14:37:44 +0100217 if !s:tex_no_error
Bram Moolenaarac7bd632013-03-19 11:35:58 +0100218 syn match texMathError "}" contained
219 endif
Bram Moolenaarb4ff5182015-11-10 21:15:48 +0100220 syn region texMathMatcher matchgroup=Delimiter start="{" skip="\%(\\\\\)*\\}" end="}" end="%stopzone\>" contained contains=@texMathMatchGroup
Bram Moolenaarac7bd632013-03-19 11:35:58 +0100221 endif
Bram Moolenaar071d4272004-06-13 20:20:40 +0000222endif
223
224" TeX/LaTeX keywords: {{{1
225" Instead of trying to be All Knowing, I just match \..alphameric..
226" Note that *.tex files may not have "@" in their \commands
227if exists("g:tex_tex") || b:tex_stylish
228 syn match texStatement "\\[a-zA-Z@]\+"
229else
230 syn match texStatement "\\\a\+"
Bram Moolenaara0f849e2015-10-30 14:37:44 +0100231 if !s:tex_no_error
Bram Moolenaar071d4272004-06-13 20:20:40 +0000232 syn match texError "\\\a*@[a-zA-Z@]*"
233 endif
234endif
235
236" TeX/LaTeX delimiters: {{{1
237syn match texDelimiter "&"
238syn match texDelimiter "\\\\"
239
240" Tex/Latex Options: {{{1
Bram Moolenaard38b0552012-04-25 19:07:41 +0200241syn match texOption "[^\\]\zs#\d\+\|^#\d\+"
Bram Moolenaar071d4272004-06-13 20:20:40 +0000242
243" texAccent (tnx to Karim Belabas) avoids annoying highlighting for accents: {{{1
244if b:tex_stylish
245 syn match texAccent "\\[bcdvuH][^a-zA-Z@]"me=e-1
246 syn match texLigature "\\\([ijolL]\|ae\|oe\|ss\|AA\|AE\|OE\)[^a-zA-Z@]"me=e-1
247else
248 syn match texAccent "\\[bcdvuH]\A"me=e-1
249 syn match texLigature "\\\([ijolL]\|ae\|oe\|ss\|AA\|AE\|OE\)\A"me=e-1
250endif
251syn match texAccent "\\[bcdvuH]$"
252syn match texAccent +\\[=^.\~"`']+
253syn match texAccent +\\['=t'.c^ud"vb~Hr]{\a}+
254syn match texLigature "\\\([ijolL]\|ae\|oe\|ss\|AA\|AE\|OE\)$"
255
256" \begin{}/\end{} section markers: {{{1
Bram Moolenaard38b0552012-04-25 19:07:41 +0200257syn match texBeginEnd "\\begin\>\|\\end\>" nextgroup=texBeginEndName
Bram Moolenaarf3913272016-02-25 00:00:01 +0100258if s:tex_fast =~# 'm'
Bram Moolenaarb4ff5182015-11-10 21:15:48 +0100259 syn region texBeginEndName matchgroup=Delimiter start="{" end="}" contained nextgroup=texBeginEndModifier contains=texComment
Bram Moolenaar802a0d92016-06-26 16:17:58 +0200260 syn region texBeginEndModifier matchgroup=Delimiter start="\[" end="]" contained contains=texComment,@texMathZones,@NoSpell
Bram Moolenaarac7bd632013-03-19 11:35:58 +0100261endif
Bram Moolenaar071d4272004-06-13 20:20:40 +0000262
263" \documentclass, \documentstyle, \usepackage: {{{1
Bram Moolenaard38b0552012-04-25 19:07:41 +0200264syn match texDocType "\\documentclass\>\|\\documentstyle\>\|\\usepackage\>" nextgroup=texBeginEndName,texDocTypeArgs
Bram Moolenaarf3913272016-02-25 00:00:01 +0100265if s:tex_fast =~# 'm'
Bram Moolenaarac7bd632013-03-19 11:35:58 +0100266 syn region texDocTypeArgs matchgroup=Delimiter start="\[" end="]" contained nextgroup=texBeginEndName contains=texComment,@NoSpell
267endif
Bram Moolenaar071d4272004-06-13 20:20:40 +0000268
Bram Moolenaara9a568c2006-03-14 23:04:27 +0000269" Preamble syntax-based folding support: {{{1
Bram Moolenaarb4ff5182015-11-10 21:15:48 +0100270if s:tex_fold_enabled && has("folding")
Bram Moolenaard38b0552012-04-25 19:07:41 +0200271 syn region texPreamble transparent fold start='\zs\\documentclass\>' end='\ze\\begin{document}' contains=texStyle,@texPreambleMatchGroup
Bram Moolenaara9a568c2006-03-14 23:04:27 +0000272endif
273
Bram Moolenaar071d4272004-06-13 20:20:40 +0000274" TeX input: {{{1
275syn match texInput "\\input\s\+[a-zA-Z/.0-9_^]\+"hs=s+7 contains=texStatement
Bram Moolenaar5c736222010-01-06 20:54:52 +0100276syn match texInputFile "\\include\(graphics\|list\)\=\(\[.\{-}\]\)\=\s*{.\{-}}" contains=texStatement,texInputCurlies,texInputFileOpt
Bram Moolenaar071d4272004-06-13 20:20:40 +0000277syn match texInputFile "\\\(epsfig\|input\|usepackage\)\s*\(\[.*\]\)\={.\{-}}" contains=texStatement,texInputCurlies,texInputFileOpt
278syn match texInputCurlies "[{}]" contained
Bram Moolenaarf3913272016-02-25 00:00:01 +0100279if s:tex_fast =~# 'm'
Bram Moolenaarac7bd632013-03-19 11:35:58 +0100280 syn region texInputFileOpt matchgroup=Delimiter start="\[" end="\]" contained contains=texComment
281endif
Bram Moolenaar071d4272004-06-13 20:20:40 +0000282
283" Type Styles (LaTeX 2.09): {{{1
284syn match texTypeStyle "\\rm\>"
285syn match texTypeStyle "\\em\>"
286syn match texTypeStyle "\\bf\>"
287syn match texTypeStyle "\\it\>"
288syn match texTypeStyle "\\sl\>"
289syn match texTypeStyle "\\sf\>"
290syn match texTypeStyle "\\sc\>"
291syn match texTypeStyle "\\tt\>"
292
293" Type Styles: attributes, commands, families, etc (LaTeX2E): {{{1
Bram Moolenaar7db8f6f2016-03-29 23:12:46 +0200294if s:tex_conceal !~# 'b'
Bram Moolenaard38b0552012-04-25 19:07:41 +0200295 syn match texTypeStyle "\\textbf\>"
296 syn match texTypeStyle "\\textit\>"
297endif
Bram Moolenaar071d4272004-06-13 20:20:40 +0000298syn match texTypeStyle "\\textmd\>"
299syn match texTypeStyle "\\textrm\>"
300syn match texTypeStyle "\\textsc\>"
301syn match texTypeStyle "\\textsf\>"
302syn match texTypeStyle "\\textsl\>"
303syn match texTypeStyle "\\texttt\>"
304syn match texTypeStyle "\\textup\>"
305syn match texTypeStyle "\\emph\>"
306
307syn match texTypeStyle "\\mathbb\>"
308syn match texTypeStyle "\\mathbf\>"
309syn match texTypeStyle "\\mathcal\>"
310syn match texTypeStyle "\\mathfrak\>"
311syn match texTypeStyle "\\mathit\>"
312syn match texTypeStyle "\\mathnormal\>"
313syn match texTypeStyle "\\mathrm\>"
314syn match texTypeStyle "\\mathsf\>"
315syn match texTypeStyle "\\mathtt\>"
316
317syn match texTypeStyle "\\rmfamily\>"
318syn match texTypeStyle "\\sffamily\>"
319syn match texTypeStyle "\\ttfamily\>"
320
321syn match texTypeStyle "\\itshape\>"
322syn match texTypeStyle "\\scshape\>"
323syn match texTypeStyle "\\slshape\>"
324syn match texTypeStyle "\\upshape\>"
325
326syn match texTypeStyle "\\bfseries\>"
327syn match texTypeStyle "\\mdseries\>"
328
329" Some type sizes: {{{1
330syn match texTypeSize "\\tiny\>"
331syn match texTypeSize "\\scriptsize\>"
332syn match texTypeSize "\\footnotesize\>"
333syn match texTypeSize "\\small\>"
334syn match texTypeSize "\\normalsize\>"
335syn match texTypeSize "\\large\>"
336syn match texTypeSize "\\Large\>"
337syn match texTypeSize "\\LARGE\>"
338syn match texTypeSize "\\huge\>"
339syn match texTypeSize "\\Huge\>"
340
341" Spacecodes (TeX'isms): {{{1
342" \mathcode`\^^@="2201 \delcode`\(="028300 \sfcode`\)=0 \uccode`X=`X \lccode`x=`x
343syn match texSpaceCode "\\\(math\|cat\|del\|lc\|sf\|uc\)code`"me=e-1 nextgroup=texSpaceCodeChar
344syn match texSpaceCodeChar "`\\\=.\(\^.\)\==\(\d\|\"\x\{1,6}\|`.\)" contained
345
346" Sections, subsections, etc: {{{1
Bram Moolenaarf3913272016-02-25 00:00:01 +0100347if s:tex_fast =~# 'p'
Bram Moolenaarb4ff5182015-11-10 21:15:48 +0100348 if !s:tex_nospell
349 TexFold syn region texDocZone matchgroup=texSection start='\\begin\s*{\s*document\s*}' end='\\end\s*{\s*document\s*}' contains=@texFoldGroup,@texDocGroup,@Spell
350 TexFold syn region texPartZone matchgroup=texSection start='\\part\>' end='\ze\s*\\\%(part\>\|end\s*{\s*document\s*}\)' contains=@texFoldGroup,@texPartGroup,@Spell
351 TexFold syn region texChapterZone matchgroup=texSection start='\\chapter\>' end='\ze\s*\\\%(chapter\>\|part\>\|end\s*{\s*document\s*}\)' contains=@texFoldGroup,@texChapterGroup,@Spell
352 TexFold syn region texSectionZone matchgroup=texSection start='\\section\>' end='\ze\s*\\\%(section\>\|chapter\>\|part\>\|end\s*{\s*document\s*}\)' contains=@texFoldGroup,@texSectionGroup,@Spell
353 TexFold syn region texSubSectionZone matchgroup=texSection start='\\subsection\>' end='\ze\s*\\\%(\%(sub\)\=section\>\|chapter\>\|part\>\|end\s*{\s*document\s*}\)' contains=@texFoldGroup,@texSubSectionGroup,@Spell
354 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
355 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
356 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
357 TexFold syn region texTitle matchgroup=texSection start='\\\%(author\|title\)\>\s*{' end='}' contains=@texFoldGroup,@Spell
358 TexFold syn region texAbstract matchgroup=texSection start='\\begin\s*{\s*abstract\s*}' end='\\end\s*{\s*abstract\s*}' contains=@texFoldGroup,@Spell
359 else
360 TexFold syn region texDocZone matchgroup=texSection start='\\begin\s*{\s*document\s*}' end='\\end\s*{\s*document\s*}' contains=@texFoldGroup,@texDocGroup
361 TexFold syn region texPartZone matchgroup=texSection start='\\part\>' end='\ze\s*\\\%(part\>\|end\s*{\s*document\s*}\)' contains=@texFoldGroup,@texPartGroup
362 TexFold syn region texChapterZone matchgroup=texSection start='\\chapter\>' end='\ze\s*\\\%(chapter\>\|part\>\|end\s*{\s*document\s*}\)' contains=@texFoldGroup,@texChapterGroup
363 TexFold syn region texSectionZone matchgroup=texSection start='\\section\>' end='\ze\s*\\\%(section\>\|chapter\>\|part\>\|end\s*{\s*document\s*}\)' contains=@texFoldGroup,@texSectionGroup
364 TexFold syn region texSubSectionZone matchgroup=texSection start='\\subsection\>' end='\ze\s*\\\%(\%(sub\)\=section\>\|chapter\>\|part\>\|end\s*{\s*document\s*}\)' contains=@texFoldGroup,@texSubSectionGroup
365 TexFold syn region texSubSubSectionZone matchgroup=texSection start='\\subsubsection\>' end='\ze\s*\\\%(\%(sub\)\{,2}section\>\|chapter\>\|part\>\|end\s*{\s*document\s*}\)' contains=@texFoldGroup,@texSubSubSectionGroup
366 TexFold syn region texParaZone matchgroup=texSection start='\\paragraph\>' end='\ze\s*\\\%(paragraph\>\|\%(sub\)*section\>\|chapter\>\|part\>\|end\s*{\s*document\s*}\)' contains=@texFoldGroup,@texParaGroup
367 TexFold syn region texSubParaZone matchgroup=texSection start='\\subparagraph\>' end='\ze\s*\\\%(\%(sub\)\=paragraph\>\|\%(sub\)*section\>\|chapter\>\|part\>\|end\s*{\s*document\s*}\)' contains=@texFoldGroup
368 TexFold syn region texTitle matchgroup=texSection start='\\\%(author\|title\)\>\s*{' end='}' contains=@texFoldGroup
369 TexFold syn region texAbstract matchgroup=texSection start='\\begin\s*{\s*abstract\s*}' end='\\end\s*{\s*abstract\s*}' contains=@texFoldGroup
Bram Moolenaarac7bd632013-03-19 11:35:58 +0100370 endif
Bram Moolenaar293ee4d2004-12-09 21:34:53 +0000371endif
Bram Moolenaar071d4272004-06-13 20:20:40 +0000372
Bram Moolenaard38b0552012-04-25 19:07:41 +0200373" particular support for bold and italic {{{1
Bram Moolenaarf3913272016-02-25 00:00:01 +0100374if s:tex_fast =~# 'b'
375 if s:tex_conceal =~# 'b'
Bram Moolenaar83d1b192015-04-13 14:22:40 +0200376 if !exists("g:tex_nospell") || !g:tex_nospell
Bram Moolenaar541f92d2015-06-19 13:27:23 +0200377 syn region texBoldStyle matchgroup=texTypeStyle start="\\textbf\s*{" matchgroup=texTypeStyle end="}" concealends contains=@texBoldGroup,@Spell
378 syn region texBoldItalStyle matchgroup=texTypeStyle start="\\textit\s*{" matchgroup=texTypeStyle end="}" concealends contains=@texItalGroup,@Spell
379 syn region texItalStyle matchgroup=texTypeStyle start="\\textit\s*{" matchgroup=texTypeStyle end="}" concealends contains=@texItalGroup,@Spell
380 syn region texItalBoldStyle matchgroup=texTypeStyle start="\\textbf\s*{" matchgroup=texTypeStyle end="}" concealends contains=@texBoldGroup,@Spell
381 else
382 syn region texBoldStyle matchgroup=texTypeStyle start="\\textbf\s*{" matchgroup=texTypeStyle end="}" concealends contains=@texBoldGroup
383 syn region texBoldItalStyle matchgroup=texTypeStyle start="\\textit\s*{" matchgroup=texTypeStyle end="}" concealends contains=@texItalGroup
384 syn region texItalStyle matchgroup=texTypeStyle start="\\textit\s*{" matchgroup=texTypeStyle end="}" concealends contains=@texItalGroup
385 syn region texItalBoldStyle matchgroup=texTypeStyle start="\\textbf\s*{" matchgroup=texTypeStyle end="}" concealends contains=@texBoldGroup
Bram Moolenaar83d1b192015-04-13 14:22:40 +0200386 endif
Bram Moolenaarac7bd632013-03-19 11:35:58 +0100387 endif
Bram Moolenaard38b0552012-04-25 19:07:41 +0200388endif
389
Bram Moolenaar071d4272004-06-13 20:20:40 +0000390" Bad Math (mismatched): {{{1
Bram Moolenaara0f849e2015-10-30 14:37:44 +0100391if !exists("g:tex_no_math") && !s:tex_no_error
392 syn match texBadMath "\\end\s*{\s*\(array\|gathered\|bBpvV]matrix\|split\|subequations\|smallmatrix\|xxalignat\)\s*}"
Bram Moolenaar071d4272004-06-13 20:20:40 +0000393 syn match texBadMath "\\end\s*{\s*\(align\|alignat\|displaymath\|displaymath\|eqnarray\|equation\|flalign\|gather\|math\|multline\|xalignat\)\*\=\s*}"
394 syn match texBadMath "\\[\])]"
395endif
396
397" Math Zones: {{{1
Bram Moolenaare2719092015-01-10 15:09:25 +0100398if !exists("g:tex_no_math")
Bram Moolenaar488c6512005-08-11 20:09:58 +0000399 " TexNewMathZone: function creates a mathzone with the given suffix and mathzone name. {{{2
Bram Moolenaar071d4272004-06-13 20:20:40 +0000400 " Starred forms are created if starform is true. Starred
401 " forms have syntax group and synchronization groups with a
Bram Moolenaarf37506f2016-08-31 22:22:10 +0200402 " "S" appended. Handles: cluster, syntax, sync, and hi link.
Bram Moolenaar071d4272004-06-13 20:20:40 +0000403 fun! TexNewMathZone(sfx,mathzone,starform)
404 let grpname = "texMathZone".a:sfx
405 let syncname = "texSyncMathZone".a:sfx
Bram Moolenaarb4ff5182015-11-10 21:15:48 +0100406 if s:tex_fold_enabled
Bram Moolenaar3577c6f2008-06-24 21:16:56 +0000407 let foldcmd= " fold"
408 else
409 let foldcmd= ""
410 endif
Bram Moolenaar071d4272004-06-13 20:20:40 +0000411 exe "syn cluster texMathZones add=".grpname
Bram Moolenaarf3913272016-02-25 00:00:01 +0100412 if s:tex_fast =~# 'M'
Bram Moolenaarac7bd632013-03-19 11:35:58 +0100413 exe 'syn region '.grpname.' start='."'".'\\begin\s*{\s*'.a:mathzone.'\s*}'."'".' end='."'".'\\end\s*{\s*'.a:mathzone.'\s*}'."'".' keepend contains=@texMathZoneGroup'.foldcmd
414 exe 'syn sync match '.syncname.' grouphere '.grpname.' "\\begin\s*{\s*'.a:mathzone.'\*\s*}"'
415 exe 'syn sync match '.syncname.' grouphere '.grpname.' "\\begin\s*{\s*'.a:mathzone.'\*\s*}"'
416 endif
Bram Moolenaar5c736222010-01-06 20:54:52 +0100417 exe 'hi def link '.grpname.' texMath'
Bram Moolenaar071d4272004-06-13 20:20:40 +0000418 if a:starform
419 let grpname = "texMathZone".a:sfx.'S'
420 let syncname = "texSyncMathZone".a:sfx.'S'
421 exe "syn cluster texMathZones add=".grpname
Bram Moolenaarf3913272016-02-25 00:00:01 +0100422 if s:tex_fast =~# 'M'
Bram Moolenaarac7bd632013-03-19 11:35:58 +0100423 exe 'syn region '.grpname.' start='."'".'\\begin\s*{\s*'.a:mathzone.'\*\s*}'."'".' end='."'".'\\end\s*{\s*'.a:mathzone.'\*\s*}'."'".' keepend contains=@texMathZoneGroup'.foldcmd
424 exe 'syn sync match '.syncname.' grouphere '.grpname.' "\\begin\s*{\s*'.a:mathzone.'\*\s*}"'
425 exe 'syn sync match '.syncname.' grouphere '.grpname.' "\\begin\s*{\s*'.a:mathzone.'\*\s*}"'
426 endif
Bram Moolenaar5c736222010-01-06 20:54:52 +0100427 exe 'hi def link '.grpname.' texMath'
Bram Moolenaar071d4272004-06-13 20:20:40 +0000428 endif
429 endfun
430
431 " Standard Math Zones: {{{2
432 call TexNewMathZone("A","align",1)
433 call TexNewMathZone("B","alignat",1)
434 call TexNewMathZone("C","displaymath",1)
435 call TexNewMathZone("D","eqnarray",1)
436 call TexNewMathZone("E","equation",1)
437 call TexNewMathZone("F","flalign",1)
438 call TexNewMathZone("G","gather",1)
439 call TexNewMathZone("H","math",1)
440 call TexNewMathZone("I","multline",1)
Bram Moolenaarbc8801c2016-08-02 21:04:33 +0200441 call TexNewMathZone("J","xalignat",1)
442 call TexNewMathZone("K","xxalignat",0)
Bram Moolenaar071d4272004-06-13 20:20:40 +0000443
444 " Inline Math Zones: {{{2
Bram Moolenaarf3913272016-02-25 00:00:01 +0100445 if s:tex_fast =~# 'M'
446 if has("conceal") && &enc == 'utf-8' && s:tex_conceal =~# 'd'
Bram Moolenaar541f92d2015-06-19 13:27:23 +0200447 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
Bram Moolenaarac7bd632013-03-19 11:35:58 +0100451 else
Bram Moolenaar541f92d2015-06-19 13:27:23 +0200452 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
Bram Moolenaarb4ff5182015-11-10 21:15:48 +0100454 syn region texMathZoneX matchgroup=Delimiter start="\$" skip="\%(\\\\\)*\\\$" matchgroup=Delimiter end="\$" end="%stopzone\>" contains=@texMathZoneGroup
Bram Moolenaar541f92d2015-06-19 13:27:23 +0200455 syn region texMathZoneY matchgroup=Delimiter start="\$\$" matchgroup=Delimiter end="\$\$" end="%stopzone\>" keepend contains=@texMathZoneGroup
Bram Moolenaarac7bd632013-03-19 11:35:58 +0100456 endif
Bram Moolenaar541f92d2015-06-19 13:27:23 +0200457 syn region texMathZoneZ matchgroup=texStatement start="\\ensuremath\s*{" matchgroup=texStatement end="}" end="%stopzone\>" contains=@texMathZoneGroup
Bram Moolenaare0021c72010-07-28 17:25:21 +0200458 endif
Bram Moolenaar071d4272004-06-13 20:20:40 +0000459
460 syn match texMathOper "[_^=]" contained
461
Bram Moolenaar74cbdf02010-08-04 23:03:17 +0200462 " Text Inside Math Zones: {{{2
Bram Moolenaarf3913272016-02-25 00:00:01 +0100463 if s:tex_fast =~# 'M'
Bram Moolenaarac7bd632013-03-19 11:35:58 +0100464 if !exists("g:tex_nospell") || !g:tex_nospell
465 syn region texMathText matchgroup=texStatement start='\\\(\(inter\)\=text\|mbox\)\s*{' end='}' contains=@texFoldGroup,@Spell
466 else
467 syn region texMathText matchgroup=texStatement start='\\\(\(inter\)\=text\|mbox\)\s*{' end='}' contains=@texFoldGroup
468 endif
Bram Moolenaard960d762011-09-21 19:22:10 +0200469 endif
Bram Moolenaar74cbdf02010-08-04 23:03:17 +0200470
Bram Moolenaar071d4272004-06-13 20:20:40 +0000471 " \left..something.. and \right..something.. support: {{{2
472 syn match texMathDelimBad contained "\S"
Bram Moolenaarf3913272016-02-25 00:00:01 +0100473 if has("conceal") && &enc == 'utf-8' && s:tex_conceal =~# 'm'
Bram Moolenaarbc8801c2016-08-02 21:04:33 +0200474 syn match texMathDelim contained "\\left\["
475 syn match texMathDelim contained "\\left\\{" skipwhite nextgroup=texMathDelimSet1,texMathDelimSet2,texMathDelimBad contains=texMathSymbol cchar={
476 syn match texMathDelim contained "\\right\\}" skipwhite nextgroup=texMathDelimSet1,texMathDelimSet2,texMathDelimBad contains=texMathSymbol cchar=}
Bram Moolenaaradc21822011-04-01 18:03:16 +0200477 let s:texMathDelimList=[
478 \ ['<' , '<'] ,
479 \ ['>' , '>'] ,
480 \ ['(' , '('] ,
481 \ [')' , ')'] ,
482 \ ['\[' , '['] ,
483 \ [']' , ']'] ,
484 \ ['\\{' , '{'] ,
485 \ ['\\}' , '}'] ,
486 \ ['|' , '|'] ,
487 \ ['\\|' , '‖'] ,
488 \ ['\\backslash' , '\'] ,
489 \ ['\\downarrow' , '↓'] ,
490 \ ['\\Downarrow' , '⇓'] ,
491 \ ['\\langle' , '<'] ,
492 \ ['\\lbrace' , '['] ,
493 \ ['\\lceil' , '⌈'] ,
494 \ ['\\lfloor' , '⌊'] ,
495 \ ['\\lgroup' , '⌊'] ,
496 \ ['\\lmoustache' , '⎛'] ,
497 \ ['\\rangle' , '>'] ,
498 \ ['\\rbrace' , ']'] ,
499 \ ['\\rceil' , '⌉'] ,
500 \ ['\\rfloor' , '⌋'] ,
501 \ ['\\rgroup' , '⌋'] ,
502 \ ['\\rmoustache' , '⎞'] ,
503 \ ['\\uparrow' , '↑'] ,
504 \ ['\\Uparrow' , '↑'] ,
505 \ ['\\updownarrow', '↕'] ,
506 \ ['\\Updownarrow', '⇕']]
507 syn match texMathDelim '\\[bB]igg\=[lr]' contained nextgroup=texMathDelimBad
508 for texmath in s:texMathDelimList
509 exe "syn match texMathDelim '\\\\[bB]igg\\=[lr]\\=".texmath[0]."' contained conceal cchar=".texmath[1]
510 endfor
511
Bram Moolenaar4b22cdb2010-08-02 22:12:46 +0200512 else
513 syn match texMathDelim contained "\\\(left\|right\)\>" skipwhite nextgroup=texMathDelimSet1,texMathDelimSet2,texMathDelimBad
Bram Moolenaaradc21822011-04-01 18:03:16 +0200514 syn match texMathDelim contained "\\[bB]igg\=[lr]\=\>" skipwhite nextgroup=texMathDelimSet1,texMathDelimSet2,texMathDelimBad
515 syn match texMathDelimSet2 contained "\\" nextgroup=texMathDelimKey,texMathDelimBad
516 syn match texMathDelimSet1 contained "[<>()[\]|/.]\|\\[{}|]"
517 syn keyword texMathDelimKey contained backslash lceil lVert rgroup uparrow
518 syn keyword texMathDelimKey contained downarrow lfloor rangle rmoustache Uparrow
519 syn keyword texMathDelimKey contained Downarrow lgroup rbrace rvert updownarrow
520 syn keyword texMathDelimKey contained langle lmoustache rceil rVert Updownarrow
521 syn keyword texMathDelimKey contained lbrace lvert rfloor
Bram Moolenaar4b22cdb2010-08-02 22:12:46 +0200522 endif
Bram Moolenaar071d4272004-06-13 20:20:40 +0000523 syn match texMathDelim contained "\\\(left\|right\)arrow\>\|\<\([aA]rrow\|brace\)\=vert\>"
524 syn match texMathDelim contained "\\lefteqn\>"
Bram Moolenaar071d4272004-06-13 20:20:40 +0000525endif
526
527" Special TeX characters ( \$ \& \% \# \{ \} \_ \S \P ) : {{{1
528syn match texSpecialChar "\\[$&%#{}_]"
529if b:tex_stylish
530 syn match texSpecialChar "\\[SP@][^a-zA-Z@]"me=e-1
531else
532 syn match texSpecialChar "\\[SP@]\A"me=e-1
533endif
534syn match texSpecialChar "\\\\"
Bram Moolenaare2719092015-01-10 15:09:25 +0100535if !exists("g:tex_no_math")
Bram Moolenaar071d4272004-06-13 20:20:40 +0000536 syn match texOnlyMath "[_^]"
537endif
538syn match texSpecialChar "\^\^[0-9a-f]\{2}\|\^\^\S"
Bram Moolenaar7db8f6f2016-03-29 23:12:46 +0200539if s:tex_conceal !~# 'S'
Bram Moolenaarbc488a72013-07-05 21:01:22 +0200540 syn match texSpecialChar '\\glq\>' contained conceal cchar=‚
541 syn match texSpecialChar '\\grq\>' contained conceal cchar=‘
542 syn match texSpecialChar '\\glqq\>' contained conceal cchar=„
543 syn match texSpecialChar '\\grqq\>' contained conceal cchar=“
544 syn match texSpecialChar '\\hyp\>' contained conceal cchar=-
545endif
Bram Moolenaar071d4272004-06-13 20:20:40 +0000546
547" Comments: {{{1
548" Normal TeX LaTeX : %....
549" Documented TeX Format: ^^A... -and- leading %s (only)
Bram Moolenaarb4ff5182015-11-10 21:15:48 +0100550if !s:tex_comment_nospell
Bram Moolenaar3577c6f2008-06-24 21:16:56 +0000551 syn cluster texCommentGroup contains=texTodo,@Spell
552else
553 syn cluster texCommentGroup contains=texTodo,@NoSpell
554endif
Bram Moolenaar071d4272004-06-13 20:20:40 +0000555syn case ignore
Bram Moolenaar18144c82006-04-12 21:52:12 +0000556syn keyword texTodo contained combak fixme todo xxx
Bram Moolenaar071d4272004-06-13 20:20:40 +0000557syn case match
Bram Moolenaar81af9252010-12-10 20:35:50 +0100558if s:extfname == "dtx"
Bram Moolenaara0f849e2015-10-30 14:37:44 +0100559 syn match texComment "\^\^A.*$" contains=@texCommentGroup
560 syn match texComment "^%\+" contains=@texCommentGroup
Bram Moolenaar071d4272004-06-13 20:20:40 +0000561else
Bram Moolenaarb4ff5182015-11-10 21:15:48 +0100562 if s:tex_fold_enabled
Bram Moolenaara0f849e2015-10-30 14:37:44 +0100563 " allows syntax-folding of 2 or more contiguous comment lines
564 " single-line comments are not folded
Bram Moolenaarb4ff5182015-11-10 21:15:48 +0100565 syn match texComment "%.*$" contains=@texCommentGroup
Bram Moolenaarf3913272016-02-25 00:00:01 +0100566 if s:tex_fast =~# 'c'
Bram Moolenaarb4ff5182015-11-10 21:15:48 +0100567 TexFold syn region texComment start="^\zs\s*%.*\_s*%" skip="^\s*%" end='^\ze\s*[^%]' contains=@texCommentGroup
568 TexFold syn region texNoSpell contained matchgroup=texComment start="%\s*nospell\s*{" end="%\s*nospell\s*}" contains=@texFoldGroup,@NoSpell
Bram Moolenaarfd2ac762006-03-01 22:09:21 +0000569 endif
Bram Moolenaara0f849e2015-10-30 14:37:44 +0100570 else
571 syn match texComment "%.*$" contains=@texCommentGroup
Bram Moolenaarf3913272016-02-25 00:00:01 +0100572 if s:tex_fast =~# 'c'
Bram Moolenaarb4ff5182015-11-10 21:15:48 +0100573 syn region texNoSpell contained matchgroup=texComment start="%\s*nospell\s*{" end="%\s*nospell\s*}" contains=@texFoldGroup,@NoSpell
Bram Moolenaara0f849e2015-10-30 14:37:44 +0100574 endif
575 endif
Bram Moolenaar071d4272004-06-13 20:20:40 +0000576endif
577
578" Separate lines used for verb` and verb# so that the end conditions {{{1
Bram Moolenaar74cbdf02010-08-04 23:03:17 +0200579" will appropriately terminate.
580" If g:tex_verbspell exists, then verbatim texZones will permit spellchecking there.
Bram Moolenaarf3913272016-02-25 00:00:01 +0100581if s:tex_fast =~# 'v'
Bram Moolenaarac7bd632013-03-19 11:35:58 +0100582 if exists("g:tex_verbspell") && g:tex_verbspell
583 syn region texZone start="\\begin{[vV]erbatim}" end="\\end{[vV]erbatim}\|%stopzone\>" contains=@Spell
584 " listings package:
585 syn region texZone start="\\begin{lstlisting}" end="\\end{lstlisting}\|%stopzone\>" contains=@Spell
Bram Moolenaar89bcfda2016-08-30 23:26:57 +0200586 if b:tex_stylish
587 syn region texZone start="\\verb\*\=\z([^\ta-zA-Z@]\)" end="\z1\|%stopzone\>" contains=@Spell
Bram Moolenaar74cbdf02010-08-04 23:03:17 +0200588 else
Bram Moolenaar89bcfda2016-08-30 23:26:57 +0200589 syn region texZone start="\\verb\*\=\z([^\ta-zA-Z]\)" end="\z1\|%stopzone\>" contains=@Spell
Bram Moolenaar74cbdf02010-08-04 23:03:17 +0200590 endif
Bram Moolenaarac7bd632013-03-19 11:35:58 +0100591 else
592 syn region texZone start="\\begin{[vV]erbatim}" end="\\end{[vV]erbatim}\|%stopzone\>"
Bram Moolenaar89bcfda2016-08-30 23:26:57 +0200593 if b:tex_stylish
594 syn region texZone start="\\verb\*\=\z([^\ta-zA-Z@]\)" end="\z1\|%stopzone\>"
Bram Moolenaar74cbdf02010-08-04 23:03:17 +0200595 else
Bram Moolenaar89bcfda2016-08-30 23:26:57 +0200596 syn region texZone start="\\verb\*\=\z([^\ta-zA-Z]\)" end="\z1\|%stopzone\>"
Bram Moolenaar74cbdf02010-08-04 23:03:17 +0200597 endif
Bram Moolenaarac7bd632013-03-19 11:35:58 +0100598 endif
Bram Moolenaar071d4272004-06-13 20:20:40 +0000599endif
600
601" Tex Reference Zones: {{{1
Bram Moolenaarf3913272016-02-25 00:00:01 +0100602if s:tex_fast =~# 'r'
Bram Moolenaarac7bd632013-03-19 11:35:58 +0100603 syn region texZone matchgroup=texStatement start="@samp{" end="}\|%stopzone\>" contains=@texRefGroup
604 syn region texRefZone matchgroup=texStatement start="\\nocite{" end="}\|%stopzone\>" contains=@texRefGroup
605 syn region texRefZone matchgroup=texStatement start="\\bibliography{" end="}\|%stopzone\>" contains=@texRefGroup
606 syn region texRefZone matchgroup=texStatement start="\\label{" end="}\|%stopzone\>" contains=@texRefGroup
607 syn region texRefZone matchgroup=texStatement start="\\\(page\|eq\)ref{" end="}\|%stopzone\>" contains=@texRefGroup
608 syn region texRefZone matchgroup=texStatement start="\\v\=ref{" end="}\|%stopzone\>" contains=@texRefGroup
609 syn region texRefOption contained matchgroup=Delimiter start='\[' end=']' contains=@texRefGroup,texRefZone nextgroup=texRefOption,texCite
Bram Moolenaar6e932462014-09-09 18:48:09 +0200610 syn region texCite contained matchgroup=Delimiter start='{' end='}' contains=@texRefGroup,texRefZone,texCite
Bram Moolenaarac7bd632013-03-19 11:35:58 +0100611endif
Bram Moolenaard960d762011-09-21 19:22:10 +0200612syn match texRefZone '\\cite\%([tp]\*\=\)\=' nextgroup=texRefOption,texCite
Bram Moolenaar071d4272004-06-13 20:20:40 +0000613
614" Handle newcommand, newenvironment : {{{1
615syn match texNewCmd "\\newcommand\>" nextgroup=texCmdName skipwhite skipnl
Bram Moolenaarf3913272016-02-25 00:00:01 +0100616if s:tex_fast =~# 'V'
Bram Moolenaarac7bd632013-03-19 11:35:58 +0100617 syn region texCmdName contained matchgroup=Delimiter start="{"rs=s+1 end="}" nextgroup=texCmdArgs,texCmdBody skipwhite skipnl
618 syn region texCmdArgs contained matchgroup=Delimiter start="\["rs=s+1 end="]" nextgroup=texCmdBody skipwhite skipnl
619 syn region texCmdBody contained matchgroup=Delimiter start="{"rs=s+1 skip="\\\\\|\\[{}]" matchgroup=Delimiter end="}" contains=@texCmdGroup
620endif
Bram Moolenaar071d4272004-06-13 20:20:40 +0000621syn match texNewEnv "\\newenvironment\>" nextgroup=texEnvName skipwhite skipnl
Bram Moolenaarf3913272016-02-25 00:00:01 +0100622if s:tex_fast =~# 'V'
Bram Moolenaarac7bd632013-03-19 11:35:58 +0100623 syn region texEnvName contained matchgroup=Delimiter start="{"rs=s+1 end="}" nextgroup=texEnvBgn skipwhite skipnl
624 syn region texEnvBgn contained matchgroup=Delimiter start="{"rs=s+1 end="}" nextgroup=texEnvEnd skipwhite skipnl contains=@texEnvGroup
625 syn region texEnvEnd contained matchgroup=Delimiter start="{"rs=s+1 end="}" skipwhite skipnl contains=@texEnvGroup
626endif
Bram Moolenaar071d4272004-06-13 20:20:40 +0000627
628" Definitions/Commands: {{{1
629syn match texDefCmd "\\def\>" nextgroup=texDefName skipwhite skipnl
630if b:tex_stylish
631 syn match texDefName contained "\\[a-zA-Z@]\+" nextgroup=texDefParms,texCmdBody skipwhite skipnl
632 syn match texDefName contained "\\[^a-zA-Z@]" nextgroup=texDefParms,texCmdBody skipwhite skipnl
633else
634 syn match texDefName contained "\\\a\+" nextgroup=texDefParms,texCmdBody skipwhite skipnl
635 syn match texDefName contained "\\\A" nextgroup=texDefParms,texCmdBody skipwhite skipnl
636endif
637syn match texDefParms contained "#[^{]*" contains=texDefParm nextgroup=texCmdBody skipwhite skipnl
638syn match texDefParm contained "#\d\+"
639
640" TeX Lengths: {{{1
Bram Moolenaar9964e462007-05-05 17:54:07 +0000641syn match texLength "\<\d\+\([.,]\d\+\)\=\s*\(true\)\=\s*\(bp\|cc\|cm\|dd\|em\|ex\|in\|mm\|pc\|pt\|sp\)\>"
Bram Moolenaar071d4272004-06-13 20:20:40 +0000642
643" TeX String Delimiters: {{{1
644syn match texString "\(``\|''\|,,\)"
645
Bram Moolenaar5c736222010-01-06 20:54:52 +0100646" makeatletter -- makeatother sections
Bram Moolenaara0f849e2015-10-30 14:37:44 +0100647if !s:tex_no_error
Bram Moolenaarf3913272016-02-25 00:00:01 +0100648 if s:tex_fast =~# 'S'
Bram Moolenaarac7bd632013-03-19 11:35:58 +0100649 syn region texStyle matchgroup=texStatement start='\\makeatletter' end='\\makeatother' contains=@texStyleGroup contained
650 endif
Bram Moolenaar5c736222010-01-06 20:54:52 +0100651 syn match texStyleStatement "\\[a-zA-Z@]\+" contained
Bram Moolenaarf3913272016-02-25 00:00:01 +0100652 if s:tex_fast =~# 'S'
Bram Moolenaarac7bd632013-03-19 11:35:58 +0100653 syn region texStyleMatcher matchgroup=Delimiter start="{" skip="\\\\\|\\[{}]" end="}" contains=@texStyleGroup,texError contained
654 syn region texStyleMatcher matchgroup=Delimiter start="\[" end="]" contains=@texStyleGroup,texError contained
655 endif
Bram Moolenaar5c736222010-01-06 20:54:52 +0100656endif
657
Bram Moolenaar7fc0c062010-08-10 21:43:35 +0200658" Conceal mode support (supports set cole=2) {{{1
Bram Moolenaarb2c03502010-07-02 20:20:09 +0200659if has("conceal") && &enc == 'utf-8'
Bram Moolenaar611df5b2010-07-26 22:51:56 +0200660
661 " Math Symbols {{{2
Bram Moolenaar7fc0c062010-08-10 21:43:35 +0200662 " (many of these symbols were contributed by Björn Winckler)
Bram Moolenaarf3913272016-02-25 00:00:01 +0100663 if s:tex_conceal =~# 'm'
Bram Moolenaar7fc0c062010-08-10 21:43:35 +0200664 let s:texMathList=[
Bram Moolenaaradc21822011-04-01 18:03:16 +0200665 \ ['|' , '‖'],
Bram Moolenaard960d762011-09-21 19:22:10 +0200666 \ ['aleph' , 'ℵ'],
Bram Moolenaar6be7f872012-01-20 21:08:56 +0100667 \ ['amalg' , '∐'],
Bram Moolenaar7fc0c062010-08-10 21:43:35 +0200668 \ ['angle' , '∠'],
669 \ ['approx' , '≈'],
670 \ ['ast' , '∗'],
671 \ ['asymp' , '≍'],
672 \ ['backepsilon' , '∍'],
673 \ ['backsimeq' , '≃'],
Bram Moolenaard960d762011-09-21 19:22:10 +0200674 \ ['backslash' , '∖'],
Bram Moolenaar7fc0c062010-08-10 21:43:35 +0200675 \ ['barwedge' , '⊼'],
676 \ ['because' , '∵'],
677 \ ['between' , '≬'],
678 \ ['bigcap' , '∩'],
Bram Moolenaar6be7f872012-01-20 21:08:56 +0100679 \ ['bigcirc' , '○'],
Bram Moolenaar7fc0c062010-08-10 21:43:35 +0200680 \ ['bigcup' , '∪'],
681 \ ['bigodot' , '⊙'],
682 \ ['bigoplus' , '⊕'],
683 \ ['bigotimes' , '⊗'],
684 \ ['bigsqcup' , '⊔'],
685 \ ['bigtriangledown', '∇'],
Bram Moolenaar6be7f872012-01-20 21:08:56 +0100686 \ ['bigtriangleup' , '∆'],
Bram Moolenaar7fc0c062010-08-10 21:43:35 +0200687 \ ['bigvee' , '⋁'],
688 \ ['bigwedge' , '⋀'],
689 \ ['blacksquare' , '∎'],
690 \ ['bot' , '⊥'],
Bram Moolenaar6be7f872012-01-20 21:08:56 +0100691 \ ['bowtie' , '⋈'],
Bram Moolenaar7fc0c062010-08-10 21:43:35 +0200692 \ ['boxdot' , '⊡'],
693 \ ['boxminus' , '⊟'],
694 \ ['boxplus' , '⊞'],
695 \ ['boxtimes' , '⊠'],
Bram Moolenaar6be7f872012-01-20 21:08:56 +0100696 \ ['bullet' , '•'],
Bram Moolenaar7fc0c062010-08-10 21:43:35 +0200697 \ ['bumpeq' , '≏'],
698 \ ['Bumpeq' , '≎'],
699 \ ['cap' , '∩'],
700 \ ['Cap' , '⋒'],
701 \ ['cdot' , '·'],
702 \ ['cdots' , '⋯'],
703 \ ['circ' , '∘'],
704 \ ['circeq' , '≗'],
705 \ ['circlearrowleft', '↺'],
706 \ ['circlearrowright', '↻'],
707 \ ['circledast' , '⊛'],
708 \ ['circledcirc' , '⊚'],
Bram Moolenaard960d762011-09-21 19:22:10 +0200709 \ ['clubsuit' , '♣'],
Bram Moolenaar7fc0c062010-08-10 21:43:35 +0200710 \ ['complement' , '∁'],
711 \ ['cong' , '≅'],
712 \ ['coprod' , '∐'],
Bram Moolenaard960d762011-09-21 19:22:10 +0200713 \ ['copyright' , '©'],
Bram Moolenaar7fc0c062010-08-10 21:43:35 +0200714 \ ['cup' , '∪'],
715 \ ['Cup' , '⋓'],
716 \ ['curlyeqprec' , '⋞'],
717 \ ['curlyeqsucc' , '⋟'],
718 \ ['curlyvee' , '⋎'],
719 \ ['curlywedge' , '⋏'],
Bram Moolenaar6be7f872012-01-20 21:08:56 +0100720 \ ['dagger' , '†'],
Bram Moolenaar7fc0c062010-08-10 21:43:35 +0200721 \ ['dashv' , '⊣'],
Bram Moolenaar6be7f872012-01-20 21:08:56 +0100722 \ ['ddagger' , '‡'],
723 \ ['ddots' , '⋱'],
Bram Moolenaar7fc0c062010-08-10 21:43:35 +0200724 \ ['diamond' , '⋄'],
Bram Moolenaard960d762011-09-21 19:22:10 +0200725 \ ['diamondsuit' , '♢'],
Bram Moolenaar7fc0c062010-08-10 21:43:35 +0200726 \ ['div' , '÷'],
727 \ ['doteq' , '≐'],
728 \ ['doteqdot' , '≑'],
729 \ ['dotplus' , '∔'],
Bram Moolenaar6be7f872012-01-20 21:08:56 +0100730 \ ['dots' , '…'],
Bram Moolenaar7fc0c062010-08-10 21:43:35 +0200731 \ ['dotsb' , '⋯'],
732 \ ['dotsc' , '…'],
Bram Moolenaar7fc0c062010-08-10 21:43:35 +0200733 \ ['dotsi' , '⋯'],
734 \ ['dotso' , '…'],
735 \ ['doublebarwedge' , '⩞'],
736 \ ['downarrow' , '↓'],
737 \ ['Downarrow' , '⇓'],
Bram Moolenaar6be7f872012-01-20 21:08:56 +0100738 \ ['ell' , 'ℓ'],
Bram Moolenaar7fc0c062010-08-10 21:43:35 +0200739 \ ['emptyset' , '∅'],
740 \ ['eqcirc' , '≖'],
741 \ ['eqsim' , '≂'],
742 \ ['eqslantgtr' , '⪖'],
743 \ ['eqslantless' , '⪕'],
744 \ ['equiv' , '≡'],
745 \ ['exists' , '∃'],
746 \ ['fallingdotseq' , '≒'],
Bram Moolenaard960d762011-09-21 19:22:10 +0200747 \ ['flat' , '♭'],
Bram Moolenaar7fc0c062010-08-10 21:43:35 +0200748 \ ['forall' , '∀'],
Bram Moolenaar6be7f872012-01-20 21:08:56 +0100749 \ ['frown' , '⁔'],
Bram Moolenaar7fc0c062010-08-10 21:43:35 +0200750 \ ['ge' , '≥'],
751 \ ['geq' , '≥'],
752 \ ['geqq' , '≧'],
753 \ ['gets' , '←'],
Bram Moolenaar6be7f872012-01-20 21:08:56 +0100754 \ ['gg' , '⟫'],
Bram Moolenaar7fc0c062010-08-10 21:43:35 +0200755 \ ['gneqq' , '≩'],
756 \ ['gtrdot' , '⋗'],
757 \ ['gtreqless' , '⋛'],
758 \ ['gtrless' , '≷'],
759 \ ['gtrsim' , '≳'],
Bram Moolenaard960d762011-09-21 19:22:10 +0200760 \ ['hbar' , 'ℏ'],
761 \ ['heartsuit' , '♡'],
Bram Moolenaar7fc0c062010-08-10 21:43:35 +0200762 \ ['hookleftarrow' , '↩'],
763 \ ['hookrightarrow' , '↪'],
764 \ ['iiint' , '∭'],
765 \ ['iint' , '∬'],
766 \ ['Im' , 'ℑ'],
Bram Moolenaard960d762011-09-21 19:22:10 +0200767 \ ['imath' , 'ɩ'],
Bram Moolenaar7fc0c062010-08-10 21:43:35 +0200768 \ ['in' , '∈'],
769 \ ['infty' , '∞'],
770 \ ['int' , '∫'],
771 \ ['lceil' , '⌈'],
772 \ ['ldots' , '…'],
773 \ ['le' , '≤'],
Bram Moolenaar6be7f872012-01-20 21:08:56 +0100774 \ ['leadsto' , '↝'],
Bram Moolenaar7fc0c062010-08-10 21:43:35 +0200775 \ ['left(' , '('],
776 \ ['left\[' , '['],
777 \ ['left\\{' , '{'],
Bram Moolenaare2719092015-01-10 15:09:25 +0100778 \ ['leftarrow' , '←'],
779 \ ['Leftarrow' , '⇐'],
Bram Moolenaar6be7f872012-01-20 21:08:56 +0100780 \ ['leftarrowtail' , '↢'],
781 \ ['leftharpoondown', '↽'],
782 \ ['leftharpoonup' , '↼'],
Bram Moolenaar97d62492012-11-15 21:28:22 +0100783 \ ['leftrightarrow' , '↔'],
Bram Moolenaar6be7f872012-01-20 21:08:56 +0100784 \ ['Leftrightarrow' , '⇔'],
Bram Moolenaar7fc0c062010-08-10 21:43:35 +0200785 \ ['leftrightsquigarrow', '↭'],
786 \ ['leftthreetimes' , '⋋'],
787 \ ['leq' , '≤'],
Bram Moolenaar6be7f872012-01-20 21:08:56 +0100788 \ ['leq' , '≤'],
Bram Moolenaar7fc0c062010-08-10 21:43:35 +0200789 \ ['leqq' , '≦'],
790 \ ['lessdot' , '⋖'],
791 \ ['lesseqgtr' , '⋚'],
792 \ ['lesssim' , '≲'],
793 \ ['lfloor' , '⌊'],
Bram Moolenaar6be7f872012-01-20 21:08:56 +0100794 \ ['ll' , '≪'],
Bram Moolenaaradc21822011-04-01 18:03:16 +0200795 \ ['lmoustache' , '╭'],
Bram Moolenaar7fc0c062010-08-10 21:43:35 +0200796 \ ['lneqq' , '≨'],
797 \ ['ltimes' , '⋉'],
798 \ ['mapsto' , '↦'],
799 \ ['measuredangle' , '∡'],
800 \ ['mid' , '∣'],
Bram Moolenaar6be7f872012-01-20 21:08:56 +0100801 \ ['models' , '╞'],
Bram Moolenaar7fc0c062010-08-10 21:43:35 +0200802 \ ['mp' , '∓'],
803 \ ['nabla' , '∇'],
Bram Moolenaard960d762011-09-21 19:22:10 +0200804 \ ['natural' , '♮'],
Bram Moolenaar7fc0c062010-08-10 21:43:35 +0200805 \ ['ncong' , '≇'],
Bram Moolenaar7fc0c062010-08-10 21:43:35 +0200806 \ ['ne' , '≠'],
Bram Moolenaar6be7f872012-01-20 21:08:56 +0100807 \ ['nearrow' , '↗'],
Bram Moolenaar7fc0c062010-08-10 21:43:35 +0200808 \ ['neg' , '¬'],
809 \ ['neq' , '≠'],
810 \ ['nexists' , '∄'],
811 \ ['ngeq' , '≱'],
812 \ ['ngeqq' , '≱'],
813 \ ['ngtr' , '≯'],
814 \ ['ni' , '∋'],
815 \ ['nleftarrow' , '↚'],
816 \ ['nLeftarrow' , '⇍'],
817 \ ['nLeftrightarrow', '⇎'],
818 \ ['nleq' , '≰'],
819 \ ['nleqq' , '≰'],
820 \ ['nless' , '≮'],
821 \ ['nmid' , '∤'],
822 \ ['notin' , '∉'],
823 \ ['nprec' , '⊀'],
824 \ ['nrightarrow' , '↛'],
825 \ ['nRightarrow' , '⇏'],
826 \ ['nsim' , '≁'],
827 \ ['nsucc' , '⊁'],
828 \ ['ntriangleleft' , '⋪'],
829 \ ['ntrianglelefteq', '⋬'],
830 \ ['ntriangleright' , '⋫'],
831 \ ['ntrianglerighteq', '⋭'],
832 \ ['nvdash' , '⊬'],
833 \ ['nvDash' , '⊭'],
834 \ ['nVdash' , '⊮'],
835 \ ['nwarrow' , '↖'],
836 \ ['odot' , '⊙'],
837 \ ['oint' , '∮'],
838 \ ['ominus' , '⊖'],
839 \ ['oplus' , '⊕'],
840 \ ['oslash' , '⊘'],
841 \ ['otimes' , '⊗'],
842 \ ['owns' , '∋'],
Bram Moolenaard960d762011-09-21 19:22:10 +0200843 \ ['P' , '¶'],
Bram Moolenaar6be7f872012-01-20 21:08:56 +0100844 \ ['parallel' , '║'],
Bram Moolenaar7fc0c062010-08-10 21:43:35 +0200845 \ ['partial' , '∂'],
846 \ ['perp' , '⊥'],
847 \ ['pitchfork' , '⋔'],
848 \ ['pm' , '±'],
Bram Moolenaar7fc0c062010-08-10 21:43:35 +0200849 \ ['prec' , '≺'],
Bram Moolenaar6be7f872012-01-20 21:08:56 +0100850 \ ['precapprox' , '⪷'],
Bram Moolenaar7fc0c062010-08-10 21:43:35 +0200851 \ ['preccurlyeq' , '≼'],
852 \ ['preceq' , '⪯'],
853 \ ['precnapprox' , '⪹'],
854 \ ['precneqq' , '⪵'],
855 \ ['precsim' , '≾'],
Bram Moolenaard960d762011-09-21 19:22:10 +0200856 \ ['prime' , '′'],
Bram Moolenaar7fc0c062010-08-10 21:43:35 +0200857 \ ['prod' , '∏'],
858 \ ['propto' , '∝'],
859 \ ['rceil' , '⌉'],
860 \ ['Re' , 'ℜ'],
861 \ ['rfloor' , '⌋'],
Bram Moolenaar7fc0c062010-08-10 21:43:35 +0200862 \ ['right)' , ')'],
863 \ ['right]' , ']'],
864 \ ['right\\}' , '}'],
Bram Moolenaare2719092015-01-10 15:09:25 +0100865 \ ['rightarrow' , '→'],
866 \ ['Rightarrow' , '⇒'],
Bram Moolenaar6be7f872012-01-20 21:08:56 +0100867 \ ['rightarrowtail' , '↣'],
868 \ ['rightleftharpoons', '⇌'],
Bram Moolenaar7fc0c062010-08-10 21:43:35 +0200869 \ ['rightsquigarrow', '↝'],
870 \ ['rightthreetimes', '⋌'],
871 \ ['risingdotseq' , '≓'],
Bram Moolenaaradc21822011-04-01 18:03:16 +0200872 \ ['rmoustache' , '╮'],
Bram Moolenaar7fc0c062010-08-10 21:43:35 +0200873 \ ['rtimes' , '⋊'],
Bram Moolenaard960d762011-09-21 19:22:10 +0200874 \ ['S' , '§'],
Bram Moolenaar7fc0c062010-08-10 21:43:35 +0200875 \ ['searrow' , '↘'],
876 \ ['setminus' , '∖'],
Bram Moolenaard960d762011-09-21 19:22:10 +0200877 \ ['sharp' , '♯'],
Bram Moolenaar7fc0c062010-08-10 21:43:35 +0200878 \ ['sim' , '∼'],
Bram Moolenaar6be7f872012-01-20 21:08:56 +0100879 \ ['simeq' , '⋍'],
880 \ ['smile' , '‿'],
Bram Moolenaard960d762011-09-21 19:22:10 +0200881 \ ['spadesuit' , '♠'],
Bram Moolenaar7fc0c062010-08-10 21:43:35 +0200882 \ ['sphericalangle' , '∢'],
883 \ ['sqcap' , '⊓'],
884 \ ['sqcup' , '⊔'],
885 \ ['sqsubset' , '⊏'],
886 \ ['sqsubseteq' , '⊑'],
887 \ ['sqsupset' , '⊐'],
888 \ ['sqsupseteq' , '⊒'],
Bram Moolenaar6be7f872012-01-20 21:08:56 +0100889 \ ['star' , '✫'],
Bram Moolenaar7fc0c062010-08-10 21:43:35 +0200890 \ ['subset' , '⊂'],
891 \ ['Subset' , '⋐'],
892 \ ['subseteq' , '⊆'],
893 \ ['subseteqq' , '⫅'],
894 \ ['subsetneq' , '⊊'],
895 \ ['subsetneqq' , '⫋'],
Bram Moolenaar7fc0c062010-08-10 21:43:35 +0200896 \ ['succ' , '≻'],
Bram Moolenaar6be7f872012-01-20 21:08:56 +0100897 \ ['succapprox' , '⪸'],
Bram Moolenaar7fc0c062010-08-10 21:43:35 +0200898 \ ['succcurlyeq' , '≽'],
899 \ ['succeq' , '⪰'],
900 \ ['succnapprox' , '⪺'],
901 \ ['succneqq' , '⪶'],
902 \ ['succsim' , '≿'],
903 \ ['sum' , '∑'],
Bram Moolenaar6be7f872012-01-20 21:08:56 +0100904 \ ['supset' , '⊃'],
Bram Moolenaar7fc0c062010-08-10 21:43:35 +0200905 \ ['Supset' , '⋑'],
906 \ ['supseteq' , '⊇'],
907 \ ['supseteqq' , '⫆'],
908 \ ['supsetneq' , '⊋'],
909 \ ['supsetneqq' , '⫌'],
910 \ ['surd' , '√'],
911 \ ['swarrow' , '↙'],
912 \ ['therefore' , '∴'],
913 \ ['times' , '×'],
914 \ ['to' , '→'],
915 \ ['top' , '⊤'],
Bram Moolenaard960d762011-09-21 19:22:10 +0200916 \ ['triangle' , '∆'],
Bram Moolenaar7fc0c062010-08-10 21:43:35 +0200917 \ ['triangleleft' , '⊲'],
918 \ ['trianglelefteq' , '⊴'],
919 \ ['triangleq' , '≜'],
920 \ ['triangleright' , '⊳'],
921 \ ['trianglerighteq', '⊵'],
922 \ ['twoheadleftarrow', '↞'],
923 \ ['twoheadrightarrow', '↠'],
924 \ ['uparrow' , '↑'],
925 \ ['Uparrow' , '⇑'],
926 \ ['updownarrow' , '↕'],
927 \ ['Updownarrow' , '⇕'],
928 \ ['varnothing' , '∅'],
929 \ ['vartriangle' , '∆'],
930 \ ['vdash' , '⊢'],
931 \ ['vDash' , '⊨'],
932 \ ['Vdash' , '⊩'],
933 \ ['vdots' , '⋮'],
Bram Moolenaar7fc0c062010-08-10 21:43:35 +0200934 \ ['vee' , '∨'],
Bram Moolenaar6be7f872012-01-20 21:08:56 +0100935 \ ['veebar' , '⊻'],
Bram Moolenaar7fc0c062010-08-10 21:43:35 +0200936 \ ['Vvdash' , '⊪'],
937 \ ['wedge' , '∧'],
Bram Moolenaard960d762011-09-21 19:22:10 +0200938 \ ['wp' , '℘'],
Bram Moolenaar7fc0c062010-08-10 21:43:35 +0200939 \ ['wr' , '≀']]
Bram Moolenaar6be7f872012-01-20 21:08:56 +0100940" \ ['jmath' , 'X']
941" \ ['uminus' , 'X']
942" \ ['uplus' , 'X']
Bram Moolenaar7fc0c062010-08-10 21:43:35 +0200943 for texmath in s:texMathList
Bram Moolenaarf3913272016-02-25 00:00:01 +0100944 if texmath[0] =~# '\w$'
Bram Moolenaar81af9252010-12-10 20:35:50 +0100945 exe "syn match texMathSymbol '\\\\".texmath[0]."\\>' contained conceal cchar=".texmath[1]
946 else
947 exe "syn match texMathSymbol '\\\\".texmath[0]."' contained conceal cchar=".texmath[1]
948 endif
Bram Moolenaar7fc0c062010-08-10 21:43:35 +0200949 endfor
Bram Moolenaar74cbdf02010-08-04 23:03:17 +0200950
951 if &ambw == "double"
952 syn match texMathSymbol '\\gg\>' contained conceal cchar=≫
953 syn match texMathSymbol '\\ll\>' contained conceal cchar=≪
954 else
955 syn match texMathSymbol '\\gg\>' contained conceal cchar=⟫
956 syn match texMathSymbol '\\ll\>' contained conceal cchar=⟪
957 endif
Bram Moolenaard960d762011-09-21 19:22:10 +0200958
959 syn match texMathSymbol '\\hat{a}' contained conceal cchar=â
960 syn match texMathSymbol '\\hat{A}' contained conceal cchar=Â
961 syn match texMathSymbol '\\hat{c}' contained conceal cchar=ĉ
962 syn match texMathSymbol '\\hat{C}' contained conceal cchar=Ĉ
963 syn match texMathSymbol '\\hat{e}' contained conceal cchar=ê
964 syn match texMathSymbol '\\hat{E}' contained conceal cchar=Ê
965 syn match texMathSymbol '\\hat{g}' contained conceal cchar=ĝ
966 syn match texMathSymbol '\\hat{G}' contained conceal cchar=Ĝ
967 syn match texMathSymbol '\\hat{i}' contained conceal cchar=î
968 syn match texMathSymbol '\\hat{I}' contained conceal cchar=Î
969 syn match texMathSymbol '\\hat{o}' contained conceal cchar=ô
970 syn match texMathSymbol '\\hat{O}' contained conceal cchar=Ô
971 syn match texMathSymbol '\\hat{s}' contained conceal cchar=ŝ
972 syn match texMathSymbol '\\hat{S}' contained conceal cchar=Ŝ
973 syn match texMathSymbol '\\hat{u}' contained conceal cchar=û
974 syn match texMathSymbol '\\hat{U}' contained conceal cchar=Û
975 syn match texMathSymbol '\\hat{w}' contained conceal cchar=ŵ
976 syn match texMathSymbol '\\hat{W}' contained conceal cchar=Ŵ
977 syn match texMathSymbol '\\hat{y}' contained conceal cchar=ŷ
978 syn match texMathSymbol '\\hat{Y}' contained conceal cchar=Ŷ
Bram Moolenaare2719092015-01-10 15:09:25 +0100979" syn match texMathSymbol '\\bar{a}' contained conceal cchar=a̅
Bram Moolenaar4b22cdb2010-08-02 22:12:46 +0200980 endif
Bram Moolenaar611df5b2010-07-26 22:51:56 +0200981
982 " Greek {{{2
Bram Moolenaarf3913272016-02-25 00:00:01 +0100983 if s:tex_conceal =~# 'g'
Bram Moolenaar4b22cdb2010-08-02 22:12:46 +0200984 fun! s:Greek(group,pat,cchar)
985 exe 'syn match '.a:group." '".a:pat."' contained conceal cchar=".a:cchar
986 endfun
987 call s:Greek('texGreek','\\alpha\>' ,'α')
988 call s:Greek('texGreek','\\beta\>' ,'β')
989 call s:Greek('texGreek','\\gamma\>' ,'γ')
990 call s:Greek('texGreek','\\delta\>' ,'δ')
991 call s:Greek('texGreek','\\epsilon\>' ,'ϵ')
992 call s:Greek('texGreek','\\varepsilon\>' ,'ε')
993 call s:Greek('texGreek','\\zeta\>' ,'ζ')
994 call s:Greek('texGreek','\\eta\>' ,'η')
995 call s:Greek('texGreek','\\theta\>' ,'θ')
Bram Moolenaare2719092015-01-10 15:09:25 +0100996 call s:Greek('texGreek','\\vartheta\>' ,'ϑ')
Bram Moolenaar4b22cdb2010-08-02 22:12:46 +0200997 call s:Greek('texGreek','\\kappa\>' ,'κ')
998 call s:Greek('texGreek','\\lambda\>' ,'λ')
999 call s:Greek('texGreek','\\mu\>' ,'μ')
1000 call s:Greek('texGreek','\\nu\>' ,'ν')
1001 call s:Greek('texGreek','\\xi\>' ,'ξ')
1002 call s:Greek('texGreek','\\pi\>' ,'π')
1003 call s:Greek('texGreek','\\varpi\>' ,'ϖ')
1004 call s:Greek('texGreek','\\rho\>' ,'ρ')
1005 call s:Greek('texGreek','\\varrho\>' ,'ϱ')
1006 call s:Greek('texGreek','\\sigma\>' ,'σ')
Bram Moolenaare2719092015-01-10 15:09:25 +01001007 call s:Greek('texGreek','\\varsigma\>' ,'ς')
Bram Moolenaar4b22cdb2010-08-02 22:12:46 +02001008 call s:Greek('texGreek','\\tau\>' ,'τ')
1009 call s:Greek('texGreek','\\upsilon\>' ,'υ')
Bram Moolenaare2719092015-01-10 15:09:25 +01001010 call s:Greek('texGreek','\\phi\>' ,'ϕ')
1011 call s:Greek('texGreek','\\varphi\>' ,'φ')
Bram Moolenaar4b22cdb2010-08-02 22:12:46 +02001012 call s:Greek('texGreek','\\chi\>' ,'χ')
1013 call s:Greek('texGreek','\\psi\>' ,'ψ')
1014 call s:Greek('texGreek','\\omega\>' ,'ω')
1015 call s:Greek('texGreek','\\Gamma\>' ,'Γ')
1016 call s:Greek('texGreek','\\Delta\>' ,'Δ')
1017 call s:Greek('texGreek','\\Theta\>' ,'Θ')
1018 call s:Greek('texGreek','\\Lambda\>' ,'Λ')
1019 call s:Greek('texGreek','\\Xi\>' ,'Χ')
1020 call s:Greek('texGreek','\\Pi\>' ,'Π')
1021 call s:Greek('texGreek','\\Sigma\>' ,'Σ')
1022 call s:Greek('texGreek','\\Upsilon\>' ,'Υ')
1023 call s:Greek('texGreek','\\Phi\>' ,'Φ')
1024 call s:Greek('texGreek','\\Psi\>' ,'Ψ')
1025 call s:Greek('texGreek','\\Omega\>' ,'Ω')
1026 delfun s:Greek
1027 endif
Bram Moolenaar611df5b2010-07-26 22:51:56 +02001028
1029 " Superscripts/Subscripts {{{2
Bram Moolenaarf3913272016-02-25 00:00:01 +01001030 if s:tex_conceal =~# 's'
1031 if s:tex_fast =~# 's'
Bram Moolenaarac7bd632013-03-19 11:35:58 +01001032 syn region texSuperscript matchgroup=Delimiter start='\^{' skip="\\\\\|\\[{}]" end='}' contained concealends contains=texSpecialChar,texSuperscripts,texStatement,texSubscript,texSuperscript,texMathMatcher
1033 syn region texSubscript matchgroup=Delimiter start='_{' skip="\\\\\|\\[{}]" end='}' contained concealends contains=texSpecialChar,texSubscripts,texStatement,texSubscript,texSuperscript,texMathMatcher
1034 endif
Bram Moolenaar541f92d2015-06-19 13:27:23 +02001035 " s:SuperSub:
Bram Moolenaar4b22cdb2010-08-02 22:12:46 +02001036 fun! s:SuperSub(group,leader,pat,cchar)
Bram Moolenaar03413f42016-04-12 21:07:15 +02001037 if a:pat =~# '^\\' || (a:leader == '\^' && a:pat =~# s:tex_superscripts) || (a:leader == '_' && a:pat =~# s:tex_subscripts)
Bram Moolenaar6e932462014-09-09 18:48:09 +02001038" call Decho("SuperSub: group<".a:group."> leader<".a:leader."> pat<".a:pat."> cchar<".a:cchar.">")
1039 exe 'syn match '.a:group." '".a:leader.a:pat."' contained conceal cchar=".a:cchar
Bram Moolenaar541f92d2015-06-19 13:27:23 +02001040 exe 'syn match '.a:group."s '".a:pat ."' contained conceal cchar=".a:cchar.' nextgroup='.a:group.'s'
Bram Moolenaar6e932462014-09-09 18:48:09 +02001041 endif
Bram Moolenaar4b22cdb2010-08-02 22:12:46 +02001042 endfun
1043 call s:SuperSub('texSuperscript','\^','0','⁰')
1044 call s:SuperSub('texSuperscript','\^','1','¹')
1045 call s:SuperSub('texSuperscript','\^','2','²')
1046 call s:SuperSub('texSuperscript','\^','3','³')
1047 call s:SuperSub('texSuperscript','\^','4','⁴')
1048 call s:SuperSub('texSuperscript','\^','5','⁵')
1049 call s:SuperSub('texSuperscript','\^','6','⁶')
1050 call s:SuperSub('texSuperscript','\^','7','⁷')
1051 call s:SuperSub('texSuperscript','\^','8','⁸')
1052 call s:SuperSub('texSuperscript','\^','9','⁹')
1053 call s:SuperSub('texSuperscript','\^','a','ᵃ')
1054 call s:SuperSub('texSuperscript','\^','b','ᵇ')
1055 call s:SuperSub('texSuperscript','\^','c','ᶜ')
1056 call s:SuperSub('texSuperscript','\^','d','ᵈ')
1057 call s:SuperSub('texSuperscript','\^','e','ᵉ')
1058 call s:SuperSub('texSuperscript','\^','f','ᶠ')
1059 call s:SuperSub('texSuperscript','\^','g','ᵍ')
1060 call s:SuperSub('texSuperscript','\^','h','ʰ')
1061 call s:SuperSub('texSuperscript','\^','i','ⁱ')
1062 call s:SuperSub('texSuperscript','\^','j','ʲ')
1063 call s:SuperSub('texSuperscript','\^','k','ᵏ')
1064 call s:SuperSub('texSuperscript','\^','l','ˡ')
1065 call s:SuperSub('texSuperscript','\^','m','ᵐ')
1066 call s:SuperSub('texSuperscript','\^','n','ⁿ')
1067 call s:SuperSub('texSuperscript','\^','o','ᵒ')
1068 call s:SuperSub('texSuperscript','\^','p','ᵖ')
1069 call s:SuperSub('texSuperscript','\^','r','ʳ')
1070 call s:SuperSub('texSuperscript','\^','s','ˢ')
1071 call s:SuperSub('texSuperscript','\^','t','ᵗ')
1072 call s:SuperSub('texSuperscript','\^','u','ᵘ')
1073 call s:SuperSub('texSuperscript','\^','v','ᵛ')
1074 call s:SuperSub('texSuperscript','\^','w','ʷ')
1075 call s:SuperSub('texSuperscript','\^','x','ˣ')
1076 call s:SuperSub('texSuperscript','\^','y','ʸ')
1077 call s:SuperSub('texSuperscript','\^','z','ᶻ')
1078 call s:SuperSub('texSuperscript','\^','A','ᴬ')
1079 call s:SuperSub('texSuperscript','\^','B','ᴮ')
1080 call s:SuperSub('texSuperscript','\^','D','ᴰ')
1081 call s:SuperSub('texSuperscript','\^','E','ᴱ')
1082 call s:SuperSub('texSuperscript','\^','G','ᴳ')
1083 call s:SuperSub('texSuperscript','\^','H','ᴴ')
1084 call s:SuperSub('texSuperscript','\^','I','ᴵ')
1085 call s:SuperSub('texSuperscript','\^','J','ᴶ')
1086 call s:SuperSub('texSuperscript','\^','K','ᴷ')
1087 call s:SuperSub('texSuperscript','\^','L','ᴸ')
1088 call s:SuperSub('texSuperscript','\^','M','ᴹ')
1089 call s:SuperSub('texSuperscript','\^','N','ᴺ')
1090 call s:SuperSub('texSuperscript','\^','O','ᴼ')
1091 call s:SuperSub('texSuperscript','\^','P','ᴾ')
1092 call s:SuperSub('texSuperscript','\^','R','ᴿ')
1093 call s:SuperSub('texSuperscript','\^','T','ᵀ')
1094 call s:SuperSub('texSuperscript','\^','U','ᵁ')
1095 call s:SuperSub('texSuperscript','\^','W','ᵂ')
Bram Moolenaar6be7f872012-01-20 21:08:56 +01001096 call s:SuperSub('texSuperscript','\^',',','︐')
1097 call s:SuperSub('texSuperscript','\^',':','︓')
1098 call s:SuperSub('texSuperscript','\^',';','︔')
Bram Moolenaar4b22cdb2010-08-02 22:12:46 +02001099 call s:SuperSub('texSuperscript','\^','+','⁺')
1100 call s:SuperSub('texSuperscript','\^','-','⁻')
1101 call s:SuperSub('texSuperscript','\^','<','˂')
1102 call s:SuperSub('texSuperscript','\^','>','˃')
1103 call s:SuperSub('texSuperscript','\^','/','ˊ')
1104 call s:SuperSub('texSuperscript','\^','(','⁽')
1105 call s:SuperSub('texSuperscript','\^',')','⁾')
1106 call s:SuperSub('texSuperscript','\^','\.','˙')
1107 call s:SuperSub('texSuperscript','\^','=','˭')
1108 call s:SuperSub('texSubscript','_','0','₀')
1109 call s:SuperSub('texSubscript','_','1','₁')
1110 call s:SuperSub('texSubscript','_','2','₂')
1111 call s:SuperSub('texSubscript','_','3','₃')
1112 call s:SuperSub('texSubscript','_','4','₄')
1113 call s:SuperSub('texSubscript','_','5','₅')
1114 call s:SuperSub('texSubscript','_','6','₆')
1115 call s:SuperSub('texSubscript','_','7','₇')
1116 call s:SuperSub('texSubscript','_','8','₈')
1117 call s:SuperSub('texSubscript','_','9','₉')
1118 call s:SuperSub('texSubscript','_','a','ₐ')
1119 call s:SuperSub('texSubscript','_','e','ₑ')
Bram Moolenaar802a0d92016-06-26 16:17:58 +02001120 call s:SuperSub('texSubscript','_','h','ₕ')
Bram Moolenaar4b22cdb2010-08-02 22:12:46 +02001121 call s:SuperSub('texSubscript','_','i','ᵢ')
Bram Moolenaar802a0d92016-06-26 16:17:58 +02001122 call s:SuperSub('texSubscript','_','j','ⱼ')
1123 call s:SuperSub('texSubscript','_','k','ₖ')
1124 call s:SuperSub('texSubscript','_','l','ₗ')
1125 call s:SuperSub('texSubscript','_','m','ₘ')
1126 call s:SuperSub('texSubscript','_','n','ₙ')
Bram Moolenaar4b22cdb2010-08-02 22:12:46 +02001127 call s:SuperSub('texSubscript','_','o','ₒ')
Bram Moolenaar802a0d92016-06-26 16:17:58 +02001128 call s:SuperSub('texSubscript','_','p','ₚ')
1129 call s:SuperSub('texSubscript','_','r','ᵣ')
1130 call s:SuperSub('texSubscript','_','s','ₛ')
1131 call s:SuperSub('texSubscript','_','t','ₜ')
Bram Moolenaar4b22cdb2010-08-02 22:12:46 +02001132 call s:SuperSub('texSubscript','_','u','ᵤ')
Bram Moolenaar802a0d92016-06-26 16:17:58 +02001133 call s:SuperSub('texSubscript','_','v','ᵥ')
1134 call s:SuperSub('texSubscript','_','x','ₓ')
Bram Moolenaar6be7f872012-01-20 21:08:56 +01001135 call s:SuperSub('texSubscript','_',',','︐')
Bram Moolenaar4b22cdb2010-08-02 22:12:46 +02001136 call s:SuperSub('texSubscript','_','+','₊')
1137 call s:SuperSub('texSubscript','_','-','₋')
1138 call s:SuperSub('texSubscript','_','/','ˏ')
1139 call s:SuperSub('texSubscript','_','(','₍')
1140 call s:SuperSub('texSubscript','_',')','₎')
1141 call s:SuperSub('texSubscript','_','\.','‸')
1142 call s:SuperSub('texSubscript','_','r','ᵣ')
1143 call s:SuperSub('texSubscript','_','v','ᵥ')
1144 call s:SuperSub('texSubscript','_','x','ₓ')
1145 call s:SuperSub('texSubscript','_','\\beta\>' ,'ᵦ')
1146 call s:SuperSub('texSubscript','_','\\delta\>','ᵨ')
1147 call s:SuperSub('texSubscript','_','\\phi\>' ,'ᵩ')
1148 call s:SuperSub('texSubscript','_','\\gamma\>','ᵧ')
1149 call s:SuperSub('texSubscript','_','\\chi\>' ,'ᵪ')
Bram Moolenaar802a0d92016-06-26 16:17:58 +02001150
Bram Moolenaar4b22cdb2010-08-02 22:12:46 +02001151 delfun s:SuperSub
1152 endif
Bram Moolenaar611df5b2010-07-26 22:51:56 +02001153
1154 " Accented characters: {{{2
Bram Moolenaarf3913272016-02-25 00:00:01 +01001155 if s:tex_conceal =~# 'a'
Bram Moolenaar4b22cdb2010-08-02 22:12:46 +02001156 if b:tex_stylish
1157 syn match texAccent "\\[bcdvuH][^a-zA-Z@]"me=e-1
1158 syn match texLigature "\\\([ijolL]\|ae\|oe\|ss\|AA\|AE\|OE\)[^a-zA-Z@]"me=e-1
1159 else
1160 fun! s:Accents(chr,...)
1161 let i= 1
Bram Moolenaara6878372014-03-22 21:02:50 +01001162 for accent in ["`","\\'","^",'"','\~','\.','=',"c","H","k","r","u","v"]
Bram Moolenaar4b22cdb2010-08-02 22:12:46 +02001163 if i > a:0
1164 break
1165 endif
Bram Moolenaar7fc0c062010-08-10 21:43:35 +02001166 if strlen(a:{i}) == 0 || a:{i} == ' ' || a:{i} == '?'
Bram Moolenaar4b22cdb2010-08-02 22:12:46 +02001167 let i= i + 1
1168 continue
1169 endif
Bram Moolenaarf3913272016-02-25 00:00:01 +01001170 if accent =~# '\a'
Bram Moolenaar7fc0c062010-08-10 21:43:35 +02001171 exe "syn match texAccent '".'\\'.accent.'\(\s*{'.a:chr.'}\|\s\+'.a:chr.'\)'."' conceal cchar=".a:{i}
1172 else
1173 exe "syn match texAccent '".'\\'.accent.'\s*\({'.a:chr.'}\|'.a:chr.'\)'."' conceal cchar=".a:{i}
1174 endif
Bram Moolenaare0021c72010-07-28 17:25:21 +02001175 let i= i + 1
Bram Moolenaar4b22cdb2010-08-02 22:12:46 +02001176 endfor
1177 endfun
Bram Moolenaar6e932462014-09-09 18:48:09 +02001178 " \` \' \^ \" \~ \. \= \c \H \k \r \u \v
1179 call s:Accents('a','à','á','â','ä','ã','ȧ','ā',' ',' ','ą','å','ă','ǎ')
1180 call s:Accents('A','À','Á','Â','Ä','Ã','Ȧ','Ā',' ',' ','Ą','Å','Ă','Ǎ')
1181 call s:Accents('c',' ','ć','ĉ',' ',' ','ċ',' ','ç',' ',' ',' ',' ','č')
1182 call s:Accents('C',' ','Ć','Ĉ',' ',' ','Ċ',' ','Ç',' ',' ',' ',' ','Č')
1183 call s:Accents('d',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','ď')
1184 call s:Accents('D',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','Ď')
1185 call s:Accents('e','è','é','ê','ë','ẽ','ė','ē','ȩ',' ','ę',' ','ĕ','ě')
1186 call s:Accents('E','È','É','Ê','Ë','Ẽ','Ė','Ē','Ȩ',' ','Ę',' ','Ĕ','Ě')
1187 call s:Accents('g',' ','ǵ','ĝ',' ',' ','ġ',' ','ģ',' ',' ',' ','ğ','ǧ')
1188 call s:Accents('G',' ','Ǵ','Ĝ',' ',' ','Ġ',' ','Ģ',' ',' ',' ','Ğ','Ǧ')
1189 call s:Accents('h',' ',' ','ĥ',' ',' ',' ',' ',' ',' ',' ',' ',' ','ȟ')
1190 call s:Accents('H',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','Ȟ')
1191 call s:Accents('i','ì','í','î','ï','ĩ','į','ī',' ',' ','į',' ','ĭ','ǐ')
1192 call s:Accents('I','Ì','Í','Î','Ï','Ĩ','İ','Ī',' ',' ','Į',' ','Ĭ','Ǐ')
1193 call s:Accents('J',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','ǰ')
1194 call s:Accents('k',' ',' ',' ',' ',' ',' ',' ','ķ',' ',' ',' ',' ','ǩ')
1195 call s:Accents('K',' ',' ',' ',' ',' ',' ',' ','Ķ',' ',' ',' ',' ','Ǩ')
1196 call s:Accents('l',' ','ĺ','ľ',' ',' ',' ',' ','ļ',' ',' ',' ',' ','ľ')
1197 call s:Accents('L',' ','Ĺ','Ľ',' ',' ',' ',' ','Ļ',' ',' ',' ',' ','Ľ')
1198 call s:Accents('n',' ','ń',' ',' ','ñ',' ',' ','ņ',' ',' ',' ',' ','ň')
1199 call s:Accents('N',' ','Ń',' ',' ','Ñ',' ',' ','Ņ',' ',' ',' ',' ','Ň')
1200 call s:Accents('o','ò','ó','ô','ö','õ','ȯ','ō',' ','ő','ǫ',' ','ŏ','ǒ')
1201 call s:Accents('O','Ò','Ó','Ô','Ö','Õ','Ȯ','Ō',' ','Ő','Ǫ',' ','Ŏ','Ǒ')
1202 call s:Accents('r',' ','ŕ',' ',' ',' ',' ',' ','ŗ',' ',' ',' ',' ','ř')
1203 call s:Accents('R',' ','Ŕ',' ',' ',' ',' ',' ','Ŗ',' ',' ',' ',' ','Ř')
1204 call s:Accents('s',' ','ś','ŝ',' ',' ',' ',' ','ş',' ','ȿ',' ',' ','š')
1205 call s:Accents('S',' ','Ś','Ŝ',' ',' ',' ',' ','Ş',' ',' ',' ',' ','Š')
1206 call s:Accents('t',' ',' ',' ',' ',' ',' ',' ','ţ',' ',' ',' ',' ','ť')
1207 call s:Accents('T',' ',' ',' ',' ',' ',' ',' ','Ţ',' ',' ',' ',' ','Ť')
1208 call s:Accents('u','ù','ú','û','ü','ũ',' ','ū',' ','ű','ų','ů','ŭ','ǔ')
1209 call s:Accents('U','Ù','Ú','Û','Ü','Ũ',' ','Ū',' ','Ű','Ų','Ů','Ŭ','Ǔ')
1210 call s:Accents('w',' ',' ','ŵ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ')
1211 call s:Accents('W',' ',' ','Ŵ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ')
1212 call s:Accents('y','ỳ','ý','ŷ','ÿ','ỹ',' ',' ',' ',' ',' ',' ',' ',' ')
1213 call s:Accents('Y','Ỳ','Ý','Ŷ','Ÿ','Ỹ',' ',' ',' ',' ',' ',' ',' ',' ')
1214 call s:Accents('z',' ','ź',' ',' ',' ','ż',' ',' ',' ',' ',' ',' ','ž')
1215 call s:Accents('Z',' ','Ź',' ',' ',' ','Ż',' ',' ',' ',' ',' ',' ','Ž')
Bram Moolenaara6878372014-03-22 21:02:50 +01001216 call s:Accents('\\i','ì','í','î','ï','ĩ','į',' ',' ',' ',' ',' ','ĭ',' ')
1217 " \` \' \^ \" \~ \. \= \c \H \k \r \u \v
Bram Moolenaar4b22cdb2010-08-02 22:12:46 +02001218 delfun s:Accents
1219 syn match texAccent '\\aa\>' conceal cchar=å
1220 syn match texAccent '\\AA\>' conceal cchar=Å
Bram Moolenaar4b22cdb2010-08-02 22:12:46 +02001221 syn match texAccent '\\o\>' conceal cchar=ø
1222 syn match texAccent '\\O\>' conceal cchar=Ø
Bram Moolenaar4b22cdb2010-08-02 22:12:46 +02001223 syn match texLigature '\\AE\>' conceal cchar=Æ
1224 syn match texLigature '\\ae\>' conceal cchar=æ
1225 syn match texLigature '\\oe\>' conceal cchar=œ
1226 syn match texLigature '\\OE\>' conceal cchar=Œ
1227 syn match texLigature '\\ss\>' conceal cchar=ß
1228 endif
Bram Moolenaar611df5b2010-07-26 22:51:56 +02001229 endif
Bram Moolenaarb2c03502010-07-02 20:20:09 +02001230endif
1231
1232" ---------------------------------------------------------------------
Bram Moolenaar071d4272004-06-13 20:20:40 +00001233" LaTeX synchronization: {{{1
1234syn sync maxlines=200
1235syn sync minlines=50
1236
1237syn sync match texSyncStop groupthere NONE "%stopzone\>"
1238
1239" Synchronization: {{{1
1240" The $..$ and $$..$$ make for impossible sync patterns
1241" (one can't tell if a "$$" starts or stops a math zone by itself)
1242" The following grouptheres coupled with minlines above
1243" help improve the odds of good syncing.
Bram Moolenaare2719092015-01-10 15:09:25 +01001244if !exists("g:tex_no_math")
Bram Moolenaar071d4272004-06-13 20:20:40 +00001245 syn sync match texSyncMathZoneA groupthere NONE "\\end{abstract}"
1246 syn sync match texSyncMathZoneA groupthere NONE "\\end{center}"
1247 syn sync match texSyncMathZoneA groupthere NONE "\\end{description}"
1248 syn sync match texSyncMathZoneA groupthere NONE "\\end{enumerate}"
1249 syn sync match texSyncMathZoneA groupthere NONE "\\end{itemize}"
1250 syn sync match texSyncMathZoneA groupthere NONE "\\end{table}"
1251 syn sync match texSyncMathZoneA groupthere NONE "\\end{tabular}"
1252 syn sync match texSyncMathZoneA groupthere NONE "\\\(sub\)*section\>"
1253endif
1254
Bram Moolenaarb2c03502010-07-02 20:20:09 +02001255" ---------------------------------------------------------------------
Bram Moolenaar071d4272004-06-13 20:20:40 +00001256" Highlighting: {{{1
Bram Moolenaarf37506f2016-08-31 22:22:10 +02001257
1258" Define the default highlighting. {{{1
1259if !exists("skip_tex_syntax_inits")
1260
Bram Moolenaar071d4272004-06-13 20:20:40 +00001261 " TeX highlighting groups which should share similar highlighting
Bram Moolenaar6e932462014-09-09 18:48:09 +02001262 if !exists("g:tex_no_error")
Bram Moolenaar543b7ef2013-06-01 14:50:56 +02001263 if !exists("g:tex_no_math")
Bram Moolenaarf37506f2016-08-31 22:22:10 +02001264 hi def link texBadMath texError
1265 hi def link texMathDelimBad texError
1266 hi def link texMathError texError
Bram Moolenaar071d4272004-06-13 20:20:40 +00001267 if !b:tex_stylish
Bram Moolenaarf37506f2016-08-31 22:22:10 +02001268 hi def link texOnlyMath texError
Bram Moolenaar071d4272004-06-13 20:20:40 +00001269 endif
1270 endif
Bram Moolenaarf37506f2016-08-31 22:22:10 +02001271 hi def link texError Error
Bram Moolenaar071d4272004-06-13 20:20:40 +00001272 endif
1273
Bram Moolenaard38b0552012-04-25 19:07:41 +02001274 hi texBoldStyle gui=bold cterm=bold
1275 hi texItalStyle gui=italic cterm=italic
1276 hi texBoldItalStyle gui=bold,italic cterm=bold,italic
1277 hi texItalBoldStyle gui=bold,italic cterm=bold,italic
Bram Moolenaarf37506f2016-08-31 22:22:10 +02001278 hi def link texCite texRefZone
1279 hi def link texDefCmd texDef
1280 hi def link texDefName texDef
1281 hi def link texDocType texCmdName
1282 hi def link texDocTypeArgs texCmdArgs
1283 hi def link texInputFileOpt texCmdArgs
1284 hi def link texInputCurlies texDelimiter
1285 hi def link texLigature texSpecialChar
Bram Moolenaare2719092015-01-10 15:09:25 +01001286 if !exists("g:tex_no_math")
Bram Moolenaarf37506f2016-08-31 22:22:10 +02001287 hi def link texMathDelimSet1 texMathDelim
1288 hi def link texMathDelimSet2 texMathDelim
1289 hi def link texMathDelimKey texMathDelim
1290 hi def link texMathMatcher texMath
1291 hi def link texAccent texStatement
1292 hi def link texGreek texStatement
1293 hi def link texSuperscript texStatement
1294 hi def link texSubscript texStatement
1295 hi def link texSuperscripts texSuperscript
1296 hi def link texSubscripts texSubscript
1297 hi def link texMathSymbol texStatement
1298 hi def link texMathZoneV texMath
1299 hi def link texMathZoneW texMath
1300 hi def link texMathZoneX texMath
1301 hi def link texMathZoneY texMath
1302 hi def link texMathZoneV texMath
1303 hi def link texMathZoneZ texMath
Bram Moolenaar071d4272004-06-13 20:20:40 +00001304 endif
Bram Moolenaarf37506f2016-08-31 22:22:10 +02001305 hi def link texBeginEnd texCmdName
1306 hi def link texBeginEndName texSection
1307 hi def link texSpaceCode texStatement
1308 hi def link texStyleStatement texStatement
1309 hi def link texTypeSize texType
1310 hi def link texTypeStyle texType
Bram Moolenaar071d4272004-06-13 20:20:40 +00001311
1312 " Basic TeX highlighting groups
Bram Moolenaarf37506f2016-08-31 22:22:10 +02001313 hi def link texCmdArgs Number
1314 hi def link texCmdName Statement
1315 hi def link texComment Comment
1316 hi def link texDef Statement
1317 hi def link texDefParm Special
1318 hi def link texDelimiter Delimiter
1319 hi def link texInput Special
1320 hi def link texInputFile Special
1321 hi def link texLength Number
1322 hi def link texMath Special
1323 hi def link texMathDelim Statement
1324 hi def link texMathOper Operator
1325 hi def link texNewCmd Statement
1326 hi def link texNewEnv Statement
1327 hi def link texOption Number
1328 hi def link texRefZone Special
1329 hi def link texSection PreCondit
1330 hi def link texSpaceCodeChar Special
1331 hi def link texSpecialChar SpecialChar
1332 hi def link texStatement Statement
1333 hi def link texString String
1334 hi def link texTodo Todo
1335 hi def link texType Type
1336 hi def link texZone PreCondit
Bram Moolenaar071d4272004-06-13 20:20:40 +00001337
Bram Moolenaar071d4272004-06-13 20:20:40 +00001338endif
1339
Bram Moolenaar15146672011-10-20 22:22:38 +02001340" Cleanup: {{{1
Bram Moolenaara0f849e2015-10-30 14:37:44 +01001341delc TexFold
Bram Moolenaar81af9252010-12-10 20:35:50 +01001342unlet s:extfname
Bram Moolenaar071d4272004-06-13 20:20:40 +00001343let b:current_syntax = "tex"
Bram Moolenaar15146672011-10-20 22:22:38 +02001344let &cpo = s:keepcpo
1345unlet s:keepcpo
Bram Moolenaare90ee312010-08-05 22:08:47 +02001346" vim: ts=8 fdm=marker