Mercurial > vim
annotate runtime/syntax/context.vim @ 17096:a8e6a8fbe880
Added tag v8.1.1547 for changeset 10e0d7d96cb0ca636c06a17978c82427190626ce
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Sat, 15 Jun 2019 19:45:07 +0200 |
parents | 07d2b5a3b7cc |
children | 2acb87ee55fc |
rev | line source |
---|---|
375 | 1 " Vim syntax file |
10301
07d2b5a3b7cc
commit https://github.com/vim/vim/commit/46fceaaa8d1447a9588736d86eb4908214187b08
Christian Brabandt <cb@256bit.org>
parents:
1224
diff
changeset
|
2 " Language: ConTeXt typesetting engine |
07d2b5a3b7cc
commit https://github.com/vim/vim/commit/46fceaaa8d1447a9588736d86eb4908214187b08
Christian Brabandt <cb@256bit.org>
parents:
1224
diff
changeset
|
3 " Maintainer: Nicola Vitacolonna <nvitacolonna@gmail.com> |
07d2b5a3b7cc
commit https://github.com/vim/vim/commit/46fceaaa8d1447a9588736d86eb4908214187b08
Christian Brabandt <cb@256bit.org>
parents:
1224
diff
changeset
|
4 " Former Maintainers: Nikolai Weibull <now@bitwi.se> |
07d2b5a3b7cc
commit https://github.com/vim/vim/commit/46fceaaa8d1447a9588736d86eb4908214187b08
Christian Brabandt <cb@256bit.org>
parents:
1224
diff
changeset
|
5 " Latest Revision: 2016 Oct 16 |
375 | 6 |
7 if exists("b:current_syntax") | |
8 finish | |
9 endif | |
10 | |
839 | 11 runtime! syntax/plaintex.vim |
1224 | 12 unlet b:current_syntax |
839 | 13 |
375 | 14 let s:cpo_save = &cpo |
15 set cpo&vim | |
16 | |
10301
07d2b5a3b7cc
commit https://github.com/vim/vim/commit/46fceaaa8d1447a9588736d86eb4908214187b08
Christian Brabandt <cb@256bit.org>
parents:
1224
diff
changeset
|
17 " Dictionary of (filetype, group) pairs to highlight between \startGROUP \stopGROUP. |
07d2b5a3b7cc
commit https://github.com/vim/vim/commit/46fceaaa8d1447a9588736d86eb4908214187b08
Christian Brabandt <cb@256bit.org>
parents:
1224
diff
changeset
|
18 let s:context_include = get(b:, 'context_include', get(g:, 'context_include', {'xml': 'XML'})) |
07d2b5a3b7cc
commit https://github.com/vim/vim/commit/46fceaaa8d1447a9588736d86eb4908214187b08
Christian Brabandt <cb@256bit.org>
parents:
1224
diff
changeset
|
19 |
07d2b5a3b7cc
commit https://github.com/vim/vim/commit/46fceaaa8d1447a9588736d86eb4908214187b08
Christian Brabandt <cb@256bit.org>
parents:
1224
diff
changeset
|
20 " For backward compatibility (g:context_include used to be a List) |
07d2b5a3b7cc
commit https://github.com/vim/vim/commit/46fceaaa8d1447a9588736d86eb4908214187b08
Christian Brabandt <cb@256bit.org>
parents:
1224
diff
changeset
|
21 if type(s:context_include) ==# type([]) |
07d2b5a3b7cc
commit https://github.com/vim/vim/commit/46fceaaa8d1447a9588736d86eb4908214187b08
Christian Brabandt <cb@256bit.org>
parents:
1224
diff
changeset
|
22 let g:context_metapost = (index(s:context_include, 'mp') != -1) |
07d2b5a3b7cc
commit https://github.com/vim/vim/commit/46fceaaa8d1447a9588736d86eb4908214187b08
Christian Brabandt <cb@256bit.org>
parents:
1224
diff
changeset
|
23 let s:context_include = filter( |
07d2b5a3b7cc
commit https://github.com/vim/vim/commit/46fceaaa8d1447a9588736d86eb4908214187b08
Christian Brabandt <cb@256bit.org>
parents:
1224
diff
changeset
|
24 \ {'c': 'C', 'javascript': 'JS', 'ruby': 'Ruby', 'xml': 'XML'}, |
07d2b5a3b7cc
commit https://github.com/vim/vim/commit/46fceaaa8d1447a9588736d86eb4908214187b08
Christian Brabandt <cb@256bit.org>
parents:
1224
diff
changeset
|
25 \ { k,_ -> index(s:context_include, k) != -1 } |
07d2b5a3b7cc
commit https://github.com/vim/vim/commit/46fceaaa8d1447a9588736d86eb4908214187b08
Christian Brabandt <cb@256bit.org>
parents:
1224
diff
changeset
|
26 \ ) |
839 | 27 endif |
375 | 28 |
10301
07d2b5a3b7cc
commit https://github.com/vim/vim/commit/46fceaaa8d1447a9588736d86eb4908214187b08
Christian Brabandt <cb@256bit.org>
parents:
1224
diff
changeset
|
29 syn iskeyword @,48-57,a-z,A-Z,192-255 |
07d2b5a3b7cc
commit https://github.com/vim/vim/commit/46fceaaa8d1447a9588736d86eb4908214187b08
Christian Brabandt <cb@256bit.org>
parents:
1224
diff
changeset
|
30 |
1224 | 31 syn spell toplevel |
32 | |
10301
07d2b5a3b7cc
commit https://github.com/vim/vim/commit/46fceaaa8d1447a9588736d86eb4908214187b08
Christian Brabandt <cb@256bit.org>
parents:
1224
diff
changeset
|
33 " ConTeXt options, i.e., [...] blocks |
07d2b5a3b7cc
commit https://github.com/vim/vim/commit/46fceaaa8d1447a9588736d86eb4908214187b08
Christian Brabandt <cb@256bit.org>
parents:
1224
diff
changeset
|
34 syn region contextOptions matchgroup=contextDelimiter start='\[' end=']\|\ze\\stop' skip='\\\[\|\\\]' contains=ALLBUT,contextBeginEndLua,@Spell |
07d2b5a3b7cc
commit https://github.com/vim/vim/commit/46fceaaa8d1447a9588736d86eb4908214187b08
Christian Brabandt <cb@256bit.org>
parents:
1224
diff
changeset
|
35 |
07d2b5a3b7cc
commit https://github.com/vim/vim/commit/46fceaaa8d1447a9588736d86eb4908214187b08
Christian Brabandt <cb@256bit.org>
parents:
1224
diff
changeset
|
36 " Highlight braces |
07d2b5a3b7cc
commit https://github.com/vim/vim/commit/46fceaaa8d1447a9588736d86eb4908214187b08
Christian Brabandt <cb@256bit.org>
parents:
1224
diff
changeset
|
37 syn match contextDelimiter '[{}]' |
375 | 38 |
10301
07d2b5a3b7cc
commit https://github.com/vim/vim/commit/46fceaaa8d1447a9588736d86eb4908214187b08
Christian Brabandt <cb@256bit.org>
parents:
1224
diff
changeset
|
39 " Comments |
07d2b5a3b7cc
commit https://github.com/vim/vim/commit/46fceaaa8d1447a9588736d86eb4908214187b08
Christian Brabandt <cb@256bit.org>
parents:
1224
diff
changeset
|
40 syn match contextComment '\\\@<!\%(\\\\\)*\zs%.*$' display contains=initexTodo |
07d2b5a3b7cc
commit https://github.com/vim/vim/commit/46fceaaa8d1447a9588736d86eb4908214187b08
Christian Brabandt <cb@256bit.org>
parents:
1224
diff
changeset
|
41 syn match contextComment '^\s*%[CDM].*$' display contains=initexTodo |
07d2b5a3b7cc
commit https://github.com/vim/vim/commit/46fceaaa8d1447a9588736d86eb4908214187b08
Christian Brabandt <cb@256bit.org>
parents:
1224
diff
changeset
|
42 |
07d2b5a3b7cc
commit https://github.com/vim/vim/commit/46fceaaa8d1447a9588736d86eb4908214187b08
Christian Brabandt <cb@256bit.org>
parents:
1224
diff
changeset
|
43 syn match contextBlockDelim '\\\%(start\|stop\)\a\+' contains=@NoSpell |
07d2b5a3b7cc
commit https://github.com/vim/vim/commit/46fceaaa8d1447a9588736d86eb4908214187b08
Christian Brabandt <cb@256bit.org>
parents:
1224
diff
changeset
|
44 |
07d2b5a3b7cc
commit https://github.com/vim/vim/commit/46fceaaa8d1447a9588736d86eb4908214187b08
Christian Brabandt <cb@256bit.org>
parents:
1224
diff
changeset
|
45 syn region contextEscaped matchgroup=contextPreProc start='\\type\%(\s*\|\n\)*\z([^A-Za-z%]\)' end='\z1' |
07d2b5a3b7cc
commit https://github.com/vim/vim/commit/46fceaaa8d1447a9588736d86eb4908214187b08
Christian Brabandt <cb@256bit.org>
parents:
1224
diff
changeset
|
46 syn region contextEscaped matchgroup=contextPreProc start='\\type\=\%(\s\|\n\)*{' end='}' |
07d2b5a3b7cc
commit https://github.com/vim/vim/commit/46fceaaa8d1447a9588736d86eb4908214187b08
Christian Brabandt <cb@256bit.org>
parents:
1224
diff
changeset
|
47 syn region contextEscaped matchgroup=contextPreProc start='\\type\=\%(\s*\|\n\)*<<' end='>>' |
375 | 48 syn region contextEscaped matchgroup=contextPreProc |
49 \ start='\\start\z(\a*\%(typing\|typen\)\)' | |
1224 | 50 \ end='\\stop\z1' contains=plaintexComment keepend |
10301
07d2b5a3b7cc
commit https://github.com/vim/vim/commit/46fceaaa8d1447a9588736d86eb4908214187b08
Christian Brabandt <cb@256bit.org>
parents:
1224
diff
changeset
|
51 syn region contextEscaped matchgroup=contextPreProc start='\\\h\+Type\%(\s\|\n\)*{' end='}' |
07d2b5a3b7cc
commit https://github.com/vim/vim/commit/46fceaaa8d1447a9588736d86eb4908214187b08
Christian Brabandt <cb@256bit.org>
parents:
1224
diff
changeset
|
52 syn region contextEscaped matchgroup=contextPreProc start='\\Typed\h\+\%(\s\|\n\)*{' end='}' |
375 | 53 |
839 | 54 syn match contextBuiltin display contains=@NoSpell |
10301
07d2b5a3b7cc
commit https://github.com/vim/vim/commit/46fceaaa8d1447a9588736d86eb4908214187b08
Christian Brabandt <cb@256bit.org>
parents:
1224
diff
changeset
|
55 \ '\\\%(unprotect\|protect\|unexpanded\)\>' |
375 | 56 |
10301
07d2b5a3b7cc
commit https://github.com/vim/vim/commit/46fceaaa8d1447a9588736d86eb4908214187b08
Christian Brabandt <cb@256bit.org>
parents:
1224
diff
changeset
|
57 syn match contextPreProc '^\s*\\\%(start\|stop\)\=\%(component\|environment\|project\|product\)\>' |
375 | 58 \ contains=@NoSpell |
839 | 59 |
10301
07d2b5a3b7cc
commit https://github.com/vim/vim/commit/46fceaaa8d1447a9588736d86eb4908214187b08
Christian Brabandt <cb@256bit.org>
parents:
1224
diff
changeset
|
60 if get(b:, 'context_metapost', get(g:, 'context_metapost', 1)) |
07d2b5a3b7cc
commit https://github.com/vim/vim/commit/46fceaaa8d1447a9588736d86eb4908214187b08
Christian Brabandt <cb@256bit.org>
parents:
1224
diff
changeset
|
61 let b:mp_metafun_macros = 1 " Highlight MetaFun keywords |
839 | 62 syn include @mpTop syntax/mp.vim |
63 unlet b:current_syntax | |
64 | |
10301
07d2b5a3b7cc
commit https://github.com/vim/vim/commit/46fceaaa8d1447a9588736d86eb4908214187b08
Christian Brabandt <cb@256bit.org>
parents:
1224
diff
changeset
|
65 syn region contextMPGraphic matchgroup=contextBlockDelim |
07d2b5a3b7cc
commit https://github.com/vim/vim/commit/46fceaaa8d1447a9588736d86eb4908214187b08
Christian Brabandt <cb@256bit.org>
parents:
1224
diff
changeset
|
66 \ start='\\start\z(MP\%(clip\|code\|definitions\|drawing\|environment\|extensions\|inclusions\|initializations\|page\|\)\)\>.*$' |
839 | 67 \ end='\\stop\z1' |
10301
07d2b5a3b7cc
commit https://github.com/vim/vim/commit/46fceaaa8d1447a9588736d86eb4908214187b08
Christian Brabandt <cb@256bit.org>
parents:
1224
diff
changeset
|
68 \ contains=@mpTop,@NoSpell |
07d2b5a3b7cc
commit https://github.com/vim/vim/commit/46fceaaa8d1447a9588736d86eb4908214187b08
Christian Brabandt <cb@256bit.org>
parents:
1224
diff
changeset
|
69 syn region contextMPGraphic matchgroup=contextBlockDelim |
07d2b5a3b7cc
commit https://github.com/vim/vim/commit/46fceaaa8d1447a9588736d86eb4908214187b08
Christian Brabandt <cb@256bit.org>
parents:
1224
diff
changeset
|
70 \ start='\\start\z(\%(\%[re]usable\|use\|unique\|static\)MPgraphic\|staticMPfigure\|uniqueMPpagegraphic\)\>.*$' |
07d2b5a3b7cc
commit https://github.com/vim/vim/commit/46fceaaa8d1447a9588736d86eb4908214187b08
Christian Brabandt <cb@256bit.org>
parents:
1224
diff
changeset
|
71 \ end='\\stop\z1' |
07d2b5a3b7cc
commit https://github.com/vim/vim/commit/46fceaaa8d1447a9588736d86eb4908214187b08
Christian Brabandt <cb@256bit.org>
parents:
1224
diff
changeset
|
72 \ contains=@mpTop,@NoSpell |
839 | 73 endif |
74 | |
10301
07d2b5a3b7cc
commit https://github.com/vim/vim/commit/46fceaaa8d1447a9588736d86eb4908214187b08
Christian Brabandt <cb@256bit.org>
parents:
1224
diff
changeset
|
75 if get(b:, 'context_lua', get(g:, 'context_lua', 1)) |
07d2b5a3b7cc
commit https://github.com/vim/vim/commit/46fceaaa8d1447a9588736d86eb4908214187b08
Christian Brabandt <cb@256bit.org>
parents:
1224
diff
changeset
|
76 syn include @luaTop syntax/lua.vim |
07d2b5a3b7cc
commit https://github.com/vim/vim/commit/46fceaaa8d1447a9588736d86eb4908214187b08
Christian Brabandt <cb@256bit.org>
parents:
1224
diff
changeset
|
77 unlet b:current_syntax |
07d2b5a3b7cc
commit https://github.com/vim/vim/commit/46fceaaa8d1447a9588736d86eb4908214187b08
Christian Brabandt <cb@256bit.org>
parents:
1224
diff
changeset
|
78 |
07d2b5a3b7cc
commit https://github.com/vim/vim/commit/46fceaaa8d1447a9588736d86eb4908214187b08
Christian Brabandt <cb@256bit.org>
parents:
1224
diff
changeset
|
79 syn region contextLuaCode matchgroup=contextBlockDelim |
07d2b5a3b7cc
commit https://github.com/vim/vim/commit/46fceaaa8d1447a9588736d86eb4908214187b08
Christian Brabandt <cb@256bit.org>
parents:
1224
diff
changeset
|
80 \ start='\\startluacode\>' |
07d2b5a3b7cc
commit https://github.com/vim/vim/commit/46fceaaa8d1447a9588736d86eb4908214187b08
Christian Brabandt <cb@256bit.org>
parents:
1224
diff
changeset
|
81 \ end='\\stopluacode\>' keepend |
07d2b5a3b7cc
commit https://github.com/vim/vim/commit/46fceaaa8d1447a9588736d86eb4908214187b08
Christian Brabandt <cb@256bit.org>
parents:
1224
diff
changeset
|
82 \ contains=@luaTop,@NoSpell |
839 | 83 |
10301
07d2b5a3b7cc
commit https://github.com/vim/vim/commit/46fceaaa8d1447a9588736d86eb4908214187b08
Christian Brabandt <cb@256bit.org>
parents:
1224
diff
changeset
|
84 syn match contextDirectLua "\\\%(directlua\|ctxlua\)\>\%(\s*%.*$\)\=" |
07d2b5a3b7cc
commit https://github.com/vim/vim/commit/46fceaaa8d1447a9588736d86eb4908214187b08
Christian Brabandt <cb@256bit.org>
parents:
1224
diff
changeset
|
85 \ nextgroup=contextBeginEndLua skipwhite skipempty |
07d2b5a3b7cc
commit https://github.com/vim/vim/commit/46fceaaa8d1447a9588736d86eb4908214187b08
Christian Brabandt <cb@256bit.org>
parents:
1224
diff
changeset
|
86 \ contains=initexComment |
07d2b5a3b7cc
commit https://github.com/vim/vim/commit/46fceaaa8d1447a9588736d86eb4908214187b08
Christian Brabandt <cb@256bit.org>
parents:
1224
diff
changeset
|
87 syn region contextBeginEndLua matchgroup=contextSpecial |
07d2b5a3b7cc
commit https://github.com/vim/vim/commit/46fceaaa8d1447a9588736d86eb4908214187b08
Christian Brabandt <cb@256bit.org>
parents:
1224
diff
changeset
|
88 \ start="{" end="}" skip="\\[{}]" |
07d2b5a3b7cc
commit https://github.com/vim/vim/commit/46fceaaa8d1447a9588736d86eb4908214187b08
Christian Brabandt <cb@256bit.org>
parents:
1224
diff
changeset
|
89 \ contained contains=@luaTop,@NoSpell |
07d2b5a3b7cc
commit https://github.com/vim/vim/commit/46fceaaa8d1447a9588736d86eb4908214187b08
Christian Brabandt <cb@256bit.org>
parents:
1224
diff
changeset
|
90 endif |
375 | 91 |
10301
07d2b5a3b7cc
commit https://github.com/vim/vim/commit/46fceaaa8d1447a9588736d86eb4908214187b08
Christian Brabandt <cb@256bit.org>
parents:
1224
diff
changeset
|
92 for synname in keys(s:context_include) |
07d2b5a3b7cc
commit https://github.com/vim/vim/commit/46fceaaa8d1447a9588736d86eb4908214187b08
Christian Brabandt <cb@256bit.org>
parents:
1224
diff
changeset
|
93 execute 'syn include @' . synname . 'Top' 'syntax/' . synname . '.vim' |
07d2b5a3b7cc
commit https://github.com/vim/vim/commit/46fceaaa8d1447a9588736d86eb4908214187b08
Christian Brabandt <cb@256bit.org>
parents:
1224
diff
changeset
|
94 unlet b:current_syntax |
07d2b5a3b7cc
commit https://github.com/vim/vim/commit/46fceaaa8d1447a9588736d86eb4908214187b08
Christian Brabandt <cb@256bit.org>
parents:
1224
diff
changeset
|
95 execute 'syn region context' . s:context_include[synname] . 'Code' |
07d2b5a3b7cc
commit https://github.com/vim/vim/commit/46fceaaa8d1447a9588736d86eb4908214187b08
Christian Brabandt <cb@256bit.org>
parents:
1224
diff
changeset
|
96 \ 'matchgroup=contextBlockDelim' |
07d2b5a3b7cc
commit https://github.com/vim/vim/commit/46fceaaa8d1447a9588736d86eb4908214187b08
Christian Brabandt <cb@256bit.org>
parents:
1224
diff
changeset
|
97 \ 'start=+\\start' . s:context_include[synname] . '+' |
07d2b5a3b7cc
commit https://github.com/vim/vim/commit/46fceaaa8d1447a9588736d86eb4908214187b08
Christian Brabandt <cb@256bit.org>
parents:
1224
diff
changeset
|
98 \ 'end=+\\stop' . s:context_include[synname] . '+' |
07d2b5a3b7cc
commit https://github.com/vim/vim/commit/46fceaaa8d1447a9588736d86eb4908214187b08
Christian Brabandt <cb@256bit.org>
parents:
1224
diff
changeset
|
99 \ 'contains=@' . synname . 'Top,@NoSpell' |
07d2b5a3b7cc
commit https://github.com/vim/vim/commit/46fceaaa8d1447a9588736d86eb4908214187b08
Christian Brabandt <cb@256bit.org>
parents:
1224
diff
changeset
|
100 endfor |
07d2b5a3b7cc
commit https://github.com/vim/vim/commit/46fceaaa8d1447a9588736d86eb4908214187b08
Christian Brabandt <cb@256bit.org>
parents:
1224
diff
changeset
|
101 |
07d2b5a3b7cc
commit https://github.com/vim/vim/commit/46fceaaa8d1447a9588736d86eb4908214187b08
Christian Brabandt <cb@256bit.org>
parents:
1224
diff
changeset
|
102 syn match contextSectioning '\\\%(start\|stop\)\=\%(\%(sub\)*section\|\%(sub\)*subject\|chapter\|part\|component\|product\|title\)\>' |
07d2b5a3b7cc
commit https://github.com/vim/vim/commit/46fceaaa8d1447a9588736d86eb4908214187b08
Christian Brabandt <cb@256bit.org>
parents:
1224
diff
changeset
|
103 \ contains=@NoSpell |
375 | 104 |
105 syn match contextSpecial '\\crlf\>\|\\par\>\|-\{2,3}\||[<>/]\=|' | |
106 \ contains=@NoSpell | |
839 | 107 syn match contextSpecial /\\[`'"]/ |
375 | 108 syn match contextSpecial +\\char\%(\d\{1,3}\|'\o\{1,3}\|"\x\{1,2}\)\>+ |
109 \ contains=@NoSpell | |
110 syn match contextSpecial '\^\^.' | |
111 syn match contextSpecial '`\%(\\.\|\^\^.\|.\)' | |
112 | |
839 | 113 syn match contextStyle '\\\%(em\|ss\|hw\|cg\|mf\)\>' |
375 | 114 \ contains=@NoSpell |
115 syn match contextFont '\\\%(CAP\|Cap\|cap\|Caps\|kap\|nocap\)\>' | |
116 \ contains=@NoSpell | |
117 syn match contextFont '\\\%(Word\|WORD\|Words\|WORDS\)\>' | |
118 \ contains=@NoSpell | |
119 syn match contextFont '\\\%(vi\{1,3}\|ix\|xi\{0,2}\)\>' | |
120 \ contains=@NoSpell | |
839 | 121 syn match contextFont '\\\%(tf\|b[si]\|s[cl]\|os\)\%(xx\|[xabcd]\)\=\>' |
375 | 122 \ contains=@NoSpell |
123 | |
10301
07d2b5a3b7cc
commit https://github.com/vim/vim/commit/46fceaaa8d1447a9588736d86eb4908214187b08
Christian Brabandt <cb@256bit.org>
parents:
1224
diff
changeset
|
124 hi def link contextOptions Typedef |
07d2b5a3b7cc
commit https://github.com/vim/vim/commit/46fceaaa8d1447a9588736d86eb4908214187b08
Christian Brabandt <cb@256bit.org>
parents:
1224
diff
changeset
|
125 hi def link contextComment Comment |
375 | 126 hi def link contextBlockDelim Keyword |
127 hi def link contextBuiltin Keyword | |
128 hi def link contextDelimiter Delimiter | |
10301
07d2b5a3b7cc
commit https://github.com/vim/vim/commit/46fceaaa8d1447a9588736d86eb4908214187b08
Christian Brabandt <cb@256bit.org>
parents:
1224
diff
changeset
|
129 hi def link contextEscaped String |
375 | 130 hi def link contextPreProc PreProc |
131 hi def link contextSectioning PreProc | |
132 hi def link contextSpecial Special | |
839 | 133 hi def link contextType Type |
375 | 134 hi def link contextStyle contextType |
135 hi def link contextFont contextType | |
10301
07d2b5a3b7cc
commit https://github.com/vim/vim/commit/46fceaaa8d1447a9588736d86eb4908214187b08
Christian Brabandt <cb@256bit.org>
parents:
1224
diff
changeset
|
136 hi def link contextDirectLua Keyword |
375 | 137 |
138 let b:current_syntax = "context" | |
139 | |
140 let &cpo = s:cpo_save | |
141 unlet s:cpo_save |