diff options
author | Bram Moolenaar <Bram@vim.org> | 2005-10-10 20:59:28 +0000 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2005-10-10 20:59:28 +0000 |
commit | d5cdbeb8dd859510c4674b17b67d613eff40a984 (patch) | |
tree | 7efb2d890b1eb727c0e15a2ade2613b606ad6c9b /runtime/autoload/ccomplete.vim | |
parent | 196dfbcca1af4cf07f600e0186757d9adf097e7f (diff) | |
download | vim-git-d5cdbeb8dd859510c4674b17b67d613eff40a984.tar.gz |
updated for version 7.0155
Diffstat (limited to 'runtime/autoload/ccomplete.vim')
-rw-r--r-- | runtime/autoload/ccomplete.vim | 40 |
1 files changed, 31 insertions, 9 deletions
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 <Bram@vim.org> -" 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. |