views:

993

answers:

4

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.2 compiled with Python support.

  2. filetype plugin on is in my .vimrc.

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

  4. 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.

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

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

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

What am I doing wrong?

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.

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.

+3  A: 

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

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

In Vim, do:

:python import sys
:python print sys.path

To add the module's directory:

:python sys.path.append("/path/to/directory/")
codeape
Good suggestions, thanks. These are symbols from my project's code. Yes, the path is in Vim's Python's path. I've updated the question description.
a paid nerd
+1  A: 

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 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)
gotgenes
A: 

Have you tried using <C_x><C-]> ?

m42a
A: 

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

bytemangler