Git Product home page Git Product logo

jedi-vim's Introduction

jedi-vim - awesome Python autocompletion with VIM

Travis-CI build status

jedi-vim is a VIM binding to the autocompletion library Jedi.

Here are some pictures:

image

Completion for almost anything (Ctrl+Space).

image

Display of function/class bodies, docstrings.

image

Documentation (Pydoc) support (with highlighting, Shift+k).

There is also support for goto and renaming.

Get the latest from github.

Documentation

Documentation is available in your vim: :help jedi-vim. You can also look it up on github.

You can read the Jedi library documentation here.

If you want to report issues, just use the github issue tracker. In case of questions about the software, please use stackoverflow and tag your question with jedi-vim.

Contributing

We love Pull Requests! Read the instructions in CONTRIBUTING.md.

Features

The Jedi library understands most of Python's core features. From decorators to generators, there is broad support.

Apart from that, jedi-vim supports the following commands

  • Completion <C-Space>
  • Goto assignments <leader>g (typical goto function)
  • Goto definitions <leader>d (follow identifier as far as possible, includes imports and statements)
  • Show Documentation/Pydoc K (shows a popup with assignments)
  • Renaming <leader>r
  • Usages <leader>n (shows all the usages of a name)
  • Open module, e.g. :Pyimport os (opens the os module)

Installation

Requirements

You need a VIM version that was compiled with Python 2.6 or later (+python or +python3), which is typical for most distributions on Linux. You can check this from within VIM using :python3 import sys; print(sys.version) (use :python for Python 2).

Manual installation

You might want to use pathogen or Vundle to install jedi-vim.

The first thing you need after that is an up-to-date version of Jedi. You can either install it via pip install jedi or with git submodule update --init in your jedi-vim repository.

Example installation command using Pathogen:

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

Installation with your distribution

On Arch Linux, you can also install jedi-vim from official repositories as vim-jedi. It is also available on Debian (≥8) and Ubuntu (≥14.04) as vim-python-jedi. On Fedora Linux, it is available as vim-jedi.

Please note that this version might be quite old compared to using jedi-vim from Git.

Caveats

Note that the python-mode VIM plugin seems to conflict with jedi-vim, therefore you should disable it before enabling jedi-vim.

To enjoy the full features of jedi-vim, you should have VIM >= 7.3, compiled with +conceal (which is not the case on some platforms, including OS X). If your VIM does not meet these requirements, the parameter recommendation list may not appear when you type an open bracket after a function name. Please read the documentation for details.

Settings

Jedi is by default automatically initialized. If you don't want that I suggest you disable the auto-initialization in your .vimrc:

let g:jedi#auto_initialization = 0

There are also some VIM options (like completeopt and key defaults) which are automatically initialized, but you can skip this:

let g:jedi#auto_vim_configuration = 0

You can make jedi-vim use tabs when going to a definition etc:

let g:jedi#use_tabs_not_buffers = 1

If you are a person who likes to use VIM-splits, you might want to put this in your .vimrc:

let g:jedi#use_splits_not_buffers = "left"

This options could be "left", "right", "top", "bottom" or "winwidth". It will decide the direction where the split open.

Jedi automatically starts the completion, if you type a dot, e.g. str., if you don't want this:

let g:jedi#popup_on_dot = 0

Jedi selects the first line of the completion menu: for a better typing-flow and usually saves one keypress.

let g:jedi#popup_select_first = 0

Jedi displays function call signatures in insert mode in real-time, highlighting the current argument. The call signatures can be displayed as a pop-up in the buffer (set to 1, the default), which has the advantage of being easier to refer to, or in Vim's command line aligned with the function call (set to 2), which can improve the integrity of Vim's undo history.

let g:jedi#show_call_signatures = "1"

Here are a few more defaults for actions, read the docs (:help jedi-vim) to get more information. If you set them to "", they are not assigned.

NOTE: subject to change!

let g:jedi#goto_command = "<leader>d"
let g:jedi#goto_assignments_command = "<leader>g"
let g:jedi#goto_definitions_command = ""
let g:jedi#documentation_command = "K"
let g:jedi#usages_command = "<leader>n"
let g:jedi#completions_command = "<C-Space>"
let g:jedi#rename_command = "<leader>r"

Finally, if you don't want completion, but all the other features, use:

let g:jedi#completions_enabled = 0

FAQ

I don't want the docstring window to popup during completion

This depends on the completeopt option. Jedi initializes it in its ftplugin. Add the following line to your .vimrc to disable it:

autocmd FileType python setlocal completeopt-=preview

I want <Tab> to do autocompletion

Don't even think about changing the Jedi command to <Tab>, use supertab!

The completion is waaay too slow!

Completion of complex libraries (like Numpy) should only be slow the first time you complete it. After that, the results should be cached and very fast.

If it's still slow, in case you've installed the python-mode VIM plugin, disable it. It seems to conflict with jedi-vim. See issue #163.

Testing

jedi-vim is being tested with a combination of vspec and py.test.

The tests are in the test subdirectory, you can run them calling:

py.test

The tests are automatically run with travis.

jedi-vim's People

Contributors

andviro avatar arturdryomov avatar blueyed avatar d7415 avatar davidhalter avatar dbrgn avatar ethinx avatar freeo avatar gotgenes avatar haconeco avatar heavenshell avatar inside avatar itchyny avatar justincheevers avatar justinmk avatar littleq0903 avatar lodagro avatar magicreddeer avatar mattn avatar mozbugbox avatar np1 avatar pearofducks avatar petobens avatar ricobl avatar rogererens avatar tndoan avatar toupeira avatar tweekmonster avatar wilywampa avatar zekzekus avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.