Mercurial > vim
annotate runtime/syntax/tex.vim @ 2424:ee4e1e140117 vim73
More accented characters in tex.vim syntax. (Charles Campbell)
author | Bram Moolenaar <bram@vim.org> |
---|---|
date | Wed, 28 Jul 2010 17:25:21 +0200 |
parents | acfb7eddf13c |
children | d55e70cabe2c |
rev | line source |
---|---|
7 | 1 " Vim syntax file |
2 " Language: TeX | |
477 | 3 " Maintainer: Dr. Charles E. Campbell, Jr. <NdrchipO@ScampbellPfamily.AbizM> |
2424
ee4e1e140117
More accented characters in tex.vim syntax. (Charles Campbell)
Bram Moolenaar <bram@vim.org>
parents:
2417
diff
changeset
|
4 " Last Change: Jul 28, 2010 |
ee4e1e140117
More accented characters in tex.vim syntax. (Charles Campbell)
Bram Moolenaar <bram@vim.org>
parents:
2417
diff
changeset
|
5 " Version: 51 |
477 | 6 " URL: http://mysite.verizon.net/astronaut/vim/index.html#vimlinks_syntax |
7 | 7 " |
8 " Notes: {{{1 | |
9 " | |
10 " 1. If you have a \begin{verbatim} that appears to overrun its boundaries, | |
11 " use %stopzone. | |
12 " | |
13 " 2. Run-on equations ($..$ and $$..$$, particularly) can also be stopped | |
14 " by suitable use of %stopzone. | |
15 " | |
16 " 3. If you have a slow computer, you may wish to modify | |
17 " | |
18 " syn sync maxlines=200 | |
19 " syn sync minlines=50 | |
20 " | |
21 " to values that are more to your liking. | |
22 " | |
23 " 4. There is no match-syncing for $...$ and $$...$$; hence large | |
24 " equation blocks constructed that way may exhibit syncing problems. | |
25 " (there's no difference between begin/end patterns) | |
26 " | |
27 " 5. If you have the variable "g:tex_no_error" defined then none of the | |
28 " lexical error-checking will be done. | |
29 " | |
30 " ie. let g:tex_no_error=1 | |
31 | |
32 " Version Clears: {{{1 | |
33 " For version 5.x: Clear all syntax items | |
34 " For version 6.x: Quit when a syntax file was already loaded | |
35 if version < 600 | |
36 syntax clear | |
37 elseif exists("b:current_syntax") | |
38 finish | |
39 endif | |
40 | |
41 " Define the default highlighting. {{{1 | |
42 " For version 5.7 and earlier: only when not done already | |
43 " For version 5.8 and later: only when an item doesn't have highlighting yet | |
44 if version >= 508 || !exists("did_tex_syntax_inits") | |
45 let did_tex_syntax_inits = 1 | |
46 if version < 508 | |
47 command -nargs=+ HiLink hi link <args> | |
48 else | |
49 command -nargs=+ HiLink hi def link <args> | |
50 endif | |
51 endif | |
52 if exists("g:tex_tex") && !exists("g:tex_no_error") | |
53 let g:tex_no_error= 1 | |
54 endif | |
55 | |
190 | 56 " Determine whether or not to use "*.sty" mode {{{1 |
7 | 57 " The user may override the normal determination by setting |
58 " g:tex_stylish to 1 (for "*.sty" mode) | |
59 " or to 0 else (normal "*.tex" mode) | |
60 " or on a buffer-by-buffer basis with b:tex_stylish | |
61 let b:extfname=expand("%:e") | |
62 if exists("g:tex_stylish") | |
63 let b:tex_stylish= g:tex_stylish | |
64 elseif !exists("b:tex_stylish") | |
65 if b:extfname == "sty" || b:extfname == "cls" || b:extfname == "clo" || b:extfname == "dtx" || b:extfname == "ltx" | |
66 let b:tex_stylish= 1 | |
67 else | |
68 let b:tex_stylish= 0 | |
69 endif | |
70 endif | |
71 | |
190 | 72 " handle folding {{{1 |
73 if !exists("g:tex_fold_enabled") | |
74 let g:tex_fold_enabled= 0 | |
75 elseif g:tex_fold_enabled && !has("folding") | |
527 | 76 let g:tex_fold_enabled= 0 |
190 | 77 echomsg "Ignoring g:tex_fold_enabled=".g:tex_fold_enabled."; need to re-compile vim for +fold support" |
78 endif | |
79 if g:tex_fold_enabled && &fdm == "manual" | |
2152 | 80 setl fdm=syntax |
190 | 81 endif |
82 | |
7 | 83 " (La)TeX keywords: only use the letters a-zA-Z {{{1 |
84 " but _ is the only one that causes problems. | |
85 if version < 600 | |
86 set isk-=_ | |
87 if b:tex_stylish | |
88 set isk+=@ | |
89 endif | |
90 else | |
91 setlocal isk-=_ | |
92 if b:tex_stylish | |
93 setlocal isk+=@ | |
94 endif | |
95 endif | |
96 | |
97 " Clusters: {{{1 | |
98 " -------- | |
99 syn cluster texCmdGroup contains=texCmdBody,texComment,texDefParm,texDelimiter,texDocType,texInput,texLength,texLigature,texMathDelim,texMathOper,texNewCmd,texNewEnv,texRefZone,texSection,texSectionMarker,texSectionName,texSpecialChar,texStatement,texString,texTypeSize,texTypeStyle | |
100 if !exists("g:tex_no_error") | |
101 syn cluster texCmdGroup add=texMathError | |
102 endif | |
103 syn cluster texEnvGroup contains=texMatcher,texMathDelim,texSpecialChar,texStatement | |
477 | 104 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,texSectionMarker,texSectionZone,texSpaceCode,texSpecialChar,texStatement,texString,texTypeSize,texTypeStyle,texZone,@texMathZones,texTitle,texAbstract |
482 | 105 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 |
2034 | 106 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 |
12 | 107 syn cluster texRefGroup contains=texMatcher,texComment,texDelimiter |
7 | 108 if !exists("tex_no_math") |
109 syn cluster texMathZones contains=texMathZoneV,texMathZoneW,texMathZoneX,texMathZoneY,texMathZoneZ | |
110 syn cluster texMatchGroup add=@texMathZones | |
111 syn cluster texMathDelimGroup contains=texMathDelimBad,texMathDelimKey,texMathDelimSet1,texMathDelimSet2 | |
112 syn cluster texMathMatchGroup contains=@texMathZones,texComment,texDefCmd,texDelimiter,texDocType,texInput,texLength,texLigature,texMathDelim,texMathMatcher,texMathOper,texNewCmd,texNewEnv,texRefZone,texSection,texSpecialChar,texStatement,texString,texTypeSize,texTypeStyle,texZone | |
2417 | 113 syn cluster texMathZoneGroup contains=texComment,texDelimiter,texLength,texMathDelim,texMathMatcher,texMathOper,texMathSymbol,texRefZone,texSpecialChar,texStatement,texTypeSize,texTypeStyle |
7 | 114 if !exists("g:tex_no_error") |
115 syn cluster texMathMatchGroup add=texMathError | |
116 syn cluster texMathZoneGroup add=texMathError | |
117 endif | |
482 | 118 syn cluster texMathZoneGroup add=@NoSpell |
119 " following used in the \part \chapter \section \subsection \subsubsection | |
120 " \paragraph \subparagraph \author \title highlighting | |
121 syn cluster texDocGroup contains=texPartZone,@texPartGroup | |
122 syn cluster texPartGroup contains=texChapterZone,texSectionZone,texParaZone | |
123 syn cluster texChapterGroup contains=texSectionZone,texParaZone | |
124 syn cluster texSectionGroup contains=texSubSectionZone,texParaZone | |
125 syn cluster texSubSectionGroup contains=texSubSubSectionZone,texParaZone | |
126 syn cluster texSubSubSectionGroup contains=texParaZone | |
127 syn cluster texParaGroup contains=texSubParaZone | |
2282
a888ed7ba375
Make updating text for conceal mode simpler. A few compiler warning fixes.
Bram Moolenaar <bram@vim.org>
parents:
2152
diff
changeset
|
128 if has("conceal") && &enc == 'utf-8' |
2424
ee4e1e140117
More accented characters in tex.vim syntax. (Charles Campbell)
Bram Moolenaar <bram@vim.org>
parents:
2417
diff
changeset
|
129 syn cluster texMathZoneGroup add=texGreek,texSuperscript,texSubscript,texMathSymbol |
ee4e1e140117
More accented characters in tex.vim syntax. (Charles Campbell)
Bram Moolenaar <bram@vim.org>
parents:
2417
diff
changeset
|
130 syn cluster texMathMatchGroup add=texGreek,texSuperscript,texSubscript,texMathSymbol |
2282
a888ed7ba375
Make updating text for conceal mode simpler. A few compiler warning fixes.
Bram Moolenaar <bram@vim.org>
parents:
2152
diff
changeset
|
131 endif |
7 | 132 endif |
133 | |
134 " Try to flag {} and () mismatches: {{{1 | |
135 if !exists("g:tex_no_error") | |
136 syn region texMatcher matchgroup=Delimiter start="{" skip="\\\\\|\\[{}]" end="}" contains=@texMatchGroup,texError | |
137 syn region texMatcher matchgroup=Delimiter start="\[" end="]" contains=@texMatchGroup,texError | |
138 else | |
139 syn region texMatcher matchgroup=Delimiter start="{" skip="\\\\\|\\[{}]" end="}" contains=@texMatchGroup | |
140 syn region texMatcher matchgroup=Delimiter start="\[" end="]" contains=@texMatchGroup | |
141 endif | |
36 | 142 syn region texParen start="(" end=")" contains=@texMatchGroup,@Spell |
7 | 143 if !exists("g:tex_no_error") |
144 syn match texError "[}\])]" | |
145 endif | |
146 if !exists("tex_no_math") | |
147 if !exists("g:tex_no_error") | |
148 syn match texMathError "}" contained | |
149 endif | |
150 syn region texMathMatcher matchgroup=Delimiter start="{" skip="\\\\\|\\}" end="}" end="%stopzone\>" contained contains=@texMathMatchGroup | |
151 endif | |
152 | |
153 " TeX/LaTeX keywords: {{{1 | |
154 " Instead of trying to be All Knowing, I just match \..alphameric.. | |
155 " Note that *.tex files may not have "@" in their \commands | |
156 if exists("g:tex_tex") || b:tex_stylish | |
157 syn match texStatement "\\[a-zA-Z@]\+" | |
158 else | |
159 syn match texStatement "\\\a\+" | |
160 if !exists("g:tex_no_error") | |
161 syn match texError "\\\a*@[a-zA-Z@]*" | |
162 endif | |
163 endif | |
164 | |
165 " TeX/LaTeX delimiters: {{{1 | |
166 syn match texDelimiter "&" | |
167 syn match texDelimiter "\\\\" | |
168 | |
169 " Tex/Latex Options: {{{1 | |
170 syn match texOption "[^\\]\zs#\d\+\|^#\d\+" | |
171 | |
172 " texAccent (tnx to Karim Belabas) avoids annoying highlighting for accents: {{{1 | |
173 if b:tex_stylish | |
174 syn match texAccent "\\[bcdvuH][^a-zA-Z@]"me=e-1 | |
175 syn match texLigature "\\\([ijolL]\|ae\|oe\|ss\|AA\|AE\|OE\)[^a-zA-Z@]"me=e-1 | |
176 else | |
177 syn match texAccent "\\[bcdvuH]\A"me=e-1 | |
178 syn match texLigature "\\\([ijolL]\|ae\|oe\|ss\|AA\|AE\|OE\)\A"me=e-1 | |
179 endif | |
180 syn match texAccent "\\[bcdvuH]$" | |
181 syn match texAccent +\\[=^.\~"`']+ | |
182 syn match texAccent +\\['=t'.c^ud"vb~Hr]{\a}+ | |
183 syn match texLigature "\\\([ijolL]\|ae\|oe\|ss\|AA\|AE\|OE\)$" | |
184 | |
185 " \begin{}/\end{} section markers: {{{1 | |
186 syn match texSectionMarker "\\begin\>\|\\end\>" nextgroup=texSectionName | |
2034 | 187 syn region texSectionName matchgroup=Delimiter start="{" end="}" contained nextgroup=texSectionModifier contains=texComment |
188 syn region texSectionModifier matchgroup=Delimiter start="\[" end="]" contained contains=texComment | |
7 | 189 |
190 " \documentclass, \documentstyle, \usepackage: {{{1 | |
191 syn match texDocType "\\documentclass\>\|\\documentstyle\>\|\\usepackage\>" nextgroup=texSectionName,texDocTypeArgs | |
2034 | 192 syn region texDocTypeArgs matchgroup=Delimiter start="\[" end="]" contained nextgroup=texSectionName contains=texComment |
7 | 193 |
760 | 194 " Preamble syntax-based folding support: {{{1 |
195 if g:tex_fold_enabled && has("folding") | |
2034 | 196 syn region texPreamble transparent fold start='\zs\\documentclass\>' end='\ze\\begin{document}' contains=texStyle,@texMatchGroup |
760 | 197 endif |
198 | |
7 | 199 " TeX input: {{{1 |
200 syn match texInput "\\input\s\+[a-zA-Z/.0-9_^]\+"hs=s+7 contains=texStatement | |
2034 | 201 syn match texInputFile "\\include\(graphics\|list\)\=\(\[.\{-}\]\)\=\s*{.\{-}}" contains=texStatement,texInputCurlies,texInputFileOpt |
7 | 202 syn match texInputFile "\\\(epsfig\|input\|usepackage\)\s*\(\[.*\]\)\={.\{-}}" contains=texStatement,texInputCurlies,texInputFileOpt |
203 syn match texInputCurlies "[{}]" contained | |
2034 | 204 syn region texInputFileOpt matchgroup=Delimiter start="\[" end="\]" contained contains=texComment |
7 | 205 |
206 " Type Styles (LaTeX 2.09): {{{1 | |
207 syn match texTypeStyle "\\rm\>" | |
208 syn match texTypeStyle "\\em\>" | |
209 syn match texTypeStyle "\\bf\>" | |
210 syn match texTypeStyle "\\it\>" | |
211 syn match texTypeStyle "\\sl\>" | |
212 syn match texTypeStyle "\\sf\>" | |
213 syn match texTypeStyle "\\sc\>" | |
214 syn match texTypeStyle "\\tt\>" | |
215 | |
216 " Type Styles: attributes, commands, families, etc (LaTeX2E): {{{1 | |
217 syn match texTypeStyle "\\textbf\>" | |
218 syn match texTypeStyle "\\textit\>" | |
219 syn match texTypeStyle "\\textmd\>" | |
220 syn match texTypeStyle "\\textrm\>" | |
221 syn match texTypeStyle "\\textsc\>" | |
222 syn match texTypeStyle "\\textsf\>" | |
223 syn match texTypeStyle "\\textsl\>" | |
224 syn match texTypeStyle "\\texttt\>" | |
225 syn match texTypeStyle "\\textup\>" | |
226 syn match texTypeStyle "\\emph\>" | |
227 | |
228 syn match texTypeStyle "\\mathbb\>" | |
229 syn match texTypeStyle "\\mathbf\>" | |
230 syn match texTypeStyle "\\mathcal\>" | |
231 syn match texTypeStyle "\\mathfrak\>" | |
232 syn match texTypeStyle "\\mathit\>" | |
233 syn match texTypeStyle "\\mathnormal\>" | |
234 syn match texTypeStyle "\\mathrm\>" | |
235 syn match texTypeStyle "\\mathsf\>" | |
236 syn match texTypeStyle "\\mathtt\>" | |
237 | |
238 syn match texTypeStyle "\\rmfamily\>" | |
239 syn match texTypeStyle "\\sffamily\>" | |
240 syn match texTypeStyle "\\ttfamily\>" | |
241 | |
242 syn match texTypeStyle "\\itshape\>" | |
243 syn match texTypeStyle "\\scshape\>" | |
244 syn match texTypeStyle "\\slshape\>" | |
245 syn match texTypeStyle "\\upshape\>" | |
246 | |
247 syn match texTypeStyle "\\bfseries\>" | |
248 syn match texTypeStyle "\\mdseries\>" | |
249 | |
250 " Some type sizes: {{{1 | |
251 syn match texTypeSize "\\tiny\>" | |
252 syn match texTypeSize "\\scriptsize\>" | |
253 syn match texTypeSize "\\footnotesize\>" | |
254 syn match texTypeSize "\\small\>" | |
255 syn match texTypeSize "\\normalsize\>" | |
256 syn match texTypeSize "\\large\>" | |
257 syn match texTypeSize "\\Large\>" | |
258 syn match texTypeSize "\\LARGE\>" | |
259 syn match texTypeSize "\\huge\>" | |
260 syn match texTypeSize "\\Huge\>" | |
261 | |
262 " Spacecodes (TeX'isms): {{{1 | |
263 " \mathcode`\^^@="2201 \delcode`\(="028300 \sfcode`\)=0 \uccode`X=`X \lccode`x=`x | |
264 syn match texSpaceCode "\\\(math\|cat\|del\|lc\|sf\|uc\)code`"me=e-1 nextgroup=texSpaceCodeChar | |
265 syn match texSpaceCodeChar "`\\\=.\(\^.\)\==\(\d\|\"\x\{1,6}\|`.\)" contained | |
266 | |
267 " Sections, subsections, etc: {{{1 | |
190 | 268 if g:tex_fold_enabled && has("folding") |
1620 | 269 syn region texDocZone matchgroup=texSection start='\\begin\s*{\s*document\s*}' end='\\end\s*{\s*document\s*}' fold contains=@texFoldGroup,@texDocGroup,@Spell |
270 syn region texPartZone matchgroup=texSection start='\\part\>' end='\ze\s*\\\%(part\>\|end\s*{\s*document\s*}\)' fold contains=@texFoldGroup,@texPartGroup,@Spell | |
271 syn region texChapterZone matchgroup=texSection start='\\chapter\>' end='\ze\s*\\\%(chapter\>\|part\>\|end\s*{\s*document\s*}\)' fold contains=@texFoldGroup,@texChapterGroup,@Spell | |
272 syn region texSectionZone matchgroup=texSection start='\\section\>' end='\ze\s*\\\%(section\>\|chapter\>\|part\>\|end\s*{\s*document\s*}\)' fold contains=@texFoldGroup,@texSectionGroup,@Spell | |
273 syn region texSubSectionZone matchgroup=texSection start='\\subsection\>' end='\ze\s*\\\%(\%(sub\)\=section\>\|chapter\>\|part\>\|end\s*{\s*document\s*}\)' fold contains=@texFoldGroup,@texSubSectionGroup,@Spell | |
274 syn region texSubSubSectionZone matchgroup=texSection start='\\subsubsection\>' end='\ze\s*\\\%(\%(sub\)\{,2}section\>\|chapter\>\|part\>\|end\s*{\s*document\s*}\)' fold contains=@texFoldGroup,@texSubSubSectionGroup,@Spell | |
275 syn region texParaZone matchgroup=texSection start='\\paragraph\>' end='\ze\s*\\\%(paragraph\>\|\%(sub\)*section\>\|chapter\>\|part\>\|end\s*{\s*document\s*}\)' fold contains=@texFoldGroup,@texParaGroup,@Spell | |
276 syn region texSubParaZone matchgroup=texSection start='\\subparagraph\>' end='\ze\s*\\\%(\%(sub\)\=paragraph\>\|\%(sub\)*section\>\|chapter\>\|part\>\|end\s*{\s*document\s*}\)' fold contains=@texFoldGroup,@Spell | |
277 syn region texTitle matchgroup=texSection start='\\\%(author\|title\)\>\s*{' end='}' fold contains=@texFoldGroup,@Spell | |
278 syn region texAbstract matchgroup=texSection start='\\begin\s*{\s*abstract\s*}' end='\\end\s*{\s*abstract\s*}' fold contains=@texFoldGroup,@Spell | |
36 | 279 else |
1620 | 280 syn region texDocZone matchgroup=texSection start='\\begin\s*{\s*document\s*}' end='\\end\s*{\s*document\s*}' contains=@texFoldGroup,@texDocGroup,@Spell |
281 syn region texPartZone matchgroup=texSection start='\\part\>' end='\ze\s*\\\%(part\>\|end\s*{\s*document\s*}\)' contains=@texFoldGroup,@texPartGroup,@Spell | |
282 syn region texChapterZone matchgroup=texSection start='\\chapter\>' end='\ze\s*\\\%(chapter\>\|part\>\|end\s*{\s*document\s*}\)' contains=@texFoldGroup,@texChapterGroup,@Spell | |
283 syn region texSectionZone matchgroup=texSection start='\\section\>' end='\ze\s*\\\%(section\>\|chapter\>\|part\>\|end\s*{\s*document\s*}\)' contains=@texFoldGroup,@texSectionGroup,@Spell | |
284 syn region texSubSectionZone matchgroup=texSection start='\\subsection\>' end='\ze\s*\\\%(\%(sub\)\=section\>\|chapter\>\|part\>\|end\s*{\s*document\s*}\)' contains=@texFoldGroup,@texSubSectionGroup,@Spell | |
285 syn region texSubSubSectionZone matchgroup=texSection start='\\subsubsection\>' end='\ze\s*\\\%(\%(sub\)\{,2}section\>\|chapter\>\|part\>\|end\s*{\s*document\s*}\)' contains=@texFoldGroup,@texSubSubSectionGroup,@Spell | |
286 syn region texParaZone matchgroup=texSection start='\\paragraph\>' end='\ze\s*\\\%(paragraph\>\|\%(sub\)*section\>\|chapter\>\|part\>\|end\s*{\s*document\s*}\)' contains=@texFoldGroup,@texParaGroup,@Spell | |
287 syn region texSubParaZone matchgroup=texSection start='\\subparagraph\>' end='\ze\s*\\\%(\%(sub\)\=paragraph\>\|\%(sub\)*section\>\|chapter\>\|part\>\|end\s*{\s*document\s*}\)' contains=@texFoldGroup,@Spell | |
288 syn region texTitle matchgroup=texSection start='\\\%(author\|title\)\>\s*{' end='}' contains=@texFoldGroup,@Spell | |
289 syn region texAbstract matchgroup=texSection start='\\begin\s*{\s*abstract\s*}' end='\\end\s*{\s*abstract\s*}' contains=@texFoldGroup,@Spell | |
36 | 290 endif |
7 | 291 |
292 " Bad Math (mismatched): {{{1 | |
293 if !exists("tex_no_math") | |
294 syn match texBadMath "\\end\s*{\s*\(array\|gathered\|bBpvV]matrix\|split\|subequations\|smallmatrix\|xxalignat\)\s*}" | |
295 syn match texBadMath "\\end\s*{\s*\(align\|alignat\|displaymath\|displaymath\|eqnarray\|equation\|flalign\|gather\|math\|multline\|xalignat\)\*\=\s*}" | |
296 syn match texBadMath "\\[\])]" | |
297 endif | |
298 | |
299 " Math Zones: {{{1 | |
300 if !exists("tex_no_math") | |
477 | 301 " TexNewMathZone: function creates a mathzone with the given suffix and mathzone name. {{{2 |
7 | 302 " Starred forms are created if starform is true. Starred |
303 " forms have syntax group and synchronization groups with a | |
304 " "S" appended. Handles: cluster, syntax, sync, and HiLink. | |
305 fun! TexNewMathZone(sfx,mathzone,starform) | |
306 let grpname = "texMathZone".a:sfx | |
307 let syncname = "texSyncMathZone".a:sfx | |
1620 | 308 if g:tex_fold_enabled |
309 let foldcmd= " fold" | |
310 else | |
311 let foldcmd= "" | |
312 endif | |
7 | 313 exe "syn cluster texMathZones add=".grpname |
1620 | 314 exe 'syn region '.grpname.' start='."'".'\\begin\s*{\s*'.a:mathzone.'\s*}'."'".' end='."'".'\\end\s*{\s*'.a:mathzone.'\s*}'."'".' keepend contains=@texMathZoneGroup'.foldcmd |
7 | 315 exe 'syn sync match '.syncname.' grouphere '.grpname.' "\\begin\s*{\s*'.a:mathzone.'\*\s*}"' |
316 exe 'syn sync match '.syncname.' grouphere '.grpname.' "\\begin\s*{\s*'.a:mathzone.'\*\s*}"' | |
2034 | 317 exe 'hi def link '.grpname.' texMath' |
7 | 318 if a:starform |
319 let grpname = "texMathZone".a:sfx.'S' | |
320 let syncname = "texSyncMathZone".a:sfx.'S' | |
321 exe "syn cluster texMathZones add=".grpname | |
1620 | 322 exe 'syn region '.grpname.' start='."'".'\\begin\s*{\s*'.a:mathzone.'\*\s*}'."'".' end='."'".'\\end\s*{\s*'.a:mathzone.'\*\s*}'."'".' keepend contains=@texMathZoneGroup'.foldcmd |
7 | 323 exe 'syn sync match '.syncname.' grouphere '.grpname.' "\\begin\s*{\s*'.a:mathzone.'\*\s*}"' |
324 exe 'syn sync match '.syncname.' grouphere '.grpname.' "\\begin\s*{\s*'.a:mathzone.'\*\s*}"' | |
2034 | 325 exe 'hi def link '.grpname.' texMath' |
7 | 326 endif |
327 endfun | |
328 | |
329 " Standard Math Zones: {{{2 | |
330 call TexNewMathZone("A","align",1) | |
331 call TexNewMathZone("B","alignat",1) | |
332 call TexNewMathZone("C","displaymath",1) | |
333 call TexNewMathZone("D","eqnarray",1) | |
334 call TexNewMathZone("E","equation",1) | |
335 call TexNewMathZone("F","flalign",1) | |
336 call TexNewMathZone("G","gather",1) | |
337 call TexNewMathZone("H","math",1) | |
338 call TexNewMathZone("I","multline",1) | |
339 call TexNewMathZone("J","subequations",0) | |
340 call TexNewMathZone("K","xalignat",1) | |
341 call TexNewMathZone("L","xxalignat",0) | |
342 | |
343 " Inline Math Zones: {{{2 | |
2424
ee4e1e140117
More accented characters in tex.vim syntax. (Charles Campbell)
Bram Moolenaar <bram@vim.org>
parents:
2417
diff
changeset
|
344 if has("conceal") && &enc == 'utf-8' |
ee4e1e140117
More accented characters in tex.vim syntax. (Charles Campbell)
Bram Moolenaar <bram@vim.org>
parents:
2417
diff
changeset
|
345 syn region texMathZoneV matchgroup=Delimiter start="\\(" matchgroup=Delimiter end="\\)\|%stopzone\>" keepend concealends contains=@texMathZoneGroup |
ee4e1e140117
More accented characters in tex.vim syntax. (Charles Campbell)
Bram Moolenaar <bram@vim.org>
parents:
2417
diff
changeset
|
346 syn region texMathZoneW matchgroup=Delimiter start="\\\[" matchgroup=Delimiter end="\\]\|%stopzone\>" keepend concealends contains=@texMathZoneGroup |
ee4e1e140117
More accented characters in tex.vim syntax. (Charles Campbell)
Bram Moolenaar <bram@vim.org>
parents:
2417
diff
changeset
|
347 syn region texMathZoneX matchgroup=Delimiter start="\$" skip="\\\\\|\\\$" matchgroup=Delimiter end="\$" end="%stopzone\>" concealends contains=@texMathZoneGroup |
ee4e1e140117
More accented characters in tex.vim syntax. (Charles Campbell)
Bram Moolenaar <bram@vim.org>
parents:
2417
diff
changeset
|
348 syn region texMathZoneY matchgroup=Delimiter start="\$\$" matchgroup=Delimiter end="\$\$" end="%stopzone\>" concealends keepend contains=@texMathZoneGroup |
ee4e1e140117
More accented characters in tex.vim syntax. (Charles Campbell)
Bram Moolenaar <bram@vim.org>
parents:
2417
diff
changeset
|
349 else |
ee4e1e140117
More accented characters in tex.vim syntax. (Charles Campbell)
Bram Moolenaar <bram@vim.org>
parents:
2417
diff
changeset
|
350 syn region texMathZoneV matchgroup=Delimiter start="\\(" matchgroup=Delimiter end="\\)\|%stopzone\>" keepend contains=@texMathZoneGroup |
ee4e1e140117
More accented characters in tex.vim syntax. (Charles Campbell)
Bram Moolenaar <bram@vim.org>
parents:
2417
diff
changeset
|
351 syn region texMathZoneW matchgroup=Delimiter start="\\\[" matchgroup=Delimiter end="\\]\|%stopzone\>" keepend contains=@texMathZoneGroup |
ee4e1e140117
More accented characters in tex.vim syntax. (Charles Campbell)
Bram Moolenaar <bram@vim.org>
parents:
2417
diff
changeset
|
352 syn region texMathZoneX matchgroup=Delimiter start="\$" skip="\\\\\|\\\$" matchgroup=Delimiter end="\$" end="%stopzone\>" contains=@texMathZoneGroup |
ee4e1e140117
More accented characters in tex.vim syntax. (Charles Campbell)
Bram Moolenaar <bram@vim.org>
parents:
2417
diff
changeset
|
353 syn region texMathZoneY matchgroup=Delimiter start="\$\$" matchgroup=Delimiter end="\$\$" end="%stopzone\>" keepend contains=@texMathZoneGroup |
ee4e1e140117
More accented characters in tex.vim syntax. (Charles Campbell)
Bram Moolenaar <bram@vim.org>
parents:
2417
diff
changeset
|
354 endif |
2282
a888ed7ba375
Make updating text for conceal mode simpler. A few compiler warning fixes.
Bram Moolenaar <bram@vim.org>
parents:
2152
diff
changeset
|
355 syn region texMathZoneZ matchgroup=texStatement start="\\ensuremath\s*{" matchgroup=texStatement end="}" end="%stopzone\>" contains=@texMathZoneGroup |
7 | 356 |
357 syn match texMathOper "[_^=]" contained | |
358 | |
359 " \left..something.. and \right..something.. support: {{{2 | |
360 syn match texMathDelimBad contained "\S" | |
361 syn match texMathDelim contained "\\\(left\|right\|[bB]igg\=[lr]\)\>" skipwhite nextgroup=texMathDelimSet1,texMathDelimSet2,texMathDelimBad | |
362 syn match texMathDelim contained "\\\(left\|right\)arrow\>\|\<\([aA]rrow\|brace\)\=vert\>" | |
363 syn match texMathDelim contained "\\lefteqn\>" | |
364 syn match texMathDelimSet2 contained "\\" nextgroup=texMathDelimKey,texMathDelimBad | |
365 syn match texMathDelimSet1 contained "[<>()[\]|/.]\|\\[{}|]" | |
366 syn keyword texMathDelimKey contained backslash lceil lVert rgroup uparrow | |
367 syn keyword texMathDelimKey contained downarrow lfloor rangle rmoustache Uparrow | |
368 syn keyword texMathDelimKey contained Downarrow lgroup rbrace rvert updownarrow | |
369 syn keyword texMathDelimKey contained langle lmoustache rceil rVert Updownarrow | |
370 syn keyword texMathDelimKey contained lbrace lvert rfloor | |
371 endif | |
372 | |
373 " Special TeX characters ( \$ \& \% \# \{ \} \_ \S \P ) : {{{1 | |
374 syn match texSpecialChar "\\[$&%#{}_]" | |
375 if b:tex_stylish | |
376 syn match texSpecialChar "\\[SP@][^a-zA-Z@]"me=e-1 | |
377 else | |
378 syn match texSpecialChar "\\[SP@]\A"me=e-1 | |
379 endif | |
380 syn match texSpecialChar "\\\\" | |
381 if !exists("tex_no_math") | |
382 syn match texOnlyMath "[_^]" | |
383 endif | |
384 syn match texSpecialChar "\^\^[0-9a-f]\{2}\|\^\^\S" | |
385 | |
386 " Comments: {{{1 | |
387 " Normal TeX LaTeX : %.... | |
388 " Documented TeX Format: ^^A... -and- leading %s (only) | |
1620 | 389 if !exists("g:tex_comment_nospell") || !g:tex_comment_nospell |
390 syn cluster texCommentGroup contains=texTodo,@Spell | |
391 else | |
392 syn cluster texCommentGroup contains=texTodo,@NoSpell | |
393 endif | |
7 | 394 syn case ignore |
827 | 395 syn keyword texTodo contained combak fixme todo xxx |
7 | 396 syn case match |
397 if b:extfname == "dtx" | |
398 syn match texComment "\^\^A.*$" contains=@texCommentGroup | |
399 syn match texComment "^%\+" contains=@texCommentGroup | |
400 else | |
699 | 401 if g:tex_fold_enabled |
402 " allows syntax-folding of 2 or more contiguous comment lines | |
403 " single-line comments are not folded | |
404 syn match texComment "%.*$" contains=@texCommentGroup | |
405 syn region texComment start="^\zs\s*%.*\_s*%" skip="^\s*%" end='^\ze\s*[^%]' fold | |
406 else | |
407 syn match texComment "%.*$" contains=@texCommentGroup | |
408 endif | |
7 | 409 endif |
410 | |
411 " Separate lines used for verb` and verb# so that the end conditions {{{1 | |
412 " will appropriately terminate. Ideally vim would let me save a | |
413 " character from the start pattern and re-use it in the end-pattern. | |
2034 | 414 syn region texZone start="\\begin{[vV]erbatim}" end="\\end{[vV]erbatim}\|%stopzone\>" contains=@Spell |
836 | 415 " listings package: |
416 syn region texZone start="\\begin{lstlisting}" end="\\end{lstlisting}\|%stopzone\>" contains=@Spell | |
417 " moreverb package: | |
418 syn region texZone start="\\begin{verbatimtab}" end="\\end{verbatimtab}\|%stopzone\>" contains=@Spell | |
419 syn region texZone start="\\begin{verbatimwrite}" end="\\end{verbatimwrite}\|%stopzone\>" contains=@Spell | |
420 syn region texZone start="\\begin{boxedverbatim}" end="\\end{boxedverbatim}\|%stopzone\>" contains=@Spell | |
7 | 421 if version < 600 |
422 syn region texZone start="\\verb\*\=`" end="`\|%stopzone\>" | |
423 syn region texZone start="\\verb\*\=#" end="#\|%stopzone\>" | |
424 else | |
425 if b:tex_stylish | |
426 syn region texZone start="\\verb\*\=\z([^\ta-zA-Z@]\)" end="\z1\|%stopzone\>" | |
427 else | |
428 syn region texZone start="\\verb\*\=\z([^\ta-zA-Z]\)" end="\z1\|%stopzone\>" | |
429 endif | |
430 endif | |
431 | |
432 " Tex Reference Zones: {{{1 | |
12 | 433 syn region texZone matchgroup=texStatement start="@samp{" end="}\|%stopzone\>" contains=@texRefGroup |
434 syn region texRefZone matchgroup=texStatement start="\\nocite{" end="}\|%stopzone\>" contains=@texRefGroup | |
435 syn region texRefZone matchgroup=texStatement start="\\bibliography{" end="}\|%stopzone\>" contains=@texRefGroup | |
436 syn region texRefZone matchgroup=texStatement start="\\label{" end="}\|%stopzone\>" contains=@texRefGroup | |
437 syn region texRefZone matchgroup=texStatement start="\\\(page\|eq\)ref{" end="}\|%stopzone\>" contains=@texRefGroup | |
438 syn region texRefZone matchgroup=texStatement start="\\v\=ref{" end="}\|%stopzone\>" contains=@texRefGroup | |
587 | 439 syn match texRefZone '\\cite\%([tp]\*\=\)\=' nextgroup=texRefOption,texCite |
440 syn region texRefOption contained matchgroup=Delimiter start='\[' end=']' contains=@texRefGroup nextgroup=texRefOption,texCite | |
441 syn region texCite contained matchgroup=Delimiter start='{' end='}' contains=@texRefGroup | |
7 | 442 |
443 " Handle newcommand, newenvironment : {{{1 | |
444 syn match texNewCmd "\\newcommand\>" nextgroup=texCmdName skipwhite skipnl | |
445 syn region texCmdName contained matchgroup=Delimiter start="{"rs=s+1 end="}" nextgroup=texCmdArgs,texCmdBody skipwhite skipnl | |
446 syn region texCmdArgs contained matchgroup=Delimiter start="\["rs=s+1 end="]" nextgroup=texCmdBody skipwhite skipnl | |
447 syn region texCmdBody contained matchgroup=Delimiter start="{"rs=s+1 skip="\\\\\|\\[{}]" matchgroup=Delimiter end="}" contains=@texCmdGroup | |
448 syn match texNewEnv "\\newenvironment\>" nextgroup=texEnvName skipwhite skipnl | |
449 syn region texEnvName contained matchgroup=Delimiter start="{"rs=s+1 end="}" nextgroup=texEnvBgn skipwhite skipnl | |
450 syn region texEnvBgn contained matchgroup=Delimiter start="{"rs=s+1 end="}" nextgroup=texEnvEnd skipwhite skipnl contains=@texEnvGroup | |
451 syn region texEnvEnd contained matchgroup=Delimiter start="{"rs=s+1 end="}" skipwhite skipnl contains=@texEnvGroup | |
452 | |
453 " Definitions/Commands: {{{1 | |
454 syn match texDefCmd "\\def\>" nextgroup=texDefName skipwhite skipnl | |
455 if b:tex_stylish | |
456 syn match texDefName contained "\\[a-zA-Z@]\+" nextgroup=texDefParms,texCmdBody skipwhite skipnl | |
457 syn match texDefName contained "\\[^a-zA-Z@]" nextgroup=texDefParms,texCmdBody skipwhite skipnl | |
458 else | |
459 syn match texDefName contained "\\\a\+" nextgroup=texDefParms,texCmdBody skipwhite skipnl | |
460 syn match texDefName contained "\\\A" nextgroup=texDefParms,texCmdBody skipwhite skipnl | |
461 endif | |
462 syn match texDefParms contained "#[^{]*" contains=texDefParm nextgroup=texCmdBody skipwhite skipnl | |
463 syn match texDefParm contained "#\d\+" | |
464 | |
465 " TeX Lengths: {{{1 | |
1121 | 466 syn match texLength "\<\d\+\([.,]\d\+\)\=\s*\(true\)\=\s*\(bp\|cc\|cm\|dd\|em\|ex\|in\|mm\|pc\|pt\|sp\)\>" |
7 | 467 |
468 " TeX String Delimiters: {{{1 | |
469 syn match texString "\(``\|''\|,,\)" | |
470 | |
2034 | 471 " makeatletter -- makeatother sections |
472 if !exists("g:tex_no_error") | |
473 syn region texStyle matchgroup=texStatement start='\\makeatletter' end='\\makeatother' contains=@texStyleGroup contained | |
474 syn match texStyleStatement "\\[a-zA-Z@]\+" contained | |
475 syn region texStyleMatcher matchgroup=Delimiter start="{" skip="\\\\\|\\[{}]" end="}" contains=@texStyleGroup,texError contained | |
476 syn region texStyleMatcher matchgroup=Delimiter start="\[" end="]" contains=@texStyleGroup,texError contained | |
477 endif | |
478 | |
2417 | 479 " Conceal mode support (supports set cole=1) {{{1 |
2282
a888ed7ba375
Make updating text for conceal mode simpler. A few compiler warning fixes.
Bram Moolenaar <bram@vim.org>
parents:
2152
diff
changeset
|
480 if has("conceal") && &enc == 'utf-8' |
2417 | 481 |
482 " Math Symbols {{{2 | |
483 syn match texMathSymbol '\\left(' contained conceal cchar=( | |
484 syn match texMathSymbol '\\right)' contained conceal cchar=) | |
485 syn match texMathSymbol '\\left{' contained conceal cchar={ | |
486 syn match texMathSymbol '\\right}' contained conceal cchar=} | |
487 syn match texMathSymbol '\\cdot\>' contained conceal cchar=· | |
488 syn match texMathSymbol '\\leq\>' contained conceal cchar=≤ | |
489 syn match texMathSymbol '\\geq\>' contained conceal cchar=≥ | |
490 syn match texMathSymbol '\\cdot\>' contained conceal cchar=· | |
491 syn match texMathSymbol '\\times\>' contained conceal cchar=× | |
492 syn match texMathSymbol '\\div\>' contained conceal cchar=÷ | |
493 syn match texMathSymbol '\\pm\>' contained conceal cchar=± | |
494 syn match texMathSymbol '\\neq\>' contained conceal cchar=≠ | |
495 syn match texMathSymbol '\\cong\>' contained conceal cchar=≅ | |
496 | |
497 " Greek {{{2 | |
498 fun! s:Greek(group,pat,cchar) | |
499 exe 'syn match '.a:group." '".a:pat."' contained conceal cchar=".a:cchar | |
500 endfun | |
501 call s:Greek('texGreek','\\alpha\>' ,'α') | |
502 call s:Greek('texGreek','\\beta\>' ,'β') | |
503 call s:Greek('texGreek','\\gamma\>' ,'γ') | |
504 call s:Greek('texGreek','\\delta\>' ,'δ') | |
505 call s:Greek('texGreek','\\epsilon\>' ,'ϵ') | |
506 call s:Greek('texGreek','\\varepsilon\>' ,'ε') | |
507 call s:Greek('texGreek','\\zeta\>' ,'ζ') | |
508 call s:Greek('texGreek','\\eta\>' ,'η') | |
509 call s:Greek('texGreek','\\theta\>' ,'θ') | |
510 call s:Greek('texGreek','\\vartheta\>' ,'ϑ') | |
511 call s:Greek('texGreek','\\kappa\>' ,'κ') | |
512 call s:Greek('texGreek','\\lambda\>' ,'λ') | |
513 call s:Greek('texGreek','\\mu\>' ,'μ') | |
514 call s:Greek('texGreek','\\nu\>' ,'ν') | |
515 call s:Greek('texGreek','\\xi\>' ,'ξ') | |
516 call s:Greek('texGreek','\\pi\>' ,'π') | |
517 call s:Greek('texGreek','\\varpi\>' ,'ϖ') | |
518 call s:Greek('texGreek','\\rho\>' ,'ρ') | |
519 call s:Greek('texGreek','\\varrho\>' ,'ϱ') | |
520 call s:Greek('texGreek','\\sigma\>' ,'σ') | |
521 call s:Greek('texGreek','\\varsigma\>' ,'ς') | |
522 call s:Greek('texGreek','\\tau\>' ,'τ') | |
523 call s:Greek('texGreek','\\upsilon\>' ,'υ') | |
524 call s:Greek('texGreek','\\phi\>' ,'φ') | |
525 call s:Greek('texGreek','\\varphi\>' ,'ϕ') | |
526 call s:Greek('texGreek','\\chi\>' ,'χ') | |
527 call s:Greek('texGreek','\\psi\>' ,'ψ') | |
528 call s:Greek('texGreek','\\omega\>' ,'ω') | |
529 call s:Greek('texGreek','\\Gamma\>' ,'Γ') | |
530 call s:Greek('texGreek','\\Delta\>' ,'Δ') | |
531 call s:Greek('texGreek','\\Theta\>' ,'Θ') | |
532 call s:Greek('texGreek','\\Lambda\>' ,'Λ') | |
533 call s:Greek('texGreek','\\Xi\>' ,'Χ') | |
534 call s:Greek('texGreek','\\Pi\>' ,'Π') | |
535 call s:Greek('texGreek','\\Sigma\>' ,'Σ') | |
536 call s:Greek('texGreek','\\Upsilon\>' ,'Υ') | |
537 call s:Greek('texGreek','\\Phi\>' ,'Φ') | |
538 call s:Greek('texGreek','\\Psi\>' ,'Ψ') | |
539 call s:Greek('texGreek','\\Omega\>' ,'Ω') | |
2424
ee4e1e140117
More accented characters in tex.vim syntax. (Charles Campbell)
Bram Moolenaar <bram@vim.org>
parents:
2417
diff
changeset
|
540 delfun s:Greek |
2417 | 541 |
542 " Superscripts/Subscripts {{{2 | |
2424
ee4e1e140117
More accented characters in tex.vim syntax. (Charles Campbell)
Bram Moolenaar <bram@vim.org>
parents:
2417
diff
changeset
|
543 syn region texSuperscript matchgroup=Delimiter start='\^{' end='}' contained concealends contains=texSuperscripts |
ee4e1e140117
More accented characters in tex.vim syntax. (Charles Campbell)
Bram Moolenaar <bram@vim.org>
parents:
2417
diff
changeset
|
544 syn region texSubscript matchgroup=Delimiter start='_{' end='}' contained concealends contains=texSubscripts |
2417 | 545 fun! s:SuperSub(group,leader,pat,cchar) |
546 exe 'syn match '.a:group." '".a:leader.a:pat."' contained conceal cchar=".a:cchar | |
547 exe 'syn match '.a:group."s '".a:pat."' contained conceal cchar=".a:cchar.' nextgroup='.a:group.'s' | |
548 endfun | |
549 call s:SuperSub('texSuperscript','\^','0','⁰') | |
550 call s:SuperSub('texSuperscript','\^','1','¹') | |
551 call s:SuperSub('texSuperscript','\^','2','²') | |
552 call s:SuperSub('texSuperscript','\^','3','³') | |
553 call s:SuperSub('texSuperscript','\^','4','⁴') | |
554 call s:SuperSub('texSuperscript','\^','5','⁵') | |
555 call s:SuperSub('texSuperscript','\^','6','⁶') | |
556 call s:SuperSub('texSuperscript','\^','7','⁷') | |
557 call s:SuperSub('texSuperscript','\^','8','⁸') | |
558 call s:SuperSub('texSuperscript','\^','9','⁹') | |
559 call s:SuperSub('texSuperscript','\^','a','ᵃ') | |
560 call s:SuperSub('texSuperscript','\^','b','ᵇ') | |
561 call s:SuperSub('texSuperscript','\^','c','ᶜ') | |
562 call s:SuperSub('texSuperscript','\^','d','ᵈ') | |
563 call s:SuperSub('texSuperscript','\^','e','ᵉ') | |
564 call s:SuperSub('texSuperscript','\^','f','ᶠ') | |
565 call s:SuperSub('texSuperscript','\^','g','ᵍ') | |
566 call s:SuperSub('texSuperscript','\^','h','ʰ') | |
567 call s:SuperSub('texSuperscript','\^','i','ⁱ') | |
568 call s:SuperSub('texSuperscript','\^','j','ʲ') | |
569 call s:SuperSub('texSuperscript','\^','k','ᵏ') | |
570 call s:SuperSub('texSuperscript','\^','l','ˡ') | |
571 call s:SuperSub('texSuperscript','\^','m','ᵐ') | |
572 call s:SuperSub('texSuperscript','\^','n','ⁿ') | |
573 call s:SuperSub('texSuperscript','\^','o','ᵒ') | |
574 call s:SuperSub('texSuperscript','\^','p','ᵖ') | |
575 call s:SuperSub('texSuperscript','\^','r','ʳ') | |
576 call s:SuperSub('texSuperscript','\^','s','ˢ') | |
577 call s:SuperSub('texSuperscript','\^','t','ᵗ') | |
578 call s:SuperSub('texSuperscript','\^','u','ᵘ') | |
579 call s:SuperSub('texSuperscript','\^','v','ᵛ') | |
580 call s:SuperSub('texSuperscript','\^','w','ʷ') | |
581 call s:SuperSub('texSuperscript','\^','x','ˣ') | |
582 call s:SuperSub('texSuperscript','\^','y','ʸ') | |
583 call s:SuperSub('texSuperscript','\^','z','ᶻ') | |
584 call s:SuperSub('texSuperscript','\^','A','ᴬ') | |
585 call s:SuperSub('texSuperscript','\^','B','ᴮ') | |
586 call s:SuperSub('texSuperscript','\^','D','ᴰ') | |
587 call s:SuperSub('texSuperscript','\^','E','ᴱ') | |
588 call s:SuperSub('texSuperscript','\^','G','ᴳ') | |
589 call s:SuperSub('texSuperscript','\^','H','ᴴ') | |
590 call s:SuperSub('texSuperscript','\^','I','ᴵ') | |
591 call s:SuperSub('texSuperscript','\^','J','ᴶ') | |
592 call s:SuperSub('texSuperscript','\^','K','ᴷ') | |
593 call s:SuperSub('texSuperscript','\^','L','ᴸ') | |
594 call s:SuperSub('texSuperscript','\^','M','ᴹ') | |
595 call s:SuperSub('texSuperscript','\^','N','ᴺ') | |
596 call s:SuperSub('texSuperscript','\^','O','ᴼ') | |
597 call s:SuperSub('texSuperscript','\^','P','ᴾ') | |
598 call s:SuperSub('texSuperscript','\^','R','ᴿ') | |
599 call s:SuperSub('texSuperscript','\^','T','ᵀ') | |
600 call s:SuperSub('texSuperscript','\^','U','ᵁ') | |
601 call s:SuperSub('texSuperscript','\^','W','ᵂ') | |
602 call s:SuperSub('texSuperscript','\^','+','⁺') | |
603 call s:SuperSub('texSuperscript','\^','-','⁻') | |
604 call s:SuperSub('texSuperscript','\^','<','˂') | |
605 call s:SuperSub('texSuperscript','\^','>','˃') | |
606 call s:SuperSub('texSuperscript','\^','/','ˊ') | |
607 call s:SuperSub('texSuperscript','\^','(','⁽') | |
608 call s:SuperSub('texSuperscript','\^',')','⁾') | |
609 call s:SuperSub('texSuperscript','\^','\.','˙') | |
610 call s:SuperSub('texSuperscript','\^','=','˭') | |
611 call s:SuperSub('texSubscript','_','0','₀') | |
612 call s:SuperSub('texSubscript','_','1','₁') | |
613 call s:SuperSub('texSubscript','_','2','₂') | |
614 call s:SuperSub('texSubscript','_','3','₃') | |
615 call s:SuperSub('texSubscript','_','4','₄') | |
616 call s:SuperSub('texSubscript','_','5','₅') | |
617 call s:SuperSub('texSubscript','_','6','₆') | |
618 call s:SuperSub('texSubscript','_','7','₇') | |
619 call s:SuperSub('texSubscript','_','8','₈') | |
620 call s:SuperSub('texSubscript','_','9','₉') | |
621 call s:SuperSub('texSubscript','_','a','ₐ') | |
622 call s:SuperSub('texSubscript','_','e','ₑ') | |
623 call s:SuperSub('texSubscript','_','i','ᵢ') | |
624 call s:SuperSub('texSubscript','_','o','ₒ') | |
625 call s:SuperSub('texSubscript','_','u','ᵤ') | |
626 call s:SuperSub('texSubscript','_','+','₊') | |
627 call s:SuperSub('texSubscript','_','-','₋') | |
628 call s:SuperSub('texSubscript','_','/','ˏ') | |
629 call s:SuperSub('texSubscript','_','(','₍') | |
630 call s:SuperSub('texSubscript','_',')','₎') | |
631 call s:SuperSub('texSubscript','_','\.','‸') | |
632 call s:SuperSub('texSubscript','_','r','ᵣ') | |
633 call s:SuperSub('texSubscript','_','v','ᵥ') | |
634 call s:SuperSub('texSubscript','_','x','ₓ') | |
635 call s:SuperSub('texSubscript','_','\\beta\>' ,'ᵦ') | |
636 call s:SuperSub('texSubscript','_','\\delta\>','ᵨ') | |
637 call s:SuperSub('texSubscript','_','\\phi\>' ,'ᵩ') | |
638 call s:SuperSub('texSubscript','_','\\gamma\>','ᵧ') | |
639 call s:SuperSub('texSubscript','_','\\chi\>' ,'ᵪ') | |
2424
ee4e1e140117
More accented characters in tex.vim syntax. (Charles Campbell)
Bram Moolenaar <bram@vim.org>
parents:
2417
diff
changeset
|
640 delfun s:SuperSub |
2417 | 641 |
642 " Accented characters: {{{2 | |
643 if b:tex_stylish | |
644 syn match texAccent "\\[bcdvuH][^a-zA-Z@]"me=e-1 | |
645 syn match texLigature "\\\([ijolL]\|ae\|oe\|ss\|AA\|AE\|OE\)[^a-zA-Z@]"me=e-1 | |
646 else | |
2424
ee4e1e140117
More accented characters in tex.vim syntax. (Charles Campbell)
Bram Moolenaar <bram@vim.org>
parents:
2417
diff
changeset
|
647 fun! s:Accents(chr,...) |
ee4e1e140117
More accented characters in tex.vim syntax. (Charles Campbell)
Bram Moolenaar <bram@vim.org>
parents:
2417
diff
changeset
|
648 let i= 1 |
ee4e1e140117
More accented characters in tex.vim syntax. (Charles Campbell)
Bram Moolenaar <bram@vim.org>
parents:
2417
diff
changeset
|
649 for accent in ["`","\\'","^",'"','\~',"r","v"] |
ee4e1e140117
More accented characters in tex.vim syntax. (Charles Campbell)
Bram Moolenaar <bram@vim.org>
parents:
2417
diff
changeset
|
650 if i > a:0 |
ee4e1e140117
More accented characters in tex.vim syntax. (Charles Campbell)
Bram Moolenaar <bram@vim.org>
parents:
2417
diff
changeset
|
651 break |
ee4e1e140117
More accented characters in tex.vim syntax. (Charles Campbell)
Bram Moolenaar <bram@vim.org>
parents:
2417
diff
changeset
|
652 endif |
ee4e1e140117
More accented characters in tex.vim syntax. (Charles Campbell)
Bram Moolenaar <bram@vim.org>
parents:
2417
diff
changeset
|
653 if strlen(a:{i}) == 0 |
ee4e1e140117
More accented characters in tex.vim syntax. (Charles Campbell)
Bram Moolenaar <bram@vim.org>
parents:
2417
diff
changeset
|
654 let i= i + 1 |
ee4e1e140117
More accented characters in tex.vim syntax. (Charles Campbell)
Bram Moolenaar <bram@vim.org>
parents:
2417
diff
changeset
|
655 continue |
ee4e1e140117
More accented characters in tex.vim syntax. (Charles Campbell)
Bram Moolenaar <bram@vim.org>
parents:
2417
diff
changeset
|
656 endif |
ee4e1e140117
More accented characters in tex.vim syntax. (Charles Campbell)
Bram Moolenaar <bram@vim.org>
parents:
2417
diff
changeset
|
657 exe "syn match texAccent '\\\\".accent."{".a:chr."}' conceal cchar=".a:{i} |
ee4e1e140117
More accented characters in tex.vim syntax. (Charles Campbell)
Bram Moolenaar <bram@vim.org>
parents:
2417
diff
changeset
|
658 let i= i + 1 |
ee4e1e140117
More accented characters in tex.vim syntax. (Charles Campbell)
Bram Moolenaar <bram@vim.org>
parents:
2417
diff
changeset
|
659 endfor |
ee4e1e140117
More accented characters in tex.vim syntax. (Charles Campbell)
Bram Moolenaar <bram@vim.org>
parents:
2417
diff
changeset
|
660 endfun |
ee4e1e140117
More accented characters in tex.vim syntax. (Charles Campbell)
Bram Moolenaar <bram@vim.org>
parents:
2417
diff
changeset
|
661 call s:Accents('a','à','á','â','ä','ã','å','ă') |
ee4e1e140117
More accented characters in tex.vim syntax. (Charles Campbell)
Bram Moolenaar <bram@vim.org>
parents:
2417
diff
changeset
|
662 call s:Accents('A','À','Á','Â','Ä','Ã','Å','Ă') |
ee4e1e140117
More accented characters in tex.vim syntax. (Charles Campbell)
Bram Moolenaar <bram@vim.org>
parents:
2417
diff
changeset
|
663 call s:Accents('C',"" ,'Ć','Ĉ',"" ,"" ,"" ,'Ć') |
ee4e1e140117
More accented characters in tex.vim syntax. (Charles Campbell)
Bram Moolenaar <bram@vim.org>
parents:
2417
diff
changeset
|
664 call s:Accents('e','è','é','ê','ë','ẽ',"" ,'ĕ') |
ee4e1e140117
More accented characters in tex.vim syntax. (Charles Campbell)
Bram Moolenaar <bram@vim.org>
parents:
2417
diff
changeset
|
665 call s:Accents('E','È','É','Ê','Ë','Ẽ',"" ,'Ė') |
ee4e1e140117
More accented characters in tex.vim syntax. (Charles Campbell)
Bram Moolenaar <bram@vim.org>
parents:
2417
diff
changeset
|
666 call s:Accents('i','ì','í','î','ï','ĩ',"" ,"ĭ") |
ee4e1e140117
More accented characters in tex.vim syntax. (Charles Campbell)
Bram Moolenaar <bram@vim.org>
parents:
2417
diff
changeset
|
667 call s:Accents('I','Ì','Í','Î','Ï','Ĩ',"" ,'Ĭ') |
ee4e1e140117
More accented characters in tex.vim syntax. (Charles Campbell)
Bram Moolenaar <bram@vim.org>
parents:
2417
diff
changeset
|
668 call s:Accents('o','ò','ó','ô','ö','õ',"" ,'ŏ') |
ee4e1e140117
More accented characters in tex.vim syntax. (Charles Campbell)
Bram Moolenaar <bram@vim.org>
parents:
2417
diff
changeset
|
669 call s:Accents('O','Ò','Ó','Ô','Ö','Õ',"" ,'Ŏ') |
ee4e1e140117
More accented characters in tex.vim syntax. (Charles Campbell)
Bram Moolenaar <bram@vim.org>
parents:
2417
diff
changeset
|
670 call s:Accents('r',"" ,'ŕ',"" ,"" ,"" ,"" ,'ř') |
ee4e1e140117
More accented characters in tex.vim syntax. (Charles Campbell)
Bram Moolenaar <bram@vim.org>
parents:
2417
diff
changeset
|
671 call s:Accents('R',"" ,'Ŕ',"" ,"" ,"" ,"" ,'Ř') |
ee4e1e140117
More accented characters in tex.vim syntax. (Charles Campbell)
Bram Moolenaar <bram@vim.org>
parents:
2417
diff
changeset
|
672 call s:Accents('s',"" ,'ś','ŝ',"" ,"" ,"" ,'š') |
ee4e1e140117
More accented characters in tex.vim syntax. (Charles Campbell)
Bram Moolenaar <bram@vim.org>
parents:
2417
diff
changeset
|
673 call s:Accents('S',"" ,'Ś','Ŝ',"" ,"" ,"" ,'Š') |
ee4e1e140117
More accented characters in tex.vim syntax. (Charles Campbell)
Bram Moolenaar <bram@vim.org>
parents:
2417
diff
changeset
|
674 call s:Accents('u','ù','ú','û','ü','ũ',"" ,'ŭ') |
ee4e1e140117
More accented characters in tex.vim syntax. (Charles Campbell)
Bram Moolenaar <bram@vim.org>
parents:
2417
diff
changeset
|
675 call s:Accents('U','Ù','Ú','Û','Ü','Ũ',"" ,'Ŭ') |
ee4e1e140117
More accented characters in tex.vim syntax. (Charles Campbell)
Bram Moolenaar <bram@vim.org>
parents:
2417
diff
changeset
|
676 call s:Accents('y','ỳ','ý','ŷ','ÿ','ỹ',"" ,"" ) |
ee4e1e140117
More accented characters in tex.vim syntax. (Charles Campbell)
Bram Moolenaar <bram@vim.org>
parents:
2417
diff
changeset
|
677 call s:Accents('Y','Ỳ','Ý','Ŷ','Ÿ','Ỹ',"" ,"" ) |
ee4e1e140117
More accented characters in tex.vim syntax. (Charles Campbell)
Bram Moolenaar <bram@vim.org>
parents:
2417
diff
changeset
|
678 delfun s:Accents |
ee4e1e140117
More accented characters in tex.vim syntax. (Charles Campbell)
Bram Moolenaar <bram@vim.org>
parents:
2417
diff
changeset
|
679 syn match texAccent '\\aa\>' conceal cchar=å |
ee4e1e140117
More accented characters in tex.vim syntax. (Charles Campbell)
Bram Moolenaar <bram@vim.org>
parents:
2417
diff
changeset
|
680 syn match texAccent '\\AA\>' conceal cchar=Å |
ee4e1e140117
More accented characters in tex.vim syntax. (Charles Campbell)
Bram Moolenaar <bram@vim.org>
parents:
2417
diff
changeset
|
681 syn match texAccent '\\k{a}' conceal cchar=ą |
ee4e1e140117
More accented characters in tex.vim syntax. (Charles Campbell)
Bram Moolenaar <bram@vim.org>
parents:
2417
diff
changeset
|
682 syn match texAccent '\\k{A}' conceal cchar=Ą |
ee4e1e140117
More accented characters in tex.vim syntax. (Charles Campbell)
Bram Moolenaar <bram@vim.org>
parents:
2417
diff
changeset
|
683 syn match texAccent '\\c{C}' conceal cchar=Ç |
2417 | 684 syn match texAccent '\\c{c}' conceal cchar=ç |
2424
ee4e1e140117
More accented characters in tex.vim syntax. (Charles Campbell)
Bram Moolenaar <bram@vim.org>
parents:
2417
diff
changeset
|
685 syn match texAccent '\\\~{n}' conceal cchar=ñ |
ee4e1e140117
More accented characters in tex.vim syntax. (Charles Campbell)
Bram Moolenaar <bram@vim.org>
parents:
2417
diff
changeset
|
686 syn match texAccent '\\\~{N}' conceal cchar=Ñ |
ee4e1e140117
More accented characters in tex.vim syntax. (Charles Campbell)
Bram Moolenaar <bram@vim.org>
parents:
2417
diff
changeset
|
687 syn match texAccent '\\o\>' conceal cchar=ø |
ee4e1e140117
More accented characters in tex.vim syntax. (Charles Campbell)
Bram Moolenaar <bram@vim.org>
parents:
2417
diff
changeset
|
688 syn match texAccent '\\O\>' conceal cchar=Ø |
ee4e1e140117
More accented characters in tex.vim syntax. (Charles Campbell)
Bram Moolenaar <bram@vim.org>
parents:
2417
diff
changeset
|
689 syn match texAccent '\\H{o}' conceal cchar=ő |
ee4e1e140117
More accented characters in tex.vim syntax. (Charles Campbell)
Bram Moolenaar <bram@vim.org>
parents:
2417
diff
changeset
|
690 syn match texAccent '\\H{O}' conceal cchar=Ő |
ee4e1e140117
More accented characters in tex.vim syntax. (Charles Campbell)
Bram Moolenaar <bram@vim.org>
parents:
2417
diff
changeset
|
691 syn match texAccent '\\c{r}' conceal cchar=ŗ |
ee4e1e140117
More accented characters in tex.vim syntax. (Charles Campbell)
Bram Moolenaar <bram@vim.org>
parents:
2417
diff
changeset
|
692 syn match texLigature '\\AE\>' conceal cchar=Æ |
ee4e1e140117
More accented characters in tex.vim syntax. (Charles Campbell)
Bram Moolenaar <bram@vim.org>
parents:
2417
diff
changeset
|
693 syn match texLigature '\\ae\>' conceal cchar=æ |
ee4e1e140117
More accented characters in tex.vim syntax. (Charles Campbell)
Bram Moolenaar <bram@vim.org>
parents:
2417
diff
changeset
|
694 syn match texLigature '\\oe\>' conceal cchar=œ |
ee4e1e140117
More accented characters in tex.vim syntax. (Charles Campbell)
Bram Moolenaar <bram@vim.org>
parents:
2417
diff
changeset
|
695 syn match texLigature '\\OE\>' conceal cchar=Œ |
ee4e1e140117
More accented characters in tex.vim syntax. (Charles Campbell)
Bram Moolenaar <bram@vim.org>
parents:
2417
diff
changeset
|
696 syn match texLigature '\\ss\>' conceal cchar=ß |
2417 | 697 endif |
2282
a888ed7ba375
Make updating text for conceal mode simpler. A few compiler warning fixes.
Bram Moolenaar <bram@vim.org>
parents:
2152
diff
changeset
|
698 endif |
a888ed7ba375
Make updating text for conceal mode simpler. A few compiler warning fixes.
Bram Moolenaar <bram@vim.org>
parents:
2152
diff
changeset
|
699 |
a888ed7ba375
Make updating text for conceal mode simpler. A few compiler warning fixes.
Bram Moolenaar <bram@vim.org>
parents:
2152
diff
changeset
|
700 " --------------------------------------------------------------------- |
7 | 701 " LaTeX synchronization: {{{1 |
702 syn sync maxlines=200 | |
703 syn sync minlines=50 | |
704 | |
705 syn sync match texSyncStop groupthere NONE "%stopzone\>" | |
706 | |
707 " Synchronization: {{{1 | |
708 " The $..$ and $$..$$ make for impossible sync patterns | |
709 " (one can't tell if a "$$" starts or stops a math zone by itself) | |
710 " The following grouptheres coupled with minlines above | |
711 " help improve the odds of good syncing. | |
712 if !exists("tex_no_math") | |
713 syn sync match texSyncMathZoneA groupthere NONE "\\end{abstract}" | |
714 syn sync match texSyncMathZoneA groupthere NONE "\\end{center}" | |
715 syn sync match texSyncMathZoneA groupthere NONE "\\end{description}" | |
716 syn sync match texSyncMathZoneA groupthere NONE "\\end{enumerate}" | |
717 syn sync match texSyncMathZoneA groupthere NONE "\\end{itemize}" | |
718 syn sync match texSyncMathZoneA groupthere NONE "\\end{table}" | |
719 syn sync match texSyncMathZoneA groupthere NONE "\\end{tabular}" | |
720 syn sync match texSyncMathZoneA groupthere NONE "\\\(sub\)*section\>" | |
721 endif | |
722 | |
2282
a888ed7ba375
Make updating text for conceal mode simpler. A few compiler warning fixes.
Bram Moolenaar <bram@vim.org>
parents:
2152
diff
changeset
|
723 " --------------------------------------------------------------------- |
7 | 724 " Highlighting: {{{1 |
725 if did_tex_syntax_inits == 1 | |
726 let did_tex_syntax_inits= 2 | |
727 " TeX highlighting groups which should share similar highlighting | |
728 if !exists("g:tex_no_error") | |
729 if !exists("tex_no_math") | |
730 HiLink texBadMath texError | |
731 HiLink texMathDelimBad texError | |
732 HiLink texMathError texError | |
733 if !b:tex_stylish | |
734 HiLink texOnlyMath texError | |
735 endif | |
736 endif | |
737 HiLink texError Error | |
738 endif | |
739 | |
587 | 740 HiLink texCite texRefZone |
7 | 741 HiLink texDefCmd texDef |
742 HiLink texDefName texDef | |
743 HiLink texDocType texCmdName | |
744 HiLink texDocTypeArgs texCmdArgs | |
745 HiLink texInputFileOpt texCmdArgs | |
746 HiLink texInputCurlies texDelimiter | |
747 HiLink texLigature texSpecialChar | |
748 if !exists("tex_no_math") | |
749 HiLink texMathDelimSet1 texMathDelim | |
750 HiLink texMathDelimSet2 texMathDelim | |
751 HiLink texMathDelimKey texMathDelim | |
752 HiLink texMathMatcher texMath | |
2034 | 753 HiLink texMathZoneV texMath |
7 | 754 HiLink texMathZoneW texMath |
755 HiLink texMathZoneX texMath | |
756 HiLink texMathZoneY texMath | |
1620 | 757 HiLink texMathZoneV texMath |
7 | 758 HiLink texMathZoneZ texMath |
759 endif | |
760 HiLink texSectionMarker texCmdName | |
761 HiLink texSectionName texSection | |
762 HiLink texSpaceCode texStatement | |
2034 | 763 HiLink texStyleStatement texStatement |
7 | 764 HiLink texTypeSize texType |
765 HiLink texTypeStyle texType | |
766 | |
767 " Basic TeX highlighting groups | |
768 HiLink texCmdArgs Number | |
769 HiLink texCmdName Statement | |
770 HiLink texComment Comment | |
771 HiLink texDef Statement | |
772 HiLink texDefParm Special | |
773 HiLink texDelimiter Delimiter | |
774 HiLink texInput Special | |
775 HiLink texInputFile Special | |
776 HiLink texLength Number | |
777 HiLink texMath Special | |
778 HiLink texMathDelim Statement | |
779 HiLink texMathOper Operator | |
780 HiLink texNewCmd Statement | |
781 HiLink texNewEnv Statement | |
782 HiLink texOption Number | |
783 HiLink texRefZone Special | |
784 HiLink texSection PreCondit | |
785 HiLink texSpaceCodeChar Special | |
786 HiLink texSpecialChar SpecialChar | |
787 HiLink texStatement Statement | |
788 HiLink texString String | |
789 HiLink texTodo Todo | |
790 HiLink texType Type | |
791 HiLink texZone PreCondit | |
792 | |
793 delcommand HiLink | |
794 endif | |
795 | |
796 " Current Syntax: {{{1 | |
797 unlet b:extfname | |
798 let b:current_syntax = "tex" | |
799 " vim: ts=8 fdm=marker |