523
|
1 " Vim completion script
|
|
2 " Language: XHTML 1.0 Strict
|
|
3 " Maintainer: Mikolaj Machowski ( mikmach AT wp DOT pl )
|
557
|
4 " Last Change: 2005 Now 20
|
523
|
5
|
|
6 function! htmlcomplete#CompleteTags(findstart, base)
|
|
7 if a:findstart
|
|
8 " locate the start of the word
|
|
9 let line = getline('.')
|
|
10 let start = col('.') - 1
|
548
|
11 let compl_begin = col('.') - 2
|
|
12 while start >= 0 && line[start - 1] =~ '\(\k\|[:.-]\)'
|
|
13 let start -= 1
|
523
|
14 endwhile
|
548
|
15 if start >= 0 && line[start - 1] =~ '&'
|
|
16 let b:entitiescompl = 1
|
|
17 let b:compl_context = ''
|
|
18 return start
|
|
19 endif
|
|
20 let stylestart = searchpair('<style\>', '', '<\/style\>', "bnW")
|
|
21 let styleend = searchpair('<style\>', '', '<\/style\>', "nW")
|
|
22 if stylestart != 0 && styleend != 0
|
531
|
23 let curpos = line('.')
|
548
|
24 if stylestart <= curpos && styleend >= curpos
|
|
25 let start = col('.') - 1
|
|
26 let b:csscompl = 1
|
|
27 while start >= 0 && line[start - 1] =~ '\(\k\|-\)'
|
|
28 let start -= 1
|
|
29 endwhile
|
531
|
30 endif
|
|
31 endif
|
548
|
32 if !exists("b:csscompl")
|
|
33 let b:compl_context = getline('.')[0:(compl_begin)]
|
|
34 let b:compl_context = matchstr(b:compl_context, '.*<\zs.*')
|
|
35 else
|
|
36 let b:compl_context = getline('.')[0:compl_begin]
|
|
37 endif
|
523
|
38 return start
|
|
39 else
|
548
|
40 " Initialize base return lists
|
|
41 let res = []
|
|
42 let res2 = []
|
|
43 " a:base is very short - we need context
|
|
44 let context = b:compl_context
|
|
45 unlet! b:compl_context
|
531
|
46 " Check if we should do CSS completion inside of <style> tag
|
|
47 if exists("b:csscompl")
|
|
48 unlet! b:csscompl
|
548
|
49 return csscomplete#CompleteCSS(0, context)
|
531
|
50 endif
|
548
|
51 " Make entities completion
|
|
52 if exists("b:entitiescompl")
|
|
53 unlet! b:entitiescompl
|
|
54
|
557
|
55 if !exists("g:xmldata_xhtml10s")
|
|
56 runtime! autoload/xml/xhtml10s.vim
|
|
57 endif
|
548
|
58
|
557
|
59 let entities = g:xmldata_xhtml10s['vimxmlentities']
|
|
60
|
|
61 for m in entities
|
553
|
62 if m =~ '^'.a:base
|
548
|
63 call add(res, m.';')
|
|
64 endif
|
|
65 endfor
|
|
66
|
553
|
67 return res
|
548
|
68
|
|
69 endif
|
|
70 if context =~ '>'
|
|
71 " Generally if context contains > it means we are outside of tag and
|
531
|
72 " should abandon action - with one exception: <style> span { bo
|
548
|
73 if context =~ 'style[^>]\{-}>[^<]\{-}$'
|
|
74 return csscomplete#CompleteCSS(0, context)
|
531
|
75 else
|
|
76 return []
|
|
77 endif
|
|
78 endif
|
|
79
|
523
|
80 " Set attribute groups
|
531
|
81 let coreattrs = ["id", "class", "style", "title"]
|
|
82 let i18n = ["lang", "xml:lang", "dir=\"ltr\" ", "dir=\"rtl\" "]
|
|
83 let events = ["onclick", "ondblclick", "onmousedown", "onmouseup", "onmousemove",
|
548
|
84 \ "onmouseover", "onmouseout", "onkeypress", "onkeydown", "onkeyup"]
|
531
|
85 let focus = ["accesskey", "tabindex", "onfocus", "onblur"]
|
|
86 let coregroup = coreattrs + i18n + events
|
548
|
87 " find tags matching with "context"
|
|
88 " If context contains > it means we are already outside of tag and we
|
523
|
89 " should abandon action
|
548
|
90 " If context contains white space it is attribute.
|
523
|
91 " It could be also value of attribute...
|
531
|
92 " We have to get first word to offer
|
|
93 " proper completions
|
548
|
94 if context == ''
|
|
95 let tag = ''
|
|
96 else
|
|
97 let tag = split(context)[0]
|
|
98 endif
|
531
|
99 " Get last word, it should be attr name
|
548
|
100 let attr = matchstr(context, '.*\s\zs.*')
|
523
|
101 " Possible situations where any prediction would be difficult:
|
|
102 " 1. Events attributes
|
548
|
103 if context =~ '\s'
|
523
|
104 " Sort out style, class, and on* cases
|
548
|
105 if context =~ "\\(on[a-z]*\\|id\\|style\\|class\\)\\s*=\\s*[\"']"
|
|
106 if context =~ "\\(id\\|class\\)\\s*=\\s*[\"'][a-zA-Z0-9_ -]*$"
|
|
107 if context =~ "class\\s*=\\s*[\"'][a-zA-Z0-9_ -]*$"
|
532
|
108 let search_for = "class"
|
548
|
109 elseif context =~ "id\\s*=\\s*[\"'][a-zA-Z0-9_ -]*$"
|
532
|
110 let search_for = "id"
|
|
111 endif
|
531
|
112 " Handle class name completion
|
|
113 " 1. Find lines of <link stylesheet>
|
|
114 " 1a. Check file for @import
|
|
115 " 2. Extract filename(s?) of stylesheet,
|
|
116 call cursor(1,1)
|
|
117 let head = getline(search('<head\>'), search('<\/head>'))
|
|
118 let headjoined = join(copy(head), ' ')
|
|
119 if headjoined =~ '<style'
|
557
|
120 " Remove possibly confusing CSS operators
|
532
|
121 let stylehead = substitute(headjoined, '+>\*[,', ' ', 'g')
|
|
122 if search_for == 'class'
|
|
123 let styleheadlines = split(stylehead)
|
|
124 let headclasslines = filter(copy(styleheadlines), "v:val =~ '\\([a-zA-Z0-9:]\\+\\)\\?\\.[a-zA-Z0-9_-]\\+'")
|
|
125 else
|
|
126 let stylesheet = split(headjoined, '[{}]')
|
|
127 " Get all lines which fit id syntax
|
|
128 let classlines = filter(copy(stylesheet), "v:val =~ '#[a-zA-Z0-9_-]\\+'")
|
|
129 " Filter out possible color definitions
|
|
130 call filter(classlines, "v:val !~ ':\\s*#[a-zA-Z0-9_-]\\+'")
|
|
131 " Filter out complex border definitions
|
|
132 call filter(classlines, "v:val !~ '\\(none\\|hidden\\|dotted\\|dashed\\|solid\\|double\\|groove\\|ridge\\|inset\\|outset\\)\\s*#[a-zA-Z0-9_-]\\+'")
|
|
133 let templines = join(classlines, ' ')
|
|
134 let headclasslines = split(templines)
|
|
135 call filter(headclasslines, "v:val =~ '#[a-zA-Z0-9_-]\\+'")
|
|
136 endif
|
531
|
137 let internal = 1
|
|
138 else
|
|
139 let internal = 0
|
|
140 endif
|
|
141 let styletable = []
|
|
142 let secimportfiles = []
|
|
143 let filestable = filter(copy(head), "v:val =~ '\\(@import\\|link.*stylesheet\\)'")
|
|
144 for line in filestable
|
|
145 if line =~ "@import"
|
|
146 let styletable += [matchstr(line, "import\\s\\+\\(url(\\)\\?[\"']\\?\\zs\\f\\+\\ze")]
|
|
147 elseif line =~ "<link"
|
|
148 let styletable += [matchstr(line, "href\\s*=\\s*[\"']\\zs\\f\\+\\ze")]
|
|
149 endif
|
|
150 endfor
|
532
|
151 for file in styletable
|
531
|
152 if filereadable(file)
|
|
153 let stylesheet = readfile(file)
|
|
154 let secimport = filter(copy(stylesheet), "v:val =~ '@import'")
|
|
155 if len(secimport) > 0
|
|
156 for line in secimport
|
532
|
157 let secfile = matchstr(line, "import\\s\\+\\(url(\\)\\?[\"']\\?\\zs\\f\\+\\ze")
|
|
158 let secfile = fnamemodify(file, ":p:h").'/'.secfile
|
|
159 let secimportfiles += [secfile]
|
531
|
160 endfor
|
|
161 endif
|
|
162 endif
|
|
163 endfor
|
|
164 let cssfiles = styletable + secimportfiles
|
|
165 let classes = []
|
|
166 for file in cssfiles
|
|
167 if filereadable(file)
|
|
168 let stylesheet = readfile(file)
|
532
|
169 let stylefile = join(stylesheet, ' ')
|
|
170 let stylefile = substitute(stylefile, '+>\*[,', ' ', 'g')
|
|
171 if search_for == 'class'
|
|
172 let stylesheet = split(stylefile)
|
|
173 let classlines = filter(copy(stylesheet), "v:val =~ '\\([a-zA-Z0-9:]\\+\\)\\?\\.[a-zA-Z0-9_-]\\+'")
|
|
174 else
|
|
175 let stylesheet = split(stylefile, '[{}]')
|
|
176 " Get all lines which fit id syntax
|
|
177 let classlines = filter(copy(stylesheet), "v:val =~ '#[a-zA-Z0-9_-]\\+'")
|
|
178 " Filter out possible color definitions
|
|
179 call filter(classlines, "v:val !~ ':\\s*#[a-zA-Z0-9_-]\\+'")
|
|
180 " Filter out complex border definitions
|
|
181 call filter(classlines, "v:val !~ '\\(none\\|hidden\\|dotted\\|dashed\\|solid\\|double\\|groove\\|ridge\\|inset\\|outset\\)\\s*#[a-zA-Z0-9_-]\\+'")
|
|
182 let templines = join(classlines, ' ')
|
|
183 let stylelines = split(templines)
|
|
184 let classlines = filter(stylelines, "v:val =~ '#[a-zA-Z0-9_-]\\+'")
|
|
185
|
|
186 endif
|
531
|
187 endif
|
|
188 " We gathered classes definitions from all external files
|
|
189 let classes += classlines
|
|
190 endfor
|
|
191 if internal == 1
|
|
192 let classes += headclasslines
|
|
193 endif
|
532
|
194
|
|
195 if search_for == 'class'
|
|
196 let elements = {}
|
|
197 for element in classes
|
|
198 if element =~ '^\.'
|
|
199 let class = matchstr(element, '^\.\zs[a-zA-Z][a-zA-Z0-9_-]*\ze')
|
|
200 let class = substitute(class, ':.*', '', '')
|
|
201 if has_key(elements, 'common')
|
|
202 let elements['common'] .= ' '.class
|
|
203 else
|
|
204 let elements['common'] = class
|
|
205 endif
|
531
|
206 else
|
532
|
207 let class = matchstr(element, '[a-zA-Z1-6]*\.\zs[a-zA-Z][a-zA-Z0-9_-]*\ze')
|
|
208 let tagname = tolower(matchstr(element, '[a-zA-Z1-6]*\ze.'))
|
|
209 if tagname != ''
|
|
210 if has_key(elements, tagname)
|
|
211 let elements[tagname] .= ' '.class
|
|
212 else
|
|
213 let elements[tagname] = class
|
|
214 endif
|
531
|
215 endif
|
|
216 endif
|
532
|
217 endfor
|
|
218
|
|
219 if has_key(elements, tag) && has_key(elements, 'common')
|
|
220 let values = split(elements[tag]." ".elements['common'])
|
|
221 elseif has_key(elements, tag) && !has_key(elements, 'common')
|
|
222 let values = split(elements[tag])
|
|
223 elseif !has_key(elements, tag) && has_key(elements, 'common')
|
|
224 let values = split(elements['common'])
|
|
225 else
|
|
226 return []
|
531
|
227 endif
|
|
228
|
532
|
229 elseif search_for == 'id'
|
|
230 " Find used IDs
|
|
231 " 1. Catch whole file
|
|
232 let filelines = getline(1, line('$'))
|
|
233 " 2. Find lines with possible id
|
|
234 let used_id_lines = filter(filelines, 'v:val =~ "id\\s*=\\s*[\"''][a-zA-Z0-9_-]\\+"')
|
|
235 " 3a. Join all filtered lines
|
|
236 let id_string = join(used_id_lines, ' ')
|
|
237 " 3b. And split them to be sure each id is in separate item
|
|
238 let id_list = split(id_string, 'id\s*=\s*')
|
|
239 " 4. Extract id values
|
|
240 let used_id = map(id_list, 'matchstr(v:val, "[\"'']\\zs[a-zA-Z0-9_-]\\+\\ze")')
|
|
241 let joined_used_id = ','.join(used_id, ',').','
|
|
242
|
|
243 let allvalues = map(classes, 'matchstr(v:val, ".*#\\zs[a-zA-Z0-9_-]\\+")')
|
|
244
|
|
245 let values = []
|
|
246
|
|
247 for element in classes
|
|
248 if joined_used_id !~ ','.element.','
|
|
249 let values += [element]
|
|
250 endif
|
|
251
|
|
252 endfor
|
|
253
|
531
|
254 endif
|
|
255
|
|
256 " We need special version of sbase
|
548
|
257 let classbase = matchstr(context, ".*[\"']")
|
532
|
258 let classquote = matchstr(classbase, '.$')
|
531
|
259
|
|
260 let entered_class = matchstr(attr, ".*=\\s*[\"']\\zs.*")
|
|
261
|
|
262 for m in sort(values)
|
|
263 if m =~? '^'.entered_class
|
548
|
264 call add(res, m . classquote)
|
531
|
265 elseif m =~? entered_class
|
548
|
266 call add(res2, m . classquote)
|
531
|
267 endif
|
|
268 endfor
|
|
269
|
|
270 return res + res2
|
|
271
|
548
|
272 elseif context =~ "style\\s*=\\s*[\"'][^\"']*$"
|
|
273 return csscomplete#CompleteCSS(0, context)
|
531
|
274
|
|
275 endif
|
548
|
276 let stripbase = matchstr(context, ".*\\(on[a-z]*\\|style\\|class\\)\\s*=\\s*[\"']\\zs.*")
|
|
277 " Now we have context stripped from all chars up to style/class.
|
523
|
278 " It may fail with some strange style value combinations.
|
|
279 if stripbase !~ "[\"']"
|
|
280 return []
|
|
281 endif
|
|
282 endif
|
|
283 " If attr contains =\s*[\"'] we catched value of attribute
|
|
284 if attr =~ "=\s*[\"']"
|
|
285 " Let do attribute specific completion
|
|
286 let attrname = matchstr(attr, '.*\ze\s*=')
|
|
287 let entered_value = matchstr(attr, ".*=\\s*[\"']\\zs.*")
|
|
288 let values = []
|
|
289 if attrname == 'media'
|
|
290 let values = ["screen", "tty", "tv", "projection", "handheld", "print", "braille", "aural", "all"]
|
|
291 elseif attrname == 'xml:space'
|
|
292 let values = ["preserve"]
|
|
293 elseif attrname == 'shape'
|
553
|
294 let values = ["rect", "circle", "poly", "default"]
|
523
|
295 elseif attrname == 'valuetype'
|
|
296 let values = ["data", "ref", "object"]
|
|
297 elseif attrname == 'method'
|
|
298 let values = ["get", "post"]
|
525
|
299 elseif attrname == 'dir'
|
|
300 let values = ["ltr", "rtl"]
|
523
|
301 elseif attrname == 'frame'
|
|
302 let values = ["void", "above", "below", "hsides", "lhs", "rhs", "vsides", "box", "border"]
|
|
303 elseif attrname == 'rules'
|
|
304 let values = ["none", "groups", "rows", "all"]
|
|
305 elseif attrname == 'align'
|
|
306 let values = ["left", "center", "right", "justify", "char"]
|
|
307 elseif attrname == 'valign'
|
|
308 let values = ["top", "middle", "bottom", "baseline"]
|
|
309 elseif attrname == 'scope'
|
|
310 let values = ["row", "col", "rowgroup", "colgroup"]
|
|
311 elseif attrname == 'href'
|
|
312 " Now we are looking for local anchors defined by name or id
|
|
313 if entered_value =~ '^#'
|
|
314 let file = join(getline(1, line('$')), ' ')
|
|
315 " Split it be sure there will be one id/name element in
|
|
316 " item, it will be also first word [a-zA-Z0-9_-] in element
|
|
317 let oneelement = split(file, "\\(meta \\)\\@<!\\(name\\|id\\)\\s*=\\s*[\"']")
|
|
318 for i in oneelement
|
|
319 let values += ['#'.matchstr(i, "^[a-zA-Z][a-zA-Z0-9%_-]*")]
|
|
320 endfor
|
|
321 endif
|
|
322 elseif attrname == 'type'
|
548
|
323 if context =~ '^input'
|
531
|
324 let values = ["text", "password", "checkbox", "radio", "submit", "reset", "file", "hidden", "image", "button"]
|
548
|
325 elseif context =~ '^button'
|
523
|
326 let values = ["button", "submit", "reset"]
|
548
|
327 elseif context =~ '^style'
|
532
|
328 let values = ["text/css"]
|
548
|
329 elseif context =~ '^script'
|
532
|
330 let values = ["text/javascript"]
|
523
|
331 endif
|
|
332 else
|
|
333 return []
|
|
334 endif
|
|
335
|
|
336 if len(values) == 0
|
|
337 return []
|
|
338 endif
|
|
339
|
|
340 " We need special version of sbase
|
548
|
341 let attrbase = matchstr(context, ".*[\"']")
|
531
|
342 let attrquote = matchstr(attrbase, '.$')
|
523
|
343
|
|
344 for m in values
|
531
|
345 " This if is needed to not offer all completions as-is
|
|
346 " alphabetically but sort them. Those beginning with entered
|
|
347 " part will be as first choices
|
|
348 if m =~ '^'.entered_value
|
548
|
349 call add(res, m . attrquote.' ')
|
531
|
350 elseif m =~ entered_value
|
548
|
351 call add(res2, m . attrquote.' ')
|
523
|
352 endif
|
|
353 endfor
|
531
|
354
|
|
355 return res + res2
|
|
356
|
523
|
357 endif
|
548
|
358 " Shorten context to not include last word
|
|
359 let sbase = matchstr(context, '.*\ze\s.*')
|
|
360 if tag =~ '^\(abbr\|acronym\|address\|b\|bdo\|big\|caption\|cite\|code\|dd\|dfn\|div\|dl\|dt\|em\|fieldset\|h\d\|hr\|i\|kbd\|li\|noscript\|ol\|p\|samp\|small\|span\|strong\|sub\|sup\|tt\|ul\|var\)$'
|
531
|
361 let attrs = coregroup
|
523
|
362 elseif tag == 'a'
|
531
|
363 let attrs = coregroup + focus + ["charset", "type", "name", "href", "hreflang", "rel", "rev", "shape", "coords"]
|
523
|
364 elseif tag == 'area'
|
548
|
365 let attrs = coregroup + focus + ["shape", "coords", "href", "nohref", "alt"]
|
523
|
366 elseif tag == 'base'
|
|
367 let attrs = ["href", "id"]
|
|
368 elseif tag == 'blockquote'
|
531
|
369 let attrs = coregroup + ["cite"]
|
523
|
370 elseif tag == 'body'
|
531
|
371 let attrs = coregroup + ["onload", "onunload"]
|
523
|
372 elseif tag == 'br'
|
531
|
373 let attrs = coreattrs
|
523
|
374 elseif tag == 'button'
|
548
|
375 let attrs = coregroup + focus + ["name", "value", "type"]
|
523
|
376 elseif tag == '^\(col\|colgroup\)$'
|
548
|
377 let attrs = coregroup + ["span", "width", "align", "char", "charoff", "valign"]
|
523
|
378 elseif tag =~ '^\(del\|ins\)$'
|
548
|
379 let attrs = coregroup + ["cite", "datetime"]
|
523
|
380 elseif tag == 'form'
|
548
|
381 let attrs = coregroup + ["action", "method=\"get\" ", "method=\"post\" ", "enctype", "onsubmit", "onreset", "accept", "accept-charset"]
|
523
|
382 elseif tag == 'head'
|
531
|
383 let attrs = i18n + ["id", "profile"]
|
523
|
384 elseif tag == 'html'
|
531
|
385 let attrs = i18n + ["id", "xmlns"]
|
523
|
386 elseif tag == 'img'
|
548
|
387 let attrs = coregroup + ["src", "alt", "longdesc", "height", "width", "usemap", "ismap"]
|
523
|
388 elseif tag == 'input'
|
548
|
389 let attrs = coregroup + ["type", "name", "value", "checked", "disabled", "readonly", "size", "maxlength", "src", "alt", "usemap", "onselect", "onchange", "accept"]
|
523
|
390 elseif tag == 'label'
|
548
|
391 let attrs = coregroup + ["for", "accesskey", "onfocus", "onblur"]
|
523
|
392 elseif tag == 'legend'
|
548
|
393 let attrs = coregroup + ["accesskey"]
|
523
|
394 elseif tag == 'link'
|
548
|
395 let attrs = coregroup + ["charset", "href", "hreflang", "type", "rel", "rev", "media"]
|
523
|
396 elseif tag == 'map'
|
531
|
397 let attrs = i18n + events + ["id", "class", "style", "title", "name"]
|
523
|
398 elseif tag == 'meta'
|
531
|
399 let attrs = i18n + ["id", "http-equiv", "content", "scheme", "name"]
|
523
|
400 elseif tag == 'title'
|
531
|
401 let attrs = i18n + ["id"]
|
523
|
402 elseif tag == 'object'
|
548
|
403 let attrs = coregroup + ["declare", "classid", "codebase", "data", "type", "codetype", "archive", "standby", "height", "width", "usemap", "name", "tabindex"]
|
523
|
404 elseif tag == 'optgroup'
|
548
|
405 let attrs = coregroup + ["disbled", "label"]
|
523
|
406 elseif tag == 'option'
|
548
|
407 let attrs = coregroup + ["disbled", "selected", "value", "label"]
|
523
|
408 elseif tag == 'param'
|
|
409 let attrs = ["id", "name", "value", "valuetype", "type"]
|
|
410 elseif tag == 'pre'
|
548
|
411 let attrs = coregroup + ["xml:space"]
|
523
|
412 elseif tag == 'q'
|
548
|
413 let attrs = coregroup + ["cite"]
|
523
|
414 elseif tag == 'script'
|
532
|
415 let attrs = ["id", "charset", "type=\"text/javascript\"", "type", "src", "defer", "xml:space"]
|
523
|
416 elseif tag == 'select'
|
548
|
417 let attrs = coregroup + ["name", "size", "multiple", "disabled", "tabindex", "onfocus", "onblur", "onchange"]
|
523
|
418 elseif tag == 'style'
|
532
|
419 let attrs = coreattrs + ["id", "type=\"text/css\"", "type", "media", "title", "xml:space"]
|
523
|
420 elseif tag == 'table'
|
548
|
421 let attrs = coregroup + ["summary", "width", "border", "frame", "rules", "cellspacing", "cellpadding"]
|
523
|
422 elseif tag =~ '^\(thead\|tfoot\|tbody\|tr\)$'
|
548
|
423 let attrs = coregroup + ["align", "char", "charoff", "valign"]
|
523
|
424 elseif tag == 'textarea'
|
548
|
425 let attrs = coregroup + ["name", "rows", "cols", "disabled", "readonly", "onselect", "onchange"]
|
523
|
426 elseif tag =~ '^\(th\|td\)$'
|
548
|
427 let attrs = coregroup + ["abbr", "headers", "scope", "rowspan", "colspan", "align", "char", "charoff", "valign"]
|
531
|
428 else
|
|
429 return []
|
523
|
430 endif
|
|
431
|
|
432 for m in sort(attrs)
|
531
|
433 if m =~ '^'.attr
|
|
434 if m =~ '^\(ismap\|defer\|declare\|nohref\|checked\|disabled\|selected\|readonly\)$' || m =~ '='
|
548
|
435 call add(res, m)
|
523
|
436 else
|
548
|
437 call add(res, m.'="')
|
523
|
438 endif
|
531
|
439 elseif m =~ attr
|
|
440 if m =~ '^\(ismap\|defer\|declare\|nohref\|checked\|disabled\|selected\|readonly\)$' || m =~ '='
|
548
|
441 call add(res2, m)
|
531
|
442 else
|
548
|
443 call add(res2, m.'="')
|
531
|
444 endif
|
523
|
445 endif
|
|
446 endfor
|
531
|
447
|
|
448 return res + res2
|
|
449
|
523
|
450 endif
|
525
|
451 " Close tag
|
529
|
452 let b:unaryTagsStack = "base meta link hr br param img area input col"
|
548
|
453 if context =~ '^\/'
|
557
|
454 let opentag = xmlcomplete#GetLastOpenTag("b:unaryTagsStack")
|
548
|
455 return [opentag.">"]
|
525
|
456 endif
|
|
457 " Deal with tag completion.
|
557
|
458 let opentag = xmlcomplete#GetLastOpenTag("b:unaryTagsStack")
|
525
|
459
|
557
|
460 if !exists("g:xmldata_xhtml10s")
|
|
461 runtime! autoload/xml/xhtml10s.vim
|
525
|
462 endif
|
|
463
|
557
|
464 let tags = g:xmldata_xhtml10s[opentag][0]
|
|
465
|
573
|
466 for m in sort(tags)
|
548
|
467 if m =~ '^'.context
|
523
|
468 call add(res, m)
|
548
|
469 elseif m =~ context
|
531
|
470 call add(res2, m)
|
523
|
471 endif
|
529
|
472 endfor
|
|
473
|
531
|
474 return res + res2
|
529
|
475
|
523
|
476 endif
|
|
477 endfunction
|