Vim 的 Python Omnicompletion 不起作用 [英] Vim's Omnicompletion with Python just doesn't work

查看:13
本文介绍了Vim 的 Python Omnicompletion 不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经在 Stack Overflow 和其他地方搜索了一个小时.唉!请帮忙.Vim 的omnicompletion 只是不起作用.

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

  1. 我编译了带有 Python 支持的 Vim 7.2.

  1. I have Vim 7.2 compiled with Python support.

filetype plugin on 在我的 .vimrc 中.

.py 文件打开时,:echo &omnifunc 打印 pythoncomplete#Complete.

When a .py file is open, :echo &omnifunc prints pythoncomplete#Complete.

我正在处理一个大型项目,我有一个使用 exhuberant-ctags 生成的 tags 文件.它在 Vim 的 ctags 路径中.我可以通过在符号上键入 ^] 来测试它,然后我会转到符号的定义.

I'm working with a large project and I have a tags file generated with exhuberant-ctags. It's in Vim's ctags path. I can test it by typing ^] on a symbol and I'm then taken to the symbols' definition.

更新 1:我的所有项目代码都在 python-in-Vim 的路径中.我可以 :python import myproject 成功.

Update 1: All of my project's code is in the python-in-Vim's path. I can :python import myproject successfully.

现在,无论我在哪里尝试 C-x C-o,我得到的都是:

Now, anywhere I try C-x C-o, all I get is:

-- Omni completion (^O^N^P) Pattern not found

我做错了什么?

更新 2: 当我在模块级别输入 Cx Co Cn 时,Vim 会显示一个完成弹出窗口,其中包含来自我项目中其他模块的一些模块级别常量.但它只是常量(符号大写字母),其他地方仍然无法完成.

Update 2: When I type C-x C-o C-n at the module-level, Vim displays a completion popup with a few module-level constants from other modules in my project. But it's only constants (symbols capital letters) and the completion still doesn't work anywhere else.

更新 3:我发现文件顶部的 Cx Co 启动了某种omnicompletion,以及 pprint 的完成. 调出pprint 模块中所有内容的菜单和快速参考.但是,我自己的模块的导入都没有完成.

Update 3: I've found that C-x C-o at the top of the file starts some kind of omnicompletion, and completion for pprint. brings up the menu and quick-reference of everything in the pprint module. However, none of my own module's imports are being completed.

更新 4,一年后:我放弃并学习了 Emacs.我去过黑暗的一面,那片充满阴谋诡计的神秘之地,我对你说我找到了这条路.

Update 4, one year later: I gave up and learned Emacs. I have been to the dark side, the mystical land of intrigue and spice, and I say to thee that I have found The Way.

更新 5,两年后:我又回到了 Vim.Emacs 很漂亮,但即使使用了 1.5 年的 Emacs,我在 Vim 中完成工作的速度仍然更快.但是,我现在已经停止编写 Python,并且无法测试这些建议的效果.

Update 5, two years later: I went back to Vim. Emacs is beautiful, but even after 1.5 years of Emacs, I'm still faster at getting work done in Vim. I've stopped writing Python for now, however, and can't test how well these suggestions work.

推荐答案

哪个模块包含您要完成的符号?它在python stdlib中吗?还是第三方模块?

What module contains the symbol you are trying to complete? Is it in the python stdlib? Or is it a third-party module?

确保模块/包在 PYTHONPATH 中.

Make sure that the module/package is in the PYTHONPATH.

在 Vim 中,执行:

In Vim, do:

:python import sys
:python print sys.path

添加模块目录:

:python sys.path.append("/path/to/directory/")

这篇关于Vim 的 Python Omnicompletion 不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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