How to fix absent Python autocompletion on object instances in Vim?

后端 未结 3 1722
遥遥无期
遥遥无期 2021-01-30 18:35

I have found a strange behavior in Vim when I attempt to use autocompletion on objects. If I instantiate the objects on a module level, the Vim autocompletion will work on the i

相关标签:
3条回答
  • 2021-01-30 19:09

    Expanding the @BergmannF answer. If you don't want the rope's completion to select the first entry just append <C-P> (go to previous entry -> no entry) to the imap command:

    imap <C-Space> <C-R>=RopeCodeAssistInsertMode()<CR><C-P>
    
    0 讨论(0)
  • 2021-01-30 19:15

    I had to use the following line to get ctrl+space working

    imap <Nul> <C-R>=RopeCodeAssistInsertMode()<CR>
    
    0 讨论(0)
  • 2021-01-30 19:17

    Even though it does not use Vim’s omnicompletion plugin, by using rope, ropemode and ropevim it is possible to get autocompletion in methods:

    Autocompletion screenshot

    Even though not really exactly what I wanted it works pretty well.

    I got it working like so: I installed the ropevim distribution from here and added the following lines to my .vimrc file:

    " Rope AutoComplete
    let ropevim_vim_completion = 1
    let ropevim_extended_complete = 1
    let g:ropevim_autoimport_modules = ["os.*", "traceback", "django.*",  "xml.etree"]
    imap <c-space> <C-R>=RopeCodeAssistInsertMode()<CR>
    

    Now pressing Ctrl+Space will bring up the rope completion menu.

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