I'm having trouble with Vim and Python completion. In fact I'm totally confused how does this work.
I have generic gvim 7.3, on windows 7 (with python/dyn) I'm using SuperTab plugin, amongst many others, some of which are python-specific, with following settings in vimrc:
au FileType python set omnifunc=pythoncomplete#Complete let g:SuperTabDefaultCompletionType = "context" let g:SuperTabContextDefaultCompletionType = "<c-n>"
I did not set PYTHONPATH enviroment varariable.
Completion works ok for system modules.
At first I thought that it isn't working at all for non-system code, but that's not the case. What is happening is best shown on following code:
import numpy.random # if this line is commented completion in last line works class C(object): def __init__(self, x_): self.x=x_ def getX(self): return self.x def pr(self): print 'ok' a=C(10) # nothing changes if I put C() instead, even though it would be wrong a. # here is completion in question
Problem is that completion works (a.<tab> suggests getX and pr) if import line is commented. But it there is import numpy.random, completion brakes down. Note: this import works normally when I run the code.
What are prerequisites for Python completion? What's happening and what should I do to get completion working for Python.
As I am (relatively) new to Vim, any suggestion is appreciated.
EDIT: It seems that the problem is in using a.b form in import. If I do from numpy import random, everything is ok. If this is reasonably easy to fix I would like to get a.b from to work too. But now that I know how to go around it that's not so important.
Are there more unusual problem like this one so that I know what's happening in the future?
Vim text editor supports autocompletion for the standard text files by default. Also, when configured properly, Vim enables an autocomplete feature for files with code in the languages it recognizes.
Vim (or NeoVim) is my favourite text editor / IDE. I love its extensibility, adaptability, and in-terminal slickness. Before I start, here's a quick guide on installing Neovim.
pythoncomplete is rather old and unmaintained.
Try to use Jedi: https://github.com/davidhalter/jedi-vim It was originally an improved pythoncomplete, but is now much much more powerful!
It works for complex code:
And has additional features:
There is a list of all possible features:
__call__
, __iter__
, __next__
, __get__
, __getitem__
, __init__
getattr()
/ __getattr__
/ __getattribute__
sys.path
modificationsisinstance
checks for if/while/assertIf you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With