有什么方法可以让 pythonomnicomplete 与 vim 中的非系统模块一起使用吗?
我唯一可以使用 pythonomnicomplete 的就是系统模块。 对于我的站点包中的模块或我当前正在处理的模块,我没有得到任何帮助。
The only thing I can get python omnicomplete to work with are system modules. I get nothing for help with modules in my site-packages or modules that I'm currently working on.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(6)
一旦我为我的一个站点包生成了 ctags,它就开始为该包工作——所以我猜测omnicomplete 功能依赖于非 sys 模块的 ctags。
编辑:根本不正确。
问题是——我的测试很差——omnicomplete 只适用于我项目的一部分,但不是大部分。
问题是我正在开发一个 django 项目,为了导入 django.db,您需要设置一个环境变量。 由于我无法导入 django.db,因此从 django.db 继承的任何类或导入从 django.db 继承的类的任何模块都将无法完成。
Once I generated ctags for one of my site-packages, it started working for that package -- so I'm guessing that the omnicomplete function depends on ctags for non-sys modules.
EDIT: Not true at all.
Here's the problem -- poor testing on my part -- omnicomplete WAS working for parts of my project, just not most of it.
The issue was that I'm working on a django project, and in order to import django.db, you need to have an environment variable set. Since I couldn't import django.db, any class that inherited from django.db, or any module that imported a class that inherited from django.db wouldn't complete.
我在 PYTHONPATH 或站点包中完成了我自己的模块。 我不确定您使用的 pythoncomplete.vim 脚本是什么版本,但您可能想确保它是最新的。
编辑:这是我在系统上看到的一些示例...
这个文件(mymodule.py),我放在 PYTHONPATH 中的目录中,然后放在站点包中。 两次我都能得到下面的屏幕截图。
I get completion for my own modules in my PYTHONPATH or site-packages. I'm not sure what version of the pythoncomplete.vim script you're using, but you may want to make sure it's the latest.
EDIT: Here's some examples of what I'm seeing on my system...
This file (mymodule.py), I puth in a directory in PYTHONPATH, and then in site-packages. Both times I was able to get the screenshot below.
今晚刚刚在 Python reddit 上看到了这个:PySmell。 看起来像您要找的东西。
Just ran across this on Python reddit tonight: PySmell. Looks like what you're looking for.
虽然需要注意的是,您必须正确设置
PYTHONPATH
环境变量,但根据前面的答案,有一个值得注意的 Vim 中的错误,在导入失败时会阻止omnicompletion 工作。 自 Vim 7.2.79 起,此错误尚未修复。While it's important to note that you must properly set your
PYTHONPATH
environmental variable, per the the previous answer, there is a notable bug in Vim which prevents omnicompletion from working when an import fails. As of Vim 7.2.79, this bug hasn't been fixed.故障排除提示:验证您尝试全向完成的模块是否可以通过 VIM 导入。 我有一些语法正确的 Python,但 VIM 不喜欢:
举个例子,从我的类定义中删除括号允许 VIM 导入模块,随后该模块上的 OmniComplete 开始工作。
Trouble-shooting tip: verify that the module you are trying to omni-complete can be imported by VIM. I had some syntactically correct Python that VIM didn't like:
Case-in-point, removing the parenthesis from my class definition allowed VIM to import the module, and subsequently OmniComplete on that module started to work.
我认为您在 pydiction 脚本之后。 它可以让您添加自己的东西和站点包以完成全方位。
当你这样做时,将以下内容添加到你的 python.vim 文件中...
这将使你自动完成包功能,例如,如果你输入...
然后 [CTRL][N],你将获得一个列表os.path 的函数。
I think your after the pydiction script. It lets you add your own stuff and site-packages to omni complete.
While your at it, add the following to your python.vim file...
This will let you auto-complete package functions e.g. if you enter...
and then [CTRL][N], you'll get a list of the functions for os.path.