Skip to content

Commit

Permalink
feat: upgrade jedi-vim to 0.11.2 (#85)
Browse files Browse the repository at this point in the history
  • Loading branch information
thebaptiste authored Dec 6, 2024
1 parent 59afe41 commit 707060f
Show file tree
Hide file tree
Showing 31 changed files with 1,811 additions and 690 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
[run]
branch = 1
# Used by/for neovim-python-client.
concurrency = greenlet

[report]
include = pythonx/jedi_*.py,test/*
33 changes: 23 additions & 10 deletions layers/layer4_vim/0021_configvim/vim/bundle/jedi-vim/.travis.yml
Original file line number Diff line number Diff line change
@@ -1,18 +1,31 @@
sudo: false
dist: bionic
language: python
python: 3.8
env:
matrix:
- ENV=test
- ENV=check
matrix:
allow_failures:
# Needs to be fixed!
- env: ENV=test
- ENV=test
- ENV=check
- ENV=test_coverage
install:
- |
if [ "$ENV" = "test" ]; then
pip install pytest
elif [ "$ENV" = "test_coverage" ]; then
sudo add-apt-repository ppa:neovim-ppa/stable -y
sudo apt-get update -q
sudo apt-get install neovim -y
pip install pynvim pytest-cov
pip list
nvim --version
else
vim --version
fi
script:
- vim --version
- make "$ENV"
- make --keep-going "$ENV" BUILD_VIRTUAL_ENV=$VIRTUAL_ENV

after_script:
- |
if [ "$ENV" = "test_coverage" ]; then
coverage xml
travis_retry bash <(curl -s https://codecov.io/bash) -X fix -f coverage.xml -F py${TRAVIS_PYTHON_VERSION//./}
fi
Original file line number Diff line number Diff line change
Expand Up @@ -51,5 +51,11 @@ Bagrat Aznauryan (@n9code)
Tomoyuki Kashiro (@kashiro)
Tommy Allen (@tweekmonster)
Mingliang (@Aulddays)
Brian Mego (@brianmego)
Stevan Milic (@stevanmilic) <stevan.milic@yahoo.com>
Konstantin Glukhov (@Konstantin-Glukhov)
Seungchan An (@SeungChan92) <dev.issea1015@gmail.com>
Thomas Blauth (@ThomasBlauth) <thomas.blauth@protonmail.com>
James Cherti (@jamescherti)

@something are github user names.
41 changes: 30 additions & 11 deletions layers/layer4_vim/0021_configvim/vim/bundle/jedi-vim/Makefile
Original file line number Diff line number Diff line change
@@ -1,16 +1,35 @@
BUILD_VIRTUAL_ENV:=build/venv

test:
py.test
pytest

test_nvim:
VSPEC_VIM=nvim pytest

test_coverage: export PYTEST_ADDOPTS:=--cov pythonx --cov test --cov-report=term-missing:skip-covered
test_coverage: test_nvim

$(dir $(BUILD_VIRTUAL_ENV)):
mkdir -p $@

$(BUILD_VIRTUAL_ENV): | $(dir $(BUILD_VIRTUAL_ENV))
python -m venv $@

$(BUILD_VIRTUAL_ENV)/bin/vint: | $(BUILD_VIRTUAL_ENV)
$|/bin/python -m pip install vim-vint==0.3.21

$(BUILD_VIRTUAL_ENV)/bin/flake8: | $(BUILD_VIRTUAL_ENV)
$|/bin/python -m pip install -q flake8==3.7.8

vint: $(BUILD_VIRTUAL_ENV)/bin/vint
$(BUILD_VIRTUAL_ENV)/bin/vint after autoload ftplugin plugin

flake8: $(BUILD_VIRTUAL_ENV)/bin/flake8
$(BUILD_VIRTUAL_ENV)/bin/flake8 pythonx/jedi_*.py

build:
mkdir $@
build/vint: | build
virtualenv $@
$@/bin/pip install vim-vint
check: LINT_FILES:=after autoload ftplugin plugin
check: build/vint
build/vint/bin/vint $(LINT_FILES)
check: vint flake8

clean:
rm -rf .cache build
rm -rf build

.PHONY: test check clean
.PHONY: test check clean vint flake8
90 changes: 69 additions & 21 deletions layers/layer4_vim/0021_configvim/vim/bundle/jedi-vim/README.rst
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
.. image:: https://github.com/davidhalter/jedi-vim/blob/master/doc/logotype-a.svg

#################################################
jedi-vim - awesome Python autocompletion with VIM
#################################################
Expand Down Expand Up @@ -38,7 +40,7 @@ You can read the Jedi library documentation `here <http://jedi.readthedocs.io/en

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>`_ and tag your question with ``jedi-vim``.
<https://stackoverflow.com/questions/tagged/jedi-vim>`_ and tag your question with ``jedi-vim``.


Contributing
Expand All @@ -56,9 +58,10 @@ 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,
- 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)
Expand All @@ -70,26 +73,35 @@ 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).
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)``.

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. You can
either install it via ``pip install jedi`` or with
``git submodule update --init`` in your jedi-vim repository.
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
cd ~/.vim/bundle/ && git clone --recursive https://github.com/davidhalter/jedi-vim.git
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
Expand All @@ -102,7 +114,7 @@ It is also available on
`Ubuntu (≥14.04) <http://packages.ubuntu.com/vim-python-jedi>`__ as
vim-python-jedi.
On Fedora Linux, it is available as
`vim-jedi <https://apps.fedoraproject.org/packages/vim-jedi>`__.
`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.
Expand Down Expand Up @@ -170,8 +182,10 @@ and usually saves one keypress.
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
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
Expand All @@ -187,12 +201,26 @@ get more information. If you set them to ``""``, they are not assigned.
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:

Expand All @@ -203,6 +231,12 @@ Finally, if you don't want completion, but all the other features, use:
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
------------------------------------------------------------

Expand All @@ -221,16 +255,30 @@ Don't even think about changing the Jedi command to ``<Tab>``,
use `supertab <https://github.com/ervandew/supertab>`_!


The completion is waaay too slow!
---------------------------------
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:

.. code-block:: vim
let g:pymode_rope = 0
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.
See issue `#163 <https://github.com/davidhalter/jedi-vim/issues/163>`__.

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
<https://github.com/davidhalter/jedi-vim/issues/163>`__.
3. 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
=======
Expand Down
Original file line number Diff line number Diff line change
@@ -1,23 +1,3 @@
if !jedi#init_python()
finish
endif

if g:jedi#auto_initialization
if g:jedi#completions_enabled
" We need our own omnifunc, so this overrides the omnifunc set by
" $VIMRUNTIME/ftplugin/python.vim.
setlocal omnifunc=jedi#completions

" map ctrl+space for autocompletion
if g:jedi#completions_command ==# '<C-Space>'
" In terminals, <C-Space> sometimes equals <Nul>.
imap <buffer> <Nul> <C-Space>
smap <buffer> <Nul> <C-Space>
endif
if len(g:jedi#completions_command)
execute 'inoremap <expr> <buffer> '.g:jedi#completions_command.' jedi#complete_string(0)'
" A separate mapping for select mode: deletes and completes.
execute 'snoremap <expr> <buffer> '.g:jedi#completions_command." '\<C-g>c'.jedi#complete_string(0)"
endif
endif
if jedi#init_python() && g:jedi#auto_initialization && g:jedi#completions_enabled
call jedi#setup_completion()
endif
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,9 @@ if g:jedi#show_call_signatures > 0 && has('conceal')
hi def link jediFunction CursorLine
hi def link jediFat TabLine
else
hi jediFunction term=NONE cterm=NONE ctermfg=6 guifg=Black gui=NONE ctermbg=0 guibg=Grey
hi jediFat term=bold,underline cterm=bold,underline gui=bold,underline ctermbg=0 guibg=#555555
hi def jediFunction term=NONE cterm=NONE ctermfg=6 guifg=Black gui=NONE ctermbg=0 guibg=Grey
hi def jediFat term=bold,underline cterm=bold,underline gui=bold,underline ctermbg=0 guibg=#555555
endif
endif

hi def jediUsage cterm=reverse gui=standout
Loading

0 comments on commit 707060f

Please sign in to comment.