如何在Vim中的对象实例上修复缺少的Python自动补全功能? [英] How to fix absent Python autocompletion on object instances in Vim?

查看:56
本文介绍了如何在Vim中的对象实例上修复缺少的Python自动补全功能?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我尝试在对象上使用自动完成功能时,在Vim中发现了一个奇怪的行为.如果我在模块级别实例化对象,Vim自动补全将在我创建的实例上起作用:

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 instance I create:

如果我在函数或类中尝试相同的操作,它将不再起作用:

If I try the same from within a function or class, it is no longer working:

有人知道如何解决此问题,还是有办法让非完成功能在非模块范围内的实例上工作?

Does anyone know how to fix this, or is there a way to get omnicompletion to work on instances in a non module-scope?

推荐答案

即使它不使用Vim的omnicompletion插件,通过使用rope,ropemode和ropevim,也可以通过以下方法获得自动完成功能:

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

即使不是我真正想要的,它也能很好地工作.

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

我的工作方式如下:我从此处安装了ropipim发行版,并将以下几行添加到我的 .vimrc 文件:

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>

现在按 Ctrl + Space 将弹出绳索完成菜单.

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

这篇关于如何在Vim中的对象实例上修复缺少的Python自动补全功能?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