Top Related Projects
Nodejs extension host for vim & neovim, load extensions like VSCode and host language servers.
A code-completion engine for Vim
async language server protocol plugin for vim and neovim
Check syntax in Vim/Neovim asynchronously and fix files, with Language Server Protocol (LSP) support
:stars: Dark powered asynchronous completion framework for neovim/Vim8
Language Server Protocol (LSP) support for vim and neovim.
Quick Overview
Jedi-vim is a VIM plugin that provides Python autocompletion and code navigation features using the Jedi library. It enhances the Python development experience in VIM by offering intelligent code completion, go-to-definition functionality, and documentation lookup.
Pros
- Powerful autocompletion for Python code in VIM
- Seamless integration with VIM's existing features and keybindings
- Supports multiple Python versions and virtual environments
- Provides fast and accurate code navigation and refactoring tools
Cons
- May have occasional performance issues with large codebases
- Requires additional setup and configuration for optimal performance
- Limited functionality compared to full-fledged IDEs
- Can be challenging for new VIM users to fully utilize
Getting Started
- Install Jedi-vim using your preferred VIM plugin manager. For example, with vim-plug:
" Add this to your .vimrc
Plug 'davidhalter/jedi-vim'
- Install the Jedi library:
pip install jedi
-
Restart VIM and run
:PlugInstall
to install the plugin. -
Basic usage:
- Autocompletion: Start typing and press
Ctrl+Space
- Go to definition: Place cursor on a symbol and press
<leader>d
- Show documentation: Place cursor on a symbol and press
K
- Autocompletion: Start typing and press
For more advanced configuration options, refer to the plugin's documentation.
Competitor Comparisons
Nodejs extension host for vim & neovim, load extensions like VSCode and host language servers.
Pros of coc.nvim
- Supports multiple languages and frameworks out of the box
- Offers a more comprehensive set of features, including code completion, diagnostics, and refactoring
- Provides a smoother, more IDE-like experience in Vim/Neovim
Cons of coc.nvim
- Requires Node.js as a dependency, which may not be desirable for some users
- Has a steeper learning curve and more complex configuration compared to jedi-vim
- May have higher resource usage due to its extensive feature set
Code Comparison
coc.nvim configuration example:
let g:coc_global_extensions = ['coc-python', 'coc-json', 'coc-html']
inoremap <silent><expr> <TAB> pumvisible() ? "\<C-n>" : "\<TAB>"
nmap <silent> gd <Plug>(coc-definition)
jedi-vim configuration example:
let g:jedi#auto_initialization = 1
let g:jedi#completions_enabled = 1
let g:jedi#goto_definitions_command = "<leader>d"
Both plugins aim to enhance the development experience in Vim/Neovim, but coc.nvim offers a more comprehensive solution at the cost of increased complexity and resource usage. jedi-vim, while more focused on Python, provides a simpler and lighter alternative for those primarily working with Python projects.
A code-completion engine for Vim
Pros of YouCompleteMe
- More comprehensive language support, including C-family languages, JavaScript, and TypeScript
- Faster completion suggestions due to compiled core
- Integrates semantic completion engines for better accuracy
Cons of YouCompleteMe
- More complex setup and installation process
- Heavier resource usage, which may impact performance on older systems
- Requires external dependencies and compilers for full functionality
Code Comparison
YouCompleteMe configuration:
let g:ycm_autoclose_preview_window_after_completion = 1
let g:ycm_min_num_of_chars_for_completion = 2
let g:ycm_auto_trigger = 1
Jedi-vim configuration:
let g:jedi#completions_enabled = 1
let g:jedi#popup_on_dot = 1
let g:jedi#show_call_signatures = "1"
Summary
YouCompleteMe offers more comprehensive language support and faster completions, but comes with a more complex setup and higher resource usage. Jedi-vim is simpler to install and lighter on resources, but primarily focuses on Python. The choice between the two depends on your specific needs, language preferences, and system capabilities.
async language server protocol plugin for vim and neovim
Pros of vim-lsp
- Supports multiple languages through various Language Server Protocol (LSP) servers
- More flexible and extensible due to its LSP-based architecture
- Actively maintained with frequent updates and improvements
Cons of vim-lsp
- Requires additional setup and configuration for each language server
- May have a steeper learning curve for users new to LSP concepts
- Performance can vary depending on the specific language server used
Code comparison
vim-lsp configuration:
let g:lsp_settings = {
\ 'pyls': {'workspace_config': {'pyls': {'plugins': {'pydocstyle': {'enabled': v:false}}}}}
\ }
jedi-vim configuration:
let g:jedi#completions_enabled = 1
let g:jedi#use_splits_not_buffers = "right"
Summary
vim-lsp offers broader language support and flexibility through LSP, while jedi-vim provides a more straightforward setup specifically for Python. vim-lsp requires more configuration but can be more powerful across multiple languages. jedi-vim is simpler to set up and use for Python development but lacks the extensibility of vim-lsp. The choice between the two depends on the user's specific needs and preferences for language support and configuration complexity.
Check syntax in Vim/Neovim asynchronously and fix files, with Language Server Protocol (LSP) support
Pros of ALE
- Supports multiple languages and linters, not limited to Python
- Provides real-time linting and fixing as you type
- Integrates with various external tools for a comprehensive development experience
Cons of ALE
- Can be more resource-intensive due to its broader scope
- Configuration may be more complex for specific language setups
- Potential for conflicts with other plugins due to its wide-ranging features
Code Comparison
Jedi-vim (Python-specific autocomplete):
let g:jedi#auto_initialization = 1
let g:jedi#completions_enabled = 1
let g:jedi#use_splits_not_buffers = "right"
ALE (General-purpose linting and fixing):
let g:ale_linters = {'python': ['flake8', 'pylint']}
let g:ale_fixers = {'python': ['black', 'isort']}
let g:ale_fix_on_save = 1
Summary
Jedi-vim focuses on Python-specific features like autocompletion and code navigation, offering a streamlined experience for Python developers. ALE, on the other hand, provides a more comprehensive solution for multiple languages, including linting, fixing, and integration with various tools. While ALE offers broader functionality, it may require more setup and resources compared to the more focused Jedi-vim for Python-specific tasks.
:stars: Dark powered asynchronous completion framework for neovim/Vim8
Pros of deoplete.nvim
- Asynchronous completion, providing faster and more responsive suggestions
- Supports multiple languages and completion sources out of the box
- Highly customizable with a wide range of options and settings
Cons of deoplete.nvim
- Requires Neovim or Vim with Python support, limiting compatibility
- Steeper learning curve due to its extensive configuration options
- May require additional setup for optimal performance in specific languages
Code Comparison
deoplete.nvim configuration:
call deoplete#custom#option('sources', {
\ '_': ['buffer'],
\ 'python': ['jedi'],
})
let g:deoplete#enable_at_startup = 1
jedi-vim configuration:
let g:jedi#completions_enabled = 1
let g:jedi#use_splits_not_buffers = "right"
While both plugins offer code completion for Python, deoplete.nvim provides a more flexible framework for multiple languages and sources. jedi-vim focuses specifically on Python and offers a simpler setup, but may not be as performant for large projects. deoplete.nvim's asynchronous completion can provide a smoother experience, especially in complex codebases. However, jedi-vim's simplicity and out-of-the-box functionality for Python make it an attractive option for those primarily working with Python and seeking a straightforward solution.
Language Server Protocol (LSP) support for vim and neovim.
Pros of LanguageClient-neovim
- Supports multiple programming languages through Language Server Protocol (LSP)
- Provides more advanced features like code actions and workspace symbols
- Offers better integration with modern Neovim features
Cons of LanguageClient-neovim
- Requires more setup and configuration compared to jedi-vim
- May have higher resource usage due to running language servers
- Can be less stable or have inconsistent behavior across different language servers
Code Comparison
LanguageClient-neovim configuration:
let g:LanguageClient_serverCommands = {
\ 'python': ['pyls'],
\ 'rust': ['rustup', 'run', 'stable', 'rls'],
\ }
jedi-vim configuration:
let g:jedi#completions_enabled = 1
let g:jedi#use_splits_not_buffers = "right"
LanguageClient-neovim offers more flexibility in configuring multiple language servers, while jedi-vim has a simpler setup focused solely on Python. LanguageClient-neovim's approach allows for a consistent interface across different programming languages, whereas jedi-vim provides a more tailored experience for Python development.
LanguageClient-neovim is better suited for developers working with multiple languages and those who want to leverage the full power of LSP. jedi-vim remains a solid choice for Python-specific development, offering a lighter and more straightforward solution for those primarily focused on Python coding within Vim or Neovim.
Convert designs to code with AI
Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.
Try Visual CopilotREADME
.. image:: https://github.com/davidhalter/jedi-vim/blob/master/doc/logotype-a.svg
################################################# jedi-vim - awesome Python autocompletion with VIM #################################################
.. image:: https://travis-ci.org/davidhalter/jedi-vim.svg?branch=master :target: https://travis-ci.org/davidhalter/jedi-vim :alt: Travis-CI build status
jedi-vim is a VIM binding to the autocompletion library
Jedi <http://github.com/davidhalter/jedi>
_.
Here are some pictures:
.. image:: https://github.com/davidhalter/jedi/raw/master/docs/_screenshots/screenshot_complete.png
Completion for almost anything (Ctrl+Space).
.. image:: https://github.com/davidhalter/jedi/raw/master/docs/_screenshots/screenshot_function.png
Display of function/class bodies, docstrings.
.. image:: 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 <http://github.com/davidhalter/jedi-vim>
_.
Documentation
Documentation is available in your vim: :help jedi-vim
. You can also look
it up on github <http://github.com/davidhalter/jedi-vim/blob/master/doc/jedi-vim.txt>
_.
You can read the Jedi library documentation here <http://jedi.readthedocs.io/en/latest/>
_.
If you want to report issues, just use the github issue tracker. In case of
questions about the software, please use stackoverflow <https://stackoverflow.com/questions/tagged/jedi-vim>
_ 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 theos
module)
Installation
Requirements
-
Vim: You need a VIM version that was compiled with Python 3 or later (
+python3
). You can check this from within VIM using:python3 import sys; print(sys.version)
. -
Neovim: You need a python environment with
pynvim
installed:pip install pynvim
then check your environment is correctly setup from within Neovim using
:checkhealth provider.python
Manual installation
You might want to use pathogen <https://github.com/tpope/vim-pathogen>
_ or
Vundle <https://github.com/gmarik/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:
.. code-block:: sh
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
.. code-block:: vim
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 <https://www.archlinux.org/packages/community/any/vim-jedi/>
.
It is also available on
Debian (â¥8) <https://packages.debian.org/vim-python-jedi>
and
Ubuntu (â¥14.04) <http://packages.ubuntu.com/vim-python-jedi>
__ as
vim-python-jedi.
On Fedora Linux, it is available as
vim-jedi <https://packages.fedoraproject.org/pkgs/vim-jedi/vim-jedi/>
__.
Please note that this version might be quite old compared to using jedi-vim from Git.
Caveats
Note that the python-mode <https://github.com/klen/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 <http://github.com/davidhalter/jedi-vim/blob/master/doc/jedi-vim.txt>
_
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
:
.. code-block:: vim
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:
.. code-block:: vim
let g:jedi#auto_vim_configuration = 0
You can make jedi-vim use tabs when going to a definition etc:
.. code-block:: vim
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
:
.. code-block:: vim
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:
.. code-block:: vim
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.
.. code-block:: vim
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.
.. code-block:: vim
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.
.. code-block:: vim
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"
let g:jedi#rename_command_keep_name = "<leader>R"
An example for setting up your project:
.. code-block:: vim
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:
.. code-block:: vim
let g:jedi#environment_path = "venv"
Finally, if you don't want completion, but all the other features, use:
.. code-block:: vim
let g:jedi#completions_enabled = 0
FAQ
I want to use Jedi with a Python 2 Environment, but it's not listed under "Known environments"
Starting with version 0.18.0 Jedi dropped support for Python 2.
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:
.. code-block:: vim
autocmd FileType python setlocal completeopt-=preview
I want to do autocompletion
Don't even think about changing the Jedi command to <Tab>
,
use supertab <https://github.com/ervandew/supertab>
_!
The completion is too slow!
-
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.
-
If it is still slow after the initial completion and you have installed the python-mode Vim plugin, try disabling its rope mode:
.. code-block:: vim
let g:pymode_rope = 0
See issue
#163 <https://github.com/davidhalter/jedi-vim/issues/163>
__. -
You can also use
deoplete-jedi <https://github.com/zchee/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:.. code-block:: vim
let g:jedi#completions_enabled = 0
Testing
jedi-vim is being tested with a combination of vspec <https://github.com/kana/vim-vspec>
_ and py.test <http://pytest.org/>
_.
The tests are in the test
subdirectory, you can run them calling::
py.test
The tests are automatically run with travis <https://travis-ci.org/davidhalter/jedi-vim>
_.
Top Related Projects
Nodejs extension host for vim & neovim, load extensions like VSCode and host language servers.
A code-completion engine for Vim
async language server protocol plugin for vim and neovim
Check syntax in Vim/Neovim asynchronously and fix files, with Language Server Protocol (LSP) support
:stars: Dark powered asynchronous completion framework for neovim/Vim8
Language Server Protocol (LSP) support for vim and neovim.
Convert designs to code with AI
Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.
Try Visual Copilot