views:

1915

answers:

6

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.

+2  A: 

Just ran across this on Python reddit tonight: PySmell. Looks like what you're looking for.

PySmell is a python IDE completion helper.

It tries to statically analyze Python source code, without executing it, and generates information about a project’s structure that IDE tools can use.

technomalogical
A: 

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

 set iskeyword+=.

This will let you auto-complete package functions e.g. if you enter...

 os.path.

and then [CTRL][N], you'll get a list of the functions for os.path.

Pev
+2  A: 
Jeremy Cantrell
I just downloaded the most recent version -- no luck! How are you enabling it? Are you using CTAGs as well?
andrew
how are you testing it? try just putting something like "import sys" and then do "sys.<c-x><c-o>"
Jeremy Cantrell
As I said above, system modules omnicomplete just fine. It's the modules in my site-packages that I'm not getting completion for.
andrew
yes, i understand. i'm just wondering how you're testing it. all of my personal modules, along with site-packages work.
Jeremy Cantrell
Ah. Yes. Sys modules _do_ work.Do you have CTAGs built for your site packages? What platform are you on?
andrew
I'm on Linux (Ubuntu 8.04). I have ctags, but i don't use them for anything but the taglist plugin.
Jeremy Cantrell
See my explanation below. Silly me.
andrew
ahh, i see. glad to see you got that sorted out! :)
Jeremy Cantrell
+2  A: 

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.

andrew
I had this same problem except with app engine libraries, not django... thanks for helping me figure it out
Brandon Thomson
Had this problem a few more times now, the first thing I always do is try to import the module in the vanilla interpreter, that always seems to show where the error is. If you are using django or app engine or whaterver a lot of times they do imports in a different order than the interpreter would which can cause problems.
Brandon Thomson
+2  A: 

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.

gotgenes
+1  A: 

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:

:python import {module-name}
 Traceback (most recent call last):
   File "<string>", line 1, in ?
   File "modulename/__init__.py", line 9
     class empty_paranthesis():
                            ^
 SyntaxError: invalid syntax

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.

RobM