Mercurial > vim
annotate runtime/syntax/xml.vim @ 26007:1d2e1c23e458 v8.2.3537
patch 8.2.3537: mode() does not return the right value in 'operatorfunc'
Commit: https://github.com/vim/vim/commit/75c30e96cf280a8cc01ac01c41a9252db3e503cc
Author: naohiro ono <obcat@icloud.com>
Date: Tue Oct 19 11:15:41 2021 +0100
patch 8.2.3537: mode() does not return the right value in 'operatorfunc'
Problem: mode() does not return the right value in 'operatorfunc'.
Solution: Reset finish_op while calling 'operatorfunc'.
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Tue, 19 Oct 2021 12:30:05 +0200 |
parents | 8dde7ced3344 |
children | f0d7cb510ce3 |
rev | line source |
---|---|
7 | 1 " Vim syntax file |
18456 | 2 " Language: XML |
3 " Maintainer: Christian Brabandt <cb@256bit.org> | |
4 " Repository: https://github.com/chrisbra/vim-xml-ftplugin | |
5 " Previous Maintainer: Johannes Zellner <johannes@zellner.org> | |
6 " Author: Paul Siegmann <pauls@euronet.nl> | |
18790 | 7 " Last Changed: Nov 03, 2019 |
7 | 8 " Filenames: *.xml |
18456 | 9 " Last Change: |
10 " 20190923 - Fix xmlEndTag to match xmlTag (vim/vim#884) | |
11 " 20190924 - Fix xmlAttribute property (amadeus/vim-xml@d8ce1c946) | |
18790 | 12 " 20191103 - Enable spell checking globally |
7 | 13 |
14 " CONFIGURATION: | |
15 " syntax folding can be turned on by | |
16 " | |
17 " let g:xml_syntax_folding = 1 | |
18 " | |
19 " before the syntax file gets loaded (e.g. in ~/.vimrc). | |
20 " This might slow down syntax highlighting significantly, | |
21 " especially for large files. | |
22 " | |
23 " CREDITS: | |
24 " The original version was derived by Paul Siegmann from | |
25 " Claudio Fleiner's html.vim. | |
26 " | |
27 " REFERENCES: | |
28 " [1] http://www.w3.org/TR/2000/REC-xml-20001006 | |
29 " [2] http://www.w3.org/XML/1998/06/xmlspec-report-19980910.htm | |
30 " | |
31 " as <hirauchi@kiwi.ne.jp> pointed out according to reference [1] | |
32 " | |
33 " 2.3 Common Syntactic Constructs | |
34 " [4] NameChar ::= Letter | Digit | '.' | '-' | '_' | ':' | CombiningChar | Extender | |
35 " [5] Name ::= (Letter | '_' | ':') (NameChar)* | |
36 " | |
37 " NOTE: | |
38 " 1) empty tag delimiters "/>" inside attribute values (strings) | |
39 " confuse syntax highlighting. | |
40 " 2) for large files, folding can be pretty slow, especially when | |
41 " loading a file the first time and viewoptions contains 'folds' | |
42 " so that folds of previous sessions are applied. | |
43 " Don't use 'foldmethod=syntax' in this case. | |
44 | |
45 | |
46 " Quit when a syntax file was already loaded | |
47 if exists("b:current_syntax") | |
48 finish | |
49 endif | |
50 | |
51 let s:xml_cpo_save = &cpo | |
52 set cpo&vim | |
53 | |
54 syn case match | |
55 | |
18790 | 56 " Allow spell checking in tag values, |
57 " there is no syntax region for that, | |
58 " so enable spell checking in top-level elements | |
59 " <tag>This text is spell checked</tag> | |
60 syn spell toplevel | |
61 | |
7 | 62 " mark illegal characters |
63 syn match xmlError "[<&]" | |
64 | |
65 " strings (inside tags) aka VALUES | |
66 " | |
67 " EXAMPLE: | |
68 " | |
69 " <tag foo.attribute = "value"> | |
70 " ^^^^^^^ | |
826 | 71 syn region xmlString contained start=+"+ end=+"+ contains=xmlEntity,@Spell display |
72 syn region xmlString contained start=+'+ end=+'+ contains=xmlEntity,@Spell display | |
7 | 73 |
74 | |
75 " punctuation (within attributes) e.g. <tag xml:foo.attribute ...> | |
76 " ^ ^ | |
77 " syn match xmlAttribPunct +[-:._]+ contained display | |
78 syn match xmlAttribPunct +[:.]+ contained display | |
79 | |
80 " no highlighting for xmlEqual (xmlEqual has no highlighting group) | |
81 syn match xmlEqual +=+ display | |
82 | |
83 | |
84 " attribute, everything before the '=' | |
85 " | |
86 " PROVIDES: @xmlAttribHook | |
87 " | |
88 " EXAMPLE: | |
89 " | |
90 " <tag foo.attribute = "value"> | |
91 " ^^^^^^^^^^^^^ | |
92 " | |
93 syn match xmlAttrib | |
18456 | 94 \ +[-'"<]\@1<!\<[a-zA-Z:_][-.0-9a-zA-Z:_]*\>\%(['"]\@!\|$\)+ |
7 | 95 \ contained |
96 \ contains=xmlAttribPunct,@xmlAttribHook | |
97 \ display | |
98 | |
99 | |
100 " namespace spec | |
101 " | |
102 " PROVIDES: @xmlNamespaceHook | |
103 " | |
104 " EXAMPLE: | |
105 " | |
106 " <xsl:for-each select = "lola"> | |
107 " ^^^ | |
108 " | |
109 if exists("g:xml_namespace_transparent") | |
110 syn match xmlNamespace | |
4681
2eb30f341e8d
Updated runtime files and translations.
Bram Moolenaar <bram@vim.org>
parents:
2034
diff
changeset
|
111 \ +\(<\|</\)\@2<=[^ /!?<>"':]\+[:]\@=+ |
7 | 112 \ contained |
113 \ contains=@xmlNamespaceHook | |
114 \ transparent | |
115 \ display | |
116 else | |
117 syn match xmlNamespace | |
4681
2eb30f341e8d
Updated runtime files and translations.
Bram Moolenaar <bram@vim.org>
parents:
2034
diff
changeset
|
118 \ +\(<\|</\)\@2<=[^ /!?<>"':]\+[:]\@=+ |
7 | 119 \ contained |
120 \ contains=@xmlNamespaceHook | |
121 \ display | |
122 endif | |
123 | |
124 | |
125 " tag name | |
126 " | |
127 " PROVIDES: @xmlTagHook | |
128 " | |
129 " EXAMPLE: | |
130 " | |
131 " <tag foo.attribute = "value"> | |
132 " ^^^ | |
133 " | |
134 syn match xmlTagName | |
18456 | 135 \ +\%(<\|</\)\@2<=[^ /!?<>"']\++ |
7 | 136 \ contained |
137 \ contains=xmlNamespace,xmlAttribPunct,@xmlTagHook | |
138 \ display | |
139 | |
140 | |
141 if exists('g:xml_syntax_folding') | |
142 | |
143 " start tag | |
144 " use matchgroup=xmlTag to skip over the leading '<' | |
145 " | |
146 " PROVIDES: @xmlStartTagHook | |
147 " | |
148 " EXAMPLE: | |
149 " | |
150 " <tag id="whoops"> | |
151 " s^^^^^^^^^^^^^^^e | |
152 " | |
153 syn region xmlTag | |
154 \ matchgroup=xmlTag start=+<[^ /!?<>"']\@=+ | |
155 \ matchgroup=xmlTag end=+>+ | |
156 \ contained | |
157 \ contains=xmlError,xmlTagName,xmlAttrib,xmlEqual,xmlString,@xmlStartTagHook | |
158 | |
159 | |
160 " highlight the end tag | |
161 " | |
162 " PROVIDES: @xmlTagHook | |
163 " (should we provide a separate @xmlEndTagHook ?) | |
164 " | |
165 " EXAMPLE: | |
166 " | |
167 " </tag> | |
168 " ^^^^^^ | |
169 " | |
18456 | 170 syn region xmlEndTag |
171 \ matchgroup=xmlTag start=+</[^ /!?<>"']\@=+ | |
172 \ matchgroup=xmlTag end=+>+ | |
7 | 173 \ contained |
18456 | 174 \ contains=xmlTagName,xmlNamespace,xmlAttribPunct,@xmlTagHook |
7 | 175 |
176 " tag elements with syntax-folding. | |
177 " NOTE: NO HIGHLIGHTING -- highlighting is done by contained elements | |
178 " | |
179 " PROVIDES: @xmlRegionHook | |
180 " | |
181 " EXAMPLE: | |
182 " | |
183 " <tag id="whoops"> | |
184 " <!-- comment --> | |
185 " <another.tag></another.tag> | |
186 " <empty.tag/> | |
187 " some data | |
188 " </tag> | |
189 " | |
190 syn region xmlRegion | |
191 \ start=+<\z([^ /!?<>"']\+\)+ | |
192 \ skip=+<!--\_.\{-}-->+ | |
193 \ end=+</\z1\_\s\{-}>+ | |
18456 | 194 \ end=+/>+ |
7 | 195 \ fold |
826 | 196 \ contains=xmlTag,xmlEndTag,xmlCdata,xmlRegion,xmlComment,xmlEntity,xmlProcessing,@xmlRegionHook,@Spell |
7 | 197 \ keepend |
198 \ extend | |
199 | |
200 else | |
201 | |
202 " no syntax folding: | |
203 " - contained attribute removed | |
204 " - xmlRegion not defined | |
205 " | |
206 syn region xmlTag | |
207 \ matchgroup=xmlTag start=+<[^ /!?<>"']\@=+ | |
208 \ matchgroup=xmlTag end=+>+ | |
209 \ contains=xmlError,xmlTagName,xmlAttrib,xmlEqual,xmlString,@xmlStartTagHook | |
210 | |
18456 | 211 syn region xmlEndTag |
212 \ matchgroup=xmlTag start=+</[^ /!?<>"']\@=+ | |
213 \ matchgroup=xmlTag end=+>+ | |
214 \ contains=xmlTagName,xmlNamespace,xmlAttribPunct,@xmlTagHook | |
7 | 215 |
216 endif | |
217 | |
218 | |
219 " &entities; compare with dtd | |
220 syn match xmlEntity "&[^; \t]*;" contains=xmlEntityPunct | |
221 syn match xmlEntityPunct contained "[&.;]" | |
222 | |
223 if exists('g:xml_syntax_folding') | |
224 | |
225 " The real comments (this implements the comments as defined by xml, | |
226 " but not all xml pages actually conform to it. Errors are flagged. | |
227 syn region xmlComment | |
228 \ start=+<!+ | |
229 \ end=+>+ | |
2034 | 230 \ contains=xmlCommentStart,xmlCommentError |
7 | 231 \ extend |
232 \ fold | |
233 | |
234 else | |
235 | |
236 " no syntax folding: | |
237 " - fold attribute removed | |
238 " | |
239 syn region xmlComment | |
240 \ start=+<!+ | |
241 \ end=+>+ | |
2034 | 242 \ contains=xmlCommentStart,xmlCommentError |
7 | 243 \ extend |
244 | |
245 endif | |
246 | |
2034 | 247 syn match xmlCommentStart contained "<!" nextgroup=xmlCommentPart |
236 | 248 syn keyword xmlTodo contained TODO FIXME XXX |
7 | 249 syn match xmlCommentError contained "[^><!]" |
250 syn region xmlCommentPart | |
251 \ start=+--+ | |
252 \ end=+--+ | |
253 \ contained | |
826 | 254 \ contains=xmlTodo,@xmlCommentHook,@Spell |
7 | 255 |
256 | |
257 " CData sections | |
258 " | |
259 " PROVIDES: @xmlCdataHook | |
260 " | |
261 syn region xmlCdata | |
262 \ start=+<!\[CDATA\[+ | |
263 \ end=+]]>+ | |
826 | 264 \ contains=xmlCdataStart,xmlCdataEnd,@xmlCdataHook,@Spell |
7 | 265 \ keepend |
266 \ extend | |
267 | |
268 " using the following line instead leads to corrupt folding at CDATA regions | |
269 " syn match xmlCdata +<!\[CDATA\[\_.\{-}]]>+ contains=xmlCdataStart,xmlCdataEnd,@xmlCdataHook | |
270 syn match xmlCdataStart +<!\[CDATA\[+ contained contains=xmlCdataCdata | |
271 syn keyword xmlCdataCdata CDATA contained | |
272 syn match xmlCdataEnd +]]>+ contained | |
273 | |
274 | |
275 " Processing instructions | |
276 " This allows "?>" inside strings -- good idea? | |
277 syn region xmlProcessing matchgroup=xmlProcessingDelim start="<?" end="?>" contains=xmlAttrib,xmlEqual,xmlString | |
278 | |
279 | |
280 if exists('g:xml_syntax_folding') | |
281 | |
282 " DTD -- we use dtd.vim here | |
283 syn region xmlDocType matchgroup=xmlDocTypeDecl | |
284 \ start="<!DOCTYPE"he=s+2,rs=s+2 end=">" | |
285 \ fold | |
286 \ contains=xmlDocTypeKeyword,xmlInlineDTD,xmlString | |
287 else | |
288 | |
289 " no syntax folding: | |
290 " - fold attribute removed | |
291 " | |
292 syn region xmlDocType matchgroup=xmlDocTypeDecl | |
293 \ start="<!DOCTYPE"he=s+2,rs=s+2 end=">" | |
294 \ contains=xmlDocTypeKeyword,xmlInlineDTD,xmlString | |
295 | |
296 endif | |
297 | |
298 syn keyword xmlDocTypeKeyword contained DOCTYPE PUBLIC SYSTEM | |
299 syn region xmlInlineDTD contained matchgroup=xmlDocTypeDecl start="\[" end="]" contains=@xmlDTD | |
300 syn include @xmlDTD <sfile>:p:h/dtd.vim | |
301 unlet b:current_syntax | |
302 | |
303 | |
304 " synchronizing | |
305 " TODO !!! to be improved !!! | |
306 | |
307 syn sync match xmlSyncDT grouphere xmlDocType +\_.\(<!DOCTYPE\)\@=+ | |
308 " syn sync match xmlSyncDT groupthere NONE +]>+ | |
309 | |
310 if exists('g:xml_syntax_folding') | |
311 syn sync match xmlSync grouphere xmlRegion +\_.\(<[^ /!?<>"']\+\)\@=+ | |
312 " syn sync match xmlSync grouphere xmlRegion "<[^ /!?<>"']*>" | |
313 syn sync match xmlSync groupthere xmlRegion +</[^ /!?<>"']\+>+ | |
314 endif | |
315 | |
316 syn sync minlines=100 | |
317 | |
318 | |
319 " The default highlighting. | |
320 hi def link xmlTodo Todo | |
321 hi def link xmlTag Function | |
322 hi def link xmlTagName Function | |
323 hi def link xmlEndTag Identifier | |
324 if !exists("g:xml_namespace_transparent") | |
325 hi def link xmlNamespace Tag | |
326 endif | |
327 hi def link xmlEntity Statement | |
328 hi def link xmlEntityPunct Type | |
329 | |
330 hi def link xmlAttribPunct Comment | |
331 hi def link xmlAttrib Type | |
332 | |
333 hi def link xmlString String | |
334 hi def link xmlComment Comment | |
2034 | 335 hi def link xmlCommentStart xmlComment |
7 | 336 hi def link xmlCommentPart Comment |
337 hi def link xmlCommentError Error | |
338 hi def link xmlError Error | |
339 | |
340 hi def link xmlProcessingDelim Comment | |
341 hi def link xmlProcessing Type | |
342 | |
343 hi def link xmlCdata String | |
344 hi def link xmlCdataCdata Statement | |
345 hi def link xmlCdataStart Type | |
346 hi def link xmlCdataEnd Type | |
347 | |
348 hi def link xmlDocTypeDecl Function | |
349 hi def link xmlDocTypeKeyword Statement | |
350 hi def link xmlInlineDTD Function | |
351 | |
352 let b:current_syntax = "xml" | |
353 | |
354 let &cpo = s:xml_cpo_save | |
355 unlet s:xml_cpo_save | |
356 | |
357 " vim: ts=8 |