Friday, August 28, 2009

Re: setting completion to use tagfiles

On Fri, Aug 28, 2009 at 5:48 AM, Kevin<lazyweb@gmail.com> wrote:
>
> I'm on the  verge of giving up using omnicomplete with python.
> Ideally I'd have nice context aware completions, but it seems that
> nobody knows how omnicomplete actually works with python ( I certainly
> do not. )
>
> So, moving forward:  What would be the best way to set up tagfiles to
> get completions for python?

I have the same concern as you.

Coming up with a simple tag completion function using taglist()
function is very straight-forward, but it won't perform well when
there are many matches (e.g., you have only one. Here is one that I
came up with starting from the example at |comple-functions|.

fun! 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] =~ '\a'
let start -= 1
endwhile
return start
else
return map(taglist('^'.a:base.'.*'), 'v:val.name')
endif
endfun
setl completefunc=CompleteTags

Use <C-X><C-U> to complete words from taglist. You should be able to
filter the items further by analyzing the kind, filename attributes of
the results returned by taglist() along with some static analysis of
the context from the buffer. I will leave that as an exercise, but I
will that as an exercise for someone willing to put in that time.

The taglist() function should be improved to give results
incrementally such that we could make use of complete_add() and
complete_check() functions, otherwise with large tag results
(especially when the "base" is small), it will take a long time to get
results back. There is also a python package to parse tag files on
google code, which can probably also help.

--
HTH,
Hari

--~--~---------~--~----~------------~-------~--~----~
You received this message from the "vim_use" maillist.
For more information, visit http://www.vim.org/maillist.php
-~----------~----~----~----~------~----~------~--~---

No comments:

Post a Comment