Question

I read that omnicompletion should work 'out of the box' but it doesn't, and I wonder what I'm doing wrong.

I compiled the latest version of vim and it shows "+python":

user$ vim --version
VIM - Vi IMproved 7.3 (2010 Aug 15, compiled Feb 16 2013 11:22:56)
MacOS X (unix) version
Compiled by user@computer.local
Normal version without GUI.  Features included (+) or not (-):
-arabic +autocmd -balloon_eval -browse +builtin_terms +byte_offset +cindent 
-clientserver +clipboard +cmdline_compl +cmdline_hist +cmdline_info +comments 
-conceal +cryptv -cscope +cursorbind +cursorshape +dialog_con +diff +digraphs 
-dnd -ebcdic -emacs_tags +eval +ex_extra +extra_search -farsi +file_in_path 
+find_in_path +float +folding -footer +fork() -gettext -hangul_input -iconv 
+insert_expand +jumplist -keymap -langmap +libcall +linebreak +lispindent 
+listcmds +localmap -lua +menu +mksession +modify_fname +mouse -mouseshape 
-mouse_dec -mouse_gpm -mouse_jsbterm -mouse_netterm -mouse_sysmouse 
+mouse_xterm -multi_byte +multi_lang -mzscheme +netbeans_intg -osfiletype 
+path_extra -perl +persistent_undo +postscript +printer -profile +python 
-python3 +quickfix +reltime -rightleft -ruby +scrollbind +signs +smartindent 
-sniff +startuptime +statusline -sun_workshop +syntax +tag_binary 
+tag_old_static -tag_any_white -tcl +terminfo +termresponse +textobjects +title
 -toolbar +user_commands +vertsplit +virtualedit +visual +visualextra +viminfo 
+vreplace +wildignore +wildmenu +windows +writebackup -X11 -xfontset -xim -xsmp
 -xterm_clipboard -xterm_save 
   system vimrc file: "$VIM/vimrc"
     user vimrc file: "$HOME/.vimrc"
      user exrc file: "$HOME/.exrc"
  fall-back for $VIM: "/Users/user/Software/vim/share/vim"
Compilation: gcc -c -I. -Iproto -DHAVE_CONFIG_H   -DMACOS_X_UNIX -no-cpp-precomp  -g -O2 -D_FORTIFY_SOURCE=1      
Linking: gcc   -L/usr/local/lib -o vim       -lm -lncurses  -framework Cocoa     -framework Python

I cleared out my .vimrc to just leave:

" Automatic reloading of .vimrc
autocmd! bufwritepost .vimrc source %

filetype plugin on

and my ~/.vim/ directory is just

autoload/pythoncomplete.vim

which I downloaded from http://www.vim.org/scripts/script.php?script_id=1542

and the following command returns:

:echo &omnifunc
pythoncomplete#Complete

which seems to be fine. But every time I do control-xo on the following test.py file:

#! /usr/bin/env python
import numpy
numpy.r

either after typing "num" or "numpy.r" I get

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

Is there a problem with my installation? Any thoughts are greatly appreciated. Thank you.

EDIT: Following the suggestion from TankorSmash about installing python-mode, I can get "num" to complete to "numpy" but not "numpy.r" to complete to anything.

Here is my new .vimrc file:

" Automatic reloading of .vimrc
autocmd! bufwritepost .vimrc source %

" Pathogen load
filetype off

call pathogen#infect()
call pathogen#helptags()

filetype plugin indent on
syntax on

and my .vim directory tree:

.vim
    autoload
        pathogen.vim
        pythoncomplete.vim
    bundle
        python-mode

Any ideas?

Was it helpful?

Solution

You don't need any third party completion script to be able to complete Python.

I don't have one (the only Python-specific script I have is a short ftplugin) and these are the suggestions I get when I hit <C-x><C-o> after numpy. and numpy.arc

numpy.

numpy.arc

Since you appear to be on Mac OS X, you really shouldn't compile Vim yourself. Installing the latest MacVim snapshot is the best way to run Vim on a Mac and I'm fairly certain you'd get the same suggestions as on this Linux machine out of the box.

edit

I just tested the same code on an old MacVim (snapshot 53) on my wife's bare bones iMac (python 2.5) and I got more or less the same suggestions (485 vs 551).

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top