4

I am trying to use vim on my Python journey, based on this guide.

I think I have the same problem as a paid nerd but since they didn't find a solution I am posting again here.

For some reason I can't get omnicompletion to work in vim, with python. I have installed the fabulous R-plugin and built the tags list. So I get omnicompletion with R.

But not for Python. A few observations:

  1. :echo &omnifunc prints pythoncomplete#Complete.
  2. the .vim/doc/tags file has R tags, but no python (but this is because python is supported by default right?)
  3. If I do import math in my .py file I can autocomplete eg. ma to math. but no methods are found?

How can I proceed?

halfer
  • 19,824
  • 17
  • 99
  • 186
Andreas
  • 6,612
  • 14
  • 59
  • 69
  • 1
    So, if you `vim a.py`, `import math`, `math.s^x^O` you don't see a `sin(x) sinh(x) sqrt(x)` list? – Eelvex Mar 27 '11 at 19:08
  • jesus I am an ass - yes I do. Apparently omnicompletion in vim works differently then in geany? In geany everything - even print is included in omnicompletion... Actually - trying this with geany it seems that geany's autocompletion is something entirely different. Sorry guys... I really feel embarresed about this. – Andreas Mar 27 '11 at 19:52
  • Eelvex - do you mind providing a answer that I can accept. This will give you some points and it will show my stupidity for the world to see :-) – Andreas Mar 27 '11 at 19:54
  • 1
    It still strikes me as odd - it seems that default things like `sorted` can't be autocompleted. Clearly there is something that I don't understand. E.g It's seems different from what the R-plugin does – Andreas Mar 27 '11 at 20:08

5 Answers5

6

It appears that the default omnicompletion for python (pythoncomplete#Complete) does not know about buildins/keywords.

When you Ctrl-XCtrl-O on math. (if you have imported "math") you should see the available math. functions but to do so for print, sorted etc I think you need a plugin like:

Eelvex
  • 8,975
  • 26
  • 42
0

There are a number of plugins for python completion. The vim python filetype plugin appears to be the best at this point. It requires a vim built with python support, and should otherwise work out of the box. Completion of system modules will just work, and you'll their methods in omnicompletion.

djs
  • 4,626
  • 2
  • 28
  • 38
0

I assume all modules you are importing are in Python path, right? Check if all of your imports in this file are working, in my case one failing import (syntax error in module being imported) broke omnicompletion.

kuba
  • 31
  • 3
  • I am pretty sure since I am just working with a vanilla python install in order to learn python. Have not made any modules my self. in vim: "python import sys" and "python print sys.path" prints the paths. – Andreas Mar 27 '11 at 18:21
0

check ~/.vim directory ,inside doc directory you should have NERD_tree.txt, so you should have nerd tree plugin installed. . .

Kracekumar
  • 19,457
  • 10
  • 47
  • 56
0

.vim/doc/tags contains tags for the Vim documentation (including the R plugin), and this has nothing to do with the tags used for completion. You can regenerate them using

:helptags ~/.vim/doc

When it comes to completion, which keyboard shortcut do you use? By default the omni-complete is bound to Ctrl-X Ctrl-O, not the usual Ctrl-N.

Adam Byrtek
  • 12,011
  • 2
  • 32
  • 32
  • Thanks that's what I thought. And yes - I use Ctrl-x Ctrl-o - which works with R files. When I use ctrl-x Ctrl-o I get "-- Omni completion (^O^N^P) Pattern not found" – Andreas Mar 27 '11 at 18:19