Most third libraries should work out of the box, Django isn't so nice with autocompletion, you need to have in your environment the variable DJANGO_SETTINGS
set, otherwise most imports will raise an improperly configured exception and the autocompletion will not work.
You can set this variable in you virtualenv, or with a alias in your shell, or using something like this in your .vimrc
:
function FindDjangoSettings()
if strlen($VIRTUAL_ENV) && has('python')
let output = system("find $VIRTUAL_ENV \\( -wholename '*/lib/*' -or -wholename '*/install/' \\) -or \\( -name 'settings.py' -print0 \\) | tr '\n' ' '")
let outarray= split(output, '[\/]\+')
let module = outarray[-2] . '.' . 'settings'
let syspath = system("python -c 'import sys; print sys.path' | tr '\n' ' ' ")
" let curpath = '/' . join(outarray[:-2], '/')
execute 'python import sys, os'
" execute 'python sys.path.append("' . curpath . '")'
" execute 'python sys.path.append("' . syspath . '")'
execute 'python sys.path = ' . syspath
execute 'python os.environ.setdefault("DJANGO_SETTINGS_MODULE", "' . module . '")'
endif
endfunction
autocmd FileType python call FindDjangoSettings()
This assumes that you are using virtualenv
for your projects, and might bother you if you are using a virtualenv for something that is not django.
I also recommend you to have a look in you complete me plugin, its an awesome complete plugin, it is not a replacement for jedi, in fact, it has jedi as a dependency for python completion.
set omnifunc
and:messages
– Romy:py print(sys.path)
shows. – Landers