Can't get the jedi-vim plugin to work
Asked Answered
H

5

12

I'm trying to use the jedi-vim plugin for Python autocompletion but I can't get it to work.

I have Vim 7.3, and here's what I did:

1- clone the code from

git clone http://github.com/davidhalter/jedi-vim path/to/bundles/jedi-vim

2- copy jedi-vim/plugin/jedi.vim to ~/.vim/plugin/

3- copy jedi-vim/doc/jedi-vim.txt to ~/.vim/doc/

Now when I open vim, enter the insert mode and type

import wave
wave.

nothing happens, though the doc specify Autocompletion is also triggered by typing a period in insert mode, and if I try <Ctrl-Space> I get the following error

E29: No inserted text yet
Press ENTER or type command to continue

I checked :map and it seems that <Ctrl-Space> is not used:

n  [m          *@:call <SNR>21_Python_jump('?^\s*\(class\|def\)')<CR>
n  [[          *@:call <SNR>21_Python_jump('?^\(class\|def\)')<CR>
n  ]m          *@:call <SNR>21_Python_jump('/^\s*\(class\|def\)')<CR>
n  ]]          *@:call <SNR>21_Python_jump('/^\(class\|def\)')<CR>
n  gx            <Plug>NetrwBrowseX
n  <Plug>NetrwBrowseX * :call netrw#NetrwBrowseX(expand("<cWORD>"),0)<CR>

Since I got an error using <Ctrl-Space>, I guess it must do something, right? Why can't I see it with :map?

What am I missing?

edit

:scriptnames

  1: /usr/share/vim/vimrc
  2: /usr/share/vim/vim73/debian.vim
  3: /usr/share/vim/vim73/syntax/syntax.vim
  4: /usr/share/vim/vim73/syntax/synload.vim
  5: /usr/share/vim/vim73/syntax/syncolor.vim
  6: /usr/share/vim/vim73/filetype.vim
  7: ~/.vimrc
  8: ~/.vim/plugin/jedi.vim
  9: /usr/share/vim/vim73/ftplugin.vim
 10: /usr/share/vim/vim73/plugin/getscriptPlugin.vim
 11: /usr/share/vim/vim73/plugin/gzip.vim
 12: /usr/share/vim/vim73/plugin/matchparen.vim
 13: /usr/share/vim/vim73/plugin/netrwPlugin.vim
 14: /usr/share/vim/vim73/plugin/rrhelper.vim
 15: /usr/share/vim/vim73/plugin/spellfile.vim
 16: /usr/share/vim/vim73/plugin/tarPlugin.vim
 17: /usr/share/vim/vim73/plugin/tohtml.vim
 18: /usr/share/vim/vim73/plugin/vimballPlugin.vim
 19: /usr/share/vim/vim73/plugin/zipPlugin.vim
 20: /usr/share/vim/vim73/syntax/vim.vim
 21: /usr/share/vim/vim73/syntax/python.vim
 22: /usr/share/vim/vim73/ftplugin/vim.vim

edit 2

I updated Vim to 7.4 and installed vim-jedi using pathogen as described in the doc:

1- install jedi 2- install pathogen 3- add execute pathogen#infect() in my ~/.vimrc 4- clone git repository in ~/.vim/bundle/

I create a new file, and I still have no autocompletion. Eg:

import numpy as np
np.

and control+space in insert mode returns:

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

Is there any omni completion plugin conflicting? I haven't installed such plugin...

Should I had anything else to my ~/.vimrc file?

