summaryrefslogtreecommitdiff
path: root/runtime/autoload/ccomplete.vim
blob: f699ca7582518c7ea44c3547354fe69a906db633 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
" Vim completion script
" Language:	C
" Maintainer:	Bram Moolenaar <Bram@vim.org>
" Last Change:	2005 Sep 01

function! ccomplete#Complete(findstart, base)
  if a:findstart
    " locate the start of the word
    let line = getline('.')
    let start = col('.') - 1
    while start > 0
      if line[start - 1] =~ '\w\|\.'
	let start -= 1
      elseif start > 1 && line[start - 2] == '-' && line[start - 1] == '>'
	let start -= 2
      else
	break
      endif
    endwhile
    return start
  endif

  " return list of matches
  let items = split(a:base, '\.\|->')
  if len(items) == 1
    " Only one part, no "." or "->": complete from tags file.
    let diclist = taglist(items[0])
    return map(diclist, 'v:val["name"]')
  endif
  return items
endfunction