Vim's Omnicompletion with Python just doesn't work

前端 未结 10 987
悲&欢浪女
悲&欢浪女 2020-12-07 13:22

I\'ve searched around for an hour, both on Stack Overflow and elsewhere. Alas! Please help. Vim\'s omnicompletion just doesn\'t work.

  1. I have Vim 7.

相关标签:
10条回答
  • 2020-12-07 13:59

    If you are using python2, make sure you

    sudo apt-get install vim.nox-py2 
    

    and use vim.nox-py2 instead of vim.

    0 讨论(0)
  • 2020-12-07 14:06

    Since you were prudent and made certain your code is reachable by the PYTHONPATH, per codeape's suggestion, is there a possibility that you are running into the import bug for Vim Python omni-complete? This bug still exists as of Vim 7.2.245.

    Essentially, if any import statement fails in the file you are working in, regardless of whether it's wrapped in a Try-Except clause, it will completely break omni-completion. It should be fairly easy to check for this, since most imports occur at the very beginning of the file.

    If you do decide that this bug is the cause of your troubles, your options include:

    • making sure that the modules you import are on the system path, not just the project files
    • commenting out any import statements that fail
    • fixing the bug
    • using ropevim as your completion method
    • using a different editor; Netbeans IDE has Python support, and the jVi plugin is rather good if you're a Vim addict like myself (don't let the 1990s look of the home page fool you)
    0 讨论(0)
  • 2020-12-07 14:08

    I had a similar problem with omni completion not working. In my case it turned out that the minibufexpl.vim plugin was interfering with omni completion. Here is how I found out:

    Normal keyword completion works. Omni complete does not work for any language, not just Python. omnifunc is set correctly. After I C-X C-O, nothing happens. I do ":py print globals()" and it is clear that the pythoncomplete was not loaded. I can ":call pythoncomplete#Complete(1, '')" and see it get loaded. To me this rules out it being a Vim issue. It seems something is interfering with keymapping or otherwise intercept the omni completion request. So I start to disable my plugins one by one. It turns out the culprit in my case is "minibufexpl". I have the Holgado version from github.

    It looks like there are many open issues with MBE according to the issue tracker on github and there hasn't been any progress since early 2012. I am just going to disable it for now so I can use auto completion. Meanwhile I will just add the following to my vimrc to keep multiple modified buffers open at the same time and use a simple key sequence to cycle through them (MBE more intelligently select the buffers to cycle through but seems too heavy-handed for a simple problem):

    set hidden
    noremap <C-TAB> :bnext<CR>
    noremap <C-S-TAB> :bprev<CR>
    
    0 讨论(0)
  • 2020-12-07 14:08

    c-x c-n works to get the list of members of an object.

    0 讨论(0)
提交回复
热议问题