Harmonics answered 7/2, 2014 at 13:14 Comment(3)
I don't understand step 1 and 2. They don't seem to make any sense. Just remove that stuff again. Do you use pathogen, vundle or vam? I don't see the <Ctrl-Space> command in :map either, but you should see some other Jedi commands (leader-d for example). Please also post :mes and :scriptnames.Fiddlestick
1 and 2 is to install jedi-vim. I edited my question to add the output of :scriptname.Harmonics
As long as there's no jedi-vim in your scriptnames, it obviously won't work. But that's not jedi-vim's fault, it's either pathogen/vundle/vam's fault or your mistake. (In your current scriptnames I don't see jedi-vim. But maybe it's there after edit 2? I don't know.)Fiddlestick
H
-4

I installed jedi-vim with pathogen, and it now works.

EDIT: to reply to the comments below: I get jedi-vim to work by reinstalling it using pathogen instead of installing it from source. This fixed my issue, so I considered it to be an answer.

Harmonics answered 3/3, 2014 at 4:53 Comment(3)
An usage example/command might be of help here( consider elaborating your answer ).Niagara
How is this an answer?Cypripedium
How come this be an answer ? This is not helping in any way.Rabah
F
20

This is the basic installation of Jedi with Pathogen.

  1. Install Pathogen

    mkdir -p ~/.vim/autoload ~/.vim/bundle && \
    curl -LSso ~/.vim/autoload/pathogen.vim https://tpo.pe/pathogen.vim
    
  2. Configure.vimrc
    if you have a ~/.vimrc file: add the following line to it

    execute pathogen#infect()
    

    else: create a blank file named .vimrc at your home folder and add the following lines to it.

    execute pathogen#infect()
    syntax on
    filetype plugin indent on
    
  3. Install Jedi.

    cd ~/.vim/bundle/ && git clone --recursive https://github.com/davidhalter/jedi-vim.git
    
  4. enjoy!

    enter image description here

Fen answered 12/2, 2017 at 20:57 Comment(2)
Thanks, I've spent hours trying to make VIM my next IDE. Yours is the only (unambigious) way I got working. I wonder if the pink pop up box you pictured is still expected? I get a 1/4 - 1/3 off the top of the window taken over, but that is for help on a MWE.Folksy
This should be the accepted answer! This works bestCaesarism
R
6

If you have

set paste

in your .vimrc file, jedi will fail to run.

Restraint answered 10/1, 2017 at 17:28 Comment(0)
B
6

I had a similar error because of a mismatch between the python version I intended to use and the one that was called.

Make sure jedi is using the intended version of python. E.g. add let g:jedi#force_py_version = 3 to your .vimrc

Brachial answered 7/12, 2018 at 12:18 Comment(0)
B
0

I think the problem is your vim version is too low,I suggest you update to vim 7.4 and make sure it has open the python function,If you want autocomplete function, I suggest you can try You complete Me,It is more powerful,it need Vim 7.3.584+,now the vim 7.4 is come out,it is easy to install, you can install in this ways,

#!/bin/bash  
MyInstallDir="/root/MyVim74Install/"  
cd ~  
mkdir MyVim74Install  
if [ -d $MyInstallDir ]; then  
  echo "create MyInstallDir success"  
else  
  echo "create MyInstallDir Error"  
 fi  
cd $MyInstallDir  
pwd  

wget http://ftp.gnu.org/pub/gnu/ncurses/ncurses-5.9.tar.gz  
tar -zxvf ncurses-5.9.tar.gz  
cd ncurses-5.9  
./configure  
make  
make install  
make clean  

cd ~  
cd $MyInstallDir  
wget http://www.cmake.org/files/v2.8/cmake-2.8.12.2.tar.gz
tar xzvf cmake-2.8.7.tar.gz   
cd cmake-2.8.7 
./bootstrap   
make
make install

wget ftp://ftp.vim.org/pub/vim/unix/vim-7.4.tar.bz2  
tar -jxvf vim-7.4.tar.bz2  
cd vim74 ./configure --enable-gui=gtk2 --enable-cscope --enable-multibyte --enable-xim   --enable-fontset \
--with-features=huge --enable-pythoninterp=yes --with-python-config-dir=/usr/lib/python2.7/config
make 
make install
make clean 

git clone https://github.com/gmarik/vundle.git ~/.vim/bundle/vundle 
apt-get install gcc  
apt-get install g++ 
wget http://prdownloads.sourceforge.net/ctags/ctags-5.6.tar.gz  
tar -zxvf ctags-5.6.tar.gz  
cd ctags-5.6  
./configure &&make &&make install  
ctags -R
Bisectrix answered 20/2, 2014 at 14:28 Comment(1)
1. You don't need VIM 7.4 to use jedi-vim. Jedi-vim works perfectly fine with 7.3 (and even some lower versions, but some things like call signatures are ignored [no +conceal]. 2. YouCompleteMe is not more "powerful" than jedi-vim for Python. It uses the exact same engine (Jedi) . It does support more languages, though.Fiddlestick
H
-4

I installed jedi-vim with pathogen, and it now works.

EDIT: to reply to the comments below: I get jedi-vim to work by reinstalling it using pathogen instead of installing it from source. This fixed my issue, so I considered it to be an answer.

Harmonics answered 3/3, 2014 at 4:53 Comment(3)
An usage example/command might be of help here( consider elaborating your answer ).Niagara
How is this an answer?Cypripedium
How come this be an answer ? This is not helping in any way.Rabah

© 2022 - 2024 — McMap. All rights reserved.