Mercurial > vim
comparison runtime/autoload/htmlcomplete.vim @ 649:8157079cea85
updated for version 7.0191
author | vimboss |
---|---|
date | Wed, 01 Feb 2006 21:47:16 +0000 |
parents | d3c978b4c7ce |
children | d6a69271cb9a |
comparison
equal
deleted
inserted
replaced
648:9032e4668296 | 649:8157079cea85 |
---|---|
1 " Vim completion script | 1 " Vim completion script |
2 " Language: XHTML 1.0 Strict | 2 " Language: XHTML 1.0 Strict |
3 " Maintainer: Mikolaj Machowski ( mikmach AT wp DOT pl ) | 3 " Maintainer: Mikolaj Machowski ( mikmach AT wp DOT pl ) |
4 " Last Change: 2006 Jan 24 | 4 " Last Change: 2006 Jan 30 |
5 | 5 |
6 function! htmlcomplete#CompleteTags(findstart, base) | 6 function! htmlcomplete#CompleteTags(findstart, base) |
7 if a:findstart | 7 if a:findstart |
8 " locate the start of the word | 8 " locate the start of the word |
9 let line = getline('.') | 9 let line = getline('.') |
27 while start >= 0 && line[start - 1] =~ '\(\k\|-\)' | 27 while start >= 0 && line[start - 1] =~ '\(\k\|-\)' |
28 let start -= 1 | 28 let start -= 1 |
29 endwhile | 29 endwhile |
30 endif | 30 endif |
31 endif | 31 endif |
32 if !exists("b:csscompl") | 32 let scriptstart = searchpair('<script\>', '', '<\/script\>', "bnW") |
33 let scriptend = searchpair('<script\>', '', '<\/script\>', "nW") | |
34 if scriptstart != 0 && scriptend != 0 | |
35 if scriptstart <= curline && scriptend >= curline | |
36 let start = col('.') - 1 | |
37 let b:jscompl = 1 | |
38 let b:jsrange = [scriptstart, scriptend] | |
39 while start >= 0 && line[start - 1] =~ '\(\k\|-\)' | |
40 let start -= 1 | |
41 endwhile | |
42 endif | |
43 endif | |
44 if !exists("b:csscompl") && !exists("b:jscompl") | |
33 let b:compl_context = getline('.')[0:(compl_begin)] | 45 let b:compl_context = getline('.')[0:(compl_begin)] |
34 if b:compl_context !~ '<[^>]*$' | 46 if b:compl_context !~ '<[^>]*$' |
35 " Look like we may have broken tag. Check previous lines. Up to | 47 " Look like we may have broken tag. Check previous lines. Up to |
36 " 10? | 48 " 10? |
37 let i = 1 | 49 let i = 1 |
66 " Check if we should do CSS completion inside of <style> tag | 78 " Check if we should do CSS completion inside of <style> tag |
67 if exists("b:csscompl") | 79 if exists("b:csscompl") |
68 unlet! b:csscompl | 80 unlet! b:csscompl |
69 let context = b:compl_context | 81 let context = b:compl_context |
70 return csscomplete#CompleteCSS(0, context) | 82 return csscomplete#CompleteCSS(0, context) |
83 elseif exists("b:jscompl") | |
84 unlet! b:jscompl | |
85 let context = b:compl_context | |
86 return javascriptcomplete#CompleteJS(0, context) | |
71 else | 87 else |
72 if len(b:compl_context) == 0 && !exists("b:entitiescompl") | 88 if len(b:compl_context) == 0 && !exists("b:entitiescompl") |
73 return [] | 89 return [] |
74 endif | 90 endif |
75 let context = matchstr(b:compl_context, '.\zs.*') | 91 let context = matchstr(b:compl_context, '.\zs.*') |
109 if context =~ '>' | 125 if context =~ '>' |
110 " Generally if context contains > it means we are outside of tag and | 126 " Generally if context contains > it means we are outside of tag and |
111 " should abandon action - with one exception: <style> span { bo | 127 " should abandon action - with one exception: <style> span { bo |
112 if context =~ 'style[^>]\{-}>[^<]\{-}$' | 128 if context =~ 'style[^>]\{-}>[^<]\{-}$' |
113 return csscomplete#CompleteCSS(0, context) | 129 return csscomplete#CompleteCSS(0, context) |
130 elseif context =~ 'script[^>]\{-}>[^<]\{-}$' | |
131 let b:jsrange = [line('.'), search('<\/script\>', 'nW')] | |
132 return javascriptcomplete#CompleteJS(0, context) | |
114 else | 133 else |
115 return [] | 134 return [] |
116 endif | 135 endif |
117 endif | 136 endif |
118 | 137 |