annotate runtime/autoload/htmlcomplete.vim @ 18912:ccd16426a1f9 v8.2.0017

patch 8.2.0017: OS/2 and MS-DOS are still mentioned Commit: https://github.com/vim/vim/commit/6f345a1458df2db03fba7863492404e9dc8b817c Author: Bram Moolenaar <Bram@vim.org> Date: Tue Dec 17 21:27:18 2019 +0100 patch 8.2.0017: OS/2 and MS-DOS are still mentioned Problem: OS/2 and MS-DOS are still mentioned, even though support was removed long ago. Solution: Update documentation. (Yegappan Lakshmanan, closes #5368)
author Bram Moolenaar <Bram@vim.org>
date Tue, 17 Dec 2019 21:30:04 +0100
parents 03b854983b14
children 11b656e74444
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
523
a7ae7e043e43 updated for version 7.0146
vimboss
parents:
diff changeset
1 " Vim completion script
838
8e5830943bff updated for version 7.0e04
vimboss
parents: 837
diff changeset
2 " Language: HTML and XHTML
523
a7ae7e043e43 updated for version 7.0146
vimboss
parents:
diff changeset
3 " Maintainer: Mikolaj Machowski ( mikmach AT wp DOT pl )
18186
03b854983b14 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 6009
diff changeset
4 " Last Change: 2019 Sep 27
6009
7b83c190d370 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2788
diff changeset
5
7b83c190d370 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2788
diff changeset
6 " Distinguish between HTML versions.
7b83c190d370 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2788
diff changeset
7 " To use with other HTML versions add another "elseif" condition to match
7b83c190d370 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2788
diff changeset
8 " proper DOCTYPE.
7b83c190d370 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2788
diff changeset
9 function! htmlcomplete#DetectOmniFlavor()
7b83c190d370 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2788
diff changeset
10 if &filetype == 'xhtml'
7b83c190d370 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2788
diff changeset
11 let b:html_omni_flavor = 'xhtml10s'
7b83c190d370 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2788
diff changeset
12 else
7b83c190d370 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2788
diff changeset
13 let b:html_omni_flavor = 'html401t'
7b83c190d370 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2788
diff changeset
14 endif
7b83c190d370 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2788
diff changeset
15 let i = 1
7b83c190d370 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2788
diff changeset
16 let line = ""
7b83c190d370 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2788
diff changeset
17 while i < 10 && i < line("$")
7b83c190d370 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2788
diff changeset
18 let line = getline(i)
7b83c190d370 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2788
diff changeset
19 if line =~ '<!DOCTYPE.*\<DTD '
7b83c190d370 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2788
diff changeset
20 break
7b83c190d370 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2788
diff changeset
21 endif
7b83c190d370 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2788
diff changeset
22 let i += 1
7b83c190d370 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2788
diff changeset
23 endwhile
7b83c190d370 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2788
diff changeset
24 if line =~ '<!DOCTYPE.*\<DTD ' " doctype line found above
7b83c190d370 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2788
diff changeset
25 if line =~ ' HTML 3\.2'
7b83c190d370 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2788
diff changeset
26 let b:html_omni_flavor = 'html32'
7b83c190d370 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2788
diff changeset
27 elseif line =~ ' XHTML 1\.1'
7b83c190d370 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2788
diff changeset
28 let b:html_omni_flavor = 'xhtml11'
7b83c190d370 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2788
diff changeset
29 else " two-step detection with strict/frameset/transitional
7b83c190d370 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2788
diff changeset
30 if line =~ ' XHTML 1\.0'
7b83c190d370 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2788
diff changeset
31 let b:html_omni_flavor = 'xhtml10'
7b83c190d370 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2788
diff changeset
32 elseif line =~ ' HTML 4\.01'
7b83c190d370 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2788
diff changeset
33 let b:html_omni_flavor = 'html401'
7b83c190d370 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2788
diff changeset
34 elseif line =~ ' HTML 4.0\>'
7b83c190d370 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2788
diff changeset
35 let b:html_omni_flavor = 'html40'
7b83c190d370 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2788
diff changeset
36 endif
7b83c190d370 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2788
diff changeset
37 if line =~ '\<Transitional\>'
7b83c190d370 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2788
diff changeset
38 let b:html_omni_flavor .= 't'
7b83c190d370 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2788
diff changeset
39 elseif line =~ '\<Frameset\>'
7b83c190d370 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2788
diff changeset
40 let b:html_omni_flavor .= 'f'
7b83c190d370 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2788
diff changeset
41 else
7b83c190d370 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2788
diff changeset
42 let b:html_omni_flavor .= 's'
7b83c190d370 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2788
diff changeset
43 endif
7b83c190d370 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2788
diff changeset
44 endif
7b83c190d370 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2788
diff changeset
45 endif
7b83c190d370 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2788
diff changeset
46 endfunction
523
a7ae7e043e43 updated for version 7.0146
vimboss
parents:
diff changeset
47
a7ae7e043e43 updated for version 7.0146
vimboss
parents:
diff changeset
48 function! htmlcomplete#CompleteTags(findstart, base)
a7ae7e043e43 updated for version 7.0146
vimboss
parents:
diff changeset
49 if a:findstart
a7ae7e043e43 updated for version 7.0146
vimboss
parents:
diff changeset
50 " locate the start of the word
a7ae7e043e43 updated for version 7.0146
vimboss
parents:
diff changeset
51 let line = getline('.')
a7ae7e043e43 updated for version 7.0146
vimboss
parents:
diff changeset
52 let start = col('.') - 1
643
d3c978b4c7ce updated for version 7.0187
vimboss
parents: 641
diff changeset
53 let curline = line('.')
548
f43150a669dc updated for version 7.0155
vimboss
parents: 532
diff changeset
54 let compl_begin = col('.') - 2
841
c2cae213194d updated for version 7.0e07
vimboss
parents: 838
diff changeset
55 while start >= 0 && line[start - 1] =~ '\(\k\|[!:.-]\)'
548
f43150a669dc updated for version 7.0155
vimboss
parents: 532
diff changeset
56 let start -= 1
523
a7ae7e043e43 updated for version 7.0146
vimboss
parents:
diff changeset
57 endwhile
659
d6a69271cb9a updated for version 7.0194
vimboss
parents: 649
diff changeset
58 " Handling of entities {{{
548
f43150a669dc updated for version 7.0155
vimboss
parents: 532
diff changeset
59 if start >= 0 && line[start - 1] =~ '&'
f43150a669dc updated for version 7.0155
vimboss
parents: 532
diff changeset
60 let b:entitiescompl = 1
f43150a669dc updated for version 7.0155
vimboss
parents: 532
diff changeset
61 let b:compl_context = ''
f43150a669dc updated for version 7.0155
vimboss
parents: 532
diff changeset
62 return start
f43150a669dc updated for version 7.0155
vimboss
parents: 532
diff changeset
63 endif
659
d6a69271cb9a updated for version 7.0194
vimboss
parents: 649
diff changeset
64 " }}}
d6a69271cb9a updated for version 7.0194
vimboss
parents: 649
diff changeset
65 " Handling of <style> tag {{{
548
f43150a669dc updated for version 7.0155
vimboss
parents: 532
diff changeset
66 let stylestart = searchpair('<style\>', '', '<\/style\>', "bnW")
f43150a669dc updated for version 7.0155
vimboss
parents: 532
diff changeset
67 let styleend = searchpair('<style\>', '', '<\/style\>', "nW")
856
8cd729851562 updated for version 7.0g
vimboss
parents: 844
diff changeset
68 if stylestart != 0 && styleend != 0
643
d3c978b4c7ce updated for version 7.0187
vimboss
parents: 641
diff changeset
69 if stylestart <= curline && styleend >= curline
548
f43150a669dc updated for version 7.0155
vimboss
parents: 532
diff changeset
70 let start = col('.') - 1
f43150a669dc updated for version 7.0155
vimboss
parents: 532
diff changeset
71 let b:csscompl = 1
f43150a669dc updated for version 7.0155
vimboss
parents: 532
diff changeset
72 while start >= 0 && line[start - 1] =~ '\(\k\|-\)'
f43150a669dc updated for version 7.0155
vimboss
parents: 532
diff changeset
73 let start -= 1
f43150a669dc updated for version 7.0155
vimboss
parents: 532
diff changeset
74 endwhile
531
da9142bd190a updated for version 7.0149
vimboss
parents: 529
diff changeset
75 endif
da9142bd190a updated for version 7.0149
vimboss
parents: 529
diff changeset
76 endif
659
d6a69271cb9a updated for version 7.0194
vimboss
parents: 649
diff changeset
77 " }}}
d6a69271cb9a updated for version 7.0194
vimboss
parents: 649
diff changeset
78 " Handling of <script> tag {{{
649
8157079cea85 updated for version 7.0191
vimboss
parents: 643
diff changeset
79 let scriptstart = searchpair('<script\>', '', '<\/script\>', "bnW")
8157079cea85 updated for version 7.0191
vimboss
parents: 643
diff changeset
80 let scriptend = searchpair('<script\>', '', '<\/script\>', "nW")
856
8cd729851562 updated for version 7.0g
vimboss
parents: 844
diff changeset
81 if scriptstart != 0 && scriptend != 0
649
8157079cea85 updated for version 7.0191
vimboss
parents: 643
diff changeset
82 if scriptstart <= curline && scriptend >= curline
8157079cea85 updated for version 7.0191
vimboss
parents: 643
diff changeset
83 let start = col('.') - 1
8157079cea85 updated for version 7.0191
vimboss
parents: 643
diff changeset
84 let b:jscompl = 1
8157079cea85 updated for version 7.0191
vimboss
parents: 643
diff changeset
85 let b:jsrange = [scriptstart, scriptend]
667
9090f866cd57 updated for version 7.0197
vimboss
parents: 659
diff changeset
86 while start >= 0 && line[start - 1] =~ '\k'
649
8157079cea85 updated for version 7.0191
vimboss
parents: 643
diff changeset
87 let start -= 1
8157079cea85 updated for version 7.0191
vimboss
parents: 643
diff changeset
88 endwhile
659
d6a69271cb9a updated for version 7.0194
vimboss
parents: 649
diff changeset
89 " We are inside of <script> tag. But we should also get contents
d6a69271cb9a updated for version 7.0194
vimboss
parents: 649
diff changeset
90 " of all linked external files and (secondary, less probably) other <script> tags
d6a69271cb9a updated for version 7.0194
vimboss
parents: 649
diff changeset
91 " This logic could possible be done in separate function - may be
d6a69271cb9a updated for version 7.0194
vimboss
parents: 649
diff changeset
92 " reused in events scripting (also with option could be reused for
d6a69271cb9a updated for version 7.0194
vimboss
parents: 649
diff changeset
93 " CSS
d6a69271cb9a updated for version 7.0194
vimboss
parents: 649
diff changeset
94 let b:js_extfiles = []
d6a69271cb9a updated for version 7.0194
vimboss
parents: 649
diff changeset
95 let l = line('.')
d6a69271cb9a updated for version 7.0194
vimboss
parents: 649
diff changeset
96 let c = col('.')
d6a69271cb9a updated for version 7.0194
vimboss
parents: 649
diff changeset
97 call cursor(1,1)
d6a69271cb9a updated for version 7.0194
vimboss
parents: 649
diff changeset
98 while search('<\@<=script\>', 'W') && line('.') <= l
d6a69271cb9a updated for version 7.0194
vimboss
parents: 649
diff changeset
99 if synIDattr(synID(line('.'),col('.')-1,0),"name") !~? 'comment'
d6a69271cb9a updated for version 7.0194
vimboss
parents: 649
diff changeset
100 let sname = matchstr(getline('.'), '<script[^>]*src\s*=\s*\([''"]\)\zs.\{-}\ze\1')
d6a69271cb9a updated for version 7.0194
vimboss
parents: 649
diff changeset
101 if filereadable(sname)
d6a69271cb9a updated for version 7.0194
vimboss
parents: 649
diff changeset
102 let b:js_extfiles += readfile(sname)
d6a69271cb9a updated for version 7.0194
vimboss
parents: 649
diff changeset
103 endif
d6a69271cb9a updated for version 7.0194
vimboss
parents: 649
diff changeset
104 endif
d6a69271cb9a updated for version 7.0194
vimboss
parents: 649
diff changeset
105 endwhile
d6a69271cb9a updated for version 7.0194
vimboss
parents: 649
diff changeset
106 call cursor(1,1)
d6a69271cb9a updated for version 7.0194
vimboss
parents: 649
diff changeset
107 let js_scripttags = []
d6a69271cb9a updated for version 7.0194
vimboss
parents: 649
diff changeset
108 while search('<script\>', 'W') && line('.') < l
d6a69271cb9a updated for version 7.0194
vimboss
parents: 649
diff changeset
109 if matchstr(getline('.'), '<script[^>]*src') == ''
d6a69271cb9a updated for version 7.0194
vimboss
parents: 649
diff changeset
110 let js_scripttag = getline(line('.'), search('</script>', 'W'))
d6a69271cb9a updated for version 7.0194
vimboss
parents: 649
diff changeset
111 let js_scripttags += js_scripttag
d6a69271cb9a updated for version 7.0194
vimboss
parents: 649
diff changeset
112 endif
d6a69271cb9a updated for version 7.0194
vimboss
parents: 649
diff changeset
113 endwhile
d6a69271cb9a updated for version 7.0194
vimboss
parents: 649
diff changeset
114 let b:js_extfiles += js_scripttags
d6a69271cb9a updated for version 7.0194
vimboss
parents: 649
diff changeset
115 call cursor(l,c)
d6a69271cb9a updated for version 7.0194
vimboss
parents: 649
diff changeset
116 unlet! l c
649
8157079cea85 updated for version 7.0191
vimboss
parents: 643
diff changeset
117 endif
8157079cea85 updated for version 7.0191
vimboss
parents: 643
diff changeset
118 endif
659
d6a69271cb9a updated for version 7.0194
vimboss
parents: 649
diff changeset
119 " }}}
649
8157079cea85 updated for version 7.0191
vimboss
parents: 643
diff changeset
120 if !exists("b:csscompl") && !exists("b:jscompl")
548
f43150a669dc updated for version 7.0155
vimboss
parents: 532
diff changeset
121 let b:compl_context = getline('.')[0:(compl_begin)]
643
d3c978b4c7ce updated for version 7.0187
vimboss
parents: 641
diff changeset
122 if b:compl_context !~ '<[^>]*$'
659
d6a69271cb9a updated for version 7.0194
vimboss
parents: 649
diff changeset
123 " Look like we may have broken tag. Check previous lines.
643
d3c978b4c7ce updated for version 7.0187
vimboss
parents: 641
diff changeset
124 let i = 1
d3c978b4c7ce updated for version 7.0187
vimboss
parents: 641
diff changeset
125 while 1
d3c978b4c7ce updated for version 7.0187
vimboss
parents: 641
diff changeset
126 let context_line = getline(curline-i)
d3c978b4c7ce updated for version 7.0187
vimboss
parents: 641
diff changeset
127 if context_line =~ '<[^>]*$'
d3c978b4c7ce updated for version 7.0187
vimboss
parents: 641
diff changeset
128 " Yep, this is this line
1120
e6db096b07a1 updated for version 7.1a
vimboss
parents: 856
diff changeset
129 let context_lines = getline(curline-i, curline-1) + [b:compl_context]
643
d3c978b4c7ce updated for version 7.0187
vimboss
parents: 641
diff changeset
130 let b:compl_context = join(context_lines, ' ')
d3c978b4c7ce updated for version 7.0187
vimboss
parents: 641
diff changeset
131 break
784
1cc5f2c523ee updated for version 7.0229
vimboss
parents: 714
diff changeset
132 elseif context_line =~ '>[^<]*$' || i == curline
1cc5f2c523ee updated for version 7.0229
vimboss
parents: 714
diff changeset
133 " We are in normal tag line, no need for completion at all
1cc5f2c523ee updated for version 7.0229
vimboss
parents: 714
diff changeset
134 " OR reached first line without tag at all
643
d3c978b4c7ce updated for version 7.0187
vimboss
parents: 641
diff changeset
135 let b:compl_context = ''
d3c978b4c7ce updated for version 7.0187
vimboss
parents: 641
diff changeset
136 break
d3c978b4c7ce updated for version 7.0187
vimboss
parents: 641
diff changeset
137 endif
d3c978b4c7ce updated for version 7.0187
vimboss
parents: 641
diff changeset
138 let i += 1
d3c978b4c7ce updated for version 7.0187
vimboss
parents: 641
diff changeset
139 endwhile
d3c978b4c7ce updated for version 7.0187
vimboss
parents: 641
diff changeset
140 " Make sure we don't have counter
d3c978b4c7ce updated for version 7.0187
vimboss
parents: 641
diff changeset
141 unlet! i
d3c978b4c7ce updated for version 7.0187
vimboss
parents: 641
diff changeset
142 endif
641
6a944e0bd5d2 updated for version 7.0186
vimboss
parents: 573
diff changeset
143 let b:compl_context = matchstr(b:compl_context, '.*\zs<.*')
784
1cc5f2c523ee updated for version 7.0229
vimboss
parents: 714
diff changeset
144
659
d6a69271cb9a updated for version 7.0194
vimboss
parents: 649
diff changeset
145 " Return proper start for on-events. Without that beginning of
d6a69271cb9a updated for version 7.0194
vimboss
parents: 649
diff changeset
146 " completion will be badly reported
d6a69271cb9a updated for version 7.0194
vimboss
parents: 649
diff changeset
147 if b:compl_context =~? 'on[a-z]*\s*=\s*\(''[^'']*\|"[^"]*\)$'
d6a69271cb9a updated for version 7.0194
vimboss
parents: 649
diff changeset
148 let start = col('.') - 1
667
9090f866cd57 updated for version 7.0197
vimboss
parents: 659
diff changeset
149 while start >= 0 && line[start - 1] =~ '\k'
659
d6a69271cb9a updated for version 7.0194
vimboss
parents: 649
diff changeset
150 let start -= 1
d6a69271cb9a updated for version 7.0194
vimboss
parents: 649
diff changeset
151 endwhile
d6a69271cb9a updated for version 7.0194
vimboss
parents: 649
diff changeset
152 endif
784
1cc5f2c523ee updated for version 7.0229
vimboss
parents: 714
diff changeset
153 " If b:compl_context begins with <? we are inside of PHP code. It
856
8cd729851562 updated for version 7.0g
vimboss
parents: 844
diff changeset
154 " wasn't closed so PHP completion passed it to HTML
784
1cc5f2c523ee updated for version 7.0229
vimboss
parents: 714
diff changeset
155 if &filetype =~? 'php' && b:compl_context =~ '^<?'
1cc5f2c523ee updated for version 7.0229
vimboss
parents: 714
diff changeset
156 let b:phpcompl = 1
1cc5f2c523ee updated for version 7.0229
vimboss
parents: 714
diff changeset
157 let start = col('.') - 1
1cc5f2c523ee updated for version 7.0229
vimboss
parents: 714
diff changeset
158 while start >= 0 && line[start - 1] =~ '[a-zA-Z_0-9\x7f-\xff$]'
1cc5f2c523ee updated for version 7.0229
vimboss
parents: 714
diff changeset
159 let start -= 1
1cc5f2c523ee updated for version 7.0229
vimboss
parents: 714
diff changeset
160 endwhile
1cc5f2c523ee updated for version 7.0229
vimboss
parents: 714
diff changeset
161 endif
548
f43150a669dc updated for version 7.0155
vimboss
parents: 532
diff changeset
162 else
f43150a669dc updated for version 7.0155
vimboss
parents: 532
diff changeset
163 let b:compl_context = getline('.')[0:compl_begin]
f43150a669dc updated for version 7.0155
vimboss
parents: 532
diff changeset
164 endif
523
a7ae7e043e43 updated for version 7.0146
vimboss
parents:
diff changeset
165 return start
a7ae7e043e43 updated for version 7.0146
vimboss
parents:
diff changeset
166 else
548
f43150a669dc updated for version 7.0155
vimboss
parents: 532
diff changeset
167 " Initialize base return lists
f43150a669dc updated for version 7.0155
vimboss
parents: 532
diff changeset
168 let res = []
f43150a669dc updated for version 7.0155
vimboss
parents: 532
diff changeset
169 let res2 = []
f43150a669dc updated for version 7.0155
vimboss
parents: 532
diff changeset
170 " a:base is very short - we need context
f43150a669dc updated for version 7.0155
vimboss
parents: 532
diff changeset
171 let context = b:compl_context
531
da9142bd190a updated for version 7.0149
vimboss
parents: 529
diff changeset
172 " Check if we should do CSS completion inside of <style> tag
784
1cc5f2c523ee updated for version 7.0229
vimboss
parents: 714
diff changeset
173 " or JS completion inside of <script> tag or PHP completion in case of <?
1cc5f2c523ee updated for version 7.0229
vimboss
parents: 714
diff changeset
174 " tag AND &ft==php
531
da9142bd190a updated for version 7.0149
vimboss
parents: 529
diff changeset
175 if exists("b:csscompl")
da9142bd190a updated for version 7.0149
vimboss
parents: 529
diff changeset
176 unlet! b:csscompl
641
6a944e0bd5d2 updated for version 7.0186
vimboss
parents: 573
diff changeset
177 let context = b:compl_context
659
d6a69271cb9a updated for version 7.0194
vimboss
parents: 649
diff changeset
178 unlet! b:compl_context
548
f43150a669dc updated for version 7.0155
vimboss
parents: 532
diff changeset
179 return csscomplete#CompleteCSS(0, context)
649
8157079cea85 updated for version 7.0191
vimboss
parents: 643
diff changeset
180 elseif exists("b:jscompl")
8157079cea85 updated for version 7.0191
vimboss
parents: 643
diff changeset
181 unlet! b:jscompl
659
d6a69271cb9a updated for version 7.0194
vimboss
parents: 649
diff changeset
182 return javascriptcomplete#CompleteJS(0, a:base)
784
1cc5f2c523ee updated for version 7.0229
vimboss
parents: 714
diff changeset
183 elseif exists("b:phpcompl")
1cc5f2c523ee updated for version 7.0229
vimboss
parents: 714
diff changeset
184 unlet! b:phpcompl
1cc5f2c523ee updated for version 7.0229
vimboss
parents: 714
diff changeset
185 let context = b:compl_context
1cc5f2c523ee updated for version 7.0229
vimboss
parents: 714
diff changeset
186 return phpcomplete#CompletePHP(0, a:base)
641
6a944e0bd5d2 updated for version 7.0186
vimboss
parents: 573
diff changeset
187 else
6a944e0bd5d2 updated for version 7.0186
vimboss
parents: 573
diff changeset
188 if len(b:compl_context) == 0 && !exists("b:entitiescompl")
6a944e0bd5d2 updated for version 7.0186
vimboss
parents: 573
diff changeset
189 return []
6a944e0bd5d2 updated for version 7.0186
vimboss
parents: 573
diff changeset
190 endif
6a944e0bd5d2 updated for version 7.0186
vimboss
parents: 573
diff changeset
191 let context = matchstr(b:compl_context, '.\zs.*')
531
da9142bd190a updated for version 7.0149
vimboss
parents: 529
diff changeset
192 endif
641
6a944e0bd5d2 updated for version 7.0186
vimboss
parents: 573
diff changeset
193 unlet! b:compl_context
659
d6a69271cb9a updated for version 7.0194
vimboss
parents: 649
diff changeset
194 " Entities completion {{{
548
f43150a669dc updated for version 7.0155
vimboss
parents: 532
diff changeset
195 if exists("b:entitiescompl")
f43150a669dc updated for version 7.0155
vimboss
parents: 532
diff changeset
196 unlet! b:entitiescompl
f43150a669dc updated for version 7.0155
vimboss
parents: 532
diff changeset
197
844
d3bbb5dd3913 updated for version 7.0f02
vimboss
parents: 842
diff changeset
198 if !exists("b:html_doctype")
d3bbb5dd3913 updated for version 7.0f02
vimboss
parents: 842
diff changeset
199 call htmlcomplete#CheckDoctype()
d3bbb5dd3913 updated for version 7.0f02
vimboss
parents: 842
diff changeset
200 endif
838
8e5830943bff updated for version 7.0e04
vimboss
parents: 837
diff changeset
201 if !exists("b:html_omni")
836
5a7843c57316 updated for version 7.0e02
vimboss
parents: 829
diff changeset
202 "runtime! autoload/xml/xhtml10s.vim
5a7843c57316 updated for version 7.0e02
vimboss
parents: 829
diff changeset
203 call htmlcomplete#LoadData()
557
862863033fdd updated for version 7.0158
vimboss
parents: 553
diff changeset
204 endif
548
f43150a669dc updated for version 7.0155
vimboss
parents: 532
diff changeset
205
838
8e5830943bff updated for version 7.0e04
vimboss
parents: 837
diff changeset
206 let entities = b:html_omni['vimxmlentities']
557
862863033fdd updated for version 7.0158
vimboss
parents: 553
diff changeset
207
641
6a944e0bd5d2 updated for version 7.0186
vimboss
parents: 573
diff changeset
208 if len(a:base) == 1
6a944e0bd5d2 updated for version 7.0186
vimboss
parents: 573
diff changeset
209 for m in entities
6a944e0bd5d2 updated for version 7.0186
vimboss
parents: 573
diff changeset
210 if m =~ '^'.a:base
6a944e0bd5d2 updated for version 7.0186
vimboss
parents: 573
diff changeset
211 call add(res, m.';')
6a944e0bd5d2 updated for version 7.0186
vimboss
parents: 573
diff changeset
212 endif
6a944e0bd5d2 updated for version 7.0186
vimboss
parents: 573
diff changeset
213 endfor
6a944e0bd5d2 updated for version 7.0186
vimboss
parents: 573
diff changeset
214 return res
6a944e0bd5d2 updated for version 7.0186
vimboss
parents: 573
diff changeset
215 else
6a944e0bd5d2 updated for version 7.0186
vimboss
parents: 573
diff changeset
216 for m in entities
6a944e0bd5d2 updated for version 7.0186
vimboss
parents: 573
diff changeset
217 if m =~? '^'.a:base
6a944e0bd5d2 updated for version 7.0186
vimboss
parents: 573
diff changeset
218 call add(res, m.';')
6a944e0bd5d2 updated for version 7.0186
vimboss
parents: 573
diff changeset
219 elseif m =~? a:base
6a944e0bd5d2 updated for version 7.0186
vimboss
parents: 573
diff changeset
220 call add(res2, m.';')
6a944e0bd5d2 updated for version 7.0186
vimboss
parents: 573
diff changeset
221 endif
6a944e0bd5d2 updated for version 7.0186
vimboss
parents: 573
diff changeset
222 endfor
548
f43150a669dc updated for version 7.0155
vimboss
parents: 532
diff changeset
223
641
6a944e0bd5d2 updated for version 7.0186
vimboss
parents: 573
diff changeset
224 return res + res2
6a944e0bd5d2 updated for version 7.0186
vimboss
parents: 573
diff changeset
225 endif
6a944e0bd5d2 updated for version 7.0186
vimboss
parents: 573
diff changeset
226
548
f43150a669dc updated for version 7.0155
vimboss
parents: 532
diff changeset
227
f43150a669dc updated for version 7.0155
vimboss
parents: 532
diff changeset
228 endif
659
d6a69271cb9a updated for version 7.0194
vimboss
parents: 649
diff changeset
229 " }}}
548
f43150a669dc updated for version 7.0155
vimboss
parents: 532
diff changeset
230 if context =~ '>'
f43150a669dc updated for version 7.0155
vimboss
parents: 532
diff changeset
231 " Generally if context contains > it means we are outside of tag and
531
da9142bd190a updated for version 7.0149
vimboss
parents: 529
diff changeset
232 " should abandon action - with one exception: <style> span { bo
548
f43150a669dc updated for version 7.0155
vimboss
parents: 532
diff changeset
233 if context =~ 'style[^>]\{-}>[^<]\{-}$'
f43150a669dc updated for version 7.0155
vimboss
parents: 532
diff changeset
234 return csscomplete#CompleteCSS(0, context)
649
8157079cea85 updated for version 7.0191
vimboss
parents: 643
diff changeset
235 elseif context =~ 'script[^>]\{-}>[^<]\{-}$'
8157079cea85 updated for version 7.0191
vimboss
parents: 643
diff changeset
236 let b:jsrange = [line('.'), search('<\/script\>', 'nW')]
8157079cea85 updated for version 7.0191
vimboss
parents: 643
diff changeset
237 return javascriptcomplete#CompleteJS(0, context)
531
da9142bd190a updated for version 7.0149
vimboss
parents: 529
diff changeset
238 else
da9142bd190a updated for version 7.0149
vimboss
parents: 529
diff changeset
239 return []
da9142bd190a updated for version 7.0149
vimboss
parents: 529
diff changeset
240 endif
da9142bd190a updated for version 7.0149
vimboss
parents: 529
diff changeset
241 endif
da9142bd190a updated for version 7.0149
vimboss
parents: 529
diff changeset
242
548
f43150a669dc updated for version 7.0155
vimboss
parents: 532
diff changeset
243 " If context contains > it means we are already outside of tag and we
523
a7ae7e043e43 updated for version 7.0146
vimboss
parents:
diff changeset
244 " should abandon action
856
8cd729851562 updated for version 7.0g
vimboss
parents: 844
diff changeset
245 " If context contains white space it is attribute.
659
d6a69271cb9a updated for version 7.0194
vimboss
parents: 649
diff changeset
246 " It can be also value of attribute.
d6a69271cb9a updated for version 7.0194
vimboss
parents: 649
diff changeset
247 " We have to get first word to offer proper completions
18186
03b854983b14 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 6009
diff changeset
248 if context =~ '^\s*$'
03b854983b14 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 6009
diff changeset
249 " empty or whitespace line
548
f43150a669dc updated for version 7.0155
vimboss
parents: 532
diff changeset
250 let tag = ''
f43150a669dc updated for version 7.0155
vimboss
parents: 532
diff changeset
251 else
f43150a669dc updated for version 7.0155
vimboss
parents: 532
diff changeset
252 let tag = split(context)[0]
841
c2cae213194d updated for version 7.0e07
vimboss
parents: 838
diff changeset
253 " Detect if tag is uppercase to return in proper case,
c2cae213194d updated for version 7.0e07
vimboss
parents: 838
diff changeset
254 " we need to make it lowercase for processing
c2cae213194d updated for version 7.0e07
vimboss
parents: 838
diff changeset
255 if tag =~ '^[A-Z]*$'
837
6bb1fa855dc9 updated for version 7.0e03
vimboss
parents: 836
diff changeset
256 let uppercase_tag = 1
6bb1fa855dc9 updated for version 7.0e03
vimboss
parents: 836
diff changeset
257 let tag = tolower(tag)
6bb1fa855dc9 updated for version 7.0e03
vimboss
parents: 836
diff changeset
258 else
6bb1fa855dc9 updated for version 7.0e03
vimboss
parents: 836
diff changeset
259 let uppercase_tag = 0
6bb1fa855dc9 updated for version 7.0e03
vimboss
parents: 836
diff changeset
260 endif
548
f43150a669dc updated for version 7.0155
vimboss
parents: 532
diff changeset
261 endif
531
da9142bd190a updated for version 7.0149
vimboss
parents: 529
diff changeset
262 " Get last word, it should be attr name
548
f43150a669dc updated for version 7.0155
vimboss
parents: 532
diff changeset
263 let attr = matchstr(context, '.*\s\zs.*')
523
a7ae7e043e43 updated for version 7.0146
vimboss
parents:
diff changeset
264 " Possible situations where any prediction would be difficult:
a7ae7e043e43 updated for version 7.0146
vimboss
parents:
diff changeset
265 " 1. Events attributes
548
f43150a669dc updated for version 7.0155
vimboss
parents: 532
diff changeset
266 if context =~ '\s'
523
a7ae7e043e43 updated for version 7.0146
vimboss
parents:
diff changeset
267 " Sort out style, class, and on* cases
659
d6a69271cb9a updated for version 7.0194
vimboss
parents: 649
diff changeset
268 if context =~? "\\(on[a-z]*\\|id\\|style\\|class\\)\\s*=\\s*[\"']"
d6a69271cb9a updated for version 7.0194
vimboss
parents: 649
diff changeset
269 " Id, class completion {{{
d6a69271cb9a updated for version 7.0194
vimboss
parents: 649
diff changeset
270 if context =~? "\\(id\\|class\\)\\s*=\\s*[\"'][a-zA-Z0-9_ -]*$"
d6a69271cb9a updated for version 7.0194
vimboss
parents: 649
diff changeset
271 if context =~? "class\\s*=\\s*[\"'][a-zA-Z0-9_ -]*$"
532
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 531
diff changeset
272 let search_for = "class"
659
d6a69271cb9a updated for version 7.0194
vimboss
parents: 649
diff changeset
273 elseif context =~? "id\\s*=\\s*[\"'][a-zA-Z0-9_ -]*$"
532
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 531
diff changeset
274 let search_for = "id"
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 531
diff changeset
275 endif
531
da9142bd190a updated for version 7.0149
vimboss
parents: 529
diff changeset
276 " Handle class name completion
da9142bd190a updated for version 7.0149
vimboss
parents: 529
diff changeset
277 " 1. Find lines of <link stylesheet>
da9142bd190a updated for version 7.0149
vimboss
parents: 529
diff changeset
278 " 1a. Check file for @import
da9142bd190a updated for version 7.0149
vimboss
parents: 529
diff changeset
279 " 2. Extract filename(s?) of stylesheet,
da9142bd190a updated for version 7.0149
vimboss
parents: 529
diff changeset
280 call cursor(1,1)
da9142bd190a updated for version 7.0149
vimboss
parents: 529
diff changeset
281 let head = getline(search('<head\>'), search('<\/head>'))
da9142bd190a updated for version 7.0149
vimboss
parents: 529
diff changeset
282 let headjoined = join(copy(head), ' ')
da9142bd190a updated for version 7.0149
vimboss
parents: 529
diff changeset
283 if headjoined =~ '<style'
557
862863033fdd updated for version 7.0158
vimboss
parents: 553
diff changeset
284 " Remove possibly confusing CSS operators
532
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 531
diff changeset
285 let stylehead = substitute(headjoined, '+>\*[,', ' ', 'g')
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 531
diff changeset
286 if search_for == 'class'
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 531
diff changeset
287 let styleheadlines = split(stylehead)
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 531
diff changeset
288 let headclasslines = filter(copy(styleheadlines), "v:val =~ '\\([a-zA-Z0-9:]\\+\\)\\?\\.[a-zA-Z0-9_-]\\+'")
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 531
diff changeset
289 else
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 531
diff changeset
290 let stylesheet = split(headjoined, '[{}]')
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 531
diff changeset
291 " Get all lines which fit id syntax
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 531
diff changeset
292 let classlines = filter(copy(stylesheet), "v:val =~ '#[a-zA-Z0-9_-]\\+'")
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 531
diff changeset
293 " Filter out possible color definitions
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 531
diff changeset
294 call filter(classlines, "v:val !~ ':\\s*#[a-zA-Z0-9_-]\\+'")
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 531
diff changeset
295 " Filter out complex border definitions
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 531
diff changeset
296 call filter(classlines, "v:val !~ '\\(none\\|hidden\\|dotted\\|dashed\\|solid\\|double\\|groove\\|ridge\\|inset\\|outset\\)\\s*#[a-zA-Z0-9_-]\\+'")
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 531
diff changeset
297 let templines = join(classlines, ' ')
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 531
diff changeset
298 let headclasslines = split(templines)
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 531
diff changeset
299 call filter(headclasslines, "v:val =~ '#[a-zA-Z0-9_-]\\+'")
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 531
diff changeset
300 endif
531
da9142bd190a updated for version 7.0149
vimboss
parents: 529
diff changeset
301 let internal = 1
da9142bd190a updated for version 7.0149
vimboss
parents: 529
diff changeset
302 else
da9142bd190a updated for version 7.0149
vimboss
parents: 529
diff changeset
303 let internal = 0
da9142bd190a updated for version 7.0149
vimboss
parents: 529
diff changeset
304 endif
da9142bd190a updated for version 7.0149
vimboss
parents: 529
diff changeset
305 let styletable = []
da9142bd190a updated for version 7.0149
vimboss
parents: 529
diff changeset
306 let secimportfiles = []
da9142bd190a updated for version 7.0149
vimboss
parents: 529
diff changeset
307 let filestable = filter(copy(head), "v:val =~ '\\(@import\\|link.*stylesheet\\)'")
da9142bd190a updated for version 7.0149
vimboss
parents: 529
diff changeset
308 for line in filestable
da9142bd190a updated for version 7.0149
vimboss
parents: 529
diff changeset
309 if line =~ "@import"
da9142bd190a updated for version 7.0149
vimboss
parents: 529
diff changeset
310 let styletable += [matchstr(line, "import\\s\\+\\(url(\\)\\?[\"']\\?\\zs\\f\\+\\ze")]
da9142bd190a updated for version 7.0149
vimboss
parents: 529
diff changeset
311 elseif line =~ "<link"
da9142bd190a updated for version 7.0149
vimboss
parents: 529
diff changeset
312 let styletable += [matchstr(line, "href\\s*=\\s*[\"']\\zs\\f\\+\\ze")]
da9142bd190a updated for version 7.0149
vimboss
parents: 529
diff changeset
313 endif
da9142bd190a updated for version 7.0149
vimboss
parents: 529
diff changeset
314 endfor
532
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 531
diff changeset
315 for file in styletable
531
da9142bd190a updated for version 7.0149
vimboss
parents: 529
diff changeset
316 if filereadable(file)
da9142bd190a updated for version 7.0149
vimboss
parents: 529
diff changeset
317 let stylesheet = readfile(file)
da9142bd190a updated for version 7.0149
vimboss
parents: 529
diff changeset
318 let secimport = filter(copy(stylesheet), "v:val =~ '@import'")
da9142bd190a updated for version 7.0149
vimboss
parents: 529
diff changeset
319 if len(secimport) > 0
da9142bd190a updated for version 7.0149
vimboss
parents: 529
diff changeset
320 for line in secimport
532
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 531
diff changeset
321 let secfile = matchstr(line, "import\\s\\+\\(url(\\)\\?[\"']\\?\\zs\\f\\+\\ze")
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 531
diff changeset
322 let secfile = fnamemodify(file, ":p:h").'/'.secfile
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 531
diff changeset
323 let secimportfiles += [secfile]
531
da9142bd190a updated for version 7.0149
vimboss
parents: 529
diff changeset
324 endfor
da9142bd190a updated for version 7.0149
vimboss
parents: 529
diff changeset
325 endif
da9142bd190a updated for version 7.0149
vimboss
parents: 529
diff changeset
326 endif
da9142bd190a updated for version 7.0149
vimboss
parents: 529
diff changeset
327 endfor
da9142bd190a updated for version 7.0149
vimboss
parents: 529
diff changeset
328 let cssfiles = styletable + secimportfiles
da9142bd190a updated for version 7.0149
vimboss
parents: 529
diff changeset
329 let classes = []
da9142bd190a updated for version 7.0149
vimboss
parents: 529
diff changeset
330 for file in cssfiles
2788
0877b8d6370e Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 1120
diff changeset
331 let classlines = []
531
da9142bd190a updated for version 7.0149
vimboss
parents: 529
diff changeset
332 if filereadable(file)
da9142bd190a updated for version 7.0149
vimboss
parents: 529
diff changeset
333 let stylesheet = readfile(file)
532
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 531
diff changeset
334 let stylefile = join(stylesheet, ' ')
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 531
diff changeset
335 let stylefile = substitute(stylefile, '+>\*[,', ' ', 'g')
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 531
diff changeset
336 if search_for == 'class'
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 531
diff changeset
337 let stylesheet = split(stylefile)
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 531
diff changeset
338 let classlines = filter(copy(stylesheet), "v:val =~ '\\([a-zA-Z0-9:]\\+\\)\\?\\.[a-zA-Z0-9_-]\\+'")
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 531
diff changeset
339 else
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 531
diff changeset
340 let stylesheet = split(stylefile, '[{}]')
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 531
diff changeset
341 " Get all lines which fit id syntax
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 531
diff changeset
342 let classlines = filter(copy(stylesheet), "v:val =~ '#[a-zA-Z0-9_-]\\+'")
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 531
diff changeset
343 " Filter out possible color definitions
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 531
diff changeset
344 call filter(classlines, "v:val !~ ':\\s*#[a-zA-Z0-9_-]\\+'")
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 531
diff changeset
345 " Filter out complex border definitions
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 531
diff changeset
346 call filter(classlines, "v:val !~ '\\(none\\|hidden\\|dotted\\|dashed\\|solid\\|double\\|groove\\|ridge\\|inset\\|outset\\)\\s*#[a-zA-Z0-9_-]\\+'")
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 531
diff changeset
347 let templines = join(classlines, ' ')
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 531
diff changeset
348 let stylelines = split(templines)
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 531
diff changeset
349 let classlines = filter(stylelines, "v:val =~ '#[a-zA-Z0-9_-]\\+'")
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 531
diff changeset
350
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 531
diff changeset
351 endif
531
da9142bd190a updated for version 7.0149
vimboss
parents: 529
diff changeset
352 endif
da9142bd190a updated for version 7.0149
vimboss
parents: 529
diff changeset
353 " We gathered classes definitions from all external files
da9142bd190a updated for version 7.0149
vimboss
parents: 529
diff changeset
354 let classes += classlines
da9142bd190a updated for version 7.0149
vimboss
parents: 529
diff changeset
355 endfor
da9142bd190a updated for version 7.0149
vimboss
parents: 529
diff changeset
356 if internal == 1
da9142bd190a updated for version 7.0149
vimboss
parents: 529
diff changeset
357 let classes += headclasslines
da9142bd190a updated for version 7.0149
vimboss
parents: 529
diff changeset
358 endif
532
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 531
diff changeset
359
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 531
diff changeset
360 if search_for == 'class'
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 531
diff changeset
361 let elements = {}
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 531
diff changeset
362 for element in classes
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 531
diff changeset
363 if element =~ '^\.'
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 531
diff changeset
364 let class = matchstr(element, '^\.\zs[a-zA-Z][a-zA-Z0-9_-]*\ze')
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 531
diff changeset
365 let class = substitute(class, ':.*', '', '')
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 531
diff changeset
366 if has_key(elements, 'common')
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 531
diff changeset
367 let elements['common'] .= ' '.class
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 531
diff changeset
368 else
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 531
diff changeset
369 let elements['common'] = class
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 531
diff changeset
370 endif
531
da9142bd190a updated for version 7.0149
vimboss
parents: 529
diff changeset
371 else
532
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 531
diff changeset
372 let class = matchstr(element, '[a-zA-Z1-6]*\.\zs[a-zA-Z][a-zA-Z0-9_-]*\ze')
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 531
diff changeset
373 let tagname = tolower(matchstr(element, '[a-zA-Z1-6]*\ze.'))
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 531
diff changeset
374 if tagname != ''
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 531
diff changeset
375 if has_key(elements, tagname)
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 531
diff changeset
376 let elements[tagname] .= ' '.class
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 531
diff changeset
377 else
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 531
diff changeset
378 let elements[tagname] = class
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 531
diff changeset
379 endif
531
da9142bd190a updated for version 7.0149
vimboss
parents: 529
diff changeset
380 endif
da9142bd190a updated for version 7.0149
vimboss
parents: 529
diff changeset
381 endif
532
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 531
diff changeset
382 endfor
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 531
diff changeset
383
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 531
diff changeset
384 if has_key(elements, tag) && has_key(elements, 'common')
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 531
diff changeset
385 let values = split(elements[tag]." ".elements['common'])
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 531
diff changeset
386 elseif has_key(elements, tag) && !has_key(elements, 'common')
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 531
diff changeset
387 let values = split(elements[tag])
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 531
diff changeset
388 elseif !has_key(elements, tag) && has_key(elements, 'common')
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 531
diff changeset
389 let values = split(elements['common'])
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 531
diff changeset
390 else
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 531
diff changeset
391 return []
531
da9142bd190a updated for version 7.0149
vimboss
parents: 529
diff changeset
392 endif
da9142bd190a updated for version 7.0149
vimboss
parents: 529
diff changeset
393
532
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 531
diff changeset
394 elseif search_for == 'id'
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 531
diff changeset
395 " Find used IDs
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 531
diff changeset
396 " 1. Catch whole file
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 531
diff changeset
397 let filelines = getline(1, line('$'))
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 531
diff changeset
398 " 2. Find lines with possible id
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 531
diff changeset
399 let used_id_lines = filter(filelines, 'v:val =~ "id\\s*=\\s*[\"''][a-zA-Z0-9_-]\\+"')
856
8cd729851562 updated for version 7.0g
vimboss
parents: 844
diff changeset
400 " 3a. Join all filtered lines
532
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 531
diff changeset
401 let id_string = join(used_id_lines, ' ')
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 531
diff changeset
402 " 3b. And split them to be sure each id is in separate item
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 531
diff changeset
403 let id_list = split(id_string, 'id\s*=\s*')
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 531
diff changeset
404 " 4. Extract id values
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 531
diff changeset
405 let used_id = map(id_list, 'matchstr(v:val, "[\"'']\\zs[a-zA-Z0-9_-]\\+\\ze")')
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 531
diff changeset
406 let joined_used_id = ','.join(used_id, ',').','
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 531
diff changeset
407
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 531
diff changeset
408 let allvalues = map(classes, 'matchstr(v:val, ".*#\\zs[a-zA-Z0-9_-]\\+")')
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 531
diff changeset
409
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 531
diff changeset
410 let values = []
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 531
diff changeset
411
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 531
diff changeset
412 for element in classes
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 531
diff changeset
413 if joined_used_id !~ ','.element.','
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 531
diff changeset
414 let values += [element]
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 531
diff changeset
415 endif
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 531
diff changeset
416
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 531
diff changeset
417 endfor
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 531
diff changeset
418
531
da9142bd190a updated for version 7.0149
vimboss
parents: 529
diff changeset
419 endif
da9142bd190a updated for version 7.0149
vimboss
parents: 529
diff changeset
420
da9142bd190a updated for version 7.0149
vimboss
parents: 529
diff changeset
421 " We need special version of sbase
548
f43150a669dc updated for version 7.0155
vimboss
parents: 532
diff changeset
422 let classbase = matchstr(context, ".*[\"']")
532
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 531
diff changeset
423 let classquote = matchstr(classbase, '.$')
531
da9142bd190a updated for version 7.0149
vimboss
parents: 529
diff changeset
424
da9142bd190a updated for version 7.0149
vimboss
parents: 529
diff changeset
425 let entered_class = matchstr(attr, ".*=\\s*[\"']\\zs.*")
da9142bd190a updated for version 7.0149
vimboss
parents: 529
diff changeset
426
da9142bd190a updated for version 7.0149
vimboss
parents: 529
diff changeset
427 for m in sort(values)
da9142bd190a updated for version 7.0149
vimboss
parents: 529
diff changeset
428 if m =~? '^'.entered_class
548
f43150a669dc updated for version 7.0155
vimboss
parents: 532
diff changeset
429 call add(res, m . classquote)
531
da9142bd190a updated for version 7.0149
vimboss
parents: 529
diff changeset
430 elseif m =~? entered_class
548
f43150a669dc updated for version 7.0155
vimboss
parents: 532
diff changeset
431 call add(res2, m . classquote)
531
da9142bd190a updated for version 7.0149
vimboss
parents: 529
diff changeset
432 endif
da9142bd190a updated for version 7.0149
vimboss
parents: 529
diff changeset
433 endfor
da9142bd190a updated for version 7.0149
vimboss
parents: 529
diff changeset
434
da9142bd190a updated for version 7.0149
vimboss
parents: 529
diff changeset
435 return res + res2
da9142bd190a updated for version 7.0149
vimboss
parents: 529
diff changeset
436
659
d6a69271cb9a updated for version 7.0194
vimboss
parents: 649
diff changeset
437 elseif context =~? "style\\s*=\\s*[\"'][^\"']*$"
548
f43150a669dc updated for version 7.0155
vimboss
parents: 532
diff changeset
438 return csscomplete#CompleteCSS(0, context)
531
da9142bd190a updated for version 7.0149
vimboss
parents: 529
diff changeset
439
da9142bd190a updated for version 7.0149
vimboss
parents: 529
diff changeset
440 endif
659
d6a69271cb9a updated for version 7.0194
vimboss
parents: 649
diff changeset
441 " }}}
d6a69271cb9a updated for version 7.0194
vimboss
parents: 649
diff changeset
442 " Complete on-events {{{
d6a69271cb9a updated for version 7.0194
vimboss
parents: 649
diff changeset
443 if context =~? 'on[a-z]*\s*=\s*\(''[^'']*\|"[^"]*\)$'
d6a69271cb9a updated for version 7.0194
vimboss
parents: 649
diff changeset
444 " We have to:
d6a69271cb9a updated for version 7.0194
vimboss
parents: 649
diff changeset
445 " 1. Find external files
d6a69271cb9a updated for version 7.0194
vimboss
parents: 649
diff changeset
446 let b:js_extfiles = []
d6a69271cb9a updated for version 7.0194
vimboss
parents: 649
diff changeset
447 let l = line('.')
d6a69271cb9a updated for version 7.0194
vimboss
parents: 649
diff changeset
448 let c = col('.')
d6a69271cb9a updated for version 7.0194
vimboss
parents: 649
diff changeset
449 call cursor(1,1)
d6a69271cb9a updated for version 7.0194
vimboss
parents: 649
diff changeset
450 while search('<\@<=script\>', 'W') && line('.') <= l
d6a69271cb9a updated for version 7.0194
vimboss
parents: 649
diff changeset
451 if synIDattr(synID(line('.'),col('.')-1,0),"name") !~? 'comment'
d6a69271cb9a updated for version 7.0194
vimboss
parents: 649
diff changeset
452 let sname = matchstr(getline('.'), '<script[^>]*src\s*=\s*\([''"]\)\zs.\{-}\ze\1')
d6a69271cb9a updated for version 7.0194
vimboss
parents: 649
diff changeset
453 if filereadable(sname)
d6a69271cb9a updated for version 7.0194
vimboss
parents: 649
diff changeset
454 let b:js_extfiles += readfile(sname)
d6a69271cb9a updated for version 7.0194
vimboss
parents: 649
diff changeset
455 endif
d6a69271cb9a updated for version 7.0194
vimboss
parents: 649
diff changeset
456 endif
d6a69271cb9a updated for version 7.0194
vimboss
parents: 649
diff changeset
457 endwhile
d6a69271cb9a updated for version 7.0194
vimboss
parents: 649
diff changeset
458 " 2. Find at least one <script> tag
d6a69271cb9a updated for version 7.0194
vimboss
parents: 649
diff changeset
459 call cursor(1,1)
d6a69271cb9a updated for version 7.0194
vimboss
parents: 649
diff changeset
460 let js_scripttags = []
d6a69271cb9a updated for version 7.0194
vimboss
parents: 649
diff changeset
461 while search('<script\>', 'W') && line('.') < l
d6a69271cb9a updated for version 7.0194
vimboss
parents: 649
diff changeset
462 if matchstr(getline('.'), '<script[^>]*src') == ''
d6a69271cb9a updated for version 7.0194
vimboss
parents: 649
diff changeset
463 let js_scripttag = getline(line('.'), search('</script>', 'W'))
d6a69271cb9a updated for version 7.0194
vimboss
parents: 649
diff changeset
464 let js_scripttags += js_scripttag
d6a69271cb9a updated for version 7.0194
vimboss
parents: 649
diff changeset
465 endif
d6a69271cb9a updated for version 7.0194
vimboss
parents: 649
diff changeset
466 endwhile
d6a69271cb9a updated for version 7.0194
vimboss
parents: 649
diff changeset
467 let b:js_extfiles += js_scripttags
d6a69271cb9a updated for version 7.0194
vimboss
parents: 649
diff changeset
468
d6a69271cb9a updated for version 7.0194
vimboss
parents: 649
diff changeset
469 " 3. Proper call for javascriptcomplete#CompleteJS
d6a69271cb9a updated for version 7.0194
vimboss
parents: 649
diff changeset
470 call cursor(l,c)
667
9090f866cd57 updated for version 7.0197
vimboss
parents: 659
diff changeset
471 let js_context = matchstr(a:base, '\k\+$')
659
d6a69271cb9a updated for version 7.0194
vimboss
parents: 649
diff changeset
472 let js_shortcontext = substitute(a:base, js_context.'$', '', '')
d6a69271cb9a updated for version 7.0194
vimboss
parents: 649
diff changeset
473 let b:compl_context = context
d6a69271cb9a updated for version 7.0194
vimboss
parents: 649
diff changeset
474 let b:jsrange = [l, l]
d6a69271cb9a updated for version 7.0194
vimboss
parents: 649
diff changeset
475 unlet! l c
d6a69271cb9a updated for version 7.0194
vimboss
parents: 649
diff changeset
476 return javascriptcomplete#CompleteJS(0, js_context)
d6a69271cb9a updated for version 7.0194
vimboss
parents: 649
diff changeset
477
d6a69271cb9a updated for version 7.0194
vimboss
parents: 649
diff changeset
478 endif
856
8cd729851562 updated for version 7.0g
vimboss
parents: 844
diff changeset
479
659
d6a69271cb9a updated for version 7.0194
vimboss
parents: 649
diff changeset
480 " }}}
d6a69271cb9a updated for version 7.0194
vimboss
parents: 649
diff changeset
481 let stripbase = matchstr(context, ".*\\(on[a-zA-Z]*\\|style\\|class\\)\\s*=\\s*[\"']\\zs.*")
548
f43150a669dc updated for version 7.0155
vimboss
parents: 532
diff changeset
482 " Now we have context stripped from all chars up to style/class.
523
a7ae7e043e43 updated for version 7.0146
vimboss
parents:
diff changeset
483 " It may fail with some strange style value combinations.
a7ae7e043e43 updated for version 7.0146
vimboss
parents:
diff changeset
484 if stripbase !~ "[\"']"
a7ae7e043e43 updated for version 7.0146
vimboss
parents:
diff changeset
485 return []
a7ae7e043e43 updated for version 7.0146
vimboss
parents:
diff changeset
486 endif
a7ae7e043e43 updated for version 7.0146
vimboss
parents:
diff changeset
487 endif
659
d6a69271cb9a updated for version 7.0194
vimboss
parents: 649
diff changeset
488 " Value of attribute completion {{{
523
a7ae7e043e43 updated for version 7.0146
vimboss
parents:
diff changeset
489 " If attr contains =\s*[\"'] we catched value of attribute
837
6bb1fa855dc9 updated for version 7.0e03
vimboss
parents: 836
diff changeset
490 if attr =~ "=\s*[\"']" || attr =~ "=\s*$"
523
a7ae7e043e43 updated for version 7.0146
vimboss
parents:
diff changeset
491 " Let do attribute specific completion
a7ae7e043e43 updated for version 7.0146
vimboss
parents:
diff changeset
492 let attrname = matchstr(attr, '.*\ze\s*=')
837
6bb1fa855dc9 updated for version 7.0e03
vimboss
parents: 836
diff changeset
493 let entered_value = matchstr(attr, ".*=\\s*[\"']\\?\\zs.*")
523
a7ae7e043e43 updated for version 7.0146
vimboss
parents:
diff changeset
494 let values = []
1120
e6db096b07a1 updated for version 7.1a
vimboss
parents: 856
diff changeset
495 " Load data {{{
e6db096b07a1 updated for version 7.1a
vimboss
parents: 856
diff changeset
496 if !exists("b:html_doctype")
e6db096b07a1 updated for version 7.1a
vimboss
parents: 856
diff changeset
497 call htmlcomplete#CheckDoctype()
e6db096b07a1 updated for version 7.1a
vimboss
parents: 856
diff changeset
498 endif
e6db096b07a1 updated for version 7.1a
vimboss
parents: 856
diff changeset
499 if !exists("b:html_omni")
e6db096b07a1 updated for version 7.1a
vimboss
parents: 856
diff changeset
500 "runtime! autoload/xml/xhtml10s.vim
e6db096b07a1 updated for version 7.1a
vimboss
parents: 856
diff changeset
501 call htmlcomplete#LoadData()
e6db096b07a1 updated for version 7.1a
vimboss
parents: 856
diff changeset
502 endif
e6db096b07a1 updated for version 7.1a
vimboss
parents: 856
diff changeset
503 " }}}
836
5a7843c57316 updated for version 7.0e02
vimboss
parents: 829
diff changeset
504 if attrname == 'href'
523
a7ae7e043e43 updated for version 7.0146
vimboss
parents:
diff changeset
505 " Now we are looking for local anchors defined by name or id
a7ae7e043e43 updated for version 7.0146
vimboss
parents:
diff changeset
506 if entered_value =~ '^#'
a7ae7e043e43 updated for version 7.0146
vimboss
parents:
diff changeset
507 let file = join(getline(1, line('$')), ' ')
a7ae7e043e43 updated for version 7.0146
vimboss
parents:
diff changeset
508 " Split it be sure there will be one id/name element in
a7ae7e043e43 updated for version 7.0146
vimboss
parents:
diff changeset
509 " item, it will be also first word [a-zA-Z0-9_-] in element
a7ae7e043e43 updated for version 7.0146
vimboss
parents:
diff changeset
510 let oneelement = split(file, "\\(meta \\)\\@<!\\(name\\|id\\)\\s*=\\s*[\"']")
a7ae7e043e43 updated for version 7.0146
vimboss
parents:
diff changeset
511 for i in oneelement
a7ae7e043e43 updated for version 7.0146
vimboss
parents:
diff changeset
512 let values += ['#'.matchstr(i, "^[a-zA-Z][a-zA-Z0-9%_-]*")]
a7ae7e043e43 updated for version 7.0146
vimboss
parents:
diff changeset
513 endfor
a7ae7e043e43 updated for version 7.0146
vimboss
parents:
diff changeset
514 endif
836
5a7843c57316 updated for version 7.0e02
vimboss
parents: 829
diff changeset
515 else
838
8e5830943bff updated for version 7.0e04
vimboss
parents: 837
diff changeset
516 if has_key(b:html_omni, tag) && has_key(b:html_omni[tag][1], attrname)
8e5830943bff updated for version 7.0e04
vimboss
parents: 837
diff changeset
517 let values = b:html_omni[tag][1][attrname]
836
5a7843c57316 updated for version 7.0e02
vimboss
parents: 829
diff changeset
518 else
5a7843c57316 updated for version 7.0e02
vimboss
parents: 829
diff changeset
519 return []
523
a7ae7e043e43 updated for version 7.0146
vimboss
parents:
diff changeset
520 endif
a7ae7e043e43 updated for version 7.0146
vimboss
parents:
diff changeset
521 endif
a7ae7e043e43 updated for version 7.0146
vimboss
parents:
diff changeset
522
a7ae7e043e43 updated for version 7.0146
vimboss
parents:
diff changeset
523 if len(values) == 0
a7ae7e043e43 updated for version 7.0146
vimboss
parents:
diff changeset
524 return []
a7ae7e043e43 updated for version 7.0146
vimboss
parents:
diff changeset
525 endif
a7ae7e043e43 updated for version 7.0146
vimboss
parents:
diff changeset
526
a7ae7e043e43 updated for version 7.0146
vimboss
parents:
diff changeset
527 " We need special version of sbase
548
f43150a669dc updated for version 7.0155
vimboss
parents: 532
diff changeset
528 let attrbase = matchstr(context, ".*[\"']")
531
da9142bd190a updated for version 7.0149
vimboss
parents: 529
diff changeset
529 let attrquote = matchstr(attrbase, '.$')
837
6bb1fa855dc9 updated for version 7.0e03
vimboss
parents: 836
diff changeset
530 if attrquote !~ "['\"]"
6bb1fa855dc9 updated for version 7.0e03
vimboss
parents: 836
diff changeset
531 let attrquoteopen = '"'
6bb1fa855dc9 updated for version 7.0e03
vimboss
parents: 836
diff changeset
532 let attrquote = '"'
6bb1fa855dc9 updated for version 7.0e03
vimboss
parents: 836
diff changeset
533 else
6bb1fa855dc9 updated for version 7.0e03
vimboss
parents: 836
diff changeset
534 let attrquoteopen = ''
6bb1fa855dc9 updated for version 7.0e03
vimboss
parents: 836
diff changeset
535 endif
523
a7ae7e043e43 updated for version 7.0146
vimboss
parents:
diff changeset
536
a7ae7e043e43 updated for version 7.0146
vimboss
parents:
diff changeset
537 for m in values
531
da9142bd190a updated for version 7.0149
vimboss
parents: 529
diff changeset
538 " This if is needed to not offer all completions as-is
da9142bd190a updated for version 7.0149
vimboss
parents: 529
diff changeset
539 " alphabetically but sort them. Those beginning with entered
da9142bd190a updated for version 7.0149
vimboss
parents: 529
diff changeset
540 " part will be as first choices
da9142bd190a updated for version 7.0149
vimboss
parents: 529
diff changeset
541 if m =~ '^'.entered_value
842
a209672376fd updated for version 7.0f
vimboss
parents: 841
diff changeset
542 call add(res, attrquoteopen . m . attrquote)
531
da9142bd190a updated for version 7.0149
vimboss
parents: 529
diff changeset
543 elseif m =~ entered_value
842
a209672376fd updated for version 7.0f
vimboss
parents: 841
diff changeset
544 call add(res2, attrquoteopen . m . attrquote)
523
a7ae7e043e43 updated for version 7.0146
vimboss
parents:
diff changeset
545 endif
a7ae7e043e43 updated for version 7.0146
vimboss
parents:
diff changeset
546 endfor
531
da9142bd190a updated for version 7.0149
vimboss
parents: 529
diff changeset
547
da9142bd190a updated for version 7.0149
vimboss
parents: 529
diff changeset
548 return res + res2
da9142bd190a updated for version 7.0149
vimboss
parents: 529
diff changeset
549
523
a7ae7e043e43 updated for version 7.0146
vimboss
parents:
diff changeset
550 endif
659
d6a69271cb9a updated for version 7.0194
vimboss
parents: 649
diff changeset
551 " }}}
d6a69271cb9a updated for version 7.0194
vimboss
parents: 649
diff changeset
552 " Attribute completion {{{
548
f43150a669dc updated for version 7.0155
vimboss
parents: 532
diff changeset
553 " Shorten context to not include last word
f43150a669dc updated for version 7.0155
vimboss
parents: 532
diff changeset
554 let sbase = matchstr(context, '.*\ze\s.*')
667
9090f866cd57 updated for version 7.0197
vimboss
parents: 659
diff changeset
555
9090f866cd57 updated for version 7.0197
vimboss
parents: 659
diff changeset
556 " Load data {{{
844
d3bbb5dd3913 updated for version 7.0f02
vimboss
parents: 842
diff changeset
557 if !exists("b:html_doctype")
d3bbb5dd3913 updated for version 7.0f02
vimboss
parents: 842
diff changeset
558 call htmlcomplete#CheckDoctype()
d3bbb5dd3913 updated for version 7.0f02
vimboss
parents: 842
diff changeset
559 endif
d3bbb5dd3913 updated for version 7.0f02
vimboss
parents: 842
diff changeset
560 if !exists("b:html_omni")
836
5a7843c57316 updated for version 7.0e02
vimboss
parents: 829
diff changeset
561 call htmlcomplete#LoadData()
523
a7ae7e043e43 updated for version 7.0146
vimboss
parents:
diff changeset
562 endif
667
9090f866cd57 updated for version 7.0197
vimboss
parents: 659
diff changeset
563 " }}}
856
8cd729851562 updated for version 7.0g
vimboss
parents: 844
diff changeset
564
838
8e5830943bff updated for version 7.0e04
vimboss
parents: 837
diff changeset
565 if has_key(b:html_omni, tag)
8e5830943bff updated for version 7.0e04
vimboss
parents: 837
diff changeset
566 let attrs = keys(b:html_omni[tag][1])
837
6bb1fa855dc9 updated for version 7.0e03
vimboss
parents: 836
diff changeset
567 else
6bb1fa855dc9 updated for version 7.0e03
vimboss
parents: 836
diff changeset
568 return []
6bb1fa855dc9 updated for version 7.0e03
vimboss
parents: 836
diff changeset
569 endif
523
a7ae7e043e43 updated for version 7.0146
vimboss
parents:
diff changeset
570
a7ae7e043e43 updated for version 7.0146
vimboss
parents:
diff changeset
571 for m in sort(attrs)
531
da9142bd190a updated for version 7.0149
vimboss
parents: 529
diff changeset
572 if m =~ '^'.attr
667
9090f866cd57 updated for version 7.0197
vimboss
parents: 659
diff changeset
573 call add(res, m)
531
da9142bd190a updated for version 7.0149
vimboss
parents: 529
diff changeset
574 elseif m =~ attr
667
9090f866cd57 updated for version 7.0197
vimboss
parents: 659
diff changeset
575 call add(res2, m)
523
a7ae7e043e43 updated for version 7.0146
vimboss
parents:
diff changeset
576 endif
a7ae7e043e43 updated for version 7.0146
vimboss
parents:
diff changeset
577 endfor
667
9090f866cd57 updated for version 7.0197
vimboss
parents: 659
diff changeset
578 let menu = res + res2
838
8e5830943bff updated for version 7.0e04
vimboss
parents: 837
diff changeset
579 if has_key(b:html_omni, 'vimxmlattrinfo')
667
9090f866cd57 updated for version 7.0197
vimboss
parents: 659
diff changeset
580 let final_menu = []
9090f866cd57 updated for version 7.0197
vimboss
parents: 659
diff changeset
581 for i in range(len(menu))
9090f866cd57 updated for version 7.0197
vimboss
parents: 659
diff changeset
582 let item = menu[i]
838
8e5830943bff updated for version 7.0e04
vimboss
parents: 837
diff changeset
583 if has_key(b:html_omni['vimxmlattrinfo'], item)
8e5830943bff updated for version 7.0e04
vimboss
parents: 837
diff changeset
584 let m_menu = b:html_omni['vimxmlattrinfo'][item][0]
8e5830943bff updated for version 7.0e04
vimboss
parents: 837
diff changeset
585 let m_info = b:html_omni['vimxmlattrinfo'][item][1]
667
9090f866cd57 updated for version 7.0197
vimboss
parents: 659
diff changeset
586 else
9090f866cd57 updated for version 7.0197
vimboss
parents: 659
diff changeset
587 let m_menu = ''
9090f866cd57 updated for version 7.0197
vimboss
parents: 659
diff changeset
588 let m_info = ''
844
d3bbb5dd3913 updated for version 7.0f02
vimboss
parents: 842
diff changeset
589 endif
d3bbb5dd3913 updated for version 7.0f02
vimboss
parents: 842
diff changeset
590 if len(b:html_omni[tag][1][item]) > 0 && b:html_omni[tag][1][item][0] =~ '^\(BOOL\|'.item.'\)$'
d3bbb5dd3913 updated for version 7.0f02
vimboss
parents: 842
diff changeset
591 let item = item
d3bbb5dd3913 updated for version 7.0f02
vimboss
parents: 842
diff changeset
592 let m_menu = 'Bool'
d3bbb5dd3913 updated for version 7.0f02
vimboss
parents: 842
diff changeset
593 else
667
9090f866cd57 updated for version 7.0197
vimboss
parents: 659
diff changeset
594 let item .= '="'
9090f866cd57 updated for version 7.0197
vimboss
parents: 659
diff changeset
595 endif
9090f866cd57 updated for version 7.0197
vimboss
parents: 659
diff changeset
596 let final_menu += [{'word':item, 'menu':m_menu, 'info':m_info}]
9090f866cd57 updated for version 7.0197
vimboss
parents: 659
diff changeset
597 endfor
9090f866cd57 updated for version 7.0197
vimboss
parents: 659
diff changeset
598 else
844
d3bbb5dd3913 updated for version 7.0f02
vimboss
parents: 842
diff changeset
599 let final_menu = []
d3bbb5dd3913 updated for version 7.0f02
vimboss
parents: 842
diff changeset
600 for i in range(len(menu))
d3bbb5dd3913 updated for version 7.0f02
vimboss
parents: 842
diff changeset
601 let item = menu[i]
d3bbb5dd3913 updated for version 7.0f02
vimboss
parents: 842
diff changeset
602 if len(b:html_omni[tag][1][item]) > 0 && b:html_omni[tag][1][item][0] =~ '^\(BOOL\|'.item.'\)$'
d3bbb5dd3913 updated for version 7.0f02
vimboss
parents: 842
diff changeset
603 let item = item
d3bbb5dd3913 updated for version 7.0f02
vimboss
parents: 842
diff changeset
604 else
d3bbb5dd3913 updated for version 7.0f02
vimboss
parents: 842
diff changeset
605 let item .= '="'
d3bbb5dd3913 updated for version 7.0f02
vimboss
parents: 842
diff changeset
606 endif
d3bbb5dd3913 updated for version 7.0f02
vimboss
parents: 842
diff changeset
607 let final_menu += [item]
d3bbb5dd3913 updated for version 7.0f02
vimboss
parents: 842
diff changeset
608 endfor
d3bbb5dd3913 updated for version 7.0f02
vimboss
parents: 842
diff changeset
609 return final_menu
d3bbb5dd3913 updated for version 7.0f02
vimboss
parents: 842
diff changeset
610
667
9090f866cd57 updated for version 7.0197
vimboss
parents: 659
diff changeset
611 endif
9090f866cd57 updated for version 7.0197
vimboss
parents: 659
diff changeset
612 return final_menu
531
da9142bd190a updated for version 7.0149
vimboss
parents: 529
diff changeset
613
523
a7ae7e043e43 updated for version 7.0146
vimboss
parents:
diff changeset
614 endif
659
d6a69271cb9a updated for version 7.0194
vimboss
parents: 649
diff changeset
615 " }}}
d6a69271cb9a updated for version 7.0194
vimboss
parents: 649
diff changeset
616 " Close tag {{{
529
0d6092bb72e6 updated for version 7.0148
vimboss
parents: 525
diff changeset
617 let b:unaryTagsStack = "base meta link hr br param img area input col"
548
f43150a669dc updated for version 7.0155
vimboss
parents: 532
diff changeset
618 if context =~ '^\/'
714
0f9f4761ad9c updated for version 7.0216
vimboss
parents: 674
diff changeset
619 if context =~ '^\/.'
0f9f4761ad9c updated for version 7.0216
vimboss
parents: 674
diff changeset
620 return []
0f9f4761ad9c updated for version 7.0216
vimboss
parents: 674
diff changeset
621 else
0f9f4761ad9c updated for version 7.0216
vimboss
parents: 674
diff changeset
622 let opentag = xmlcomplete#GetLastOpenTag("b:unaryTagsStack")
0f9f4761ad9c updated for version 7.0216
vimboss
parents: 674
diff changeset
623 return [opentag.">"]
0f9f4761ad9c updated for version 7.0216
vimboss
parents: 674
diff changeset
624 endif
525
1f8d8c37d6ec updated for version 7.0147
vimboss
parents: 523
diff changeset
625 endif
837
6bb1fa855dc9 updated for version 7.0e03
vimboss
parents: 836
diff changeset
626 " }}}
674
4b8583e82cb8 updated for version 7.0201
vimboss
parents: 667
diff changeset
627 " Load data {{{
844
d3bbb5dd3913 updated for version 7.0f02
vimboss
parents: 842
diff changeset
628 if !exists("b:html_doctype")
d3bbb5dd3913 updated for version 7.0f02
vimboss
parents: 842
diff changeset
629 call htmlcomplete#CheckDoctype()
d3bbb5dd3913 updated for version 7.0f02
vimboss
parents: 842
diff changeset
630 endif
838
8e5830943bff updated for version 7.0e04
vimboss
parents: 837
diff changeset
631 if !exists("b:html_omni")
836
5a7843c57316 updated for version 7.0e02
vimboss
parents: 829
diff changeset
632 "runtime! autoload/xml/xhtml10s.vim
5a7843c57316 updated for version 7.0e02
vimboss
parents: 829
diff changeset
633 call htmlcomplete#LoadData()
674
4b8583e82cb8 updated for version 7.0201
vimboss
parents: 667
diff changeset
634 endif
4b8583e82cb8 updated for version 7.0201
vimboss
parents: 667
diff changeset
635 " }}}
4b8583e82cb8 updated for version 7.0201
vimboss
parents: 667
diff changeset
636 " Tag completion {{{
525
1f8d8c37d6ec updated for version 7.0147
vimboss
parents: 523
diff changeset
637 " Deal with tag completion.
837
6bb1fa855dc9 updated for version 7.0e03
vimboss
parents: 836
diff changeset
638 let opentag = tolower(xmlcomplete#GetLastOpenTag("b:unaryTagsStack"))
714
0f9f4761ad9c updated for version 7.0216
vimboss
parents: 674
diff changeset
639 " MM: TODO: GLOT works always the same but with some weird situation it
0f9f4761ad9c updated for version 7.0216
vimboss
parents: 674
diff changeset
640 " behaves as intended in HTML but screws in PHP
841
c2cae213194d updated for version 7.0e07
vimboss
parents: 838
diff changeset
641 if opentag == '' || &filetype == 'php' && !has_key(b:html_omni, opentag)
641
6a944e0bd5d2 updated for version 7.0186
vimboss
parents: 573
diff changeset
642 " Hack for sometimes failing GetLastOpenTag.
6a944e0bd5d2 updated for version 7.0186
vimboss
parents: 573
diff changeset
643 " As far as I tested fail isn't GLOT fault but problem
6a944e0bd5d2 updated for version 7.0186
vimboss
parents: 573
diff changeset
644 " of invalid document - not properly closed tags and other mish-mash.
674
4b8583e82cb8 updated for version 7.0201
vimboss
parents: 667
diff changeset
645 " Also when document is empty. Return list of *all* tags.
838
8e5830943bff updated for version 7.0e04
vimboss
parents: 837
diff changeset
646 let tags = keys(b:html_omni)
674
4b8583e82cb8 updated for version 7.0201
vimboss
parents: 667
diff changeset
647 call filter(tags, 'v:val !~ "^vimxml"')
4b8583e82cb8 updated for version 7.0201
vimboss
parents: 667
diff changeset
648 else
838
8e5830943bff updated for version 7.0e04
vimboss
parents: 837
diff changeset
649 if has_key(b:html_omni, opentag)
8e5830943bff updated for version 7.0e04
vimboss
parents: 837
diff changeset
650 let tags = b:html_omni[opentag][0]
837
6bb1fa855dc9 updated for version 7.0e03
vimboss
parents: 836
diff changeset
651 else
6bb1fa855dc9 updated for version 7.0e03
vimboss
parents: 836
diff changeset
652 return []
6bb1fa855dc9 updated for version 7.0e03
vimboss
parents: 836
diff changeset
653 endif
641
6a944e0bd5d2 updated for version 7.0186
vimboss
parents: 573
diff changeset
654 endif
659
d6a69271cb9a updated for version 7.0194
vimboss
parents: 649
diff changeset
655 " }}}
856
8cd729851562 updated for version 7.0g
vimboss
parents: 844
diff changeset
656
837
6bb1fa855dc9 updated for version 7.0e03
vimboss
parents: 836
diff changeset
657 if exists("uppercase_tag") && uppercase_tag == 1
6bb1fa855dc9 updated for version 7.0e03
vimboss
parents: 836
diff changeset
658 let context = tolower(context)
6bb1fa855dc9 updated for version 7.0e03
vimboss
parents: 836
diff changeset
659 endif
1120
e6db096b07a1 updated for version 7.1a
vimboss
parents: 856
diff changeset
660 " Handle XML keywords: DOCTYPE
844
d3bbb5dd3913 updated for version 7.0f02
vimboss
parents: 842
diff changeset
661 if opentag == ''
841
c2cae213194d updated for version 7.0e07
vimboss
parents: 838
diff changeset
662 let tags += [
1120
e6db096b07a1 updated for version 7.1a
vimboss
parents: 856
diff changeset
663 \ '!DOCTYPE html PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">',
e6db096b07a1 updated for version 7.1a
vimboss
parents: 856
diff changeset
664 \ '!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd">',
e6db096b07a1 updated for version 7.1a
vimboss
parents: 856
diff changeset
665 \ '!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd">',
e6db096b07a1 updated for version 7.1a
vimboss
parents: 856
diff changeset
666 \ '!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Frameset//EN" "http://www.w3.org/TR/REC-html40/frameset.dtd">',
e6db096b07a1 updated for version 7.1a
vimboss
parents: 856
diff changeset
667 \ '!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">',
e6db096b07a1 updated for version 7.1a
vimboss
parents: 856
diff changeset
668 \ '!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">',
e6db096b07a1 updated for version 7.1a
vimboss
parents: 856
diff changeset
669 \ '!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN" "http://www.w3.org/TR/html4/frameset.dtd">',
e6db096b07a1 updated for version 7.1a
vimboss
parents: 856
diff changeset
670 \ '!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">',
e6db096b07a1 updated for version 7.1a
vimboss
parents: 856
diff changeset
671 \ '!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">',
e6db096b07a1 updated for version 7.1a
vimboss
parents: 856
diff changeset
672 \ '!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd">',
e6db096b07a1 updated for version 7.1a
vimboss
parents: 856
diff changeset
673 \ '!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/1999/xhtml">'
841
c2cae213194d updated for version 7.0e07
vimboss
parents: 838
diff changeset
674 \ ]
c2cae213194d updated for version 7.0e07
vimboss
parents: 838
diff changeset
675 endif
525
1f8d8c37d6ec updated for version 7.0147
vimboss
parents: 523
diff changeset
676
573
c85bf6a4999b updated for version 7.0163
vimboss
parents: 557
diff changeset
677 for m in sort(tags)
548
f43150a669dc updated for version 7.0155
vimboss
parents: 532
diff changeset
678 if m =~ '^'.context
523
a7ae7e043e43 updated for version 7.0146
vimboss
parents:
diff changeset
679 call add(res, m)
548
f43150a669dc updated for version 7.0155
vimboss
parents: 532
diff changeset
680 elseif m =~ context
531
da9142bd190a updated for version 7.0149
vimboss
parents: 529
diff changeset
681 call add(res2, m)
523
a7ae7e043e43 updated for version 7.0146
vimboss
parents:
diff changeset
682 endif
529
0d6092bb72e6 updated for version 7.0148
vimboss
parents: 525
diff changeset
683 endfor
667
9090f866cd57 updated for version 7.0197
vimboss
parents: 659
diff changeset
684 let menu = res + res2
838
8e5830943bff updated for version 7.0e04
vimboss
parents: 837
diff changeset
685 if has_key(b:html_omni, 'vimxmltaginfo')
667
9090f866cd57 updated for version 7.0197
vimboss
parents: 659
diff changeset
686 let final_menu = []
9090f866cd57 updated for version 7.0197
vimboss
parents: 659
diff changeset
687 for i in range(len(menu))
9090f866cd57 updated for version 7.0197
vimboss
parents: 659
diff changeset
688 let item = menu[i]
838
8e5830943bff updated for version 7.0e04
vimboss
parents: 837
diff changeset
689 if has_key(b:html_omni['vimxmltaginfo'], item)
8e5830943bff updated for version 7.0e04
vimboss
parents: 837
diff changeset
690 let m_menu = b:html_omni['vimxmltaginfo'][item][0]
8e5830943bff updated for version 7.0e04
vimboss
parents: 837
diff changeset
691 let m_info = b:html_omni['vimxmltaginfo'][item][1]
667
9090f866cd57 updated for version 7.0197
vimboss
parents: 659
diff changeset
692 else
9090f866cd57 updated for version 7.0197
vimboss
parents: 659
diff changeset
693 let m_menu = ''
9090f866cd57 updated for version 7.0197
vimboss
parents: 659
diff changeset
694 let m_info = ''
9090f866cd57 updated for version 7.0197
vimboss
parents: 659
diff changeset
695 endif
841
c2cae213194d updated for version 7.0e07
vimboss
parents: 838
diff changeset
696 if &filetype == 'html' && exists("uppercase_tag") && uppercase_tag == 1 && item !~ 'DOCTYPE'
838
8e5830943bff updated for version 7.0e04
vimboss
parents: 837
diff changeset
697 let item = toupper(item)
8e5830943bff updated for version 7.0e04
vimboss
parents: 837
diff changeset
698 endif
841
c2cae213194d updated for version 7.0e07
vimboss
parents: 838
diff changeset
699 if item =~ 'DOCTYPE'
c2cae213194d updated for version 7.0e07
vimboss
parents: 838
diff changeset
700 let abbr = 'DOCTYPE '.matchstr(item, 'DTD \zsX\?HTML .\{-}\ze\/\/')
c2cae213194d updated for version 7.0e07
vimboss
parents: 838
diff changeset
701 else
c2cae213194d updated for version 7.0e07
vimboss
parents: 838
diff changeset
702 let abbr = item
c2cae213194d updated for version 7.0e07
vimboss
parents: 838
diff changeset
703 endif
c2cae213194d updated for version 7.0e07
vimboss
parents: 838
diff changeset
704 let final_menu += [{'abbr':abbr, 'word':item, 'menu':m_menu, 'info':m_info}]
667
9090f866cd57 updated for version 7.0197
vimboss
parents: 659
diff changeset
705 endfor
9090f866cd57 updated for version 7.0197
vimboss
parents: 659
diff changeset
706 else
9090f866cd57 updated for version 7.0197
vimboss
parents: 659
diff changeset
707 let final_menu = menu
9090f866cd57 updated for version 7.0197
vimboss
parents: 659
diff changeset
708 endif
9090f866cd57 updated for version 7.0197
vimboss
parents: 659
diff changeset
709 return final_menu
529
0d6092bb72e6 updated for version 7.0148
vimboss
parents: 525
diff changeset
710
659
d6a69271cb9a updated for version 7.0194
vimboss
parents: 649
diff changeset
711 " }}}
523
a7ae7e043e43 updated for version 7.0146
vimboss
parents:
diff changeset
712 endif
a7ae7e043e43 updated for version 7.0146
vimboss
parents:
diff changeset
713 endfunction
836
5a7843c57316 updated for version 7.0e02
vimboss
parents: 829
diff changeset
714
5a7843c57316 updated for version 7.0e02
vimboss
parents: 829
diff changeset
715 function! htmlcomplete#LoadData() " {{{
838
8e5830943bff updated for version 7.0e04
vimboss
parents: 837
diff changeset
716 if !exists("b:html_omni_flavor")
841
c2cae213194d updated for version 7.0e07
vimboss
parents: 838
diff changeset
717 if &filetype == 'html'
838
8e5830943bff updated for version 7.0e04
vimboss
parents: 837
diff changeset
718 let b:html_omni_flavor = 'html401t'
8e5830943bff updated for version 7.0e04
vimboss
parents: 837
diff changeset
719 else
8e5830943bff updated for version 7.0e04
vimboss
parents: 837
diff changeset
720 let b:html_omni_flavor = 'xhtml10s'
8e5830943bff updated for version 7.0e04
vimboss
parents: 837
diff changeset
721 endif
836
5a7843c57316 updated for version 7.0e02
vimboss
parents: 829
diff changeset
722 endif
838
8e5830943bff updated for version 7.0e04
vimboss
parents: 837
diff changeset
723 " With that if we still have bloated memory but create new buffer
8e5830943bff updated for version 7.0e04
vimboss
parents: 837
diff changeset
724 " variables only by linking to existing g:variable, not sourcing whole
8e5830943bff updated for version 7.0e04
vimboss
parents: 837
diff changeset
725 " file.
8e5830943bff updated for version 7.0e04
vimboss
parents: 837
diff changeset
726 if exists('g:xmldata_'.b:html_omni_flavor)
8e5830943bff updated for version 7.0e04
vimboss
parents: 837
diff changeset
727 exe 'let b:html_omni = g:xmldata_'.b:html_omni_flavor
8e5830943bff updated for version 7.0e04
vimboss
parents: 837
diff changeset
728 else
8e5830943bff updated for version 7.0e04
vimboss
parents: 837
diff changeset
729 exe 'runtime! autoload/xml/'.b:html_omni_flavor.'.vim'
8e5830943bff updated for version 7.0e04
vimboss
parents: 837
diff changeset
730 exe 'let b:html_omni = g:xmldata_'.b:html_omni_flavor
8e5830943bff updated for version 7.0e04
vimboss
parents: 837
diff changeset
731 endif
836
5a7843c57316 updated for version 7.0e02
vimboss
parents: 829
diff changeset
732 endfunction
5a7843c57316 updated for version 7.0e02
vimboss
parents: 829
diff changeset
733 " }}}
844
d3bbb5dd3913 updated for version 7.0f02
vimboss
parents: 842
diff changeset
734 function! htmlcomplete#CheckDoctype() " {{{
d3bbb5dd3913 updated for version 7.0f02
vimboss
parents: 842
diff changeset
735 if exists('b:html_omni_flavor')
d3bbb5dd3913 updated for version 7.0f02
vimboss
parents: 842
diff changeset
736 let old_flavor = b:html_omni_flavor
d3bbb5dd3913 updated for version 7.0f02
vimboss
parents: 842
diff changeset
737 else
d3bbb5dd3913 updated for version 7.0f02
vimboss
parents: 842
diff changeset
738 let old_flavor = ''
d3bbb5dd3913 updated for version 7.0f02
vimboss
parents: 842
diff changeset
739 endif
d3bbb5dd3913 updated for version 7.0f02
vimboss
parents: 842
diff changeset
740 let i = 1
d3bbb5dd3913 updated for version 7.0f02
vimboss
parents: 842
diff changeset
741 while i < 10 && i < line("$")
d3bbb5dd3913 updated for version 7.0f02
vimboss
parents: 842
diff changeset
742 let line = getline(i)
d3bbb5dd3913 updated for version 7.0f02
vimboss
parents: 842
diff changeset
743 if line =~ '<!DOCTYPE.*\<DTD HTML 3\.2'
d3bbb5dd3913 updated for version 7.0f02
vimboss
parents: 842
diff changeset
744 let b:html_omni_flavor = 'html32'
d3bbb5dd3913 updated for version 7.0f02
vimboss
parents: 842
diff changeset
745 let b:html_doctype = 1
d3bbb5dd3913 updated for version 7.0f02
vimboss
parents: 842
diff changeset
746 break
d3bbb5dd3913 updated for version 7.0f02
vimboss
parents: 842
diff changeset
747 elseif line =~ '<!DOCTYPE.*\<DTD HTML 4\.0 Transitional'
d3bbb5dd3913 updated for version 7.0f02
vimboss
parents: 842
diff changeset
748 let b:html_omni_flavor = 'html40t'
d3bbb5dd3913 updated for version 7.0f02
vimboss
parents: 842
diff changeset
749 let b:html_doctype = 1
d3bbb5dd3913 updated for version 7.0f02
vimboss
parents: 842
diff changeset
750 break
d3bbb5dd3913 updated for version 7.0f02
vimboss
parents: 842
diff changeset
751 elseif line =~ '<!DOCTYPE.*\<DTD HTML 4\.0 Frameset'
d3bbb5dd3913 updated for version 7.0f02
vimboss
parents: 842
diff changeset
752 let b:html_omni_flavor = 'html40f'
d3bbb5dd3913 updated for version 7.0f02
vimboss
parents: 842
diff changeset
753 let b:html_doctype = 1
d3bbb5dd3913 updated for version 7.0f02
vimboss
parents: 842
diff changeset
754 break
d3bbb5dd3913 updated for version 7.0f02
vimboss
parents: 842
diff changeset
755 elseif line =~ '<!DOCTYPE.*\<DTD HTML 4\.0'
d3bbb5dd3913 updated for version 7.0f02
vimboss
parents: 842
diff changeset
756 let b:html_omni_flavor = 'html40s'
d3bbb5dd3913 updated for version 7.0f02
vimboss
parents: 842
diff changeset
757 let b:html_doctype = 1
d3bbb5dd3913 updated for version 7.0f02
vimboss
parents: 842
diff changeset
758 break
d3bbb5dd3913 updated for version 7.0f02
vimboss
parents: 842
diff changeset
759 elseif line =~ '<!DOCTYPE.*\<DTD HTML 4\.01 Transitional'
d3bbb5dd3913 updated for version 7.0f02
vimboss
parents: 842
diff changeset
760 let b:html_omni_flavor = 'html401t'
d3bbb5dd3913 updated for version 7.0f02
vimboss
parents: 842
diff changeset
761 let b:html_doctype = 1
d3bbb5dd3913 updated for version 7.0f02
vimboss
parents: 842
diff changeset
762 break
d3bbb5dd3913 updated for version 7.0f02
vimboss
parents: 842
diff changeset
763 elseif line =~ '<!DOCTYPE.*\<DTD HTML 4\.01 Frameset'
d3bbb5dd3913 updated for version 7.0f02
vimboss
parents: 842
diff changeset
764 let b:html_omni_flavor = 'html401f'
d3bbb5dd3913 updated for version 7.0f02
vimboss
parents: 842
diff changeset
765 let b:html_doctype = 1
d3bbb5dd3913 updated for version 7.0f02
vimboss
parents: 842
diff changeset
766 break
d3bbb5dd3913 updated for version 7.0f02
vimboss
parents: 842
diff changeset
767 elseif line =~ '<!DOCTYPE.*\<DTD HTML 4\.01'
d3bbb5dd3913 updated for version 7.0f02
vimboss
parents: 842
diff changeset
768 let b:html_omni_flavor = 'html401s'
d3bbb5dd3913 updated for version 7.0f02
vimboss
parents: 842
diff changeset
769 let b:html_doctype = 1
d3bbb5dd3913 updated for version 7.0f02
vimboss
parents: 842
diff changeset
770 break
d3bbb5dd3913 updated for version 7.0f02
vimboss
parents: 842
diff changeset
771 elseif line =~ '<!DOCTYPE.*\<DTD XHTML 1\.0 Transitional'
d3bbb5dd3913 updated for version 7.0f02
vimboss
parents: 842
diff changeset
772 let b:html_omni_flavor = 'xhtml10t'
d3bbb5dd3913 updated for version 7.0f02
vimboss
parents: 842
diff changeset
773 let b:html_doctype = 1
d3bbb5dd3913 updated for version 7.0f02
vimboss
parents: 842
diff changeset
774 break
d3bbb5dd3913 updated for version 7.0f02
vimboss
parents: 842
diff changeset
775 elseif line =~ '<!DOCTYPE.*\<DTD XHTML 1\.0 Frameset'
d3bbb5dd3913 updated for version 7.0f02
vimboss
parents: 842
diff changeset
776 let b:html_omni_flavor = 'xhtml10f'
d3bbb5dd3913 updated for version 7.0f02
vimboss
parents: 842
diff changeset
777 let b:html_doctype = 1
d3bbb5dd3913 updated for version 7.0f02
vimboss
parents: 842
diff changeset
778 break
d3bbb5dd3913 updated for version 7.0f02
vimboss
parents: 842
diff changeset
779 elseif line =~ '<!DOCTYPE.*\<DTD XHTML 1\.0 Strict'
d3bbb5dd3913 updated for version 7.0f02
vimboss
parents: 842
diff changeset
780 let b:html_omni_flavor = 'xhtml10s'
d3bbb5dd3913 updated for version 7.0f02
vimboss
parents: 842
diff changeset
781 let b:html_doctype = 1
d3bbb5dd3913 updated for version 7.0f02
vimboss
parents: 842
diff changeset
782 break
d3bbb5dd3913 updated for version 7.0f02
vimboss
parents: 842
diff changeset
783 elseif line =~ '<!DOCTYPE.*\<DTD XHTML 1\.1'
d3bbb5dd3913 updated for version 7.0f02
vimboss
parents: 842
diff changeset
784 let b:html_omni_flavor = 'xhtml11'
d3bbb5dd3913 updated for version 7.0f02
vimboss
parents: 842
diff changeset
785 let b:html_doctype = 1
d3bbb5dd3913 updated for version 7.0f02
vimboss
parents: 842
diff changeset
786 break
d3bbb5dd3913 updated for version 7.0f02
vimboss
parents: 842
diff changeset
787 endif
d3bbb5dd3913 updated for version 7.0f02
vimboss
parents: 842
diff changeset
788 let i += 1
d3bbb5dd3913 updated for version 7.0f02
vimboss
parents: 842
diff changeset
789 endwhile
d3bbb5dd3913 updated for version 7.0f02
vimboss
parents: 842
diff changeset
790 if !exists("b:html_doctype")
d3bbb5dd3913 updated for version 7.0f02
vimboss
parents: 842
diff changeset
791 return
d3bbb5dd3913 updated for version 7.0f02
vimboss
parents: 842
diff changeset
792 else
d3bbb5dd3913 updated for version 7.0f02
vimboss
parents: 842
diff changeset
793 " Tie g:xmldata with b:html_omni this way we need to sourca data file only
d3bbb5dd3913 updated for version 7.0f02
vimboss
parents: 842
diff changeset
794 " once, not every time per buffer.
d3bbb5dd3913 updated for version 7.0f02
vimboss
parents: 842
diff changeset
795 if old_flavor == b:html_omni_flavor
d3bbb5dd3913 updated for version 7.0f02
vimboss
parents: 842
diff changeset
796 return
d3bbb5dd3913 updated for version 7.0f02
vimboss
parents: 842
diff changeset
797 else
d3bbb5dd3913 updated for version 7.0f02
vimboss
parents: 842
diff changeset
798 if exists('g:xmldata_'.b:html_omni_flavor)
d3bbb5dd3913 updated for version 7.0f02
vimboss
parents: 842
diff changeset
799 exe 'let b:html_omni = g:xmldata_'.b:html_omni_flavor
d3bbb5dd3913 updated for version 7.0f02
vimboss
parents: 842
diff changeset
800 else
d3bbb5dd3913 updated for version 7.0f02
vimboss
parents: 842
diff changeset
801 exe 'runtime! autoload/xml/'.b:html_omni_flavor.'.vim'
d3bbb5dd3913 updated for version 7.0f02
vimboss
parents: 842
diff changeset
802 exe 'let b:html_omni = g:xmldata_'.b:html_omni_flavor
d3bbb5dd3913 updated for version 7.0f02
vimboss
parents: 842
diff changeset
803 endif
d3bbb5dd3913 updated for version 7.0f02
vimboss
parents: 842
diff changeset
804 return
d3bbb5dd3913 updated for version 7.0f02
vimboss
parents: 842
diff changeset
805 endif
d3bbb5dd3913 updated for version 7.0f02
vimboss
parents: 842
diff changeset
806 endif
d3bbb5dd3913 updated for version 7.0f02
vimboss
parents: 842
diff changeset
807 endfunction
d3bbb5dd3913 updated for version 7.0f02
vimboss
parents: 842
diff changeset
808 " }}}
659
d6a69271cb9a updated for version 7.0194
vimboss
parents: 649
diff changeset
809 " vim:set foldmethod=marker: