The Setup
In my .vimrc
I have the following lines:
" .vimrc
let g:virtualenv_directory="/Users/Kit/Development/virtualenv"
Then in ~/.vim/ftplugin/python/virtualenv.vim
I have these:
py << EOF
import os.path
import sys
import vim
if 'VIRTUAL_ENV' in os.environ:
project_base_dir = os.environ['VIRTUAL_ENV']
sys.path.insert(0, project_base_dir)
activate_this = os.path.join(project_base_dir, 'bin/activate_this.py')
execfile(activate_this, dict(__file__=activate_this))
print "virtualenv in os.environ!"
EOF
VirtualEnvActivate my-virtualenv-python-2.7
In ~/.vim/ftplugin/python/virtualenv.vim
I have these SuperTab settings:
setlocal omnifunc=pythoncomplete#Complete
setlocal completeopt=menuone,longest,preview
let g:SuperTabDefaultCompletionType="<c-x><c-]>"
In my working directory, where I always work from, I executed the following bash command to generate a TAGS
file for all my .py
files
find . -name '*.py' -type f -print0 | xargs -0 etags -l python
The problem
For example, I have a main.py
which has an object app
inside it, such that the following script works fine:
import main
new_app = main.app() # works totally fine Python-wise
If, for example, I write some new code and try to use SuperTab omnicompletion:
import main
new_new_app = main.<Tab>
This is what I get:
new_new_app = mainself.
And if I press Tab several times:
new_new_app = mainselfselfselfself.
What works for me
If, however, I do the following:
new_new_app = main.a<Tab>
I get a whole list of a..
objects that include those that don't belong to module main
.
What I want
If I set the following in .vimrc
:
let g:SuperTabDefaultCompletionType="context"
Then, I use a module from the standard Python library:
import sys
sys.<Tab> # This will still result in sysselfselfself.
sys.p<Tab> # This will result in the correct list of `sys` members beginning with `p`
But the "context"
setting won't work on my own modules:
new_new_app = main.a<Tab>
# Will say at the bottom: Omni completion (^O^N^P) Pattern not found
The Question
How should I set up omnicompletion and SuperTab so that it behaves for my own modules as for the standard library modules? As well as eliminate the selfselfself.
annoyance?
<C-x><C-o>
,<C-x><C-]>
,<C-x><C-u>
What is the outcome? Also what Pyton completetion script do you use? – Dyeing