annotate runtime/autoload/htmlcomplete.vim @ 15547:1dd0a47f4be2 v8.1.0781

patch 8.1.0781: build error when using if_xcmdsrv.c commit https://github.com/vim/vim/commit/a502caab8bd396316a6eb5cb821b0a0df55c502a Author: Bram Moolenaar <Bram@vim.org> Date: Sat Jan 19 18:23:41 2019 +0100 patch 8.1.0781: build error when using if_xcmdsrv.c Problem: Build error when using if_xcmdsrv.c. Solution: Add missing part of 8.1.0779.
author Bram Moolenaar <Bram@vim.org>
date Sat, 19 Jan 2019 18:30:07 +0100
parents 7b83c190d370
children 03b854983b14
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 )
6009
7b83c190d370 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2788
diff changeset
4 " Last Change: 2014 Jun 20
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
548
f43150a669dc updated for version 7.0155
vimboss
parents: 532
diff changeset
248 if context == ''
f43150a669dc updated for version 7.0155
vimboss
parents: 532
diff changeset
249 let tag = ''
f43150a669dc updated for version 7.0155
vimboss
parents: 532
diff changeset
250 else
f43150a669dc updated for version 7.0155
vimboss
parents: 532
diff changeset
251 let tag = split(context)[0]
841
c2cae213194d updated for version 7.0e07
vimboss
parents: 838
diff changeset
252 " Detect if tag is uppercase to return in proper case,
c2cae213194d updated for version 7.0e07
vimboss
parents: 838
diff changeset
253 " we need to make it lowercase for processing
c2cae213194d updated for version 7.0e07
vimboss
parents: 838
diff changeset
254 if tag =~ '^[A-Z]*$'
837
6bb1fa855dc9 updated for version 7.0e03
vimboss
parents: 836
diff changeset
255 let uppercase_tag = 1
6bb1fa855dc9 updated for version 7.0e03
vimboss
parents: 836
diff changeset
256 let tag = tolower(tag)
6bb1fa855dc9 updated for version 7.0e03
vimboss
parents: 836
diff changeset
257 else
6bb1fa855dc9 updated for version 7.0e03
vimboss
parents: 836
diff changeset
258 let uppercase_tag = 0
6bb1fa855dc9 updated for version 7.0e03
vimboss
parents: 836
diff changeset
259 endif
548
f43150a669dc updated for version 7.0155
vimboss
parents: 532
diff changeset
260 endif
531
da9142bd190a updated for version 7.0149
vimboss
parents: 529
diff changeset
261 " Get last word, it should be attr name
548
f43150a669dc updated for version 7.0155
vimboss
parents: 532
diff changeset
262 let attr = matchstr(context, '.*\s\zs.*')
523
a7ae7e043e43 updated for version 7.0146
vimboss
parents:
diff changeset
263 " Possible situations where any prediction would be difficult:
a7ae7e043e43 updated for version 7.0146
vimboss
parents:
diff changeset
264 " 1. Events attributes
548
f43150a669dc updated for version 7.0155
vimboss
parents: 532
diff changeset
265 if context =~ '\s'
523
a7ae7e043e43 updated for version 7.0146
vimboss
parents:
diff changeset
266 " Sort out style, class, and on* cases
659
d6a69271cb9a updated for version 7.0194
vimboss
parents: 649
diff changeset
267 if context =~? "\\(on[a-z]*\\|id\\|style\\|class\\)\\s*=\\s*[\"']"
d6a69271cb9a updated for version 7.0194
vimboss
parents: 649
diff changeset
268 " Id, class completion {{{
d6a69271cb9a updated for version 7.0194
vimboss
parents: 649
diff changeset
269 if context =~? "\\(id\\|class\\)\\s*=\\s*[\"'][a-zA-Z0-9_ -]*$"
d6a69271cb9a updated for version 7.0194
vimboss
parents: 649
diff changeset
270 if context =~? "class\\s*=\\s*[\"'][a-zA-Z0-9_ -]*$"
532
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 531
diff changeset
271 let search_for = "class"
659
d6a69271cb9a updated for version 7.0194
vimboss
parents: 649
diff changeset
272 elseif context =~? "id\\s*=\\s*[\"'][a-zA-Z0-9_ -]*$"
532
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 531
diff changeset
273 let search_for = "id"
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 531
diff changeset
274 endif
531
da9142bd190a updated for version 7.0149
vimboss
parents: 529
diff changeset
275 " Handle class name completion
da9142bd190a updated for version 7.0149
vimboss
parents: 529
diff changeset
276 " 1. Find lines of <link stylesheet>
da9142bd190a updated for version 7.0149
vimboss
parents: 529
diff changeset
277 " 1a. Check file for @import
da9142bd190a updated for version 7.0149
vimboss
parents: 529
diff changeset
278 " 2. Extract filename(s?) of stylesheet,
da9142bd190a updated for version 7.0149
vimboss
parents: 529
diff changeset
279 call cursor(1,1)
da9142bd190a updated for version 7.0149
vimboss
parents: 529
diff changeset
280 let head = getline(search('<head\>'), search('<\/head>'))
da9142bd190a updated for version 7.0149
vimboss
parents: 529
diff changeset
281 let headjoined = join(copy(head), ' ')
da9142bd190a updated for version 7.0149
vimboss
parents: 529
diff changeset
282 if headjoined =~ '<style'
557
862863033fdd updated for version 7.0158
vimboss
parents: 553
diff changeset
283 " Remove possibly confusing CSS operators
532
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 531
diff changeset
284 let stylehead = substitute(headjoined, '+>\*[,', ' ', 'g')
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 531
diff changeset
285 if search_for == 'class'
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 531
diff changeset
286 let styleheadlines = split(stylehead)
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 531
diff changeset
287 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
288 else
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 531
diff changeset
289 let stylesheet = split(headjoined, '[{}]')
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 531
diff changeset
290 " Get all lines which fit id syntax
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 531
diff changeset
291 let classlines = filter(copy(stylesheet), "v:val =~ '#[a-zA-Z0-9_-]\\+'")
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 531
diff changeset
292 " Filter out possible color definitions
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 531
diff changeset
293 call filter(classlines, "v:val !~ ':\\s*#[a-zA-Z0-9_-]\\+'")
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 531
diff changeset
294 " Filter out complex border definitions
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 531
diff changeset
295 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
296 let templines = join(classlines, ' ')
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 531
diff changeset
297 let headclasslines = split(templines)
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 531
diff changeset
298 call filter(headclasslines, "v:val =~ '#[a-zA-Z0-9_-]\\+'")
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 531
diff changeset
299 endif
531
da9142bd190a updated for version 7.0149
vimboss
parents: 529
diff changeset
300 let internal = 1
da9142bd190a updated for version 7.0149
vimboss
parents: 529
diff changeset
301 else
da9142bd190a updated for version 7.0149
vimboss
parents: 529
diff changeset
302 let internal = 0
da9142bd190a updated for version 7.0149
vimboss
parents: 529
diff changeset
303 endif
da9142bd190a updated for version 7.0149
vimboss
parents: 529
diff changeset
304 let styletable = []
da9142bd190a updated for version 7.0149
vimboss
parents: 529
diff changeset
305 let secimportfiles = []
da9142bd190a updated for version 7.0149
vimboss
parents: 529
diff changeset
306 let filestable = filter(copy(head), "v:val =~ '\\(@import\\|link.*stylesheet\\)'")
da9142bd190a updated for version 7.0149
vimboss
parents: 529
diff changeset
307 for line in filestable
da9142bd190a updated for version 7.0149
vimboss
parents: 529
diff changeset
308 if line =~ "@import"
da9142bd190a updated for version 7.0149
vimboss
parents: 529
diff changeset
309 let styletable += [matchstr(line, "import\\s\\+\\(url(\\)\\?[\"']\\?\\zs\\f\\+\\ze")]
da9142bd190a updated for version 7.0149
vimboss
parents: 529
diff changeset
310 elseif line =~ "<link"
da9142bd190a updated for version 7.0149
vimboss
parents: 529
diff changeset
311 let styletable += [matchstr(line, "href\\s*=\\s*[\"']\\zs\\f\\+\\ze")]
da9142bd190a updated for version 7.0149
vimboss
parents: 529
diff changeset
312 endif
da9142bd190a updated for version 7.0149
vimboss
parents: 529
diff changeset
313 endfor
532
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 531
diff changeset
314 for file in styletable
531
da9142bd190a updated for version 7.0149
vimboss
parents: 529
diff changeset
315 if filereadable(file)
da9142bd190a updated for version 7.0149
vimboss
parents: 529
diff changeset
316 let stylesheet = readfile(file)
da9142bd190a updated for version 7.0149
vimboss
parents: 529
diff changeset
317 let secimport = filter(copy(stylesheet), "v:val =~ '@import'")
da9142bd190a updated for version 7.0149
vimboss
parents: 529
diff changeset
318 if len(secimport) > 0
da9142bd190a updated for version 7.0149
vimboss
parents: 529
diff changeset
319 for line in secimport
532
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 531
diff changeset
320 let secfile = matchstr(line, "import\\s\\+\\(url(\\)\\?[\"']\\?\\zs\\f\\+\\ze")
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 531
diff changeset
321 let secfile = fnamemodify(file, ":p:h").'/'.secfile
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 531
diff changeset
322 let secimportfiles += [secfile]
531
da9142bd190a updated for version 7.0149
vimboss
parents: 529
diff changeset
323 endfor
da9142bd190a updated for version 7.0149
vimboss
parents: 529
diff changeset
324 endif
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 endfor
da9142bd190a updated for version 7.0149
vimboss
parents: 529
diff changeset
327 let cssfiles = styletable + secimportfiles
da9142bd190a updated for version 7.0149
vimboss
parents: 529
diff changeset
328 let classes = []
da9142bd190a updated for version 7.0149
vimboss
parents: 529
diff changeset
329 for file in cssfiles
2788
0877b8d6370e Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 1120
diff changeset
330 let classlines = []
531
da9142bd190a updated for version 7.0149
vimboss
parents: 529
diff changeset
331 if filereadable(file)
da9142bd190a updated for version 7.0149
vimboss
parents: 529
diff changeset
332 let stylesheet = readfile(file)
532
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 531
diff changeset
333 let stylefile = join(stylesheet, ' ')
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 531
diff changeset
334 let stylefile = substitute(stylefile, '+>\*[,', ' ', 'g')
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 531
diff changeset
335 if search_for == 'class'
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 531
diff changeset
336 let stylesheet = split(stylefile)
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 531
diff changeset
337 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
338 else
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 531
diff changeset
339 let stylesheet = split(stylefile, '[{}]')
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 531
diff changeset
340 " Get all lines which fit id syntax
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 531
diff changeset
341 let classlines = filter(copy(stylesheet), "v:val =~ '#[a-zA-Z0-9_-]\\+'")
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 531
diff changeset
342 " Filter out possible color definitions
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 531
diff changeset
343 call filter(classlines, "v:val !~ ':\\s*#[a-zA-Z0-9_-]\\+'")
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 531
diff changeset
344 " Filter out complex border definitions
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 531
diff changeset
345 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
346 let templines = join(classlines, ' ')
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 531
diff changeset
347 let stylelines = split(templines)
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 531
diff changeset
348 let classlines = filter(stylelines, "v:val =~ '#[a-zA-Z0-9_-]\\+'")
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 531
diff changeset
349
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 531
diff changeset
350 endif
531
da9142bd190a updated for version 7.0149
vimboss
parents: 529
diff changeset
351 endif
da9142bd190a updated for version 7.0149
vimboss
parents: 529
diff changeset
352 " We gathered classes definitions from all external files
da9142bd190a updated for version 7.0149
vimboss
parents: 529
diff changeset
353 let classes += classlines
da9142bd190a updated for version 7.0149
vimboss
parents: 529
diff changeset
354 endfor
da9142bd190a updated for version 7.0149
vimboss
parents: 529
diff changeset
355 if internal == 1
da9142bd190a updated for version 7.0149
vimboss
parents: 529
diff changeset
356 let classes += headclasslines
da9142bd190a updated for version 7.0149
vimboss
parents: 529
diff changeset
357 endif
532
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 531
diff changeset
358
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 531
diff changeset
359 if search_for == 'class'
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 531
diff changeset
360 let elements = {}
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 531
diff changeset
361 for element in classes
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 531
diff changeset
362 if element =~ '^\.'
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 531
diff changeset
363 let class = matchstr(element, '^\.\zs[a-zA-Z][a-zA-Z0-9_-]*\ze')
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 531
diff changeset
364 let class = substitute(class, ':.*', '', '')
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 531
diff changeset
365 if has_key(elements, 'common')
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 531
diff changeset
366 let elements['common'] .= ' '.class
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 531
diff changeset
367 else
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 531
diff changeset
368 let elements['common'] = class
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 531
diff changeset
369 endif
531
da9142bd190a updated for version 7.0149
vimboss
parents: 529
diff changeset
370 else
532
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 531
diff changeset
371 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
372 let tagname = tolower(matchstr(element, '[a-zA-Z1-6]*\ze.'))
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 531
diff changeset
373 if tagname != ''
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 531
diff changeset
374 if has_key(elements, tagname)
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 531
diff changeset
375 let elements[tagname] .= ' '.class
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 531
diff changeset
376 else
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 531
diff changeset
377 let elements[tagname] = class
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 531
diff changeset
378 endif
531
da9142bd190a updated for version 7.0149
vimboss
parents: 529
diff changeset
379 endif
da9142bd190a updated for version 7.0149
vimboss
parents: 529
diff changeset
380 endif
532
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 531
diff changeset
381 endfor
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 531
diff changeset
382
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 531
diff changeset
383 if has_key(elements, tag) && has_key(elements, 'common')
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 531
diff changeset
384 let values = split(elements[tag]." ".elements['common'])
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 531
diff changeset
385 elseif has_key(elements, tag) && !has_key(elements, 'common')
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 531
diff changeset
386 let values = split(elements[tag])
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 531
diff changeset
387 elseif !has_key(elements, tag) && has_key(elements, 'common')
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 531
diff changeset
388 let values = split(elements['common'])
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 531
diff changeset
389 else
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 531
diff changeset
390 return []
531
da9142bd190a updated for version 7.0149
vimboss
parents: 529
diff changeset
391 endif
da9142bd190a updated for version 7.0149
vimboss
parents: 529
diff changeset
392
532
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 531
diff changeset
393 elseif search_for == 'id'
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 531
diff changeset
394 " Find used IDs
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 531
diff changeset
395 " 1. Catch whole file
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 531
diff changeset
396 let filelines = getline(1, line('$'))
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 531
diff changeset
397 " 2. Find lines with possible id
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 531
diff changeset
398 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
399 " 3a. Join all filtered lines
532
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 531
diff changeset
400 let id_string = join(used_id_lines, ' ')
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 531
diff changeset
401 " 3b. And split them to be sure each id is in separate item
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 531
diff changeset
402 let id_list = split(id_string, 'id\s*=\s*')
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 531
diff changeset
403 " 4. Extract id values
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 531
diff changeset
404 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
405 let joined_used_id = ','.join(used_id, ',').','
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 531
diff changeset
406
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 531
diff changeset
407 let allvalues = map(classes, 'matchstr(v:val, ".*#\\zs[a-zA-Z0-9_-]\\+")')
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 531
diff changeset
408
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 531
diff changeset
409 let values = []
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 531
diff changeset
410
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 531
diff changeset
411 for element in classes
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 531
diff changeset
412 if joined_used_id !~ ','.element.','
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 531
diff changeset
413 let values += [element]
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 531
diff changeset
414 endif
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 531
diff changeset
415
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 531
diff changeset
416 endfor
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 531
diff changeset
417
531
da9142bd190a updated for version 7.0149
vimboss
parents: 529
diff changeset
418 endif
da9142bd190a updated for version 7.0149
vimboss
parents: 529
diff changeset
419
da9142bd190a updated for version 7.0149
vimboss
parents: 529
diff changeset
420 " We need special version of sbase
548
f43150a669dc updated for version 7.0155
vimboss
parents: 532
diff changeset
421 let classbase = matchstr(context, ".*[\"']")
532
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 531
diff changeset
422 let classquote = matchstr(classbase, '.$')
531
da9142bd190a updated for version 7.0149
vimboss
parents: 529
diff changeset
423
da9142bd190a updated for version 7.0149
vimboss
parents: 529
diff changeset
424 let entered_class = matchstr(attr, ".*=\\s*[\"']\\zs.*")
da9142bd190a updated for version 7.0149
vimboss
parents: 529
diff changeset
425
da9142bd190a updated for version 7.0149
vimboss
parents: 529
diff changeset
426 for m in sort(values)
da9142bd190a updated for version 7.0149
vimboss
parents: 529
diff changeset
427 if m =~? '^'.entered_class
548
f43150a669dc updated for version 7.0155
vimboss
parents: 532
diff changeset
428 call add(res, m . classquote)
531
da9142bd190a updated for version 7.0149
vimboss
parents: 529
diff changeset
429 elseif m =~? entered_class
548
f43150a669dc updated for version 7.0155
vimboss
parents: 532
diff changeset
430 call add(res2, m . classquote)
531
da9142bd190a updated for version 7.0149
vimboss
parents: 529
diff changeset
431 endif
da9142bd190a updated for version 7.0149
vimboss
parents: 529
diff changeset
432 endfor
da9142bd190a updated for version 7.0149
vimboss
parents: 529
diff changeset
433
da9142bd190a updated for version 7.0149
vimboss
parents: 529
diff changeset
434 return res + res2
da9142bd190a updated for version 7.0149
vimboss
parents: 529
diff changeset
435
659
d6a69271cb9a updated for version 7.0194
vimboss
parents: 649
diff changeset
436 elseif context =~? "style\\s*=\\s*[\"'][^\"']*$"
548
f43150a669dc updated for version 7.0155
vimboss
parents: 532
diff changeset
437 return csscomplete#CompleteCSS(0, context)
531
da9142bd190a updated for version 7.0149
vimboss
parents: 529
diff changeset
438
da9142bd190a updated for version 7.0149
vimboss
parents: 529
diff changeset
439 endif
659
d6a69271cb9a updated for version 7.0194
vimboss
parents: 649
diff changeset
440 " }}}
d6a69271cb9a updated for version 7.0194
vimboss
parents: 649
diff changeset
441 " Complete on-events {{{
d6a69271cb9a updated for version 7.0194
vimboss
parents: 649
diff changeset
442 if context =~? 'on[a-z]*\s*=\s*\(''[^'']*\|"[^"]*\)$'
d6a69271cb9a updated for version 7.0194
vimboss
parents: 649
diff changeset
443 " We have to:
d6a69271cb9a updated for version 7.0194
vimboss
parents: 649
diff changeset
444 " 1. Find external files
d6a69271cb9a updated for version 7.0194
vimboss
parents: 649
diff changeset
445 let b:js_extfiles = []
d6a69271cb9a updated for version 7.0194
vimboss
parents: 649
diff changeset
446 let l = line('.')
d6a69271cb9a updated for version 7.0194
vimboss
parents: 649
diff changeset
447 let c = col('.')
d6a69271cb9a updated for version 7.0194
vimboss
parents: 649
diff changeset
448 call cursor(1,1)
d6a69271cb9a updated for version 7.0194
vimboss
parents: 649
diff changeset
449 while search('<\@<=script\>', 'W') && line('.') <= l
d6a69271cb9a updated for version 7.0194
vimboss
parents: 649
diff changeset
450 if synIDattr(synID(line('.'),col('.')-1,0),"name") !~? 'comment'
d6a69271cb9a updated for version 7.0194
vimboss
parents: 649
diff changeset
451 let sname = matchstr(getline('.'), '<script[^>]*src\s*=\s*\([''"]\)\zs.\{-}\ze\1')
d6a69271cb9a updated for version 7.0194
vimboss
parents: 649
diff changeset
452 if filereadable(sname)
d6a69271cb9a updated for version 7.0194
vimboss
parents: 649
diff changeset
453 let b:js_extfiles += readfile(sname)
d6a69271cb9a updated for version 7.0194
vimboss
parents: 649
diff changeset
454 endif
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 endwhile
d6a69271cb9a updated for version 7.0194
vimboss
parents: 649
diff changeset
457 " 2. Find at least one <script> tag
d6a69271cb9a updated for version 7.0194
vimboss
parents: 649
diff changeset
458 call cursor(1,1)
d6a69271cb9a updated for version 7.0194
vimboss
parents: 649
diff changeset
459 let js_scripttags = []
d6a69271cb9a updated for version 7.0194
vimboss
parents: 649
diff changeset
460 while search('<script\>', 'W') && line('.') < l
d6a69271cb9a updated for version 7.0194
vimboss
parents: 649
diff changeset
461 if matchstr(getline('.'), '<script[^>]*src') == ''
d6a69271cb9a updated for version 7.0194
vimboss
parents: 649
diff changeset
462 let js_scripttag = getline(line('.'), search('</script>', 'W'))
d6a69271cb9a updated for version 7.0194
vimboss
parents: 649
diff changeset
463 let js_scripttags += js_scripttag
d6a69271cb9a updated for version 7.0194
vimboss
parents: 649
diff changeset
464 endif
d6a69271cb9a updated for version 7.0194
vimboss
parents: 649
diff changeset
465 endwhile
d6a69271cb9a updated for version 7.0194
vimboss
parents: 649
diff changeset
466 let b:js_extfiles += js_scripttags
d6a69271cb9a updated for version 7.0194
vimboss
parents: 649
diff changeset
467
d6a69271cb9a updated for version 7.0194
vimboss
parents: 649
diff changeset
468 " 3. Proper call for javascriptcomplete#CompleteJS
d6a69271cb9a updated for version 7.0194
vimboss
parents: 649
diff changeset
469 call cursor(l,c)
667
9090f866cd57 updated for version 7.0197
vimboss
parents: 659
diff changeset
470 let js_context = matchstr(a:base, '\k\+$')
659
d6a69271cb9a updated for version 7.0194
vimboss
parents: 649
diff changeset
471 let js_shortcontext = substitute(a:base, js_context.'$', '', '')
d6a69271cb9a updated for version 7.0194
vimboss
parents: 649
diff changeset
472 let b:compl_context = context
d6a69271cb9a updated for version 7.0194
vimboss
parents: 649
diff changeset
473 let b:jsrange = [l, l]
d6a69271cb9a updated for version 7.0194
vimboss
parents: 649
diff changeset
474 unlet! l c
d6a69271cb9a updated for version 7.0194
vimboss
parents: 649
diff changeset
475 return javascriptcomplete#CompleteJS(0, js_context)
d6a69271cb9a updated for version 7.0194
vimboss
parents: 649
diff changeset
476
d6a69271cb9a updated for version 7.0194
vimboss
parents: 649
diff changeset
477 endif
856
8cd729851562 updated for version 7.0g
vimboss
parents: 844
diff changeset
478
659
d6a69271cb9a updated for version 7.0194
vimboss
parents: 649
diff changeset
479 " }}}
d6a69271cb9a updated for version 7.0194
vimboss
parents: 649
diff changeset
480 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
481 " Now we have context stripped from all chars up to style/class.
523
a7ae7e043e43 updated for version 7.0146
vimboss
parents:
diff changeset
482 " It may fail with some strange style value combinations.
a7ae7e043e43 updated for version 7.0146
vimboss
parents:
diff changeset
483 if stripbase !~ "[\"']"
a7ae7e043e43 updated for version 7.0146
vimboss
parents:
diff changeset
484 return []
a7ae7e043e43 updated for version 7.0146
vimboss
parents:
diff changeset
485 endif
a7ae7e043e43 updated for version 7.0146
vimboss
parents:
diff changeset
486 endif
659
d6a69271cb9a updated for version 7.0194
vimboss
parents: 649
diff changeset
487 " Value of attribute completion {{{
523
a7ae7e043e43 updated for version 7.0146
vimboss
parents:
diff changeset
488 " If attr contains =\s*[\"'] we catched value of attribute
837
6bb1fa855dc9 updated for version 7.0e03
vimboss
parents: 836
diff changeset
489 if attr =~ "=\s*[\"']" || attr =~ "=\s*$"
523
a7ae7e043e43 updated for version 7.0146
vimboss
parents:
diff changeset
490 " Let do attribute specific completion
a7ae7e043e43 updated for version 7.0146
vimboss
parents:
diff changeset
491 let attrname = matchstr(attr, '.*\ze\s*=')
837
6bb1fa855dc9 updated for version 7.0e03
vimboss
parents: 836
diff changeset
492 let entered_value = matchstr(attr, ".*=\\s*[\"']\\?\\zs.*")
523
a7ae7e043e43 updated for version 7.0146
vimboss
parents:
diff changeset
493 let values = []
1120
e6db096b07a1 updated for version 7.1a
vimboss
parents: 856
diff changeset
494 " Load data {{{
e6db096b07a1 updated for version 7.1a
vimboss
parents: 856
diff changeset
495 if !exists("b:html_doctype")
e6db096b07a1 updated for version 7.1a
vimboss
parents: 856
diff changeset
496 call htmlcomplete#CheckDoctype()
e6db096b07a1 updated for version 7.1a
vimboss
parents: 856
diff changeset
497 endif
e6db096b07a1 updated for version 7.1a
vimboss
parents: 856
diff changeset
498 if !exists("b:html_omni")
e6db096b07a1 updated for version 7.1a
vimboss
parents: 856
diff changeset
499 "runtime! autoload/xml/xhtml10s.vim
e6db096b07a1 updated for version 7.1a
vimboss
parents: 856
diff changeset
500 call htmlcomplete#LoadData()
e6db096b07a1 updated for version 7.1a
vimboss
parents: 856
diff changeset
501 endif
e6db096b07a1 updated for version 7.1a
vimboss
parents: 856
diff changeset
502 " }}}
836
5a7843c57316 updated for version 7.0e02
vimboss
parents: 829
diff changeset
503 if attrname == 'href'
523
a7ae7e043e43 updated for version 7.0146
vimboss
parents:
diff changeset
504 " Now we are looking for local anchors defined by name or id
a7ae7e043e43 updated for version 7.0146
vimboss
parents:
diff changeset
505 if entered_value =~ '^#'
a7ae7e043e43 updated for version 7.0146
vimboss
parents:
diff changeset
506 let file = join(getline(1, line('$')), ' ')
a7ae7e043e43 updated for version 7.0146
vimboss
parents:
diff changeset
507 " Split it be sure there will be one id/name element in
a7ae7e043e43 updated for version 7.0146
vimboss
parents:
diff changeset
508 " item, it will be also first word [a-zA-Z0-9_-] in element
a7ae7e043e43 updated for version 7.0146
vimboss
parents:
diff changeset
509 let oneelement = split(file, "\\(meta \\)\\@<!\\(name\\|id\\)\\s*=\\s*[\"']")
a7ae7e043e43 updated for version 7.0146
vimboss
parents:
diff changeset
510 for i in oneelement
a7ae7e043e43 updated for version 7.0146
vimboss
parents:
diff changeset
511 let values += ['#'.matchstr(i, "^[a-zA-Z][a-zA-Z0-9%_-]*")]
a7ae7e043e43 updated for version 7.0146
vimboss
parents:
diff changeset
512 endfor
a7ae7e043e43 updated for version 7.0146
vimboss
parents:
diff changeset
513 endif
836
5a7843c57316 updated for version 7.0e02
vimboss
parents: 829
diff changeset
514 else
838
8e5830943bff updated for version 7.0e04
vimboss
parents: 837
diff changeset
515 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
516 let values = b:html_omni[tag][1][attrname]
836
5a7843c57316 updated for version 7.0e02
vimboss
parents: 829
diff changeset
517 else
5a7843c57316 updated for version 7.0e02
vimboss
parents: 829
diff changeset
518 return []
523
a7ae7e043e43 updated for version 7.0146
vimboss
parents:
diff changeset
519 endif
a7ae7e043e43 updated for version 7.0146
vimboss
parents:
diff changeset
520 endif
a7ae7e043e43 updated for version 7.0146
vimboss
parents:
diff changeset
521
a7ae7e043e43 updated for version 7.0146
vimboss
parents:
diff changeset
522 if len(values) == 0
a7ae7e043e43 updated for version 7.0146
vimboss
parents:
diff changeset
523 return []
a7ae7e043e43 updated for version 7.0146
vimboss
parents:
diff changeset
524 endif
a7ae7e043e43 updated for version 7.0146
vimboss
parents:
diff changeset
525
a7ae7e043e43 updated for version 7.0146
vimboss
parents:
diff changeset
526 " We need special version of sbase
548
f43150a669dc updated for version 7.0155
vimboss
parents: 532
diff changeset
527 let attrbase = matchstr(context, ".*[\"']")
531
da9142bd190a updated for version 7.0149
vimboss
parents: 529
diff changeset
528 let attrquote = matchstr(attrbase, '.$')
837
6bb1fa855dc9 updated for version 7.0e03
vimboss
parents: 836
diff changeset
529 if attrquote !~ "['\"]"
6bb1fa855dc9 updated for version 7.0e03
vimboss
parents: 836
diff changeset
530 let attrquoteopen = '"'
6bb1fa855dc9 updated for version 7.0e03
vimboss
parents: 836
diff changeset
531 let attrquote = '"'
6bb1fa855dc9 updated for version 7.0e03
vimboss
parents: 836
diff changeset
532 else
6bb1fa855dc9 updated for version 7.0e03
vimboss
parents: 836
diff changeset
533 let attrquoteopen = ''
6bb1fa855dc9 updated for version 7.0e03
vimboss
parents: 836
diff changeset
534 endif
523
a7ae7e043e43 updated for version 7.0146
vimboss
parents:
diff changeset
535
a7ae7e043e43 updated for version 7.0146
vimboss
parents:
diff changeset
536 for m in values
531
da9142bd190a updated for version 7.0149
vimboss
parents: 529
diff changeset
537 " This if is needed to not offer all completions as-is
da9142bd190a updated for version 7.0149
vimboss
parents: 529
diff changeset
538 " alphabetically but sort them. Those beginning with entered
da9142bd190a updated for version 7.0149
vimboss
parents: 529
diff changeset
539 " part will be as first choices
da9142bd190a updated for version 7.0149
vimboss
parents: 529
diff changeset
540 if m =~ '^'.entered_value
842
a209672376fd updated for version 7.0f
vimboss
parents: 841
diff changeset
541 call add(res, attrquoteopen . m . attrquote)
531
da9142bd190a updated for version 7.0149
vimboss
parents: 529
diff changeset
542 elseif m =~ entered_value
842
a209672376fd updated for version 7.0f
vimboss
parents: 841
diff changeset
543 call add(res2, attrquoteopen . m . attrquote)
523
a7ae7e043e43 updated for version 7.0146
vimboss
parents:
diff changeset
544 endif
a7ae7e043e43 updated for version 7.0146
vimboss
parents:
diff changeset
545 endfor
531
da9142bd190a updated for version 7.0149
vimboss
parents: 529
diff changeset
546
da9142bd190a updated for version 7.0149
vimboss
parents: 529
diff changeset
547 return res + res2
da9142bd190a updated for version 7.0149
vimboss
parents: 529
diff changeset
548
523
a7ae7e043e43 updated for version 7.0146
vimboss
parents:
diff changeset
549 endif
659
d6a69271cb9a updated for version 7.0194
vimboss
parents: 649
diff changeset
550 " }}}
d6a69271cb9a updated for version 7.0194
vimboss
parents: 649
diff changeset
551 " Attribute completion {{{
548
f43150a669dc updated for version 7.0155
vimboss
parents: 532
diff changeset
552 " Shorten context to not include last word
f43150a669dc updated for version 7.0155
vimboss
parents: 532
diff changeset
553 let sbase = matchstr(context, '.*\ze\s.*')
667
9090f866cd57 updated for version 7.0197
vimboss
parents: 659
diff changeset
554
9090f866cd57 updated for version 7.0197
vimboss
parents: 659
diff changeset
555 " Load data {{{
844
d3bbb5dd3913 updated for version 7.0f02
vimboss
parents: 842
diff changeset
556 if !exists("b:html_doctype")
d3bbb5dd3913 updated for version 7.0f02
vimboss
parents: 842
diff changeset
557 call htmlcomplete#CheckDoctype()
d3bbb5dd3913 updated for version 7.0f02
vimboss
parents: 842
diff changeset
558 endif
d3bbb5dd3913 updated for version 7.0f02
vimboss
parents: 842
diff changeset
559 if !exists("b:html_omni")
836
5a7843c57316 updated for version 7.0e02
vimboss
parents: 829
diff changeset
560 call htmlcomplete#LoadData()
523
a7ae7e043e43 updated for version 7.0146
vimboss
parents:
diff changeset
561 endif
667
9090f866cd57 updated for version 7.0197
vimboss
parents: 659
diff changeset
562 " }}}
856
8cd729851562 updated for version 7.0g
vimboss
parents: 844
diff changeset
563
838
8e5830943bff updated for version 7.0e04
vimboss
parents: 837
diff changeset
564 if has_key(b:html_omni, tag)
8e5830943bff updated for version 7.0e04
vimboss
parents: 837
diff changeset
565 let attrs = keys(b:html_omni[tag][1])
837
6bb1fa855dc9 updated for version 7.0e03
vimboss
parents: 836
diff changeset
566 else
6bb1fa855dc9 updated for version 7.0e03
vimboss
parents: 836
diff changeset
567 return []
6bb1fa855dc9 updated for version 7.0e03
vimboss
parents: 836
diff changeset
568 endif
523
a7ae7e043e43 updated for version 7.0146
vimboss
parents:
diff changeset
569
a7ae7e043e43 updated for version 7.0146
vimboss
parents:
diff changeset
570 for m in sort(attrs)
531
da9142bd190a updated for version 7.0149
vimboss
parents: 529
diff changeset
571 if m =~ '^'.attr
667
9090f866cd57 updated for version 7.0197
vimboss
parents: 659
diff changeset
572 call add(res, m)
531
da9142bd190a updated for version 7.0149
vimboss
parents: 529
diff changeset
573 elseif m =~ attr
667
9090f866cd57 updated for version 7.0197
vimboss
parents: 659
diff changeset
574 call add(res2, m)
523
a7ae7e043e43 updated for version 7.0146
vimboss
parents:
diff changeset
575 endif
a7ae7e043e43 updated for version 7.0146
vimboss
parents:
diff changeset
576 endfor
667
9090f866cd57 updated for version 7.0197
vimboss
parents: 659
diff changeset
577 let menu = res + res2
838
8e5830943bff updated for version 7.0e04
vimboss
parents: 837
diff changeset
578 if has_key(b:html_omni, 'vimxmlattrinfo')
667
9090f866cd57 updated for version 7.0197
vimboss
parents: 659
diff changeset
579 let final_menu = []
9090f866cd57 updated for version 7.0197
vimboss
parents: 659
diff changeset
580 for i in range(len(menu))
9090f866cd57 updated for version 7.0197
vimboss
parents: 659
diff changeset
581 let item = menu[i]
838
8e5830943bff updated for version 7.0e04
vimboss
parents: 837
diff changeset
582 if has_key(b:html_omni['vimxmlattrinfo'], item)
8e5830943bff updated for version 7.0e04
vimboss
parents: 837
diff changeset
583 let m_menu = b:html_omni['vimxmlattrinfo'][item][0]
8e5830943bff updated for version 7.0e04
vimboss
parents: 837
diff changeset
584 let m_info = b:html_omni['vimxmlattrinfo'][item][1]
667
9090f866cd57 updated for version 7.0197
vimboss
parents: 659
diff changeset
585 else
9090f866cd57 updated for version 7.0197
vimboss
parents: 659
diff changeset
586 let m_menu = ''
9090f866cd57 updated for version 7.0197
vimboss
parents: 659
diff changeset
587 let m_info = ''
844
d3bbb5dd3913 updated for version 7.0f02
vimboss
parents: 842
diff changeset
588 endif
d3bbb5dd3913 updated for version 7.0f02
vimboss
parents: 842
diff changeset
589 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
590 let item = item
d3bbb5dd3913 updated for version 7.0f02
vimboss
parents: 842
diff changeset
591 let m_menu = 'Bool'
d3bbb5dd3913 updated for version 7.0f02
vimboss
parents: 842
diff changeset
592 else
667
9090f866cd57 updated for version 7.0197
vimboss
parents: 659
diff changeset
593 let item .= '="'
9090f866cd57 updated for version 7.0197
vimboss
parents: 659
diff changeset
594 endif
9090f866cd57 updated for version 7.0197
vimboss
parents: 659
diff changeset
595 let final_menu += [{'word':item, 'menu':m_menu, 'info':m_info}]
9090f866cd57 updated for version 7.0197
vimboss
parents: 659
diff changeset
596 endfor
9090f866cd57 updated for version 7.0197
vimboss
parents: 659
diff changeset
597 else
844
d3bbb5dd3913 updated for version 7.0f02
vimboss
parents: 842
diff changeset
598 let final_menu = []
d3bbb5dd3913 updated for version 7.0f02
vimboss
parents: 842
diff changeset
599 for i in range(len(menu))
d3bbb5dd3913 updated for version 7.0f02
vimboss
parents: 842
diff changeset
600 let item = menu[i]
d3bbb5dd3913 updated for version 7.0f02
vimboss
parents: 842
diff changeset
601 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
602 let item = item
d3bbb5dd3913 updated for version 7.0f02
vimboss
parents: 842
diff changeset
603 else
d3bbb5dd3913 updated for version 7.0f02
vimboss
parents: 842
diff changeset
604 let item .= '="'
d3bbb5dd3913 updated for version 7.0f02
vimboss
parents: 842
diff changeset
605 endif
d3bbb5dd3913 updated for version 7.0f02
vimboss
parents: 842
diff changeset
606 let final_menu += [item]
d3bbb5dd3913 updated for version 7.0f02
vimboss
parents: 842
diff changeset
607 endfor
d3bbb5dd3913 updated for version 7.0f02
vimboss
parents: 842
diff changeset
608 return final_menu
d3bbb5dd3913 updated for version 7.0f02
vimboss
parents: 842
diff changeset
609
667
9090f866cd57 updated for version 7.0197
vimboss
parents: 659
diff changeset
610 endif
9090f866cd57 updated for version 7.0197
vimboss
parents: 659
diff changeset
611 return final_menu
531
da9142bd190a updated for version 7.0149
vimboss
parents: 529
diff changeset
612
523
a7ae7e043e43 updated for version 7.0146
vimboss
parents:
diff changeset
613 endif
659
d6a69271cb9a updated for version 7.0194
vimboss
parents: 649
diff changeset
614 " }}}
d6a69271cb9a updated for version 7.0194
vimboss
parents: 649
diff changeset
615 " Close tag {{{
529
0d6092bb72e6 updated for version 7.0148
vimboss
parents: 525
diff changeset
616 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
617 if context =~ '^\/'
714
0f9f4761ad9c updated for version 7.0216
vimboss
parents: 674
diff changeset
618 if context =~ '^\/.'
0f9f4761ad9c updated for version 7.0216
vimboss
parents: 674
diff changeset
619 return []
0f9f4761ad9c updated for version 7.0216
vimboss
parents: 674
diff changeset
620 else
0f9f4761ad9c updated for version 7.0216
vimboss
parents: 674
diff changeset
621 let opentag = xmlcomplete#GetLastOpenTag("b:unaryTagsStack")
0f9f4761ad9c updated for version 7.0216
vimboss
parents: 674
diff changeset
622 return [opentag.">"]
0f9f4761ad9c updated for version 7.0216
vimboss
parents: 674
diff changeset
623 endif
525
1f8d8c37d6ec updated for version 7.0147
vimboss
parents: 523
diff changeset
624 endif
837
6bb1fa855dc9 updated for version 7.0e03
vimboss
parents: 836
diff changeset
625 " }}}
674
4b8583e82cb8 updated for version 7.0201
vimboss
parents: 667
diff changeset
626 " Load data {{{
844
d3bbb5dd3913 updated for version 7.0f02
vimboss
parents: 842
diff changeset
627 if !exists("b:html_doctype")
d3bbb5dd3913 updated for version 7.0f02
vimboss
parents: 842
diff changeset
628 call htmlcomplete#CheckDoctype()
d3bbb5dd3913 updated for version 7.0f02
vimboss
parents: 842
diff changeset
629 endif
838
8e5830943bff updated for version 7.0e04
vimboss
parents: 837
diff changeset
630 if !exists("b:html_omni")
836
5a7843c57316 updated for version 7.0e02
vimboss
parents: 829
diff changeset
631 "runtime! autoload/xml/xhtml10s.vim
5a7843c57316 updated for version 7.0e02
vimboss
parents: 829
diff changeset
632 call htmlcomplete#LoadData()
674
4b8583e82cb8 updated for version 7.0201
vimboss
parents: 667
diff changeset
633 endif
4b8583e82cb8 updated for version 7.0201
vimboss
parents: 667
diff changeset
634 " }}}
4b8583e82cb8 updated for version 7.0201
vimboss
parents: 667
diff changeset
635 " Tag completion {{{
525
1f8d8c37d6ec updated for version 7.0147
vimboss
parents: 523
diff changeset
636 " Deal with tag completion.
837
6bb1fa855dc9 updated for version 7.0e03
vimboss
parents: 836
diff changeset
637 let opentag = tolower(xmlcomplete#GetLastOpenTag("b:unaryTagsStack"))
714
0f9f4761ad9c updated for version 7.0216
vimboss
parents: 674
diff changeset
638 " MM: TODO: GLOT works always the same but with some weird situation it
0f9f4761ad9c updated for version 7.0216
vimboss
parents: 674
diff changeset
639 " behaves as intended in HTML but screws in PHP
841
c2cae213194d updated for version 7.0e07
vimboss
parents: 838
diff changeset
640 if opentag == '' || &filetype == 'php' && !has_key(b:html_omni, opentag)
641
6a944e0bd5d2 updated for version 7.0186
vimboss
parents: 573
diff changeset
641 " Hack for sometimes failing GetLastOpenTag.
6a944e0bd5d2 updated for version 7.0186
vimboss
parents: 573
diff changeset
642 " As far as I tested fail isn't GLOT fault but problem
6a944e0bd5d2 updated for version 7.0186
vimboss
parents: 573
diff changeset
643 " of invalid document - not properly closed tags and other mish-mash.
674
4b8583e82cb8 updated for version 7.0201
vimboss
parents: 667
diff changeset
644 " Also when document is empty. Return list of *all* tags.
838
8e5830943bff updated for version 7.0e04
vimboss
parents: 837
diff changeset
645 let tags = keys(b:html_omni)
674
4b8583e82cb8 updated for version 7.0201
vimboss
parents: 667
diff changeset
646 call filter(tags, 'v:val !~ "^vimxml"')
4b8583e82cb8 updated for version 7.0201
vimboss
parents: 667
diff changeset
647 else
838
8e5830943bff updated for version 7.0e04
vimboss
parents: 837
diff changeset
648 if has_key(b:html_omni, opentag)
8e5830943bff updated for version 7.0e04
vimboss
parents: 837
diff changeset
649 let tags = b:html_omni[opentag][0]
837
6bb1fa855dc9 updated for version 7.0e03
vimboss
parents: 836
diff changeset
650 else
6bb1fa855dc9 updated for version 7.0e03
vimboss
parents: 836
diff changeset
651 return []
6bb1fa855dc9 updated for version 7.0e03
vimboss
parents: 836
diff changeset
652 endif
641
6a944e0bd5d2 updated for version 7.0186
vimboss
parents: 573
diff changeset
653 endif
659
d6a69271cb9a updated for version 7.0194
vimboss
parents: 649
diff changeset
654 " }}}
856
8cd729851562 updated for version 7.0g
vimboss
parents: 844
diff changeset
655
837
6bb1fa855dc9 updated for version 7.0e03
vimboss
parents: 836
diff changeset
656 if exists("uppercase_tag") && uppercase_tag == 1
6bb1fa855dc9 updated for version 7.0e03
vimboss
parents: 836
diff changeset
657 let context = tolower(context)
6bb1fa855dc9 updated for version 7.0e03
vimboss
parents: 836
diff changeset
658 endif
1120
e6db096b07a1 updated for version 7.1a
vimboss
parents: 856
diff changeset
659 " Handle XML keywords: DOCTYPE
844
d3bbb5dd3913 updated for version 7.0f02
vimboss
parents: 842
diff changeset
660 if opentag == ''
841
c2cae213194d updated for version 7.0e07
vimboss
parents: 838
diff changeset
661 let tags += [
1120
e6db096b07a1 updated for version 7.1a
vimboss
parents: 856
diff changeset
662 \ '!DOCTYPE html PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">',
e6db096b07a1 updated for version 7.1a
vimboss
parents: 856
diff changeset
663 \ '!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
664 \ '!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
665 \ '!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
666 \ '!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
667 \ '!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
668 \ '!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
669 \ '!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
670 \ '!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
671 \ '!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
672 \ '!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
673 \ ]
c2cae213194d updated for version 7.0e07
vimboss
parents: 838
diff changeset
674 endif
525
1f8d8c37d6ec updated for version 7.0147
vimboss
parents: 523
diff changeset
675
573
c85bf6a4999b updated for version 7.0163
vimboss
parents: 557
diff changeset
676 for m in sort(tags)
548
f43150a669dc updated for version 7.0155
vimboss
parents: 532
diff changeset
677 if m =~ '^'.context
523
a7ae7e043e43 updated for version 7.0146
vimboss
parents:
diff changeset
678 call add(res, m)
548
f43150a669dc updated for version 7.0155
vimboss
parents: 532
diff changeset
679 elseif m =~ context
531
da9142bd190a updated for version 7.0149
vimboss
parents: 529
diff changeset
680 call add(res2, m)
523
a7ae7e043e43 updated for version 7.0146
vimboss
parents:
diff changeset
681 endif
529
0d6092bb72e6 updated for version 7.0148
vimboss
parents: 525
diff changeset
682 endfor
667
9090f866cd57 updated for version 7.0197
vimboss
parents: 659
diff changeset
683 let menu = res + res2
838
8e5830943bff updated for version 7.0e04
vimboss
parents: 837
diff changeset
684 if has_key(b:html_omni, 'vimxmltaginfo')
667
9090f866cd57 updated for version 7.0197
vimboss
parents: 659
diff changeset
685 let final_menu = []
9090f866cd57 updated for version 7.0197
vimboss
parents: 659
diff changeset
686 for i in range(len(menu))
9090f866cd57 updated for version 7.0197
vimboss
parents: 659
diff changeset
687 let item = menu[i]
838
8e5830943bff updated for version 7.0e04
vimboss
parents: 837
diff changeset
688 if has_key(b:html_omni['vimxmltaginfo'], item)
8e5830943bff updated for version 7.0e04
vimboss
parents: 837
diff changeset
689 let m_menu = b:html_omni['vimxmltaginfo'][item][0]
8e5830943bff updated for version 7.0e04
vimboss
parents: 837
diff changeset
690 let m_info = b:html_omni['vimxmltaginfo'][item][1]
667
9090f866cd57 updated for version 7.0197
vimboss
parents: 659
diff changeset
691 else
9090f866cd57 updated for version 7.0197
vimboss
parents: 659
diff changeset
692 let m_menu = ''
9090f866cd57 updated for version 7.0197
vimboss
parents: 659
diff changeset
693 let m_info = ''
9090f866cd57 updated for version 7.0197
vimboss
parents: 659
diff changeset
694 endif
841
c2cae213194d updated for version 7.0e07
vimboss
parents: 838
diff changeset
695 if &filetype == 'html' && exists("uppercase_tag") && uppercase_tag == 1 && item !~ 'DOCTYPE'
838
8e5830943bff updated for version 7.0e04
vimboss
parents: 837
diff changeset
696 let item = toupper(item)
8e5830943bff updated for version 7.0e04
vimboss
parents: 837
diff changeset
697 endif
841
c2cae213194d updated for version 7.0e07
vimboss
parents: 838
diff changeset
698 if item =~ 'DOCTYPE'
c2cae213194d updated for version 7.0e07
vimboss
parents: 838
diff changeset
699 let abbr = 'DOCTYPE '.matchstr(item, 'DTD \zsX\?HTML .\{-}\ze\/\/')
c2cae213194d updated for version 7.0e07
vimboss
parents: 838
diff changeset
700 else
c2cae213194d updated for version 7.0e07
vimboss
parents: 838
diff changeset
701 let abbr = item
c2cae213194d updated for version 7.0e07
vimboss
parents: 838
diff changeset
702 endif
c2cae213194d updated for version 7.0e07
vimboss
parents: 838
diff changeset
703 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
704 endfor
9090f866cd57 updated for version 7.0197
vimboss
parents: 659
diff changeset
705 else
9090f866cd57 updated for version 7.0197
vimboss
parents: 659
diff changeset
706 let final_menu = menu
9090f866cd57 updated for version 7.0197
vimboss
parents: 659
diff changeset
707 endif
9090f866cd57 updated for version 7.0197
vimboss
parents: 659
diff changeset
708 return final_menu
529
0d6092bb72e6 updated for version 7.0148
vimboss
parents: 525
diff changeset
709
659
d6a69271cb9a updated for version 7.0194
vimboss
parents: 649
diff changeset
710 " }}}
523
a7ae7e043e43 updated for version 7.0146
vimboss
parents:
diff changeset
711 endif
a7ae7e043e43 updated for version 7.0146
vimboss
parents:
diff changeset
712 endfunction
836
5a7843c57316 updated for version 7.0e02
vimboss
parents: 829
diff changeset
713
5a7843c57316 updated for version 7.0e02
vimboss
parents: 829
diff changeset
714 function! htmlcomplete#LoadData() " {{{
838
8e5830943bff updated for version 7.0e04
vimboss
parents: 837
diff changeset
715 if !exists("b:html_omni_flavor")
841
c2cae213194d updated for version 7.0e07
vimboss
parents: 838
diff changeset
716 if &filetype == 'html'
838
8e5830943bff updated for version 7.0e04
vimboss
parents: 837
diff changeset
717 let b:html_omni_flavor = 'html401t'
8e5830943bff updated for version 7.0e04
vimboss
parents: 837
diff changeset
718 else
8e5830943bff updated for version 7.0e04
vimboss
parents: 837
diff changeset
719 let b:html_omni_flavor = 'xhtml10s'
8e5830943bff updated for version 7.0e04
vimboss
parents: 837
diff changeset
720 endif
836
5a7843c57316 updated for version 7.0e02
vimboss
parents: 829
diff changeset
721 endif
838
8e5830943bff updated for version 7.0e04
vimboss
parents: 837
diff changeset
722 " With that if we still have bloated memory but create new buffer
8e5830943bff updated for version 7.0e04
vimboss
parents: 837
diff changeset
723 " variables only by linking to existing g:variable, not sourcing whole
8e5830943bff updated for version 7.0e04
vimboss
parents: 837
diff changeset
724 " file.
8e5830943bff updated for version 7.0e04
vimboss
parents: 837
diff changeset
725 if exists('g:xmldata_'.b:html_omni_flavor)
8e5830943bff updated for version 7.0e04
vimboss
parents: 837
diff changeset
726 exe 'let b:html_omni = g:xmldata_'.b:html_omni_flavor
8e5830943bff updated for version 7.0e04
vimboss
parents: 837
diff changeset
727 else
8e5830943bff updated for version 7.0e04
vimboss
parents: 837
diff changeset
728 exe 'runtime! autoload/xml/'.b:html_omni_flavor.'.vim'
8e5830943bff updated for version 7.0e04
vimboss
parents: 837
diff changeset
729 exe 'let b:html_omni = g:xmldata_'.b:html_omni_flavor
8e5830943bff updated for version 7.0e04
vimboss
parents: 837
diff changeset
730 endif
836
5a7843c57316 updated for version 7.0e02
vimboss
parents: 829
diff changeset
731 endfunction
5a7843c57316 updated for version 7.0e02
vimboss
parents: 829
diff changeset
732 " }}}
844
d3bbb5dd3913 updated for version 7.0f02
vimboss
parents: 842
diff changeset
733 function! htmlcomplete#CheckDoctype() " {{{
d3bbb5dd3913 updated for version 7.0f02
vimboss
parents: 842
diff changeset
734 if exists('b:html_omni_flavor')
d3bbb5dd3913 updated for version 7.0f02
vimboss
parents: 842
diff changeset
735 let old_flavor = b:html_omni_flavor
d3bbb5dd3913 updated for version 7.0f02
vimboss
parents: 842
diff changeset
736 else
d3bbb5dd3913 updated for version 7.0f02
vimboss
parents: 842
diff changeset
737 let old_flavor = ''
d3bbb5dd3913 updated for version 7.0f02
vimboss
parents: 842
diff changeset
738 endif
d3bbb5dd3913 updated for version 7.0f02
vimboss
parents: 842
diff changeset
739 let i = 1
d3bbb5dd3913 updated for version 7.0f02
vimboss
parents: 842
diff changeset
740 while i < 10 && i < line("$")
d3bbb5dd3913 updated for version 7.0f02
vimboss
parents: 842
diff changeset
741 let line = getline(i)
d3bbb5dd3913 updated for version 7.0f02
vimboss
parents: 842
diff changeset
742 if line =~ '<!DOCTYPE.*\<DTD HTML 3\.2'
d3bbb5dd3913 updated for version 7.0f02
vimboss
parents: 842
diff changeset
743 let b:html_omni_flavor = 'html32'
d3bbb5dd3913 updated for version 7.0f02
vimboss
parents: 842
diff changeset
744 let b:html_doctype = 1
d3bbb5dd3913 updated for version 7.0f02
vimboss
parents: 842
diff changeset
745 break
d3bbb5dd3913 updated for version 7.0f02
vimboss
parents: 842
diff changeset
746 elseif line =~ '<!DOCTYPE.*\<DTD HTML 4\.0 Transitional'
d3bbb5dd3913 updated for version 7.0f02
vimboss
parents: 842
diff changeset
747 let b:html_omni_flavor = 'html40t'
d3bbb5dd3913 updated for version 7.0f02
vimboss
parents: 842
diff changeset
748 let b:html_doctype = 1
d3bbb5dd3913 updated for version 7.0f02
vimboss
parents: 842
diff changeset
749 break
d3bbb5dd3913 updated for version 7.0f02
vimboss
parents: 842
diff changeset
750 elseif line =~ '<!DOCTYPE.*\<DTD HTML 4\.0 Frameset'
d3bbb5dd3913 updated for version 7.0f02
vimboss
parents: 842
diff changeset
751 let b:html_omni_flavor = 'html40f'
d3bbb5dd3913 updated for version 7.0f02
vimboss
parents: 842
diff changeset
752 let b:html_doctype = 1
d3bbb5dd3913 updated for version 7.0f02
vimboss
parents: 842
diff changeset
753 break
d3bbb5dd3913 updated for version 7.0f02
vimboss
parents: 842
diff changeset
754 elseif line =~ '<!DOCTYPE.*\<DTD HTML 4\.0'
d3bbb5dd3913 updated for version 7.0f02
vimboss
parents: 842
diff changeset
755 let b:html_omni_flavor = 'html40s'
d3bbb5dd3913 updated for version 7.0f02
vimboss
parents: 842
diff changeset
756 let b:html_doctype = 1
d3bbb5dd3913 updated for version 7.0f02
vimboss
parents: 842
diff changeset
757 break
d3bbb5dd3913 updated for version 7.0f02
vimboss
parents: 842
diff changeset
758 elseif line =~ '<!DOCTYPE.*\<DTD HTML 4\.01 Transitional'
d3bbb5dd3913 updated for version 7.0f02
vimboss
parents: 842
diff changeset
759 let b:html_omni_flavor = 'html401t'
d3bbb5dd3913 updated for version 7.0f02
vimboss
parents: 842
diff changeset
760 let b:html_doctype = 1
d3bbb5dd3913 updated for version 7.0f02
vimboss
parents: 842
diff changeset
761 break
d3bbb5dd3913 updated for version 7.0f02
vimboss
parents: 842
diff changeset
762 elseif line =~ '<!DOCTYPE.*\<DTD HTML 4\.01 Frameset'
d3bbb5dd3913 updated for version 7.0f02
vimboss
parents: 842
diff changeset
763 let b:html_omni_flavor = 'html401f'
d3bbb5dd3913 updated for version 7.0f02
vimboss
parents: 842
diff changeset
764 let b:html_doctype = 1
d3bbb5dd3913 updated for version 7.0f02
vimboss
parents: 842
diff changeset
765 break
d3bbb5dd3913 updated for version 7.0f02
vimboss
parents: 842
diff changeset
766 elseif line =~ '<!DOCTYPE.*\<DTD HTML 4\.01'
d3bbb5dd3913 updated for version 7.0f02
vimboss
parents: 842
diff changeset
767 let b:html_omni_flavor = 'html401s'
d3bbb5dd3913 updated for version 7.0f02
vimboss
parents: 842
diff changeset
768 let b:html_doctype = 1
d3bbb5dd3913 updated for version 7.0f02
vimboss
parents: 842
diff changeset
769 break
d3bbb5dd3913 updated for version 7.0f02
vimboss
parents: 842
diff changeset
770 elseif line =~ '<!DOCTYPE.*\<DTD XHTML 1\.0 Transitional'
d3bbb5dd3913 updated for version 7.0f02
vimboss
parents: 842
diff changeset
771 let b:html_omni_flavor = 'xhtml10t'
d3bbb5dd3913 updated for version 7.0f02
vimboss
parents: 842
diff changeset
772 let b:html_doctype = 1
d3bbb5dd3913 updated for version 7.0f02
vimboss
parents: 842
diff changeset
773 break
d3bbb5dd3913 updated for version 7.0f02
vimboss
parents: 842
diff changeset
774 elseif line =~ '<!DOCTYPE.*\<DTD XHTML 1\.0 Frameset'
d3bbb5dd3913 updated for version 7.0f02
vimboss
parents: 842
diff changeset
775 let b:html_omni_flavor = 'xhtml10f'
d3bbb5dd3913 updated for version 7.0f02
vimboss
parents: 842
diff changeset
776 let b:html_doctype = 1
d3bbb5dd3913 updated for version 7.0f02
vimboss
parents: 842
diff changeset
777 break
d3bbb5dd3913 updated for version 7.0f02
vimboss
parents: 842
diff changeset
778 elseif line =~ '<!DOCTYPE.*\<DTD XHTML 1\.0 Strict'
d3bbb5dd3913 updated for version 7.0f02
vimboss
parents: 842
diff changeset
779 let b:html_omni_flavor = 'xhtml10s'
d3bbb5dd3913 updated for version 7.0f02
vimboss
parents: 842
diff changeset
780 let b:html_doctype = 1
d3bbb5dd3913 updated for version 7.0f02
vimboss
parents: 842
diff changeset
781 break
d3bbb5dd3913 updated for version 7.0f02
vimboss
parents: 842
diff changeset
782 elseif line =~ '<!DOCTYPE.*\<DTD XHTML 1\.1'
d3bbb5dd3913 updated for version 7.0f02
vimboss
parents: 842
diff changeset
783 let b:html_omni_flavor = 'xhtml11'
d3bbb5dd3913 updated for version 7.0f02
vimboss
parents: 842
diff changeset
784 let b:html_doctype = 1
d3bbb5dd3913 updated for version 7.0f02
vimboss
parents: 842
diff changeset
785 break
d3bbb5dd3913 updated for version 7.0f02
vimboss
parents: 842
diff changeset
786 endif
d3bbb5dd3913 updated for version 7.0f02
vimboss
parents: 842
diff changeset
787 let i += 1
d3bbb5dd3913 updated for version 7.0f02
vimboss
parents: 842
diff changeset
788 endwhile
d3bbb5dd3913 updated for version 7.0f02
vimboss
parents: 842
diff changeset
789 if !exists("b:html_doctype")
d3bbb5dd3913 updated for version 7.0f02
vimboss
parents: 842
diff changeset
790 return
d3bbb5dd3913 updated for version 7.0f02
vimboss
parents: 842
diff changeset
791 else
d3bbb5dd3913 updated for version 7.0f02
vimboss
parents: 842
diff changeset
792 " 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
793 " once, not every time per buffer.
d3bbb5dd3913 updated for version 7.0f02
vimboss
parents: 842
diff changeset
794 if old_flavor == b:html_omni_flavor
d3bbb5dd3913 updated for version 7.0f02
vimboss
parents: 842
diff changeset
795 return
d3bbb5dd3913 updated for version 7.0f02
vimboss
parents: 842
diff changeset
796 else
d3bbb5dd3913 updated for version 7.0f02
vimboss
parents: 842
diff changeset
797 if exists('g:xmldata_'.b:html_omni_flavor)
d3bbb5dd3913 updated for version 7.0f02
vimboss
parents: 842
diff changeset
798 exe 'let b:html_omni = g:xmldata_'.b:html_omni_flavor
d3bbb5dd3913 updated for version 7.0f02
vimboss
parents: 842
diff changeset
799 else
d3bbb5dd3913 updated for version 7.0f02
vimboss
parents: 842
diff changeset
800 exe 'runtime! autoload/xml/'.b:html_omni_flavor.'.vim'
d3bbb5dd3913 updated for version 7.0f02
vimboss
parents: 842
diff changeset
801 exe 'let b:html_omni = g:xmldata_'.b:html_omni_flavor
d3bbb5dd3913 updated for version 7.0f02
vimboss
parents: 842
diff changeset
802 endif
d3bbb5dd3913 updated for version 7.0f02
vimboss
parents: 842
diff changeset
803 return
d3bbb5dd3913 updated for version 7.0f02
vimboss
parents: 842
diff changeset
804 endif
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 endfunction
d3bbb5dd3913 updated for version 7.0f02
vimboss
parents: 842
diff changeset
807 " }}}
659
d6a69271cb9a updated for version 7.0194
vimboss
parents: 649
diff changeset
808 " vim:set foldmethod=marker: