Vim, Python, and Django autocompletion (pysmell?)

前端 未结 5 727
北海茫月
北海茫月 2020-12-04 07:08

Does anyone know how to set up auto completion to work nicely with python, django, and vim?

I\'ve been trying to use pysmell, but I can\'t seem to get it set up corr

5条回答
  •  孤街浪徒
    2020-12-04 07:26

    Today, you not need special extentions for django autocomplete in vim. Make sure that you have vim with python support. To check it, type in xterm:

    vim --version|grep python

    output:

    +python -python3 +quickfix +reltime +rightleft -ruby +scrollbind +signs ... ...

    To make work autocomplete, add this lines in your .vimrc:

    autocmd FileType python set omnifunc=pythoncomplete#Complete

    if has("python")

    python import sys,os

    python sys.path.append('/home/sergey/workspace/django')

    python os.environ['DJANGO_SETTINGS_MODULE'] = 'djangoProject.settings'

    endif

    where:

    • sys.path.append is path to your django workspace directory
    • djangoProject is name of your django project, which is going just after '/home/sergey/workspace/django'

    Finally, save it and restart vim. Now, after '.', you press default ctrl-x ctrl-o to get your autocomplete.

提交回复
热议问题