Using the jedi autocompletion library for VIM.

Overview

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:

https://github.com/davidhalter/jedi/raw/master/docs/_screenshots/screenshot_complete.png

Completion for almost anything (Ctrl+Space).

https://github.com/davidhalter/jedi/raw/master/docs/_screenshots/screenshot_function.png

Display of function/class bodies, docstrings.

https://github.com/davidhalter/jedi/raw/master/docs/_screenshots/screenshot_pydoc.png

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 assignment <leader>g (typical goto function)
  • Goto definition <leader>d (follow identifier as far as possible, includes imports and statements)
  • Goto (typing) stub <leader>s
  • 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.7 or later (+python or +python3). 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. Install git submodule update --init --recursive in your jedi-vim repository.

Example installation command using Pathogen:

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

Example installation using Vundle:

Add the following line in your ~/.vimrc

Plugin 'davidhalter/jedi-vim'

For installing Jedi, pip install jedi will also work, but you might run into issues when working in virtual environments. Please use git submodules.

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 by default (with the conceal feature), 2 otherwise), which has the advantage of being easier to refer to (but is a hack with many drawbacks since it changes the buffer's contents), 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_stubs_command = "<leader>s"
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"

An example for setting up your project:

let g:jedi#environment_path = "/usr/bin/python3.9"

jedi-vim tries its best to guess your virtual env. If you want to work with a specific virtual environment however, you can point jedi-vim towards it:

let g:jedi#environment_path = "venv"

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 too slow!

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

  2. If it is still slow after the initial completion and you have installed the python-mode Vim plugin, try disabling its rope mode:

    let g:pymode_rope = 0

    See issue #163.

  3. You can also use deoplete-jedi for completions, which uses Jedi, but does completions asynchronously (requires Neovim). It makes sense to use both jedi-vim and deoplete-jedi, but you should disable jedi-vim's completions then:

    let g:jedi#completions_enabled = 0

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.

Owner
Dave Halter
Dave Halter
JupyterLite is a JupyterLab distribution that runs entirely in the browser power by wasm

JupyterLite is a JupyterLab distribution that runs entirely in the browser built from the ground-up using JupyterLab components and extensions.

Jeremy Tuloup 76 Dec 13, 2022
Python-Text-editor: a simple text editor on Python and Tkinter

Python-Text-editor This is a simple text editor on Python and Tkinter. The proje

Innokentie 1 Jan 03, 2022
A simple Notepad-like editor written in Python

monkepad A simple Notepad-like editor written in Python Since MonkePad is written in one file, all your customization can be done without much trouble

5 Dec 28, 2021
Write maintainable, production-ready pipelines using Jupyter or your favorite text editor. Develop locally, deploy to the cloud. ☁️

Write maintainable, production-ready pipelines using Jupyter or your favorite text editor. Develop locally, deploy to the cloud. ☁️

Ploomber 2.9k Jan 06, 2023
A WYSIWYG layout editor for Jupyter widgets

Based on the React library FlexLayout, ipyflex allows you to compose the sophisticated dashboard layouts from existing Jupyter widgets without coding. It supports multiple tabs, resizable cards, drag

Duc Trung LE 93 Nov 24, 2022
A code-completion engine for Vim

YouCompleteMe: a code-completion engine for Vim NOTE: Minimum Requirements Have Changed Our policy is to support the Vim version that's in the latest

24.5k Dec 30, 2022
ReText: Simple but powerful editor for Markdown and reStructuredText

Welcome to ReText! ReText is a simple but powerful editor for Markdown and reStructuredText markup languages. One can also add support for custom mark

ReText 1.6k Dec 23, 2022
The uncompromising Python code formatter

The Uncompromising Code Formatter “Any color you like.” Black is the uncompromising Python code formatter. By using it, you agree to cede control over

Python Software Foundation 30.7k Jan 02, 2023
Using the jedi autocompletion library for VIM.

jedi-vim - awesome Python autocompletion with VIM jedi-vim is a VIM binding to the autocompletion library Jedi. Here are some pictures: Completion for

Dave Halter 5.1k Dec 31, 2022
Python Tools for Visual Studio

Python tools for Visual Studio Python support for Visual Studio is developed and managed here. Visit our product overview and downloads page, read our

Microsoft 2.4k Dec 30, 2022
Jupyter Interactive Notebook

Jupyter Notebook The Jupyter notebook is a web-based notebook environment for interactive computing. Notice Please note that this repository is curren

Project Jupyter 9.7k Jan 02, 2023
Cameray is a lens editor and simulator for fun.

Cameray is a lens editor and simulator for fun. It's could be used for studying an optics system of DSLR in an interactive way. But the project is in a very early version. The program is still crash-

Shuoliu Yang 59 Dec 10, 2022
A small, simple editor for beginner Python programmers. Written in Python and Qt5.

Mu - A Simple Python Code Editor Mu is a simple code editor for beginner programmers based on extensive feedback from teachers and learners. Having sa

Mu 1.2k Jan 03, 2023
A very simple Editor.js parser written in pure Python

pyEditor.js A very simple Editor.js parser written in pure Python. Soon-to-be published on PyPI. Features: Automatically convert Editor.js's JSON outp

Kevo 7 Nov 01, 2022
Python IDE for beginners

Thonny Thonny is a Python IDE meant for learning programming. End users See https://thonny.org and wiki for more info. Contributors Contributions are

Thonny, Python IDE for beginners 2.1k Jan 02, 2023
A JupyterLab extension for version control using Git

A JupyterLab extension for version control using Git

JupyterLab 1.2k Jan 03, 2023
A free Python source code editor and Notepad replacement for Windows

Website Download Features Toolbar Wide array of view options Syntax highlighting support for Python Usable accelerator keys for each function (Ctrl+N,

Mohamed Ahmed 7 Feb 16, 2022
Emacs Python Development Environment

Elpy, the Emacs Python IDE Elpy is an Emacs package to bring powerful Python editing to Emacs. It combines and configures a number of other packages,

Jorgen Schäfer 1.8k Jan 02, 2023
Vim plugin for executing Python's optional static type checker MyPy

Vim plugin for executing Python's optional static type checker MyPy

Mark McDonnell 91 Dec 04, 2022