VIM: autocomplete plugin to work with gtags

941 views Asked by At

I have just moved from ctags to gtags for my huge C Project. But I couldnt find any vim autocomplete plugin that works with gtags. gtags is so widely used and much more efficient than ctags. I am sure I am missing something here. Someone must have integrated gtags with any autocomplete plugin.

2

There are 2 answers

0
Kanwar Saad On BEST ANSWER

I have to write my own plugin for this. Here is the link if someone needs it. https://github.com/kanwar-saad/gtagsomnicomplete

0
Anton Styagun On

I've written a simple 'omnifunc' for Vim, that uses GNU global for completion:

augroup GlobalComplete
  autocmd!
  autocmd FileType c setlocal omnifunc=GlobalComplete
augroup END

function! GlobalComplete(findstart, base)
  if a:findstart == 1
    return s:LocateCurrentWordStart()
  else
    return split(system('global -c ' . a:base), '\n')
  endif
endfunction

function! s:LocateCurrentWordStart()
  let l:line = getline('.')
  let l:start = col('.') - 1
  while l:start > 0 && l:line[l:start - 1] =~# '\a'
    let l:start -= 1
  endwhile
  return l:start
endfunction

See also: