From: Bram Moolenaar Date: Mon, 10 Oct 2005 20:59:28 +0000 (+0000) Subject: updated for version 7.0155 X-Git-Tag: v7.0155~1 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=d5cdbeb8dd859510c4674b17b67d613eff40a984;p=vim updated for version 7.0155 --- diff --git a/runtime/autoload/README.txt b/runtime/autoload/README.txt index 0c7fcfe38..2038fa224 100644 --- a/runtime/autoload/README.txt +++ b/runtime/autoload/README.txt @@ -4,6 +4,12 @@ These are functions used by plugins and for general use. They will be loaded automatically when the function is invoked. See ":help autoload". gzip.vim for editing compressed files +netrw.vim browsing (remote) directories and editing remote files +tar.vim browsing tar files +zip.vim browsing zip files Occult completion files: -ccomplete.vim C +ccomplete.vim C +csscomplete.vim HTML / CSS +htmlcomplete.vim HTML + diff --git a/runtime/autoload/ccomplete.vim b/runtime/autoload/ccomplete.vim index c71852530..a2210d71b 100644 --- a/runtime/autoload/ccomplete.vim +++ b/runtime/autoload/ccomplete.vim @@ -1,7 +1,7 @@ " Vim completion script " Language: C " Maintainer: Bram Moolenaar -" Last Change: 2005 Sep 13 +" Last Change: 2005 Oct 06 " This function is used for the 'omnifunc' option. @@ -10,27 +10,52 @@ function! ccomplete#Complete(findstart, base) " Locate the start of the item, including "." and "->". let line = getline('.') let start = col('.') - 1 + let lastword = -1 while start > 0 - if line[start - 1] =~ '\w\|\.' + if line[start - 1] =~ '\w' + let start -= 1 + elseif line[start - 1] =~ '\.' + if lastword == -1 + let lastword = start + endif let start -= 1 elseif start > 1 && line[start - 2] == '-' && line[start - 1] == '>' + if lastword == -1 + let lastword = start + endif let start -= 2 else break endif endwhile - return start + + " Return the column of the last word, which is going to be changed. + " Remember the text that comes before it in s:prepended. + if lastword == -1 + let s:prepended = '' + return start + endif + let s:prepended = strpart(line, start, lastword - start) + return lastword endif " Return list of matches. + let base = s:prepended . a:base + " Split item in words, keep empty word after "." or "->". " "aa" -> ['aa'], "aa." -> ['aa', ''], "aa.bb" -> ['aa', 'bb'], etc. - let items = split(a:base, '\.\|->', 1) + let items = split(base, '\.\|->', 1) if len(items) <= 1 + " Don't do anything for an empty base, would result in all the tags in the + " tags file. + if base == '' + return [] + endif + " Only one part, no "." or "->": complete from tags file. " When local completion is wanted CTRL-N would have been used. - return map(taglist('^' . a:base), 'v:val["name"]') + return map(taglist('^' . base), 'v:val["name"]') endif " Find the variable items[0]. @@ -88,10 +113,7 @@ function! ccomplete#Complete(findstart, base) endif endif - " The basetext is up to the last "." or "->" and won't be changed. The - " matching members are concatenated to this. - let basetext = matchstr(a:base, '.*\(\.\|->\)') - return map(res, 'basetext . v:val["match"]') + return map(res, 'v:val["match"]') endfunc " Find composing type in "lead" and match items[0] with it. diff --git a/runtime/autoload/csscomplete.vim b/runtime/autoload/csscomplete.vim index ea52786e7..293c37031 100644 --- a/runtime/autoload/csscomplete.vim +++ b/runtime/autoload/csscomplete.vim @@ -1,12 +1,19 @@ " Vim completion script " Language: CSS 2.1 " Maintainer: Mikolaj Machowski ( mikmach AT wp DOT pl ) -" Last Change: 2005 Oct 02 +" Last Change: 2005 Oct 9 function! csscomplete#CompleteCSS(findstart, base) if a:findstart " We need whole line to proper checking - return 0 + let line = getline('.') + let start = col('.') - 1 + let compl_begin = col('.') - 2 + while start >= 0 && line[start - 1] =~ '\(\k\|-\)' + let start -= 1 + endwhile + let b:compl_context = getline('.')[0:compl_begin] + return start else " There are few chars important for context: " ^ ; : { } /* */ @@ -14,14 +21,16 @@ else " Depending on their relative position to cursor we will now what should " be completed. " 1. if nearest are ^ or { or ; current word is property - " 2. if : it is value + " 2. if : it is value (with exception of pseudo things) " 3. if } we are outside of css definitions " 4. for comments ignoring is be the easiest but assume they are the same " as 1. " 5. if @ complete at-rule " 6. if ! complete important - let line = a:base + let line = b:compl_context + unlet! b:compl_context + let res = [] let res2 = [] let borders = {} @@ -67,19 +76,19 @@ else let borders[exclam] = "exclam" endif + if len(borders) == 0 || borders[min(keys(borders))] =~ '^\(openbrace\|semicolon\|opencomm\|closecomm\|style\)$' " Complete properties - let values = split("azimuth background-attachment background-color background-image background-position background-repeat background border-collapse border-color border-spacing border-style border-top border-right border-bottom border-left border-top-color border-right-color border-bottom-color border-left-color border-top-style border-right-style border-bottom-style border-left-style border-top-width border-right-width border-bottom-width border-left-width border-width border bottom caption-side clear clip color content counter-increment counter-reset cue-after cue-before cue cursor direction display elevation empty-cells float font-family font-size font-style font-variant font-weight font height left letter-spacing line-height list-style-image list-style-position list-style-type list-style margin-right margin-left margin-top margin-bottom max-height max-width min-height min-width orphans outline-color outline-style outline-width outline overflow padding-top padding-right padding-bottom padding-left padding page-break-after page-break-before page-break-inside pause-after pause-before pause pitch-range pitch play-during position quotes richness right speak-header speak-numeral speak-punctuation speak speech-rate stress table-layout text-align text-decoration text-indent text-transform top unicode-bidi vertical-align visibility voice-family volume white-space widows width word-spacing z-index") + let values = split("azimuth background background-attachment background-color background-image background-position background-repeat border bottom border-collapse border-color border-spacing border-style border-top border-right border-bottom border-left border-top-color border-right-color border-bottom-color border-left-color border-top-style border-right-style border-bottom-style border-left-style border-top-width border-right-width border-bottom-width border-left-width border-width caption-side clear clip color content counter-increment counter-reset cue cue-after cue-before cursor display direction elevation empty-cells float font font-family font-size font-style font-variant font-weight height left letter-spacing line-height list-style list-style-image list-style-position list-style-type margin margin-right margin-left margin-top margin-bottom max-height max-width min-height min-width orphans outline outline-color outline-style outline-width overflow padding padding-top padding-right padding-bottom padding-left page-break-after page-break-before page-break-inside pause pause-after pause-before pitch pitch-range play-during position quotes right richness speak speak-header speak-numeral speak-punctuation speech-rate stress table-layout text-align text-decoration text-indent text-transform top unicode-bidi vertical-align visibility voice-family volume white-space width widows word-spacing z-index") - let propbase = matchstr(line, '.\{-}\ze[a-zA-Z-]*$') let entered_property = matchstr(line, '.\{-}\zs[a-zA-Z-]*$') for m in values if m =~? '^'.entered_property - call add(res, propbase . m.': ') + call add(res, m . ':') elseif m =~? entered_property - call add(res2, propbase . m.': ') + call add(res2, m . ':') endif endfor @@ -315,14 +324,13 @@ else endif " Complete values - let valbase = matchstr(line, '.\{-}\ze[a-zA-Z0-9#,.(_-]*$') let entered_value = matchstr(line, '.\{-}\zs[a-zA-Z0-9#,.(_-]*$') for m in values if m =~? '^'.entered_value - call add(res, valbase . m) + call add(res, m) elseif m =~? entered_value - call add(res2, valbase . m) + call add(res2, m) endif endfor @@ -335,14 +343,13 @@ else elseif borders[min(keys(borders))] == 'exclam' " Complete values - let impbase = matchstr(line, '.\{-}!\s*\ze[a-zA-Z ]*$') let entered_imp = matchstr(line, '.\{-}!\s*\zs[a-zA-Z ]*$') let values = ["important"] for m in values if m =~? '^'.entered_imp - call add(res, impbase . m) + call add(res, m) endif endfor @@ -388,9 +395,9 @@ else for m in values if m =~? '^'.entered_atruleafter - call add(res, atruleafterbase . m) + call add(res, m) elseif m =~? entered_atruleafter - call add(res2, atruleafterbase . m) + call add(res2, m) endif endfor @@ -400,14 +407,13 @@ else let values = ["charset", "page", "media", "import", "font-face"] - let atrulebase = matchstr(line, '.*@\ze[a-zA-Z -]*$') let entered_atrule = matchstr(line, '.*@\zs[a-zA-Z-]*$') for m in values if m =~? '^'.entered_atrule - call add(res, atrulebase . m.' ') + call add(res, m .' ') elseif m =~? entered_atrule - call add(res2, atrulebase . m.' ') + call add(res2, m .' ') endif endfor diff --git a/runtime/autoload/htmlcomplete.vim b/runtime/autoload/htmlcomplete.vim index 9dd5830a1..b3dae2d30 100644 --- a/runtime/autoload/htmlcomplete.vim +++ b/runtime/autoload/htmlcomplete.vim @@ -1,39 +1,76 @@ " Vim completion script " Language: XHTML 1.0 Strict " Maintainer: Mikolaj Machowski ( mikmach AT wp DOT pl ) -" Last Change: 2005 Sep 23 +" Last Change: 2005 Oct 9 function! htmlcomplete#CompleteTags(findstart, base) if a:findstart " locate the start of the word let line = getline('.') let start = col('.') - 1 - while start >= 0 && line[start - 1] !~ '<' - let start -= 1 + let compl_begin = col('.') - 2 + while start >= 0 && line[start - 1] =~ '\(\k\|[:.-]\)' + let start -= 1 endwhile - if start < 0 + if start >= 0 && line[start - 1] =~ '&' + let b:entitiescompl = 1 + let b:compl_context = '' + return start + endif + let stylestart = searchpair('', '', '<\/style\>', "bnW") + let styleend = searchpair('', '', '<\/style\>', "nW") + if stylestart != 0 && styleend != 0 let curpos = line('.') - let stylestart = searchpair('', '', '<\/style\>', "bnW") - let styleend = searchpair('', '', '<\/style\>', "nW") - if stylestart != 0 && styleend != 0 - if stylestart <= curpos && styleend >= curpos - let b:csscompl = 1 - let start = 0 - endif + if stylestart <= curpos && styleend >= curpos + let start = col('.') - 1 + let b:csscompl = 1 + while start >= 0 && line[start - 1] =~ '\(\k\|-\)' + let start -= 1 + endwhile endif endif + if !exists("b:csscompl") + let b:compl_context = getline('.')[0:(compl_begin)] + let b:compl_context = matchstr(b:compl_context, '.*<\zs.*') + else + let b:compl_context = getline('.')[0:compl_begin] + endif return start else + " Initialize base return lists + let res = [] + let res2 = [] + " a:base is very short - we need context + let context = b:compl_context + unlet! b:compl_context " Check if we should do CSS completion inside of