mirror of
https://github.com/davidhalter/jedi-vim.git
synced 2025-12-08 11:34:51 +08:00
Compare commits
214 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b9f8317595 | ||
|
|
d3f40d13ec | ||
|
|
016fb7c78e | ||
|
|
e736eea934 | ||
|
|
6c6b4dcf92 | ||
|
|
73289427ba | ||
|
|
1a053d2a23 | ||
|
|
636ad08d32 | ||
|
|
d32962f3b2 | ||
|
|
717446dd71 | ||
|
|
9c9a513aaf | ||
|
|
69aa410afa | ||
|
|
914754a04e | ||
|
|
f26b2a8802 | ||
|
|
d879d2f216 | ||
|
|
23c14f6826 | ||
|
|
1f7e661d9d | ||
|
|
c6fe4fee76 | ||
|
|
ea5e87a703 | ||
|
|
d02a72e792 | ||
|
|
42d24387ac | ||
|
|
ba5915bf26 | ||
|
|
c5c13d69d6 | ||
|
|
f36749776d | ||
|
|
7f4f2db260 | ||
|
|
2f65c636f8 | ||
|
|
b6dfc5fd49 | ||
|
|
2a43448f3b | ||
|
|
c6f05cd82c | ||
|
|
132d8506ab | ||
|
|
399c57ff72 | ||
|
|
1126ffde9b | ||
|
|
88502891ba | ||
|
|
b33392c8c8 | ||
|
|
ffec4d7fc5 | ||
|
|
43a9a9b191 | ||
|
|
e05f34646e | ||
|
|
713e78dd39 | ||
|
|
e49638ffc8 | ||
|
|
4c430ed536 | ||
|
|
40fc5ab27f | ||
|
|
9a4a4f4074 | ||
|
|
c6716c6392 | ||
|
|
5123dbbbc7 | ||
|
|
ee0f759a2e | ||
|
|
66b6a20041 | ||
|
|
8e077adb2f | ||
|
|
e7cb9a186e | ||
|
|
b5774a9554 | ||
|
|
f0d80048f1 | ||
|
|
9e2244c44e | ||
|
|
cc087ef463 | ||
|
|
efaef9cee3 | ||
|
|
58561d45f1 | ||
|
|
84b8eeb954 | ||
|
|
2bb7677b43 | ||
|
|
81ada14f0b | ||
|
|
7cade1fb62 | ||
|
|
1773837a11 | ||
|
|
67fd8c6572 | ||
|
|
d3d9a91ae6 | ||
|
|
0361d6c633 | ||
|
|
a54729ef63 | ||
|
|
5f98bfb62e | ||
|
|
745dc8a559 | ||
|
|
84a5299c8f | ||
|
|
d4006ab1bf | ||
|
|
ed8153ef2b | ||
|
|
f07ff6a535 | ||
|
|
6781eb17da | ||
|
|
5ad782d920 | ||
|
|
d75aaa470e | ||
|
|
56eb0f6d63 | ||
|
|
835e329883 | ||
|
|
49fa267e59 | ||
|
|
fa1aaa10cf | ||
|
|
e54a17ec71 | ||
|
|
48a9ea085d | ||
|
|
72a2643f7c | ||
|
|
57cbf1421f | ||
|
|
7894b38c0c | ||
|
|
1c3078e9f9 | ||
|
|
79b332a3c6 | ||
|
|
24a0369d0f | ||
|
|
d430570fd0 | ||
|
|
79c6172be7 | ||
|
|
48af2afd3e | ||
|
|
7b7e6b5859 | ||
|
|
37bd03c3d5 | ||
|
|
79ced22a37 | ||
|
|
510b1c94e4 | ||
|
|
6d05c25873 | ||
|
|
0b9bbc3495 | ||
|
|
31ebd30c31 | ||
|
|
3be8833913 | ||
|
|
77924398bd | ||
|
|
8e0cefc371 | ||
|
|
bbd456c016 | ||
|
|
41507bab99 | ||
|
|
8b7c4cbad5 | ||
|
|
65190a1856 | ||
|
|
fb52e32238 | ||
|
|
109ceeb2f8 | ||
|
|
d189d8aab7 | ||
|
|
7e6811cb4b | ||
|
|
24496c1416 | ||
|
|
8d547695e2 | ||
|
|
d42f56bc82 | ||
|
|
192e03b335 | ||
|
|
1c7c9064b7 | ||
|
|
85020495ef | ||
|
|
edde267f6b | ||
|
|
641c88111d | ||
|
|
5c6531ffae | ||
|
|
516189c7e3 | ||
|
|
ce6b60063d | ||
|
|
72c1a332d2 | ||
|
|
c8164fdfda | ||
|
|
0c6a2b7737 | ||
|
|
60bdff8eea | ||
|
|
ddaec5652b | ||
|
|
163a0b5db1 | ||
|
|
cfadac7f22 | ||
|
|
82661d515b | ||
|
|
a46ea1a1eb | ||
|
|
a2cf2291da | ||
|
|
dc7b6228b2 | ||
|
|
20312dcca8 | ||
|
|
c11b38cb48 | ||
|
|
f1d9708f7c | ||
|
|
6394614017 | ||
|
|
6411de0cd1 | ||
|
|
0ee2ed0bc6 | ||
|
|
e2d79c6434 | ||
|
|
53358dc0fa | ||
|
|
18af876d6b | ||
|
|
40a02a7fd1 | ||
|
|
eef60e056a | ||
|
|
8e34a59045 | ||
|
|
c1e279cab7 | ||
|
|
2ee9ec64d3 | ||
|
|
682f37792d | ||
|
|
0844b14866 | ||
|
|
ac6756a466 | ||
|
|
b885e10e0d | ||
|
|
0dea756fd9 | ||
|
|
8cf616b088 | ||
|
|
63ecc1dbd7 | ||
|
|
52772e171f | ||
|
|
eba90e615d | ||
|
|
f100ffad4d | ||
|
|
702da51cbe | ||
|
|
fe30fa485b | ||
|
|
3582fa6bc2 | ||
|
|
4a3dc9da84 | ||
|
|
f99d86073b | ||
|
|
636d393114 | ||
|
|
4baf4b27f7 | ||
|
|
3dc61513af | ||
|
|
80378d857b | ||
|
|
671f9f5780 | ||
|
|
b96dad9d50 | ||
|
|
a69e6b8cc0 | ||
|
|
f191ccd6fb | ||
|
|
8243015479 | ||
|
|
01787a9988 | ||
|
|
4ed33a8600 | ||
|
|
e66c2e12e6 | ||
|
|
d0c3ddb9ff | ||
|
|
12db7ad364 | ||
|
|
9384d464ec | ||
|
|
d86039ea89 | ||
|
|
b32b731767 | ||
|
|
6a6595f5c5 | ||
|
|
026ae6be03 | ||
|
|
b7163d615c | ||
|
|
443e7fe555 | ||
|
|
b3f7f3c0b5 | ||
|
|
8753bf2e16 | ||
|
|
f95ac1e8e0 | ||
|
|
f0c63f1172 | ||
|
|
02c2de1c51 | ||
|
|
99132ec545 | ||
|
|
5ea9ee7a63 | ||
|
|
ba0b44b65d | ||
|
|
369284a6bc | ||
|
|
3882c5dd32 | ||
|
|
c94a143bfb | ||
|
|
b7e42e6ad5 | ||
|
|
2eabe57616 | ||
|
|
d9f92d5b24 | ||
|
|
6b7dfe1c1a | ||
|
|
70360437cd | ||
|
|
19ad3063d9 | ||
|
|
8334e505b3 | ||
|
|
e8b88f0161 | ||
|
|
a0c3269420 | ||
|
|
75e9141111 | ||
|
|
5ccdd11282 | ||
|
|
5bcb17a8ad | ||
|
|
0f7b743b4e | ||
|
|
48ad42de86 | ||
|
|
0d613b5cf9 | ||
|
|
794af5b90a | ||
|
|
221d7dbee4 | ||
|
|
e7193b5e5f | ||
|
|
9ae6da6467 | ||
|
|
f08abefa31 | ||
|
|
cdfb7a5b4f | ||
|
|
de793216f5 | ||
|
|
6b8d900b05 | ||
|
|
df39189578 | ||
|
|
625c568b12 | ||
|
|
8215b220f9 |
7
.coveragerc
Normal file
7
.coveragerc
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
[run]
|
||||||
|
branch = 1
|
||||||
|
# Used by/for neovim-python-client.
|
||||||
|
concurrency = greenlet
|
||||||
|
|
||||||
|
[report]
|
||||||
|
include = pythonx/jedi_*.py,test/*
|
||||||
44
.github/ISSUE_TEMPLATE.md
vendored
Normal file
44
.github/ISSUE_TEMPLATE.md
vendored
Normal file
@@ -0,0 +1,44 @@
|
|||||||
|
### Issue
|
||||||
|
|
||||||
|
<!--
|
||||||
|
Please describe the issue here.
|
||||||
|
|
||||||
|
If you are not using jedi-vim from Git (but e.g. from a distribution's package,
|
||||||
|
please try it with jedi-vim's Git master, too).
|
||||||
|
-->
|
||||||
|
|
||||||
|
### Steps to reproduce
|
||||||
|
|
||||||
|
<!--
|
||||||
|
Include if relevant.
|
||||||
|
|
||||||
|
Please provide steps to reproduce it here, preferably based on a minimal Vim
|
||||||
|
configuration.
|
||||||
|
|
||||||
|
You can use the following template (save it as `minimal.vimrc` in the directory
|
||||||
|
where jedi-vim is installed, `cd` into that directory, and run Vim with
|
||||||
|
`vim -u minimal.vimrc`):
|
||||||
|
|
||||||
|
```
|
||||||
|
set nocompatible
|
||||||
|
|
||||||
|
let script_dir = fnamemodify(expand('<sfile>'), ':h')
|
||||||
|
let &runtimepath .= ','.script_dir.','.script_dir.'/after'
|
||||||
|
|
||||||
|
" Put your config changes here.
|
||||||
|
" let g:jedi#show_call_signatures=1
|
||||||
|
|
||||||
|
syntax on
|
||||||
|
filetype plugin indent on
|
||||||
|
```
|
||||||
|
|
||||||
|
Please provide the `minimal.vimrc` you have used here, too.
|
||||||
|
-->
|
||||||
|
|
||||||
|
### Output of “:verbose JediDebugInfo”
|
||||||
|
|
||||||
|
<!--
|
||||||
|
Please execute `:redir @+> | silent verb JediDebugInfo | redir END` in a
|
||||||
|
Python buffer to copy debug information into your clipboard.
|
||||||
|
Then paste it here.
|
||||||
|
-->
|
||||||
4
.gitignore
vendored
4
.gitignore
vendored
@@ -3,4 +3,6 @@
|
|||||||
*.py[cod]
|
*.py[cod]
|
||||||
.ropeproject
|
.ropeproject
|
||||||
doc/tags
|
doc/tags
|
||||||
.cache
|
.pytest-cache
|
||||||
|
build
|
||||||
|
.coverage*
|
||||||
|
|||||||
5
.gitmodules
vendored
5
.gitmodules
vendored
@@ -1,3 +1,6 @@
|
|||||||
[submodule "jedi"]
|
[submodule "jedi"]
|
||||||
path = jedi
|
path = pythonx/jedi
|
||||||
url = https://github.com/davidhalter/jedi.git
|
url = https://github.com/davidhalter/jedi.git
|
||||||
|
[submodule "pythonx/parso"]
|
||||||
|
path = pythonx/parso
|
||||||
|
url = https://github.com/davidhalter/parso.git
|
||||||
|
|||||||
34
.travis.yml
34
.travis.yml
@@ -1,6 +1,34 @@
|
|||||||
|
dist: xenial
|
||||||
language: python
|
language: python
|
||||||
|
python: 3.7
|
||||||
|
env:
|
||||||
|
matrix:
|
||||||
|
- ENV=test
|
||||||
|
- ENV=check
|
||||||
|
- ENV=test_coverage
|
||||||
|
matrix:
|
||||||
|
include:
|
||||||
|
- env: ENV=test_coverage
|
||||||
|
python: 2.7
|
||||||
install:
|
install:
|
||||||
- pip install --quiet --use-mirrors pytest
|
- |
|
||||||
|
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
|
||||||
|
else
|
||||||
|
vim --version
|
||||||
|
fi
|
||||||
script:
|
script:
|
||||||
- vim --version
|
- make --keep-going "$ENV" BUILD_VIRTUAL_ENV=$VIRTUAL_ENV
|
||||||
- py.test
|
|
||||||
|
after_success:
|
||||||
|
- |
|
||||||
|
if [ "$ENV" = "test_coverage" ]; then
|
||||||
|
coverage xml
|
||||||
|
bash <(curl -s https://codecov.io/bash) -X gcov -X coveragepy -X fix -X search -X xcode -f coverage.xml -F py${TRAVIS_PYTHON_VERSION//./}
|
||||||
|
fi
|
||||||
|
|||||||
@@ -49,5 +49,9 @@ Daniel Hahler (@blueyed)
|
|||||||
Dave Honneffer (@pearofducks)
|
Dave Honneffer (@pearofducks)
|
||||||
Bagrat Aznauryan (@n9code)
|
Bagrat Aznauryan (@n9code)
|
||||||
Tomoyuki Kashiro (@kashiro)
|
Tomoyuki Kashiro (@kashiro)
|
||||||
|
Tommy Allen (@tweekmonster)
|
||||||
|
Mingliang (@Aulddays)
|
||||||
|
Brian Mego (@brianmego)
|
||||||
|
Stevan Milic (@stevanmilic) <stevan.milic@yahoo.com>
|
||||||
|
|
||||||
@something are github user names.
|
@something are github user names.
|
||||||
|
|||||||
35
Makefile
Normal file
35
Makefile
Normal file
@@ -0,0 +1,35 @@
|
|||||||
|
BUILD_VIRTUAL_ENV:=build/venv
|
||||||
|
|
||||||
|
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.19
|
||||||
|
|
||||||
|
$(BUILD_VIRTUAL_ENV)/bin/flake8: | $(BUILD_VIRTUAL_ENV)
|
||||||
|
$|/bin/python -m pip install -q flake8==3.5.0
|
||||||
|
|
||||||
|
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
|
||||||
|
|
||||||
|
check: vint flake8
|
||||||
|
|
||||||
|
clean:
|
||||||
|
rm -rf build
|
||||||
|
|
||||||
|
.PHONY: test check clean vint flake8
|
||||||
92
README.rst
92
README.rst
@@ -1,8 +1,10 @@
|
|||||||
|
.. image:: https://github.com/davidhalter/jedi-vim/blob/master/doc/logotype-a.svg
|
||||||
|
|
||||||
#################################################
|
#################################################
|
||||||
jedi-vim - awesome Python autocompletion with VIM
|
jedi-vim - awesome Python autocompletion with VIM
|
||||||
#################################################
|
#################################################
|
||||||
|
|
||||||
.. image:: https://travis-ci.org/davidhalter/jedi-vim.png?branch=master
|
.. image:: https://travis-ci.org/davidhalter/jedi-vim.svg?branch=master
|
||||||
:target: https://travis-ci.org/davidhalter/jedi-vim
|
:target: https://travis-ci.org/davidhalter/jedi-vim
|
||||||
:alt: Travis-CI build status
|
:alt: Travis-CI build status
|
||||||
|
|
||||||
@@ -34,11 +36,11 @@ Documentation
|
|||||||
Documentation is available in your vim: ``:help jedi-vim``. You can also look
|
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>`_.
|
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.jedidjah.ch>`_.
|
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
|
If you want to report issues, just use the github issue tracker. In case of
|
||||||
questions about the software, please use `stackoverflow
|
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
|
Contributing
|
||||||
@@ -68,28 +70,56 @@ Apart from that, jedi-vim supports the following commands
|
|||||||
Installation
|
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 <https://github.com/tpope/vim-pathogen>`_ or
|
You might want to use `pathogen <https://github.com/tpope/vim-pathogen>`_ or
|
||||||
`vundle <https://github.com/gmarik/vundle>`_ to install jedi in VIM. Also you
|
`Vundle <https://github.com/gmarik/vundle>`_ to install jedi-vim.
|
||||||
need a VIM version that was compiled with ``+python``, which is typical for most
|
|
||||||
distributions on Linux. The Python version compiled into VIM must be 2.6 or later
|
|
||||||
(you can check this from within VIM using ``:python import sys; print sys.version`` )
|
|
||||||
|
|
||||||
The first thing you need after that is an up-to-date version of Jedi. You can
|
The first thing you need after that is an up-to-date version of Jedi. Install
|
||||||
either get it via ``pip install jedi`` or with ``git submodule update --init``
|
``git submodule update --init --recursive`` in your jedi-vim repository.
|
||||||
in your jedi-vim repository.
|
|
||||||
|
|
||||||
Example Installation Command using Pathogen:
|
Example installation command using Pathogen:
|
||||||
|
|
||||||
.. code-block:: sh
|
.. 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.
|
||||||
|
|
||||||
|
|
||||||
On Arch Linux, you can also install jedi-vim from official repositories as `vim-jedi
|
Installation with your distribution
|
||||||
<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,
|
On Arch Linux, you can also install jedi-vim from official repositories as
|
||||||
it is available as `vim-jedi <https://apps.fedoraproject.org/packages/vim-jedi>`__.
|
`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://apps.fedoraproject.org/packages/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
|
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
|
to conflict with jedi-vim, therefore you should disable it before enabling
|
||||||
@@ -202,16 +232,30 @@ Don't even think about changing the Jedi command to ``<Tab>``,
|
|||||||
use `supertab <https://github.com/ervandew/supertab>`_!
|
use `supertab <https://github.com/ervandew/supertab>`_!
|
||||||
|
|
||||||
|
|
||||||
The completion is waaay too slow!
|
The completion is too slow!
|
||||||
---------------------------------
|
---------------------------
|
||||||
|
|
||||||
Completion of complex libraries (like Numpy) should only be slow the first time
|
1. Completion of complex libraries (like Numpy) should only be slow the first
|
||||||
you complete it. After that, the results should be cached and very fast.
|
time you complete them. 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
|
2. If it is still slow after the initial completion and you have installed the
|
||||||
it. It seems to conflict with jedi-vim. See issue `#163
|
python-mode Vim plugin, try disabling its rope mode:
|
||||||
<https://github.com/davidhalter/jedi-vim/issues/163>`__.
|
|
||||||
|
|
||||||
|
.. code-block:: vim
|
||||||
|
|
||||||
|
let g:pymode_rope = 0
|
||||||
|
|
||||||
|
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
|
Testing
|
||||||
=======
|
=======
|
||||||
|
|||||||
@@ -1,23 +1,3 @@
|
|||||||
if !jedi#init_python()
|
if jedi#init_python() && g:jedi#auto_initialization && g:jedi#completions_enabled
|
||||||
finish
|
call jedi#setup_completion()
|
||||||
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 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
|
|
||||||
endif
|
endif
|
||||||
|
|||||||
@@ -26,7 +26,9 @@ if g:jedi#show_call_signatures > 0 && has('conceal')
|
|||||||
hi def link jediFunction CursorLine
|
hi def link jediFunction CursorLine
|
||||||
hi def link jediFat TabLine
|
hi def link jediFat TabLine
|
||||||
else
|
else
|
||||||
hi jediFunction term=NONE cterm=NONE ctermfg=6 guifg=Black gui=NONE ctermbg=0 guibg=Grey
|
hi def 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 jediFat term=bold,underline cterm=bold,underline gui=bold,underline ctermbg=0 guibg=#555555
|
||||||
endif
|
endif
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
hi def jediUsage cterm=reverse gui=standout
|
||||||
|
|||||||
4
autoload/health/jedi.vim
Normal file
4
autoload/health/jedi.vim
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
function! health#jedi#check() abort
|
||||||
|
call health#report_start('jedi')
|
||||||
|
silent call jedi#debug_info()
|
||||||
|
endfunction
|
||||||
@@ -19,22 +19,23 @@ let s:default_settings = {
|
|||||||
\ 'goto_command': "'<leader>d'",
|
\ 'goto_command': "'<leader>d'",
|
||||||
\ 'goto_assignments_command': "'<leader>g'",
|
\ 'goto_assignments_command': "'<leader>g'",
|
||||||
\ 'goto_definitions_command': "''",
|
\ 'goto_definitions_command': "''",
|
||||||
|
\ 'goto_stubs_command': "'<leader>s'",
|
||||||
\ 'completions_command': "'<C-Space>'",
|
\ 'completions_command': "'<C-Space>'",
|
||||||
\ 'call_signatures_command': "'<leader>n'",
|
\ 'call_signatures_command': "'<leader>n'",
|
||||||
\ 'usages_command': "'<leader>n'",
|
\ 'usages_command': "'<leader>n'",
|
||||||
\ 'rename_command': "'<leader>r'",
|
\ 'rename_command': "'<leader>r'",
|
||||||
\ 'popup_on_dot': 1,
|
\ 'completions_enabled': 1,
|
||||||
|
\ 'popup_on_dot': 'g:jedi#completions_enabled',
|
||||||
\ 'documentation_command': "'K'",
|
\ 'documentation_command': "'K'",
|
||||||
\ 'show_call_signatures': 1,
|
\ 'show_call_signatures': 1,
|
||||||
\ 'show_call_signatures_delay': 500,
|
\ 'show_call_signatures_delay': 500,
|
||||||
\ 'call_signature_escape': "'=`='",
|
\ 'call_signature_escape': "'?!?'",
|
||||||
\ 'auto_close_doc': 1,
|
\ 'auto_close_doc': 1,
|
||||||
\ 'max_doc_height': 30,
|
\ 'max_doc_height': 30,
|
||||||
\ 'popup_select_first': 1,
|
\ 'popup_select_first': 1,
|
||||||
\ 'quickfix_window_height': 10,
|
\ 'quickfix_window_height': 10,
|
||||||
\ 'completions_enabled': 1,
|
|
||||||
\ 'force_py_version': "'auto'",
|
\ 'force_py_version': "'auto'",
|
||||||
\ 'smart_auto_mappings': 1,
|
\ 'smart_auto_mappings': 0,
|
||||||
\ 'use_tag_stack': 1
|
\ 'use_tag_stack': 1
|
||||||
\ }
|
\ }
|
||||||
|
|
||||||
@@ -57,81 +58,83 @@ endfor
|
|||||||
" ------------------------------------------------------------------------
|
" ------------------------------------------------------------------------
|
||||||
let s:script_path = fnameescape(expand('<sfile>:p:h:h'))
|
let s:script_path = fnameescape(expand('<sfile>:p:h:h'))
|
||||||
|
|
||||||
function! s:init_python()
|
" Initialize Python (PythonJedi command).
|
||||||
if g:jedi#force_py_version != 'auto'
|
function! s:init_python() abort
|
||||||
" Always use the user supplied version.
|
" Use g:jedi#force_py_version for loading Jedi, or fall back to using
|
||||||
try
|
" `has()` - preferring Python 3.
|
||||||
return jedi#force_py_version(g:jedi#force_py_version)
|
let loader_version = get(g:, 'jedi#loader_py_version', g:jedi#force_py_version)
|
||||||
catch
|
if loader_version ==# 'auto'
|
||||||
throw "Could not setup g:jedi#force_py_version: ".v:exception
|
if has('python3')
|
||||||
endtry
|
let loader_version = 3
|
||||||
endif
|
elseif has('python')
|
||||||
|
let loader_version = 2
|
||||||
" Handle "auto" version.
|
|
||||||
if has('nvim') || (has('python') && has('python3'))
|
|
||||||
" Neovim usually has both python providers. Skipping the `has` check
|
|
||||||
" avoids starting both of them.
|
|
||||||
|
|
||||||
" Get default python version from interpreter in $PATH.
|
|
||||||
let s:def_py = system('python -c '.shellescape('import sys; sys.stdout.write(str(sys.version_info[0]))'))
|
|
||||||
if v:shell_error != 0 || !len(s:def_py)
|
|
||||||
if !exists("g:jedi#squelch_py_warning")
|
|
||||||
echohl WarningMsg
|
|
||||||
echom "Warning: jedi-vim failed to get Python version from sys.version_info: " . s:def_py
|
|
||||||
echom "Falling back to version 2."
|
|
||||||
echohl None
|
|
||||||
endif
|
|
||||||
let s:def_py = 2
|
|
||||||
elseif &verbose
|
|
||||||
echom "jedi-vim: auto-detected Python: ".s:def_py
|
|
||||||
endif
|
|
||||||
|
|
||||||
" Make sure that the auto-detected version is available in Vim.
|
|
||||||
if !has('nvim') || has('python'.(s:def_py == 2 ? '' : s:def_py))
|
|
||||||
return jedi#force_py_version(s:def_py)
|
|
||||||
endif
|
|
||||||
|
|
||||||
" Add a warning in case the auto-detected version is not available,
|
|
||||||
" usually because of a missing neovim module in a VIRTUAL_ENV.
|
|
||||||
if has('nvim')
|
|
||||||
echohl WarningMsg
|
|
||||||
echom "jedi-vim: the detected Python version (".s:def_py.")"
|
|
||||||
\ "is not functional."
|
|
||||||
\ "Is the 'neovim' module installed?"
|
|
||||||
\ "While jedi-vim will work, it might not use the"
|
|
||||||
\ "expected Python path."
|
|
||||||
echohl None
|
|
||||||
endif
|
|
||||||
endif
|
|
||||||
|
|
||||||
if has('python')
|
|
||||||
call jedi#setup_py_version(2)
|
|
||||||
elseif has('python3')
|
|
||||||
call jedi#setup_py_version(3)
|
|
||||||
else
|
else
|
||||||
throw "jedi-vim requires Vim with support for Python 2 or 3."
|
throw 'jedi-vim requires Vim with support for Python 2 or 3.'
|
||||||
endif
|
endif
|
||||||
|
else
|
||||||
|
if loader_version =~# '^3'
|
||||||
|
let loader_version = 3
|
||||||
|
elseif loader_version =~# '^2'
|
||||||
|
let loader_version = 2
|
||||||
|
else
|
||||||
|
if !exists('g:jedi#squelch_py_warning')
|
||||||
|
echohl WarningMsg
|
||||||
|
echom printf("jedi-vim: could not determine Python loader version from 'g:jedi#loader_py_version/g:jedi#force_py_version' (%s), using 3.",
|
||||||
|
\ loader_version)
|
||||||
|
echohl None
|
||||||
|
endif
|
||||||
|
let loader_version = 3
|
||||||
|
endif
|
||||||
|
endif
|
||||||
|
call jedi#setup_python_imports(loader_version)
|
||||||
return 1
|
return 1
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
|
|
||||||
function! jedi#reinit_python()
|
function! jedi#reinit_python() abort
|
||||||
unlet! s:_init_python
|
let s:_init_python = -1
|
||||||
call jedi#init_python()
|
call jedi#init_python()
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
|
|
||||||
function! jedi#init_python()
|
" This is meant to be called with `:unsilent` (for &shortmess+=F).
|
||||||
if !exists('s:_init_python')
|
function! s:display_exception() abort
|
||||||
|
let error_lines = split(v:exception, '\n')
|
||||||
|
let msg = 'Error: jedi-vim failed to initialize Python: '
|
||||||
|
\ .error_lines[0].' (in '.v:throwpoint.')'
|
||||||
|
if len(error_lines) > 1
|
||||||
|
echohl ErrorMsg
|
||||||
|
echom 'jedi-vim error: '.error_lines[0]
|
||||||
|
for line in error_lines[1:]
|
||||||
|
echom line
|
||||||
|
endfor
|
||||||
|
echohl None
|
||||||
|
let help_cmd = ':JediDebugInfo'
|
||||||
|
if exists(':checkhealth') == 2
|
||||||
|
let help_cmd .= ' / :checkhealth'
|
||||||
|
endif
|
||||||
|
let msg .= printf('. See :messages and/or %s for more information.',
|
||||||
|
\ help_cmd)
|
||||||
|
endif
|
||||||
|
redraw " Redraw to only have the main message by default.
|
||||||
|
echoerr msg
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
|
||||||
|
let s:_init_python = -1
|
||||||
|
function! jedi#init_python() abort
|
||||||
|
if s:_init_python == -1
|
||||||
|
let s:_init_python = 0
|
||||||
try
|
try
|
||||||
let s:_init_python = s:init_python()
|
let s:_init_python = s:init_python()
|
||||||
catch
|
let s:_init_python = 1
|
||||||
if !exists("g:jedi#squelch_py_warning")
|
catch /^jedi/
|
||||||
echohl WarningMsg
|
" Only catch errors from jedi-vim itself here, so that for
|
||||||
echom "Error: jedi-vim failed to initialize Python: ".v:exception." (in ".v:throwpoint.")"
|
" unexpected Python exceptions the traceback will be shown
|
||||||
echohl None
|
" (e.g. with NameError in jedi#setup_python_imports's code).
|
||||||
|
if !exists('g:jedi#squelch_py_warning')
|
||||||
|
unsilent call s:display_exception()
|
||||||
endif
|
endif
|
||||||
let s:_init_python = 0
|
|
||||||
endtry
|
endtry
|
||||||
endif
|
endif
|
||||||
return s:_init_python
|
return s:_init_python
|
||||||
@@ -139,54 +142,120 @@ endfunction
|
|||||||
|
|
||||||
|
|
||||||
let s:python_version = 'null'
|
let s:python_version = 'null'
|
||||||
function! jedi#setup_py_version(py_version)
|
function! jedi#setup_python_imports(py_version) abort
|
||||||
if a:py_version == 2
|
if a:py_version == 2
|
||||||
let cmd_init = 'pyfile'
|
|
||||||
let cmd_exec = 'python'
|
let cmd_exec = 'python'
|
||||||
let s:python_version = 2
|
let s:python_version = 2
|
||||||
elseif a:py_version == 3
|
elseif a:py_version == 3
|
||||||
let cmd_init = 'py3file'
|
|
||||||
let cmd_exec = 'python3'
|
let cmd_exec = 'python3'
|
||||||
let s:python_version = 3
|
let s:python_version = 3
|
||||||
else
|
else
|
||||||
throw "jedi#setup_py_version: invalid py_version: ".a:py_version
|
throw 'jedi#setup_python_imports: invalid py_version: '.a:py_version
|
||||||
endif
|
endif
|
||||||
|
|
||||||
try
|
|
||||||
execute cmd_init.' '.s:script_path.'/initialize.py'
|
|
||||||
execute 'command! -nargs=1 PythonJedi '.cmd_exec.' <args>'
|
execute 'command! -nargs=1 PythonJedi '.cmd_exec.' <args>'
|
||||||
|
|
||||||
|
let g:_jedi_init_error = 0
|
||||||
|
let init_lines = [
|
||||||
|
\ 'import vim',
|
||||||
|
\ 'try:',
|
||||||
|
\ ' import jedi_vim',
|
||||||
|
\ ' if hasattr(jedi_vim, "jedi_import_error"):',
|
||||||
|
\ ' from jedi_vim_debug import format_exc_info',
|
||||||
|
\ ' vim.vars["_jedi_init_error"] = format_exc_info(jedi_vim.jedi_import_error)',
|
||||||
|
\ 'except Exception as exc:',
|
||||||
|
\ ' from jedi_vim_debug import format_exc_info',
|
||||||
|
\ ' vim.vars["_jedi_init_error"] = format_exc_info()',
|
||||||
|
\ ]
|
||||||
|
exe 'PythonJedi exec('''.escape(join(init_lines, '\n'), "'").''')'
|
||||||
|
if g:_jedi_init_error isnot 0
|
||||||
|
throw printf('jedi#setup_python_imports: %s', g:_jedi_init_error)
|
||||||
|
endif
|
||||||
return 1
|
return 1
|
||||||
catch
|
|
||||||
throw "jedi#setup_py_version: ".v:exception
|
|
||||||
endtry
|
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
|
|
||||||
function! jedi#debug_info()
|
function! jedi#debug_info() abort
|
||||||
echom "Using Python version:" s:python_version
|
if &verbose
|
||||||
endfunction
|
if &filetype !=# 'python'
|
||||||
|
echohl WarningMsg | echo 'You should run this in a buffer with filetype "python".' | echohl None
|
||||||
|
endif
|
||||||
function! jedi#force_py_version(py_version)
|
endif
|
||||||
let g:jedi#force_py_version = a:py_version
|
echo '#### Jedi-vim debug information'
|
||||||
return jedi#setup_py_version(a:py_version)
|
echo "\n"
|
||||||
endfunction
|
echo '##### jedi-vim version'
|
||||||
|
echo "\n"
|
||||||
|
echo ' - jedi-vim git version: '
|
||||||
function! jedi#force_py_version_switch()
|
echon substitute(system('git -C '.s:script_path.' describe --tags --always --dirty'), '\v\n$', '', '')
|
||||||
if g:jedi#force_py_version == 2
|
echo ' - jedi git submodule status: '
|
||||||
call jedi#force_py_version(3)
|
echon substitute(system('git -C '.s:script_path.' submodule status pythonx/jedi'), '\v\n$', '', '')
|
||||||
elseif g:jedi#force_py_version == 3
|
echo ' - parso git submodule status: '
|
||||||
call jedi#force_py_version(2)
|
echon substitute(system('git -C '.s:script_path.' submodule status pythonx/parso'), '\v\n$', '', '')
|
||||||
|
echo "\n"
|
||||||
|
echo '##### Global Python'
|
||||||
|
echo "\n"
|
||||||
|
echo 'Using Python version '.s:python_version.' to access Jedi.'
|
||||||
|
let pyeval = s:python_version == 3 ? 'py3eval' : 'pyeval'
|
||||||
|
let s:pythonjedi_called = 0
|
||||||
|
PythonJedi import vim; vim.command('let s:pythonjedi_called = 1')
|
||||||
|
if !s:pythonjedi_called
|
||||||
|
echohl WarningMsg
|
||||||
|
echom 'PythonJedi failed to run, likely a Python config issue.'
|
||||||
|
if exists(':checkhealth') == 2
|
||||||
|
echom 'Try :checkhealth for more information.'
|
||||||
|
endif
|
||||||
|
echohl None
|
||||||
else
|
else
|
||||||
throw "Don't know how to switch from ".g:jedi#force_py_version."!"
|
PythonJedi from jedi_vim_debug import display_debug_info
|
||||||
|
PythonJedi display_debug_info()
|
||||||
|
endif
|
||||||
|
echo "\n"
|
||||||
|
echo '##### Settings'
|
||||||
|
echo "\n"
|
||||||
|
echo '```'
|
||||||
|
let jedi_settings = items(filter(copy(g:), "v:key =~# '\\v^jedi#'"))
|
||||||
|
let has_nondefault_settings = 0
|
||||||
|
for [k, V] in jedi_settings
|
||||||
|
exe 'let default = '.get(s:default_settings,
|
||||||
|
\ substitute(k, '\v^jedi#', '', ''), "'-'")
|
||||||
|
" vint: -ProhibitUsingUndeclaredVariable
|
||||||
|
if default !=# V
|
||||||
|
echo printf('g:%s = %s (default: %s)', k, string(V), string(default))
|
||||||
|
unlet! V " Fix variable type mismatch with Vim 7.3.
|
||||||
|
let has_nondefault_settings = 1
|
||||||
|
endif
|
||||||
|
" vint: +ProhibitUsingUndeclaredVariable
|
||||||
|
endfor
|
||||||
|
if has_nondefault_settings
|
||||||
|
echo "\n"
|
||||||
|
endif
|
||||||
|
verb set omnifunc? completeopt?
|
||||||
|
echo '```'
|
||||||
|
|
||||||
|
if &verbose
|
||||||
|
echo "\n"
|
||||||
|
echo '#### :version'
|
||||||
|
echo '```'
|
||||||
|
version
|
||||||
|
echo '```'
|
||||||
|
echo "\n"
|
||||||
|
echo '#### :messages'
|
||||||
|
echo '```'
|
||||||
|
messages
|
||||||
|
echo '```'
|
||||||
|
echo "\n"
|
||||||
|
echo '<details><summary>:scriptnames</summary>'
|
||||||
|
echo "\n"
|
||||||
|
echo '```'
|
||||||
|
scriptnames
|
||||||
|
echo '```'
|
||||||
|
echo '</details>'
|
||||||
endif
|
endif
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
|
|
||||||
" Helper function instead of `python vim.eval()`, and `.command()` because
|
" Helper function instead of `python vim.eval()`, and `.command()` because
|
||||||
" these also return error definitions.
|
" these also return error definitions.
|
||||||
function! jedi#_vim_exceptions(str, is_eval)
|
function! jedi#_vim_exceptions(str, is_eval) abort
|
||||||
let l:result = {}
|
let l:result = {}
|
||||||
try
|
try
|
||||||
if a:is_eval
|
if a:is_eval
|
||||||
@@ -202,82 +271,98 @@ function! jedi#_vim_exceptions(str, is_eval)
|
|||||||
return l:result
|
return l:result
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
|
call jedi#init_python() " Might throw an error.
|
||||||
if !jedi#init_python()
|
|
||||||
" Do not define any functions when Python initialization failed.
|
|
||||||
finish
|
|
||||||
endif
|
|
||||||
|
|
||||||
|
|
||||||
" ------------------------------------------------------------------------
|
" ------------------------------------------------------------------------
|
||||||
" functions that call python code
|
" functions that call python code
|
||||||
" ------------------------------------------------------------------------
|
" ------------------------------------------------------------------------
|
||||||
function! jedi#goto()
|
function! jedi#goto() abort
|
||||||
PythonJedi jedi_vim.goto(mode="goto")
|
PythonJedi jedi_vim.goto(mode="goto")
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! jedi#goto_assignments()
|
function! jedi#goto_assignments() abort
|
||||||
PythonJedi jedi_vim.goto(mode="assignment")
|
PythonJedi jedi_vim.goto(mode="assignment")
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! jedi#goto_definitions()
|
function! jedi#goto_definitions() abort
|
||||||
PythonJedi jedi_vim.goto(mode="definition")
|
PythonJedi jedi_vim.goto(mode="definition")
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! jedi#usages()
|
function! jedi#goto_stubs() abort
|
||||||
PythonJedi jedi_vim.goto(mode="related_name")
|
PythonJedi jedi_vim.goto(mode="stubs")
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! jedi#rename(...)
|
function! jedi#usages() abort
|
||||||
|
call jedi#remove_usages()
|
||||||
|
PythonJedi jedi_vim.usages()
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
function! jedi#remove_usages() abort
|
||||||
|
for match in getmatches()
|
||||||
|
if stridx(match['group'], 'jediUsage') == 0
|
||||||
|
call matchdelete(match['id'])
|
||||||
|
endif
|
||||||
|
endfor
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
function! jedi#rename(...) abort
|
||||||
PythonJedi jedi_vim.rename()
|
PythonJedi jedi_vim.rename()
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! jedi#rename_visual(...)
|
function! jedi#rename_visual(...) abort
|
||||||
PythonJedi jedi_vim.rename_visual()
|
PythonJedi jedi_vim.rename_visual()
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! jedi#completions(findstart, base)
|
function! jedi#completions(findstart, base) abort
|
||||||
PythonJedi jedi_vim.completions()
|
PythonJedi jedi_vim.completions()
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! jedi#enable_speed_debugging()
|
function! jedi#enable_speed_debugging() abort
|
||||||
PythonJedi jedi_vim.jedi.set_debug_function(jedi_vim.print_to_stdout, speed=True, warnings=False, notices=False)
|
PythonJedi jedi_vim.jedi.set_debug_function(jedi_vim.print_to_stdout, speed=True, warnings=False, notices=False)
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! jedi#enable_debugging()
|
function! jedi#enable_debugging() abort
|
||||||
PythonJedi jedi_vim.jedi.set_debug_function(jedi_vim.print_to_stdout)
|
PythonJedi jedi_vim.jedi.set_debug_function(jedi_vim.print_to_stdout)
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! jedi#disable_debugging()
|
function! jedi#disable_debugging() abort
|
||||||
PythonJedi jedi_vim.jedi.set_debug_function(None)
|
PythonJedi jedi_vim.jedi.set_debug_function(None)
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! jedi#py_import(args)
|
function! jedi#py_import(args) abort
|
||||||
PythonJedi jedi_vim.py_import()
|
PythonJedi jedi_vim.py_import()
|
||||||
endfun
|
endfun
|
||||||
|
|
||||||
function! jedi#py_import_completions(argl, cmdl, pos)
|
function! jedi#py_import_completions(argl, cmdl, pos) abort
|
||||||
PythonJedi jedi_vim.py_import_completions()
|
PythonJedi jedi_vim.py_import_completions()
|
||||||
endfun
|
endfun
|
||||||
|
|
||||||
|
function! jedi#clear_cache(bang) abort
|
||||||
|
if a:bang
|
||||||
|
PythonJedi jedi_vim.jedi.cache.clear_time_caches(True)
|
||||||
|
else
|
||||||
|
PythonJedi jedi_vim.jedi.cache.clear_time_caches(False)
|
||||||
|
endif
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
|
||||||
" ------------------------------------------------------------------------
|
" ------------------------------------------------------------------------
|
||||||
" show_documentation
|
" show_documentation
|
||||||
" ------------------------------------------------------------------------
|
" ------------------------------------------------------------------------
|
||||||
function! jedi#show_documentation()
|
function! jedi#show_documentation() abort
|
||||||
PythonJedi if jedi_vim.show_documentation() is None: vim.command('return')
|
PythonJedi if jedi_vim.show_documentation() is None: vim.command('return')
|
||||||
|
|
||||||
let bn = bufnr("__doc__")
|
let bn = bufnr('__doc__')
|
||||||
if bn > 0
|
if bn > 0
|
||||||
let wi=index(tabpagebuflist(tabpagenr()), bn)
|
let wi=index(tabpagebuflist(tabpagenr()), bn)
|
||||||
if wi >= 0
|
if wi >= 0
|
||||||
" If the __doc__ buffer is open in the current tab, jump to it
|
" If the __doc__ buffer is open in the current tab, jump to it
|
||||||
silent execute (wi+1).'wincmd w'
|
silent execute (wi+1).'wincmd w'
|
||||||
else
|
else
|
||||||
silent execute "sbuffer ".bn
|
silent execute 'sbuffer '.bn
|
||||||
endif
|
endif
|
||||||
else
|
else
|
||||||
split '__doc__'
|
split __doc__
|
||||||
endif
|
endif
|
||||||
|
|
||||||
setlocal modifiable
|
setlocal modifiable
|
||||||
@@ -289,31 +374,25 @@ function! jedi#show_documentation()
|
|||||||
setlocal nomodifiable
|
setlocal nomodifiable
|
||||||
setlocal nomodified
|
setlocal nomodified
|
||||||
setlocal filetype=rst
|
setlocal filetype=rst
|
||||||
|
setlocal foldlevel=200 " do not fold in __doc__
|
||||||
|
|
||||||
if l:doc_lines > g:jedi#max_doc_height " max lines for plugin
|
if l:doc_lines > g:jedi#max_doc_height " max lines for plugin
|
||||||
let l:doc_lines = g:jedi#max_doc_height
|
let l:doc_lines = g:jedi#max_doc_height
|
||||||
endif
|
endif
|
||||||
execute "resize ".l:doc_lines
|
execute 'resize '.l:doc_lines
|
||||||
|
|
||||||
" quit comands
|
" quit comands
|
||||||
nnoremap <buffer> q ZQ
|
nnoremap <buffer> q ZQ
|
||||||
execute "nnoremap <buffer> ".g:jedi#documentation_command." ZQ"
|
if len(g:jedi#documentation_command)
|
||||||
|
execute 'nnoremap <buffer> '.g:jedi#documentation_command.' ZQ'
|
||||||
" highlight python code within rst
|
endif
|
||||||
unlet! b:current_syntax
|
|
||||||
syn include @rstPythonScript syntax/python.vim
|
|
||||||
" 4 spaces
|
|
||||||
syn region rstPythonRegion start=/^\v {4}/ end=/\v^( {4}|\n)@!/ contains=@rstPythonScript
|
|
||||||
" >>> python code -> (doctests)
|
|
||||||
syn region rstPythonRegion matchgroup=pythonDoctest start=/^>>>\s*/ end=/\n/ contains=@rstPythonScript
|
|
||||||
let b:current_syntax = "rst"
|
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
" ------------------------------------------------------------------------
|
" ------------------------------------------------------------------------
|
||||||
" helper functions
|
" helper functions
|
||||||
" ------------------------------------------------------------------------
|
" ------------------------------------------------------------------------
|
||||||
|
|
||||||
function! jedi#add_goto_window(len)
|
function! jedi#add_goto_window(len) abort
|
||||||
set lazyredraw
|
set lazyredraw
|
||||||
cclose
|
cclose
|
||||||
let height = min([a:len, g:jedi#quickfix_window_height])
|
let height = min([a:len, g:jedi#quickfix_window_height])
|
||||||
@@ -322,37 +401,40 @@ function! jedi#add_goto_window(len)
|
|||||||
if g:jedi#use_tabs_not_buffers == 1
|
if g:jedi#use_tabs_not_buffers == 1
|
||||||
noremap <buffer> <CR> :call jedi#goto_window_on_enter()<CR>
|
noremap <buffer> <CR> :call jedi#goto_window_on_enter()<CR>
|
||||||
endif
|
endif
|
||||||
|
augroup jedi_goto_window
|
||||||
|
au!
|
||||||
au WinLeave <buffer> q " automatically leave, if an option is chosen
|
au WinLeave <buffer> q " automatically leave, if an option is chosen
|
||||||
|
augroup END
|
||||||
redraw!
|
redraw!
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
|
|
||||||
function! jedi#goto_window_on_enter()
|
function! jedi#goto_window_on_enter() abort
|
||||||
let l:list = getqflist()
|
let l:list = getqflist()
|
||||||
let l:data = l:list[line('.') - 1]
|
let l:data = l:list[line('.') - 1]
|
||||||
if l:data.bufnr
|
if l:data.bufnr
|
||||||
" close goto_window buffer
|
" close goto_window buffer
|
||||||
normal ZQ
|
normal! ZQ
|
||||||
PythonJedi jedi_vim.new_buffer(vim.eval('bufname(l:data.bufnr)'))
|
PythonJedi jedi_vim.new_buffer(vim.eval('bufname(l:data.bufnr)'))
|
||||||
call cursor(l:data.lnum, l:data.col)
|
call cursor(l:data.lnum, l:data.col)
|
||||||
else
|
else
|
||||||
echohl WarningMsg | echo "Builtin module cannot be opened." | echohl None
|
echohl WarningMsg | echo 'Builtin module cannot be opened.' | echohl None
|
||||||
endif
|
endif
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
|
|
||||||
function! s:syn_stack()
|
function! s:syn_stack() abort
|
||||||
if !exists("*synstack")
|
if !exists('*synstack')
|
||||||
return []
|
return []
|
||||||
endif
|
endif
|
||||||
return map(synstack(line('.'), col('.') - 1), 'synIDattr(v:val, "name")')
|
return map(synstack(line('.'), col('.') - 1), "synIDattr(v:val, 'name')")
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
|
|
||||||
function! jedi#do_popup_on_dot_in_highlight()
|
function! jedi#do_popup_on_dot_in_highlight() abort
|
||||||
let highlight_groups = s:syn_stack()
|
let highlight_groups = s:syn_stack()
|
||||||
for a in highlight_groups
|
for a in highlight_groups
|
||||||
if a == 'pythonDoctest'
|
if a ==# 'pythonDoctest'
|
||||||
return 1
|
return 1
|
||||||
endif
|
endif
|
||||||
endfor
|
endfor
|
||||||
@@ -369,7 +451,10 @@ endfunc
|
|||||||
|
|
||||||
|
|
||||||
let s:show_call_signatures_last = [0, 0, '']
|
let s:show_call_signatures_last = [0, 0, '']
|
||||||
function! jedi#show_call_signatures()
|
function! jedi#show_call_signatures() abort
|
||||||
|
if s:_init_python == 0
|
||||||
|
return 1
|
||||||
|
endif
|
||||||
let [line, col] = [line('.'), col('.')]
|
let [line, col] = [line('.'), col('.')]
|
||||||
let curline = getline(line)
|
let curline = getline(line)
|
||||||
let reload_signatures = 1
|
let reload_signatures = 1
|
||||||
@@ -396,13 +481,17 @@ function! jedi#show_call_signatures()
|
|||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
|
|
||||||
function! jedi#clear_call_signatures()
|
function! jedi#clear_call_signatures() abort
|
||||||
|
if s:_init_python == 0
|
||||||
|
return 1
|
||||||
|
endif
|
||||||
|
|
||||||
let s:show_call_signatures_last = [0, 0, '']
|
let s:show_call_signatures_last = [0, 0, '']
|
||||||
PythonJedi jedi_vim.clear_call_signatures()
|
PythonJedi jedi_vim.clear_call_signatures()
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
|
|
||||||
function! jedi#configure_call_signatures()
|
function! jedi#configure_call_signatures() abort
|
||||||
augroup jedi_call_signatures
|
augroup jedi_call_signatures
|
||||||
autocmd! * <buffer>
|
autocmd! * <buffer>
|
||||||
if g:jedi#show_call_signatures == 2 " Command line call signatures
|
if g:jedi#show_call_signatures == 2 " Command line call signatures
|
||||||
@@ -427,7 +516,7 @@ endfunction
|
|||||||
|
|
||||||
" Determine where the current window is on the screen for displaying call
|
" Determine where the current window is on the screen for displaying call
|
||||||
" signatures in the correct column.
|
" signatures in the correct column.
|
||||||
function! s:save_first_col()
|
function! s:save_first_col() abort
|
||||||
if bufname('%') ==# '[Command Line]' || winnr('$') == 1
|
if bufname('%') ==# '[Command Line]' || winnr('$') == 1
|
||||||
return 0
|
return 0
|
||||||
endif
|
endif
|
||||||
@@ -469,48 +558,80 @@ function! s:save_first_col()
|
|||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
|
|
||||||
function! jedi#complete_string(is_popup_on_dot)
|
function! jedi#complete_string(autocomplete) abort
|
||||||
|
if a:autocomplete
|
||||||
if a:is_popup_on_dot && !(g:jedi#popup_on_dot && jedi#do_popup_on_dot_in_highlight())
|
if !(g:jedi#popup_on_dot && jedi#do_popup_on_dot_in_highlight())
|
||||||
return ''
|
return ''
|
||||||
|
endif
|
||||||
|
|
||||||
endif
|
let s:saved_completeopt = &completeopt
|
||||||
if pumvisible() && !a:is_popup_on_dot
|
set completeopt-=longest
|
||||||
return "\<C-n>"
|
set completeopt+=menuone
|
||||||
|
set completeopt-=menu
|
||||||
|
if &completeopt !~# 'noinsert\|noselect'
|
||||||
|
" Patch 775 introduced noinsert and noselect, previously these
|
||||||
|
" options didn't exist. Setting them in earlier versions results in
|
||||||
|
" errors (E474).
|
||||||
|
if has('patch-7.4-775')
|
||||||
|
if g:jedi#popup_select_first
|
||||||
|
set completeopt+=noinsert
|
||||||
else
|
else
|
||||||
return "\<C-x>\<C-o>\<C-r>=jedi#complete_opened(".a:is_popup_on_dot.")\<CR>"
|
set completeopt+=noselect
|
||||||
endif
|
endif
|
||||||
|
else
|
||||||
|
" To pass the tests we use this, it seems to get the closest to
|
||||||
|
" the other options. I'm really not sure if this properly
|
||||||
|
" works, but VIM 7.4-775 is already pretty old, so it might not
|
||||||
|
" be a problem anymore in a few years.
|
||||||
|
set completeopt+=longest
|
||||||
|
endif
|
||||||
|
endif
|
||||||
|
elseif pumvisible()
|
||||||
|
return "\<C-n>"
|
||||||
|
endif
|
||||||
|
return "\<C-x>\<C-o>\<C-r>=jedi#complete_opened(".a:autocomplete.")\<CR>"
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
|
|
||||||
function! jedi#complete_opened(is_popup_on_dot)
|
function! jedi#complete_opened(autocomplete) abort
|
||||||
if pumvisible()
|
if a:autocomplete
|
||||||
" Only go down if it is visible, user-enabled and the longest
|
let &completeopt = s:saved_completeopt
|
||||||
" option is set.
|
unlet s:saved_completeopt
|
||||||
if g:jedi#popup_select_first && stridx(&completeopt, 'longest') > -1
|
elseif pumvisible() && g:jedi#popup_select_first && stridx(&completeopt, 'longest') > -1
|
||||||
return "\<Down>"
|
return "\<Down>"
|
||||||
endif
|
endif
|
||||||
if a:is_popup_on_dot
|
return ''
|
||||||
if &completeopt !~ '\(noinsert\|noselect\)'
|
|
||||||
" Prevent completion of the first entry with dot completion.
|
|
||||||
return "\<C-p>"
|
|
||||||
endif
|
|
||||||
endif
|
|
||||||
endif
|
|
||||||
return ""
|
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
|
|
||||||
function! jedi#smart_auto_mappings()
|
function! jedi#smart_auto_mappings() abort
|
||||||
" Auto put import statement after from module.name<space> and complete
|
" Auto put import statement after from module.name<space> and complete
|
||||||
if search('^\s*from\s\+[A-Za-z0-9._]\{1,50}\%#\s*$', 'bcn', line('.'))
|
if search('\m^\s*from\s\+[A-Za-z0-9._]\{1,50}\%#\s*$', 'bcn', line('.'))
|
||||||
" Enter character and start completion.
|
" Enter character and start completion.
|
||||||
return "\<space>import \<C-x>\<C-o>\<C-r>=jedi#complete_opened(1)\<CR>"
|
return "\<space>import \<C-r>=jedi#complete_string(1)\<CR>"
|
||||||
endif
|
endif
|
||||||
return "\<space>"
|
return "\<space>"
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
|
|
||||||
|
function! jedi#setup_completion() abort
|
||||||
|
" 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
|
||||||
|
endfunction
|
||||||
|
|
||||||
"PythonJedi jedi_vim.jedi.set_debug_function(jedi_vim.print_to_stdout, speed=True, warnings=False, notices=False)
|
"PythonJedi jedi_vim.jedi.set_debug_function(jedi_vim.print_to_stdout, speed=True, warnings=False, notices=False)
|
||||||
"PythonJedi jedi_vim.jedi.set_debug_function(jedi_vim.print_to_stdout)
|
"PythonJedi jedi_vim.jedi.set_debug_function(jedi_vim.print_to_stdout)
|
||||||
|
|
||||||
|
|||||||
60
conftest.py
60
conftest.py
@@ -1,60 +0,0 @@
|
|||||||
import os
|
|
||||||
import subprocess
|
|
||||||
import urllib
|
|
||||||
import zipfile
|
|
||||||
|
|
||||||
import pytest
|
|
||||||
|
|
||||||
VSPEC_URL = 'https://github.com/kana/vim-vspec/archive/1.4.1.zip'
|
|
||||||
CACHE_FOLDER = '.cache'
|
|
||||||
VSPEC_FOLDER = os.path.join(CACHE_FOLDER, 'vim-vspec-1.4.1')
|
|
||||||
VSPEC_RUNNER = os.path.join(VSPEC_FOLDER, 'bin/vspec')
|
|
||||||
TEST_DIR = 'test'
|
|
||||||
|
|
||||||
|
|
||||||
class IntegrationTestFile(object):
|
|
||||||
def __init__(self, path):
|
|
||||||
self.path = path
|
|
||||||
|
|
||||||
def run(self):
|
|
||||||
output = subprocess.check_output(
|
|
||||||
[VSPEC_RUNNER, '.', VSPEC_FOLDER, self.path])
|
|
||||||
for line in output.splitlines():
|
|
||||||
if line.startswith(b'not ok') or line.startswith(b'Error'):
|
|
||||||
pytest.fail("{} failed:\n{}".format(
|
|
||||||
self.path, output.decode('utf-8')), pytrace=False)
|
|
||||||
|
|
||||||
def __repr__(self):
|
|
||||||
return "<%s: %s>" % (type(self), self.path)
|
|
||||||
|
|
||||||
|
|
||||||
def pytest_configure(config):
|
|
||||||
if not os.path.isdir(CACHE_FOLDER):
|
|
||||||
os.mkdir(CACHE_FOLDER)
|
|
||||||
|
|
||||||
if not os.path.exists(VSPEC_FOLDER):
|
|
||||||
name, hdrs = urllib.urlretrieve(VSPEC_URL)
|
|
||||||
z = zipfile.ZipFile(name)
|
|
||||||
for n in z.namelist():
|
|
||||||
dest = os.path.join(CACHE_FOLDER, n)
|
|
||||||
destdir = os.path.dirname(dest)
|
|
||||||
if not os.path.isdir(destdir):
|
|
||||||
os.makedirs(destdir)
|
|
||||||
data = z.read(n)
|
|
||||||
if not os.path.isdir(dest):
|
|
||||||
with open(dest, 'w') as f:
|
|
||||||
f.write(data)
|
|
||||||
z.close()
|
|
||||||
os.chmod(VSPEC_RUNNER, 0o777)
|
|
||||||
|
|
||||||
|
|
||||||
def pytest_generate_tests(metafunc):
|
|
||||||
"""
|
|
||||||
:type metafunc: _pytest.python.Metafunc
|
|
||||||
"""
|
|
||||||
def collect_tests():
|
|
||||||
for f in os.listdir(TEST_DIR):
|
|
||||||
if f.endswith('.vim'):
|
|
||||||
yield IntegrationTestFile(os.path.join(TEST_DIR, f))
|
|
||||||
|
|
||||||
metafunc.parametrize('case', list(collect_tests()))
|
|
||||||
@@ -60,7 +60,7 @@ Jedi-vim is a Vim binding to the awesome Python autocompletion library
|
|||||||
- Infers function arguments from Sphinx/Epydoc strings
|
- Infers function arguments from Sphinx/Epydoc strings
|
||||||
- Doesn't execute Python code
|
- Doesn't execute Python code
|
||||||
- Supports Virtualenv
|
- Supports Virtualenv
|
||||||
- Supports Python 2.5+ and 3.2+
|
- Supports Python 2.7 and 3.4+
|
||||||
|
|
||||||
By leveraging this library, jedi-vim adds the following capabilities to Vim:
|
By leveraging this library, jedi-vim adds the following capabilities to Vim:
|
||||||
|
|
||||||
@@ -78,15 +78,6 @@ By leveraging this library, jedi-vim adds the following capabilities to Vim:
|
|||||||
|
|
||||||
First of all, jedi-vim requires Vim to be compiled with the `+python` option.
|
First of all, jedi-vim requires Vim to be compiled with the `+python` option.
|
||||||
|
|
||||||
The jedi library has to be installed for jedi-vim to work properly. You can
|
|
||||||
install it first, by using e.g. your distribution's package manager, or by
|
|
||||||
using pip: >
|
|
||||||
|
|
||||||
pip install jedi
|
|
||||||
|
|
||||||
However, you can also install it as a git submodule if you don't want to use
|
|
||||||
jedi for anything but this plugin. How to do this is detailed below.
|
|
||||||
|
|
||||||
It is best if you have VIM >= 7.3, compiled with the `+conceal` option. With
|
It is best if you have VIM >= 7.3, compiled with the `+conceal` option. With
|
||||||
older versions, you will probably not see the parameter recommendation list
|
older versions, you will probably not see the parameter recommendation list
|
||||||
for functions after typing the open bracket. Some platforms (including OS X
|
for functions after typing the open bracket. Some platforms (including OS X
|
||||||
@@ -107,11 +98,7 @@ feature (such as MacVim on OS X, which also contains a console binary).
|
|||||||
------------------------------------------------------------------------------
|
------------------------------------------------------------------------------
|
||||||
2.1. Installing manually *jedi-vim-installation-manually*
|
2.1. Installing manually *jedi-vim-installation-manually*
|
||||||
|
|
||||||
1a. Get the latest repository from Github: >
|
1. If you want to install jedi as a submodule instead, issue this command: >
|
||||||
|
|
||||||
git clone http://github.com/davidhalter/jedi-vim path/to/bundles/jedi-vim
|
|
||||||
|
|
||||||
1b. If you want to install jedi as a submodule instead, issue this command: >
|
|
||||||
|
|
||||||
git clone --recursive http://github.com/davidhalter/jedi-vim
|
git clone --recursive http://github.com/davidhalter/jedi-vim
|
||||||
|
|
||||||
@@ -123,7 +110,7 @@ feature (such as MacVim on OS X, which also contains a console binary).
|
|||||||
:helptags <path/to/vimruntime>/doc
|
:helptags <path/to/vimruntime>/doc
|
||||||
|
|
||||||
------------------------------------------------------------------------------
|
------------------------------------------------------------------------------
|
||||||
2.1. Installing using Pathogen *jedi-vim-installation-pathogen*
|
2.2. Installing using Pathogen *jedi-vim-installation-pathogen*
|
||||||
|
|
||||||
Pathogen simplifies installation considerably.
|
Pathogen simplifies installation considerably.
|
||||||
|
|
||||||
@@ -161,8 +148,8 @@ repositories. On Arch Linux, install vim-jedi. On Debian (8+) or Ubuntu
|
|||||||
==============================================================================
|
==============================================================================
|
||||||
3. Supported Python features *jedi-vim-support*
|
3. Supported Python features *jedi-vim-support*
|
||||||
|
|
||||||
The Jedi library does all the hard work behind the scenes. It supports
|
The Jedi library does all the hard work behind the scenes. It understands most
|
||||||
completion of a large number of Python features, among them:
|
Python features, among them:
|
||||||
|
|
||||||
- Builtins
|
- Builtins
|
||||||
- Multiple `return`s or `yield`s
|
- Multiple `return`s or `yield`s
|
||||||
@@ -185,10 +172,12 @@ completion of a large number of Python features, among them:
|
|||||||
- Simple/usual `sys.path` modifications
|
- Simple/usual `sys.path` modifications
|
||||||
- `isinstance` checks for `if`/`while`/`assert` case, that doesn’t work with
|
- `isinstance` checks for `if`/`while`/`assert` case, that doesn’t work with
|
||||||
Jedi
|
Jedi
|
||||||
|
- Stubs
|
||||||
- And more...
|
- And more...
|
||||||
|
|
||||||
Note: This list is not necessarily up to date. For a complete list of
|
Note: This list is not necessarily up to date. For a complete list of
|
||||||
features, please refer to the Jedi documentation at http://jedi.jedidjah.ch.
|
features, please refer to the Jedi documentation at
|
||||||
|
http://jedi.readthedocs.io.
|
||||||
|
|
||||||
==============================================================================
|
==============================================================================
|
||||||
4. Usage *jedi-vim-usage*
|
4. Usage *jedi-vim-usage*
|
||||||
@@ -308,7 +297,7 @@ Default: <leader>r Rename variables
|
|||||||
|
|
||||||
Jedi-vim deletes the word currently under the cursor and puts Vim in insert
|
Jedi-vim deletes the word currently under the cursor and puts Vim in insert
|
||||||
mode, where the user is expected to enter the new variable name. Upon leaving
|
mode, where the user is expected to enter the new variable name. Upon leaving
|
||||||
insert mode, jedi-vim then renames all occurences of the old variable name
|
insert mode, jedi-vim then renames all occurrences of the old variable name
|
||||||
with the new one. The number of performed renames is displayed in the command
|
with the new one. The number of performed renames is displayed in the command
|
||||||
line.
|
line.
|
||||||
|
|
||||||
@@ -373,6 +362,7 @@ However, when working with large modules, this can slow down your typing flow
|
|||||||
since you have to wait for jedi to parse the module and show the completion
|
since you have to wait for jedi to parse the module and show the completion
|
||||||
menu. By disabling this setting, completion is only started when you manually
|
menu. By disabling this setting, completion is only started when you manually
|
||||||
press the completion key.
|
press the completion key.
|
||||||
|
You need to also have `g:jedi#completions_enabled` enabled for this.
|
||||||
|
|
||||||
Options: 0 or 1
|
Options: 0 or 1
|
||||||
Default: 1 (Start completion on typing a period)
|
Default: 1 (Start completion on typing a period)
|
||||||
@@ -438,10 +428,10 @@ Default: 500
|
|||||||
|
|
||||||
You can make jedi-vim open a new tab if you use the "go to", "show
|
You can make jedi-vim open a new tab if you use the "go to", "show
|
||||||
definition", or "related names" commands. When you leave this at the default
|
definition", or "related names" commands. When you leave this at the default
|
||||||
(0), they open in the current buffer instead.
|
(0), they open in the current window instead.
|
||||||
|
|
||||||
Options: 0 or 1
|
Options: 0 or 1
|
||||||
Default: 0 (Command output is put in a new tab)
|
Default: 0 (Command output reuses current window)
|
||||||
|
|
||||||
------------------------------------------------------------------------------
|
------------------------------------------------------------------------------
|
||||||
6.9. `g:jedi#squelch_py_warning` *g:jedi#squelch_py_warning*
|
6.9. `g:jedi#squelch_py_warning` *g:jedi#squelch_py_warning*
|
||||||
@@ -479,38 +469,37 @@ small a horizontal split happens.
|
|||||||
------------------------------------------------------------------------------
|
------------------------------------------------------------------------------
|
||||||
6.12. `g:jedi#force_py_version` *g:jedi#force_py_version*
|
6.12. `g:jedi#force_py_version` *g:jedi#force_py_version*
|
||||||
|
|
||||||
If you have installed both python 2 and python 3, you can force which one jedi
|
If you have installed multiple Python versions, you can force the Python
|
||||||
should use by setting this variable. It forces the internal Vim command, which
|
version that is going to be used.
|
||||||
will be used for every jedi call to the respective python interpreter.
|
You don't have to compile VIM with multiple Python versions.
|
||||||
The variable can be set in the .vimrc like this to force python 3:
|
The variable can be set in the .vimrc like this to force python 2:
|
||||||
|
|
||||||
let g:jedi#force_py_version = 3
|
let g:jedi#force_py_version = 2
|
||||||
|
|
||||||
This variable can be switched during runtime using the following function:
|
By default jedi loads the latest Python version installed on your system that
|
||||||
Function: `jedi#force_py_version_switch()`
|
can be found.
|
||||||
|
|
||||||
or set directly using this function, which has the same name as the variable:
|
This variable can be changed during runtime.
|
||||||
Function: `jedi#force_py_version(py_version)`
|
|
||||||
|
|
||||||
Options: 2 or 3
|
Options: 2, 2.7, 3, 3.5, 3.6, ...
|
||||||
Default: "auto" (will use sys.version_info from "python" in your $PATH)
|
Default: "auto"
|
||||||
------------------------------------------------------------------------------
|
------------------------------------------------------------------------------
|
||||||
6.13. `g:jedi#smart_auto_mappings` *g:jedi#smart_auto_mappings*
|
6.13. `g:jedi#smart_auto_mappings` *g:jedi#smart_auto_mappings*
|
||||||
|
|
||||||
When you start typing `from module.name<space>` jedi-vim automatically
|
When you start typing `from module.name<space>` jedi-vim automatically
|
||||||
adds the "import" statement and displays the autocomplete popup.
|
can add the "import" statement and trigger the autocompletion popup.
|
||||||
|
|
||||||
This option can be disabled in the .vimrc:
|
You can enable this using: >
|
||||||
|
|
||||||
`let g:jedi#smart_auto_mappings = 0`
|
|
||||||
|
|
||||||
|
let g:jedi#smart_auto_mappings = 1
|
||||||
|
<
|
||||||
Options: 0 or 1
|
Options: 0 or 1
|
||||||
Default: 1 (enabled by default)
|
Default: 0 (disabled by default)
|
||||||
|
|
||||||
------------------------------------------------------------------------------
|
------------------------------------------------------------------------------
|
||||||
6.14. `g:jedi#use_tag_stack` *g:jedi#use_tag_stack*
|
6.14. `g:jedi#use_tag_stack` *g:jedi#use_tag_stack*
|
||||||
|
|
||||||
Write results of |jedi#goto| to a temporary file and use the *:tjump* command
|
Write results of |jedi#goto| to a temporary file and use the |:tjump| command
|
||||||
to enable full |tagstack| functionality. Use of the tag stack allows
|
to enable full |tagstack| functionality. Use of the tag stack allows
|
||||||
returning to the usage of a function with CTRL-T after exploring the
|
returning to the usage of a function with CTRL-T after exploring the
|
||||||
definition with arbitrary changes to the |jumplist|.
|
definition with arbitrary changes to the |jumplist|.
|
||||||
|
|||||||
140
doc/logotype-a.svg
Normal file
140
doc/logotype-a.svg
Normal file
@@ -0,0 +1,140 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<!-- Generator: Adobe Illustrator 15.1.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
|
||||||
|
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
|
||||||
|
<svg version="1.1" id="Layer_2" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
|
||||||
|
width="897.845px" height="247.51px" viewBox="0 0 897.845 247.51" enable-background="new 0 0 897.845 247.51"
|
||||||
|
xml:space="preserve">
|
||||||
|
<g>
|
||||||
|
<g>
|
||||||
|
<linearGradient id="SVGID_1_" gradientUnits="userSpaceOnUse" x1="287.3965" y1="65.2686" x2="287.3965" y2="106.4546">
|
||||||
|
<stop offset="0" style="stop-color:#E27817"/>
|
||||||
|
<stop offset="0.3906" style="stop-color:#E47519"/>
|
||||||
|
<stop offset="0.7116" style="stop-color:#E96B1F"/>
|
||||||
|
<stop offset="1" style="stop-color:#F15A29"/>
|
||||||
|
</linearGradient>
|
||||||
|
<polygon fill="url(#SVGID_1_)" points="285.068,66.556 272.054,95.664 302.739,95.664 302.739,66.556 "/>
|
||||||
|
<linearGradient id="SVGID_2_" gradientUnits="userSpaceOnUse" x1="216.8877" y1="65.2686" x2="216.8877" y2="106.4546">
|
||||||
|
<stop offset="0" style="stop-color:#E27817"/>
|
||||||
|
<stop offset="0.3906" style="stop-color:#E47519"/>
|
||||||
|
<stop offset="0.7116" style="stop-color:#E96B1F"/>
|
||||||
|
<stop offset="1" style="stop-color:#F15A29"/>
|
||||||
|
</linearGradient>
|
||||||
|
<polygon fill="url(#SVGID_2_)" points="180.483,95.664 193.893,95.664 240.172,95.664 253.292,66.556 180.483,66.556 "/>
|
||||||
|
<g>
|
||||||
|
<polygon fill="#019733" points="256.464,59.293 253.603,65.696 253.593,65.696 253.197,66.592 240.172,95.7 215.738,150.321
|
||||||
|
199.788,185.978 231.676,185.978 231.676,185.969 272.071,95.7 275.634,87.737 285.089,66.592 288.355,59.293 "/>
|
||||||
|
</g>
|
||||||
|
<g>
|
||||||
|
<polygon fill="#019733" points="215.738,150.321 194.605,95.7 180.483,95.7 180.483,135.118 199.788,185.969 199.788,185.978
|
||||||
|
"/>
|
||||||
|
</g>
|
||||||
|
<path fill="#019733" d="M151.355,59.294v100.005h-28.989h-11.292v-7.972c3.644-4.232,6.749-9.936,6.749-16.218
|
||||||
|
c0-2.846-0.456-5.578-1.294-8.104h0.011l-4.274-12.151c-0.238-1.16-0.633-2.257-1.15-3.281v-0.032l-5.878-11.59
|
||||||
|
c-1.201-2.808-3.975-4.897-7.34-5.362c0.281-4.969,2.837-8.87,5.932-8.87l-3.137-1.004l3.137-3.033
|
||||||
|
c-5.01,0-9.098,5.775-9.388,13.021c-3.116,0.609-5.672,2.598-6.79,5.258l-5.723,11.271c-0.052,0.104-0.104,0.197-0.155,0.3v0.01
|
||||||
|
c-0.528,1.057-0.932,2.174-1.169,3.344l-4.232,12.079c-0.012,0.02-0.012,0.03-0.021,0.042c-0.828,2.525-1.294,5.258-1.294,8.104
|
||||||
|
c0,6.282,3.25,11.985,6.904,16.218v35.616h29.112h11.294h58.105V59.294H151.355z M86.554,117.834
|
||||||
|
c-0.673,2.019-2.442,3.252-3.954,2.744c-1.51-0.508-2.194-2.547-1.521-4.565c0.673-2.017,2.443-3.25,3.953-2.742
|
||||||
|
C86.544,113.777,87.228,115.817,86.554,117.834z M110.163,120.578c-1.51,0.508-3.27-0.726-3.954-2.744
|
||||||
|
c-0.672-2.017,0.011-4.057,1.521-4.563c1.512-0.508,3.282,0.726,3.955,2.742C112.357,118.031,111.674,120.07,110.163,120.578z"/>
|
||||||
|
<linearGradient id="SVGID_3_" gradientUnits="userSpaceOnUse" x1="134.6348" y1="65.2686" x2="134.6348" y2="106.4546">
|
||||||
|
<stop offset="0" style="stop-color:#E27817"/>
|
||||||
|
<stop offset="0.3906" style="stop-color:#E47519"/>
|
||||||
|
<stop offset="0.7116" style="stop-color:#E96B1F"/>
|
||||||
|
<stop offset="1" style="stop-color:#F15A29"/>
|
||||||
|
</linearGradient>
|
||||||
|
<polygon fill="url(#SVGID_3_)" points="151.292,66.556 117.914,66.556 117.914,95.664 145.981,95.664 151.292,95.664
|
||||||
|
151.355,95.664 151.355,66.592 151.292,66.592 "/>
|
||||||
|
<g opacity="0.5">
|
||||||
|
<linearGradient id="SVGID_4_" gradientUnits="userSpaceOnUse" x1="244.0713" y1="198.6924" x2="244.0713" y2="111.1674">
|
||||||
|
<stop offset="0" style="stop-color:#019733"/>
|
||||||
|
<stop offset="0.1363" style="stop-color:#0B732D;stop-opacity:0.8637"/>
|
||||||
|
<stop offset="0.2826" style="stop-color:#145529;stop-opacity:0.7174"/>
|
||||||
|
<stop offset="0.4366" style="stop-color:#1A3D25;stop-opacity:0.5634"/>
|
||||||
|
<stop offset="0.5997" style="stop-color:#1F2C22;stop-opacity:0.4003"/>
|
||||||
|
<stop offset="0.778" style="stop-color:#222221;stop-opacity:0.222"/>
|
||||||
|
<stop offset="1" style="stop-color:#231F20;stop-opacity:0"/>
|
||||||
|
</linearGradient>
|
||||||
|
<polygon fill="url(#SVGID_4_)" points="256.464,59.293 253.603,65.696 253.593,65.696 253.197,66.592 240.172,95.7
|
||||||
|
215.738,150.321 199.788,185.978 231.676,185.978 231.676,185.969 272.071,95.7 275.634,87.737 285.089,66.592 288.355,59.293
|
||||||
|
"/>
|
||||||
|
</g>
|
||||||
|
<linearGradient id="SVGID_5_" gradientUnits="userSpaceOnUse" x1="165.9131" y1="41.1123" x2="165.9131" y2="128.6277">
|
||||||
|
<stop offset="0" style="stop-color:#019733"/>
|
||||||
|
<stop offset="0.1363" style="stop-color:#0B732D;stop-opacity:0.8637"/>
|
||||||
|
<stop offset="0.2826" style="stop-color:#145529;stop-opacity:0.7174"/>
|
||||||
|
<stop offset="0.4366" style="stop-color:#1A3D25;stop-opacity:0.5634"/>
|
||||||
|
<stop offset="0.5997" style="stop-color:#1F2C22;stop-opacity:0.4003"/>
|
||||||
|
<stop offset="0.778" style="stop-color:#222221;stop-opacity:0.222"/>
|
||||||
|
<stop offset="1" style="stop-color:#231F20;stop-opacity:0"/>
|
||||||
|
</linearGradient>
|
||||||
|
<rect x="151.355" y="59.294" opacity="0.5" fill="url(#SVGID_5_)" width="29.116" height="127.649"/>
|
||||||
|
<g opacity="0.58">
|
||||||
|
<linearGradient id="SVGID_6_" gradientUnits="userSpaceOnUse" x1="198.1104" y1="83.4141" x2="198.1104" y2="154.2879">
|
||||||
|
<stop offset="0" style="stop-color:#019733"/>
|
||||||
|
<stop offset="0.0409" style="stop-color:#038E32;stop-opacity:0.9591"/>
|
||||||
|
<stop offset="0.2465" style="stop-color:#0F662B;stop-opacity:0.7535"/>
|
||||||
|
<stop offset="0.4491" style="stop-color:#184726;stop-opacity:0.5509"/>
|
||||||
|
<stop offset="0.6453" style="stop-color:#1E3123;stop-opacity:0.3547"/>
|
||||||
|
<stop offset="0.8322" style="stop-color:#222421;stop-opacity:0.1678"/>
|
||||||
|
<stop offset="1" style="stop-color:#231F20;stop-opacity:0"/>
|
||||||
|
</linearGradient>
|
||||||
|
<polygon fill="url(#SVGID_6_)" points="215.738,150.321 194.605,95.7 180.483,95.7 180.483,135.118 199.788,185.969
|
||||||
|
199.788,185.978 "/>
|
||||||
|
</g>
|
||||||
|
<linearGradient id="SVGID_7_" gradientUnits="userSpaceOnUse" x1="127.7627" y1="192.1367" x2="127.7627" y2="137.5901">
|
||||||
|
<stop offset="0" style="stop-color:#019733"/>
|
||||||
|
<stop offset="0.0409" style="stop-color:#038E32;stop-opacity:0.9591"/>
|
||||||
|
<stop offset="0.2465" style="stop-color:#0F662B;stop-opacity:0.7535"/>
|
||||||
|
<stop offset="0.4491" style="stop-color:#184726;stop-opacity:0.5509"/>
|
||||||
|
<stop offset="0.6453" style="stop-color:#1E3123;stop-opacity:0.3547"/>
|
||||||
|
<stop offset="0.8322" style="stop-color:#222421;stop-opacity:0.1678"/>
|
||||||
|
<stop offset="1" style="stop-color:#231F20;stop-opacity:0"/>
|
||||||
|
</linearGradient>
|
||||||
|
<path opacity="0.6" fill="url(#SVGID_7_)" d="M151.355,59.294v100.005h-28.989h-11.292v-7.972
|
||||||
|
c3.644-4.232,6.749-9.936,6.749-16.218c0-2.846-0.456-5.578-1.294-8.104h0.011l-4.274-12.151c-0.238-1.16-0.633-2.257-1.15-3.281
|
||||||
|
v-0.032l-5.878-11.59c-1.201-2.808-3.975-4.897-7.34-5.362c0.281-4.969,2.837-8.87,5.932-8.87l-3.137-1.004l3.137-3.033
|
||||||
|
c-5.01,0-9.098,5.775-9.388,13.021c-3.116,0.609-5.672,2.598-6.79,5.258l-5.723,11.271c-0.052,0.104-0.104,0.197-0.155,0.3v0.01
|
||||||
|
c-0.528,1.057-0.932,2.174-1.169,3.344l-4.232,12.079c-0.012,0.02-0.012,0.03-0.021,0.042c-0.828,2.525-1.294,5.258-1.294,8.104
|
||||||
|
c0,6.282,3.25,11.985,6.904,16.218v35.616h29.112h11.294h58.105V59.294H151.355z M86.554,117.834
|
||||||
|
c-0.673,2.019-2.442,3.252-3.954,2.744c-1.51-0.508-2.194-2.547-1.521-4.565c0.673-2.017,2.443-3.25,3.953-2.742
|
||||||
|
C86.544,113.777,87.228,115.817,86.554,117.834z M110.163,120.578c-1.51,0.508-3.27-0.726-3.954-2.744
|
||||||
|
c-0.672-2.017,0.011-4.057,1.521-4.563c1.512-0.508,3.282,0.726,3.955,2.742C112.357,118.031,111.674,120.07,110.163,120.578z"/>
|
||||||
|
<g opacity="0.5">
|
||||||
|
<linearGradient id="SVGID_8_" gradientUnits="userSpaceOnUse" x1="244.0713" y1="53.3584" x2="244.0713" y2="78.0277">
|
||||||
|
<stop offset="0" style="stop-color:#019733"/>
|
||||||
|
<stop offset="0.1363" style="stop-color:#0B732D;stop-opacity:0.8637"/>
|
||||||
|
<stop offset="0.2826" style="stop-color:#145529;stop-opacity:0.7174"/>
|
||||||
|
<stop offset="0.4366" style="stop-color:#1A3D25;stop-opacity:0.5634"/>
|
||||||
|
<stop offset="0.5997" style="stop-color:#1F2C22;stop-opacity:0.4003"/>
|
||||||
|
<stop offset="0.778" style="stop-color:#222221;stop-opacity:0.222"/>
|
||||||
|
<stop offset="1" style="stop-color:#231F20;stop-opacity:0"/>
|
||||||
|
</linearGradient>
|
||||||
|
<polygon fill="url(#SVGID_8_)" points="256.464,59.293 253.603,65.696 253.593,65.696 253.197,66.592 240.172,95.7
|
||||||
|
215.738,150.321 199.788,185.978 231.676,185.978 231.676,185.969 272.071,95.7 275.634,87.737 285.089,66.592 288.355,59.293
|
||||||
|
"/>
|
||||||
|
</g>
|
||||||
|
<polygon fill="#019733" points="180.483,59.198 183.329,66.556 180.471,66.556 "/>
|
||||||
|
<polygon fill="#019733" points="180.483,59.198 183.329,66.556 180.471,66.556 "/>
|
||||||
|
<g>
|
||||||
|
<polygon fill="#019733" points="290.713,66.592 285.054,66.592 288.32,59.293 "/>
|
||||||
|
<polygon fill="#019733" points="308.417,120.554 283.562,95.7 300.261,95.7 "/>
|
||||||
|
<polygon opacity="0.6" fill="#019733" points="308.417,120.554 283.562,95.7 300.261,95.7 "/>
|
||||||
|
<polygon fill="#019733" points="290.713,66.592 285.054,66.592 288.32,59.293 "/>
|
||||||
|
</g>
|
||||||
|
</g>
|
||||||
|
<g>
|
||||||
|
<path fill="#666666" d="M358.849,130.077v23.827h28.81V77.887h16.547v91.732h-62.987v-39.542H358.849z"/>
|
||||||
|
<path fill="#666666" d="M434.61,93.602v22.677h45.356v14.949H434.61v22.677h45.356v15.715h-62.987V77.887h62.987v15.715H434.61z"
|
||||||
|
/>
|
||||||
|
<path fill="#666666" d="M492.744,169.619V77.887h56.342l6.643,8.05v75.634l-6.579,8.049H492.744z M539.184,93.602h-28.811v60.303
|
||||||
|
h28.811V93.602z"/>
|
||||||
|
<path fill="#666666" d="M586.136,169.619h-17.632V77.887h17.632V169.619z"/>
|
||||||
|
<path fill="#666666" d="M598.913,116.278h33.281v14.949h-33.281V116.278z"/>
|
||||||
|
<path fill="#666666" d="M691.412,77.887h16.544l-19.995,91.732h-21.462l-21.527-91.732h17.63l13.798,70.588L691.412,77.887z"/>
|
||||||
|
<path fill="#666666" d="M738.364,169.619h-17.631V77.887h17.631V169.619z"/>
|
||||||
|
<path fill="#666666" d="M768.77,169.619h-17.632V77.887h17.632l17.886,50.273l18.59-50.273h16.545v91.732h-16.545v-38.392
|
||||||
|
l-12.84,38.392h-10.35l-13.286-38.392V169.619z"/>
|
||||||
|
</g>
|
||||||
|
</g>
|
||||||
|
</svg>
|
||||||
|
After Width: | Height: | Size: 9.8 KiB |
@@ -7,26 +7,29 @@ endif
|
|||||||
|
|
||||||
if g:jedi#auto_initialization
|
if g:jedi#auto_initialization
|
||||||
" goto / get_definition / usages
|
" goto / get_definition / usages
|
||||||
if g:jedi#goto_command != ''
|
if len(g:jedi#goto_command)
|
||||||
execute "nnoremap <buffer> ".g:jedi#goto_command." :call jedi#goto()<CR>"
|
execute 'nnoremap <buffer> '.g:jedi#goto_command.' :call jedi#goto()<CR>'
|
||||||
endif
|
endif
|
||||||
if g:jedi#goto_assignments_command != ''
|
if len(g:jedi#goto_assignments_command)
|
||||||
execute "nnoremap <buffer> ".g:jedi#goto_assignments_command." :call jedi#goto_assignments()<CR>"
|
execute 'nnoremap <buffer> '.g:jedi#goto_assignments_command.' :call jedi#goto_assignments()<CR>'
|
||||||
endif
|
endif
|
||||||
if g:jedi#goto_definitions_command != ''
|
if len(g:jedi#goto_definitions_command)
|
||||||
execute "nnoremap <buffer> ".g:jedi#goto_definitions_command." :call jedi#goto_definitions()<CR>"
|
execute 'nnoremap <buffer> '.g:jedi#goto_definitions_command.' :call jedi#goto_definitions()<CR>'
|
||||||
endif
|
endif
|
||||||
if g:jedi#usages_command != ''
|
if len(g:jedi#goto_stubs_command)
|
||||||
execute "nnoremap <buffer> ".g:jedi#usages_command." :call jedi#usages()<CR>"
|
execute 'nnoremap <buffer> '.g:jedi#goto_stubs_command.' :call jedi#goto_stubs()<CR>'
|
||||||
|
endif
|
||||||
|
if len(g:jedi#usages_command)
|
||||||
|
execute 'nnoremap <buffer> '.g:jedi#usages_command.' :call jedi#usages()<CR>'
|
||||||
endif
|
endif
|
||||||
" rename
|
" rename
|
||||||
if g:jedi#rename_command != ''
|
if len(g:jedi#rename_command)
|
||||||
execute "nnoremap <buffer> ".g:jedi#rename_command." :call jedi#rename()<CR>"
|
execute 'nnoremap <buffer> '.g:jedi#rename_command.' :call jedi#rename()<CR>'
|
||||||
execute "vnoremap <buffer> ".g:jedi#rename_command." :call jedi#rename_visual()<CR>"
|
execute 'vnoremap <buffer> '.g:jedi#rename_command.' :call jedi#rename_visual()<CR>'
|
||||||
endif
|
endif
|
||||||
" documentation/pydoc
|
" documentation/pydoc
|
||||||
if g:jedi#documentation_command != ''
|
if len(g:jedi#documentation_command)
|
||||||
execute "nnoremap <silent> <buffer>".g:jedi#documentation_command." :call jedi#show_documentation()<CR>"
|
execute 'nnoremap <silent> <buffer>'.g:jedi#documentation_command.' :call jedi#show_documentation()<CR>'
|
||||||
endif
|
endif
|
||||||
|
|
||||||
if g:jedi#show_call_signatures > 0 && has('conceal')
|
if g:jedi#show_call_signatures > 0 && has('conceal')
|
||||||
@@ -43,6 +46,12 @@ if g:jedi#auto_initialization
|
|||||||
|
|
||||||
if g:jedi#auto_close_doc
|
if g:jedi#auto_close_doc
|
||||||
" close preview if its still open after insert
|
" close preview if its still open after insert
|
||||||
autocmd InsertLeave <buffer> if pumvisible() == 0|pclose|endif
|
augroup jedi_preview
|
||||||
|
autocmd! InsertLeave <buffer> if pumvisible() == 0|pclose|endif
|
||||||
|
augroup END
|
||||||
endif
|
endif
|
||||||
|
augroup jedi_usages
|
||||||
|
autocmd! TextChanged <buffer> call jedi#remove_usages()
|
||||||
|
autocmd! InsertEnter <buffer> call jedi#remove_usages()
|
||||||
|
augroup END
|
||||||
endif
|
endif
|
||||||
|
|||||||
@@ -1,22 +0,0 @@
|
|||||||
''' ------------------------------------------------------------------------
|
|
||||||
Python initialization
|
|
||||||
---------------------------------------------------------------------------
|
|
||||||
here we initialize the jedi stuff '''
|
|
||||||
|
|
||||||
import vim
|
|
||||||
|
|
||||||
# update the system path, to include the jedi path
|
|
||||||
import sys
|
|
||||||
import os
|
|
||||||
|
|
||||||
# vim.command('echom expand("<sfile>:p:h:h")') # broken, <sfile> inside function
|
|
||||||
# sys.path.insert(0, os.path.join(vim.eval('expand("<sfile>:p:h:h")'), 'jedi'))
|
|
||||||
sys.path.insert(0, os.path.join(vim.eval('expand(s:script_path)'), 'jedi'))
|
|
||||||
|
|
||||||
# to display errors correctly
|
|
||||||
import traceback
|
|
||||||
|
|
||||||
# update the sys path to include the jedi_vim script
|
|
||||||
sys.path.insert(0, vim.eval('expand(s:script_path)'))
|
|
||||||
import jedi_vim
|
|
||||||
sys.path.pop(1)
|
|
||||||
1
jedi
1
jedi
Submodule jedi deleted from 995a653122
@@ -4,23 +4,46 @@
|
|||||||
" This part of the software is just the vim interface. The really big deal is
|
" This part of the software is just the vim interface. The really big deal is
|
||||||
" the Jedi Python library.
|
" the Jedi Python library.
|
||||||
|
|
||||||
if !exists("g:jedi#auto_vim_configuration") || g:jedi#auto_vim_configuration
|
if get(g:, 'jedi#auto_vim_configuration', 1)
|
||||||
" jedi-vim doesn't work in compatible mode (vim script syntax problems)
|
" jedi-vim doesn't work in compatible mode (vim script syntax problems)
|
||||||
if &compatible
|
if &compatible
|
||||||
|
" vint: -ProhibitSetNoCompatible
|
||||||
set nocompatible
|
set nocompatible
|
||||||
|
" vint: +ProhibitSetNoCompatible
|
||||||
endif
|
endif
|
||||||
|
|
||||||
" jedi-vim really needs, otherwise jedi-vim cannot start.
|
" jedi-vim really needs, otherwise jedi-vim cannot start.
|
||||||
filetype plugin on
|
filetype plugin on
|
||||||
|
|
||||||
" Change completeopt, but only if it has Vim's default value.
|
augroup jedi_pyi
|
||||||
let s:save_completeopt=&completeopt
|
au!
|
||||||
set completeopt&
|
autocmd BufNewFile,BufRead *.pyi set filetype=python
|
||||||
let s:default_completeopt=&completeopt
|
augroup END
|
||||||
let &completeopt=s:save_completeopt
|
|
||||||
if s:default_completeopt == &completeopt
|
" Change completeopt, but only if it was not set already.
|
||||||
|
" This gets done on VimEnter, since otherwise Vim fails to restore the
|
||||||
|
" screen. Neovim is not affected, this is likely caused by using
|
||||||
|
" :redir/execute() before the (alternate) terminal is configured.
|
||||||
|
function! s:setup_completeopt()
|
||||||
|
if exists('*execute')
|
||||||
|
let completeopt = execute('silent verb set completeopt?')
|
||||||
|
else
|
||||||
|
redir => completeopt
|
||||||
|
silent verb set completeopt?
|
||||||
|
redir END
|
||||||
|
endif
|
||||||
|
if len(split(completeopt, '\n')) == 1
|
||||||
set completeopt=menuone,longest,preview
|
set completeopt=menuone,longest,preview
|
||||||
endif
|
endif
|
||||||
|
endfunction
|
||||||
|
if has('nvim')
|
||||||
|
call s:setup_completeopt()
|
||||||
|
else
|
||||||
|
augroup jedi_startup
|
||||||
|
au!
|
||||||
|
autocmd VimEnter * call s:setup_completeopt()
|
||||||
|
augroup END
|
||||||
|
endif
|
||||||
|
|
||||||
if len(mapcheck('<C-c>', 'i')) == 0
|
if len(mapcheck('<C-c>', 'i')) == 0
|
||||||
inoremap <C-c> <ESC>
|
inoremap <C-c> <ESC>
|
||||||
@@ -30,6 +53,21 @@ endif
|
|||||||
" Pyimport command
|
" Pyimport command
|
||||||
command! -nargs=1 -complete=custom,jedi#py_import_completions Pyimport :call jedi#py_import(<q-args>)
|
command! -nargs=1 -complete=custom,jedi#py_import_completions Pyimport :call jedi#py_import(<q-args>)
|
||||||
|
|
||||||
command! -nargs=0 JediDebugInfo call jedi#debug_info()
|
function! s:jedi_debug_info()
|
||||||
|
" Ensure the autoload file has been loaded (and ignore any errors, which
|
||||||
|
" will be displayed with the debug info).
|
||||||
|
let unset = {}
|
||||||
|
let saved_squelch_py_warning = get(g:, 'jedi#squelch_py_warning', unset)
|
||||||
|
let g:jedi#squelch_py_warning = 1
|
||||||
|
call jedi#init_python()
|
||||||
|
if saved_squelch_py_warning is unset
|
||||||
|
unlet g:jedi#squelch_py_warning
|
||||||
|
else
|
||||||
|
let g:jedi#squelch_py_warning = saved_squelch_py_warning
|
||||||
|
endif
|
||||||
|
call jedi#debug_info()
|
||||||
|
endfunction
|
||||||
|
command! -nargs=0 -bar JediDebugInfo call s:jedi_debug_info()
|
||||||
|
command! -nargs=0 -bang JediClearCache call jedi#clear_cache(<bang>0)
|
||||||
|
|
||||||
" vim: set et ts=4:
|
" vim: set et ts=4:
|
||||||
|
|||||||
@@ -1,3 +0,0 @@
|
|||||||
[pytest]
|
|
||||||
# Ignore all files
|
|
||||||
norecursedirs = *
|
|
||||||
1
pythonx/jedi
Submodule
1
pythonx/jedi
Submodule
Submodule pythonx/jedi added at 60415033b4
@@ -15,6 +15,7 @@ try:
|
|||||||
except ImportError:
|
except ImportError:
|
||||||
from itertools import izip_longest as zip_longest # Python 2
|
from itertools import izip_longest as zip_longest # Python 2
|
||||||
|
|
||||||
|
import vim
|
||||||
|
|
||||||
is_py3 = sys.version_info[0] >= 3
|
is_py3 = sys.version_info[0] >= 3
|
||||||
if is_py3:
|
if is_py3:
|
||||||
@@ -24,15 +25,27 @@ else:
|
|||||||
ELLIPSIS = u"…"
|
ELLIPSIS = u"…"
|
||||||
|
|
||||||
|
|
||||||
|
try:
|
||||||
|
# Somehow sys.prefix is set in combination with VIM and virtualenvs.
|
||||||
|
# However the sys path is not affected. Just reset it to the normal value.
|
||||||
|
sys.prefix = sys.base_prefix
|
||||||
|
sys.exec_prefix = sys.base_exec_prefix
|
||||||
|
except AttributeError:
|
||||||
|
# If we're not in a virtualenv we don't care. Everything is fine.
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
class PythonToVimStr(unicode):
|
class PythonToVimStr(unicode):
|
||||||
""" Vim has a different string implementation of single quotes """
|
""" Vim has a different string implementation of single quotes """
|
||||||
__slots__ = []
|
__slots__ = []
|
||||||
|
|
||||||
def __new__(cls, obj, encoding='UTF-8'):
|
def __new__(cls, obj, encoding='UTF-8'):
|
||||||
if is_py3 or isinstance(obj, unicode):
|
if not (is_py3 or isinstance(obj, unicode)):
|
||||||
|
obj = unicode.__new__(cls, obj, encoding)
|
||||||
|
|
||||||
|
# Vim cannot deal with zero bytes:
|
||||||
|
obj = obj.replace('\0', '\\0')
|
||||||
return unicode.__new__(cls, obj)
|
return unicode.__new__(cls, obj)
|
||||||
else:
|
|
||||||
return unicode.__new__(cls, obj, encoding)
|
|
||||||
|
|
||||||
def __repr__(self):
|
def __repr__(self):
|
||||||
# this is totally stupid and makes no sense but vim/python unicode
|
# this is totally stupid and makes no sense but vim/python unicode
|
||||||
@@ -62,46 +75,52 @@ def _catch_exception(string, is_eval):
|
|||||||
Interface between vim and python calls back to it.
|
Interface between vim and python calls back to it.
|
||||||
Necessary, because the exact error message is not given by `vim.error`.
|
Necessary, because the exact error message is not given by `vim.error`.
|
||||||
"""
|
"""
|
||||||
e = 'jedi#_vim_exceptions(%s, %s)'
|
result = vim.eval('jedi#_vim_exceptions({0}, {1})'.format(
|
||||||
result = vim.eval(e % (repr(PythonToVimStr(string, 'UTF-8')), is_eval))
|
repr(PythonToVimStr(string, 'UTF-8')), int(is_eval)))
|
||||||
if 'exception' in result:
|
if 'exception' in result:
|
||||||
raise VimError(result['exception'], result['throwpoint'], string)
|
raise VimError(result['exception'], result['throwpoint'], string)
|
||||||
return result['result']
|
return result['result']
|
||||||
|
|
||||||
|
|
||||||
def vim_command(string):
|
def vim_command(string):
|
||||||
_catch_exception(string, 0)
|
_catch_exception(string, is_eval=False)
|
||||||
|
|
||||||
|
|
||||||
def vim_eval(string):
|
def vim_eval(string):
|
||||||
return _catch_exception(string, 1)
|
return _catch_exception(string, is_eval=True)
|
||||||
|
|
||||||
|
|
||||||
def no_jedi_warning(error=None):
|
def no_jedi_warning(error=None):
|
||||||
msg = "Please install Jedi if you want to use jedi-vim."
|
vim.command('echohl WarningMsg')
|
||||||
|
vim.command('echom "Please install Jedi if you want to use jedi-vim."')
|
||||||
if error:
|
if error:
|
||||||
msg = '{} The error was: {}'.format(msg, error)
|
vim.command('echom "The error was: {0}"'.format(error))
|
||||||
vim.command('echohl WarningMsg'
|
vim.command('echohl None')
|
||||||
'| echom "Please install Jedi if you want to use jedi-vim."'
|
|
||||||
'| echohl None')
|
|
||||||
|
|
||||||
|
|
||||||
def echo_highlight(msg):
|
def echo_highlight(msg):
|
||||||
vim_command('echohl WarningMsg | echom "{}" | echohl None'.format(
|
vim_command('echohl WarningMsg | echom "jedi-vim: {0}" | echohl None'.format(
|
||||||
msg.replace('"', '\\"')))
|
str(msg).replace('"', '\\"')))
|
||||||
|
|
||||||
|
|
||||||
import vim
|
jedi_path = os.path.join(os.path.dirname(__file__), 'jedi')
|
||||||
|
sys.path.insert(0, jedi_path)
|
||||||
|
parso_path = os.path.join(os.path.dirname(__file__), 'parso')
|
||||||
|
sys.path.insert(0, parso_path)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
import jedi
|
import jedi
|
||||||
except ImportError as e:
|
except ImportError:
|
||||||
no_jedi_warning(str(e))
|
|
||||||
jedi = None
|
jedi = None
|
||||||
|
jedi_import_error = sys.exc_info()
|
||||||
else:
|
else:
|
||||||
try:
|
try:
|
||||||
version = jedi.__version__
|
version = jedi.__version__
|
||||||
except Exception as e: # e.g. AttributeError
|
except Exception as e: # e.g. AttributeError
|
||||||
echo_highlight("Could not load jedi python module: {}".format(e))
|
echo_highlight(
|
||||||
|
"Error when loading the jedi python module ({0}). "
|
||||||
|
"Please ensure that Jedi is installed correctly (see Installation "
|
||||||
|
"in the README.".format(e))
|
||||||
jedi = None
|
jedi = None
|
||||||
else:
|
else:
|
||||||
if isinstance(version, str):
|
if isinstance(version, str):
|
||||||
@@ -110,6 +129,9 @@ else:
|
|||||||
version = utils.version_info()
|
version = utils.version_info()
|
||||||
if version < (0, 7):
|
if version < (0, 7):
|
||||||
echo_highlight('Please update your Jedi version, it is too old.')
|
echo_highlight('Please update your Jedi version, it is too old.')
|
||||||
|
finally:
|
||||||
|
sys.path.remove(jedi_path)
|
||||||
|
sys.path.remove(parso_path)
|
||||||
|
|
||||||
|
|
||||||
def catch_and_print_exceptions(func):
|
def catch_and_print_exceptions(func):
|
||||||
@@ -135,18 +157,68 @@ def _check_jedi_availability(show_error=False):
|
|||||||
return func_receiver
|
return func_receiver
|
||||||
|
|
||||||
|
|
||||||
|
current_environment = (None, None)
|
||||||
|
|
||||||
|
|
||||||
|
def get_environment(use_cache=True):
|
||||||
|
global current_environment
|
||||||
|
|
||||||
|
vim_force_python_version = vim_eval("g:jedi#force_py_version")
|
||||||
|
if use_cache and vim_force_python_version == current_environment[0]:
|
||||||
|
return current_environment[1]
|
||||||
|
|
||||||
|
environment = None
|
||||||
|
if vim_force_python_version == "auto":
|
||||||
|
environment = jedi.api.environment.get_cached_default_environment()
|
||||||
|
else:
|
||||||
|
force_python_version = vim_force_python_version
|
||||||
|
if '0000' in force_python_version or '9999' in force_python_version:
|
||||||
|
# It's probably a float that wasn't shortened.
|
||||||
|
try:
|
||||||
|
force_python_version = "{:.1f}".format(float(force_python_version))
|
||||||
|
except ValueError:
|
||||||
|
pass
|
||||||
|
elif isinstance(force_python_version, float):
|
||||||
|
force_python_version = "{:.1f}".format(force_python_version)
|
||||||
|
|
||||||
|
try:
|
||||||
|
environment = jedi.get_system_environment(force_python_version)
|
||||||
|
except jedi.InvalidPythonEnvironment as exc:
|
||||||
|
environment = jedi.api.environment.get_cached_default_environment()
|
||||||
|
echo_highlight(
|
||||||
|
"force_python_version=%s is not supported: %s - using %s." % (
|
||||||
|
vim_force_python_version, str(exc), str(environment)))
|
||||||
|
|
||||||
|
current_environment = (vim_force_python_version, environment)
|
||||||
|
return environment
|
||||||
|
|
||||||
|
|
||||||
|
def get_known_environments():
|
||||||
|
"""Get known Jedi environments."""
|
||||||
|
envs = list(jedi.api.environment.find_virtualenvs())
|
||||||
|
envs.extend(jedi.api.environment.find_system_environments())
|
||||||
|
return envs
|
||||||
|
|
||||||
|
|
||||||
@catch_and_print_exceptions
|
@catch_and_print_exceptions
|
||||||
def get_script(source=None, column=None):
|
def get_script(source=None, column=None):
|
||||||
jedi.settings.additional_dynamic_modules = \
|
jedi.settings.additional_dynamic_modules = [
|
||||||
[b.name for b in vim.buffers if b.name is not None and b.name.endswith('.py')]
|
b.name for b in vim.buffers if (
|
||||||
|
b.name is not None and
|
||||||
|
b.name.endswith('.py') and
|
||||||
|
b.options['buflisted'])]
|
||||||
if source is None:
|
if source is None:
|
||||||
source = '\n'.join(vim.current.buffer)
|
source = '\n'.join(vim.current.buffer)
|
||||||
row = vim.current.window.cursor[0]
|
row = vim.current.window.cursor[0]
|
||||||
if column is None:
|
if column is None:
|
||||||
column = vim.current.window.cursor[1]
|
column = vim.current.window.cursor[1]
|
||||||
buf_path = vim.current.buffer.name
|
buf_path = vim.current.buffer.name
|
||||||
encoding = vim_eval('&encoding') or 'latin1'
|
|
||||||
return jedi.Script(source, row, column, buf_path, encoding)
|
return jedi.Script(
|
||||||
|
source, row, column, buf_path,
|
||||||
|
encoding=vim_eval('&encoding') or 'latin1',
|
||||||
|
environment=get_environment(),
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
@_check_jedi_availability(show_error=False)
|
@_check_jedi_availability(show_error=False)
|
||||||
@@ -155,12 +227,12 @@ def completions():
|
|||||||
row, column = vim.current.window.cursor
|
row, column = vim.current.window.cursor
|
||||||
# Clear call signatures in the buffer so they aren't seen by the completer.
|
# Clear call signatures in the buffer so they aren't seen by the completer.
|
||||||
# Call signatures in the command line can stay.
|
# Call signatures in the command line can stay.
|
||||||
if vim_eval("g:jedi#show_call_signatures") == '1':
|
if int(vim_eval("g:jedi#show_call_signatures")) == 1:
|
||||||
clear_call_signatures()
|
clear_call_signatures()
|
||||||
if vim.eval('a:findstart') == '1':
|
if vim.eval('a:findstart') == '1':
|
||||||
count = 0
|
count = 0
|
||||||
for char in reversed(vim.current.line[:column]):
|
for char in reversed(vim.current.line[:column]):
|
||||||
if not re.match('[\w\d]', char):
|
if not re.match(r'[\w\d]', char):
|
||||||
break
|
break
|
||||||
count += 1
|
count += 1
|
||||||
vim.command('return %i' % (column - count))
|
vim.command('return %i' % (column - count))
|
||||||
@@ -184,7 +256,7 @@ def completions():
|
|||||||
out = []
|
out = []
|
||||||
for c in completions:
|
for c in completions:
|
||||||
d = dict(word=PythonToVimStr(c.name[:len(base)] + c.complete),
|
d = dict(word=PythonToVimStr(c.name[:len(base)] + c.complete),
|
||||||
abbr=PythonToVimStr(c.name),
|
abbr=PythonToVimStr(c.name_with_symbols),
|
||||||
# stuff directly behind the completion
|
# stuff directly behind the completion
|
||||||
menu=PythonToVimStr(c.description),
|
menu=PythonToVimStr(c.description),
|
||||||
info=PythonToVimStr(c.docstring()), # docstr
|
info=PythonToVimStr(c.docstring()), # docstr
|
||||||
@@ -216,59 +288,48 @@ def tempfile(content):
|
|||||||
finally:
|
finally:
|
||||||
os.unlink(f.name)
|
os.unlink(f.name)
|
||||||
|
|
||||||
|
|
||||||
@_check_jedi_availability(show_error=True)
|
@_check_jedi_availability(show_error=True)
|
||||||
@catch_and_print_exceptions
|
@catch_and_print_exceptions
|
||||||
def goto(mode="goto", no_output=False):
|
def goto(mode="goto"):
|
||||||
"""
|
"""
|
||||||
:param str mode: "related_name", "definition", "assignment", "auto"
|
:param str mode: "definition", "assignment", "goto"
|
||||||
:return: list of definitions/assignments
|
:return: list of definitions/assignments
|
||||||
:rtype: list
|
:rtype: list
|
||||||
"""
|
"""
|
||||||
script = get_script()
|
script = get_script()
|
||||||
try:
|
|
||||||
if mode == "goto":
|
if mode == "goto":
|
||||||
definitions = [x for x in script.goto_definitions()
|
definitions = script.goto_assignments(follow_imports=True)
|
||||||
if not x.in_builtin_module()]
|
|
||||||
if not definitions:
|
|
||||||
definitions = script.goto_assignments()
|
|
||||||
elif mode == "related_name":
|
|
||||||
definitions = script.usages()
|
|
||||||
elif mode == "definition":
|
elif mode == "definition":
|
||||||
definitions = script.goto_definitions()
|
definitions = script.goto_definitions()
|
||||||
elif mode == "assignment":
|
elif mode == "assignment":
|
||||||
definitions = script.goto_assignments()
|
definitions = script.goto_assignments()
|
||||||
except jedi.NotFoundError:
|
elif mode == "stubs":
|
||||||
echo_highlight("Cannot follow nothing. Put your cursor on a valid name.")
|
definitions = script.goto_assignments(follow_imports=True, only_stubs=True)
|
||||||
definitions = []
|
|
||||||
else:
|
|
||||||
if no_output:
|
|
||||||
return definitions
|
|
||||||
if not definitions:
|
if not definitions:
|
||||||
echo_highlight("Couldn't find any definitions for this.")
|
echo_highlight("Couldn't find any definitions for this.")
|
||||||
elif len(definitions) == 1 and mode != "related_name":
|
elif len(definitions) == 1 and mode != "related_name":
|
||||||
# just add some mark to add the current position to the jumplist.
|
|
||||||
# this is ugly, because it overrides the mark for '`', so if anyone
|
|
||||||
# has a better idea, let me know.
|
|
||||||
vim_command('normal! m`')
|
|
||||||
|
|
||||||
d = list(definitions)[0]
|
d = list(definitions)[0]
|
||||||
if d.in_builtin_module():
|
if d.column is None:
|
||||||
if d.is_keyword:
|
if d.is_keyword:
|
||||||
echo_highlight("Cannot get the definition of Python keywords.")
|
echo_highlight("Cannot get the definition of Python keywords.")
|
||||||
else:
|
else:
|
||||||
echo_highlight("Builtin modules cannot be displayed (%s)."
|
echo_highlight("Builtin modules cannot be displayed (%s)."
|
||||||
% d.desc_with_module)
|
% d.desc_with_module)
|
||||||
else:
|
else:
|
||||||
using_tagstack = vim_eval('g:jedi#use_tag_stack') == '1'
|
using_tagstack = int(vim_eval('g:jedi#use_tag_stack')) == 1
|
||||||
if d.module_path != vim.current.buffer.name:
|
if (d.module_path or '') != vim.current.buffer.name:
|
||||||
result = new_buffer(d.module_path,
|
result = new_buffer(d.module_path,
|
||||||
using_tagstack=using_tagstack)
|
using_tagstack=using_tagstack)
|
||||||
if not result:
|
if not result:
|
||||||
return []
|
return []
|
||||||
if d.module_path and using_tagstack:
|
if (using_tagstack and d.module_path and
|
||||||
|
os.path.exists(d.module_path)):
|
||||||
tagname = d.name
|
tagname = d.name
|
||||||
with tempfile('{0}\t{1}\t{2}'.format(tagname, d.module_path,
|
with tempfile('{0}\t{1}\t{2}'.format(
|
||||||
'call cursor({0}, {1})'.format(d.line, d.column + 1))) as f:
|
tagname, d.module_path, 'call cursor({0}, {1})'.format(
|
||||||
|
d.line, d.column + 1))) as f:
|
||||||
old_tags = vim.eval('&tags')
|
old_tags = vim.eval('&tags')
|
||||||
old_wildignore = vim.eval('&wildignore')
|
old_wildignore = vim.eval('&wildignore')
|
||||||
try:
|
try:
|
||||||
@@ -284,19 +345,74 @@ def goto(mode="goto", no_output=False):
|
|||||||
repr(PythonToVimStr(old_wildignore)))
|
repr(PythonToVimStr(old_wildignore)))
|
||||||
vim.current.window.cursor = d.line, d.column
|
vim.current.window.cursor = d.line, d.column
|
||||||
else:
|
else:
|
||||||
# multiple solutions
|
show_goto_multi_results(definitions)
|
||||||
|
return definitions
|
||||||
|
|
||||||
|
|
||||||
|
def relpath(path):
|
||||||
|
"""Make path relative to cwd if it is below."""
|
||||||
|
abspath = os.path.abspath(path)
|
||||||
|
if abspath.startswith(os.getcwd()):
|
||||||
|
return os.path.relpath(path)
|
||||||
|
return path
|
||||||
|
|
||||||
|
|
||||||
|
def annotate_description(d):
|
||||||
|
code = d.get_line_code().strip()
|
||||||
|
if d.type == 'statement':
|
||||||
|
return code
|
||||||
|
if d.type == 'function':
|
||||||
|
if code.startswith('def'):
|
||||||
|
return code
|
||||||
|
typ = 'def'
|
||||||
|
else:
|
||||||
|
typ = d.type
|
||||||
|
return '[%s] %s' % (typ, code)
|
||||||
|
|
||||||
|
|
||||||
|
def show_goto_multi_results(definitions):
|
||||||
|
"""Create a quickfix list for multiple definitions."""
|
||||||
lst = []
|
lst = []
|
||||||
for d in definitions:
|
for d in definitions:
|
||||||
if d.in_builtin_module():
|
if d.column is None:
|
||||||
lst.append(dict(text=PythonToVimStr('Builtin ' + d.description)))
|
# Typically a namespace, in the future maybe other things as
|
||||||
|
# well.
|
||||||
|
lst.append(dict(text=PythonToVimStr(d.description)))
|
||||||
else:
|
else:
|
||||||
lst.append(dict(filename=PythonToVimStr(d.module_path),
|
text = annotate_description(d)
|
||||||
|
lst.append(dict(filename=PythonToVimStr(relpath(d.module_path)),
|
||||||
lnum=d.line, col=d.column + 1,
|
lnum=d.line, col=d.column + 1,
|
||||||
text=PythonToVimStr(d.description)))
|
text=PythonToVimStr(text)))
|
||||||
vim_eval('setqflist(%s)' % repr(lst))
|
vim_eval('setqflist(%s)' % repr(lst))
|
||||||
vim_eval('jedi#add_goto_window(' + str(len(lst)) + ')')
|
vim_eval('jedi#add_goto_window(' + str(len(lst)) + ')')
|
||||||
|
|
||||||
|
|
||||||
|
@catch_and_print_exceptions
|
||||||
|
def usages(visuals=True):
|
||||||
|
script = get_script()
|
||||||
|
definitions = script.usages()
|
||||||
|
if not definitions:
|
||||||
|
echo_highlight("No usages found here.")
|
||||||
return definitions
|
return definitions
|
||||||
|
|
||||||
|
if visuals:
|
||||||
|
highlight_usages(definitions)
|
||||||
|
show_goto_multi_results(definitions)
|
||||||
|
return definitions
|
||||||
|
|
||||||
|
|
||||||
|
def highlight_usages(definitions, length=None):
|
||||||
|
for definition in definitions:
|
||||||
|
# Only color the current module/buffer.
|
||||||
|
if (definition.module_path or '') == vim.current.buffer.name:
|
||||||
|
# mathaddpos needs a list of positions where a position is a list
|
||||||
|
# of (line, column, length).
|
||||||
|
# The column starts with 1 and not 0.
|
||||||
|
positions = [
|
||||||
|
[definition.line, definition.column + 1, length or len(definition.name)]
|
||||||
|
]
|
||||||
|
vim_eval("matchaddpos('jediUsage', %s)" % repr(positions))
|
||||||
|
|
||||||
|
|
||||||
@_check_jedi_availability(show_error=True)
|
@_check_jedi_availability(show_error=True)
|
||||||
@catch_and_print_exceptions
|
@catch_and_print_exceptions
|
||||||
@@ -304,8 +420,6 @@ def show_documentation():
|
|||||||
script = get_script()
|
script = get_script()
|
||||||
try:
|
try:
|
||||||
definitions = script.goto_definitions()
|
definitions = script.goto_definitions()
|
||||||
except jedi.NotFoundError:
|
|
||||||
definitions = []
|
|
||||||
except Exception:
|
except Exception:
|
||||||
# print to stdout, will be in :messages
|
# print to stdout, will be in :messages
|
||||||
definitions = []
|
definitions = []
|
||||||
@@ -327,7 +441,7 @@ def show_documentation():
|
|||||||
@catch_and_print_exceptions
|
@catch_and_print_exceptions
|
||||||
def clear_call_signatures():
|
def clear_call_signatures():
|
||||||
# Check if using command line call signatures
|
# Check if using command line call signatures
|
||||||
if vim_eval("g:jedi#show_call_signatures") == '2':
|
if int(vim_eval("g:jedi#show_call_signatures")) == 2:
|
||||||
vim_command('echo ""')
|
vim_command('echo ""')
|
||||||
return
|
return
|
||||||
cursor = vim.current.window.cursor
|
cursor = vim.current.window.cursor
|
||||||
@@ -336,7 +450,8 @@ def clear_call_signatures():
|
|||||||
# 1. Search for a line with a call signature and save the appended
|
# 1. Search for a line with a call signature and save the appended
|
||||||
# characters
|
# characters
|
||||||
# 2. Actually replace the line and redo the status quo.
|
# 2. Actually replace the line and redo the status quo.
|
||||||
py_regex = r'%sjedi=([0-9]+), (.*?)%s.*?%sjedi%s'.replace('%s', e)
|
py_regex = r'%sjedi=([0-9]+), (.*?)%s.*?%sjedi%s'.replace(
|
||||||
|
'%s', re.escape(e))
|
||||||
for i, line in enumerate(vim.current.buffer):
|
for i, line in enumerate(vim.current.buffer):
|
||||||
match = re.search(py_regex, line)
|
match = re.search(py_regex, line)
|
||||||
if match is not None:
|
if match is not None:
|
||||||
@@ -352,7 +467,7 @@ def clear_call_signatures():
|
|||||||
@_check_jedi_availability(show_error=False)
|
@_check_jedi_availability(show_error=False)
|
||||||
@catch_and_print_exceptions
|
@catch_and_print_exceptions
|
||||||
def show_call_signatures(signatures=()):
|
def show_call_signatures(signatures=()):
|
||||||
if vim_eval("has('conceal') && g:jedi#show_call_signatures") == '0':
|
if int(vim_eval("has('conceal') && g:jedi#show_call_signatures")) == 0:
|
||||||
return
|
return
|
||||||
|
|
||||||
if signatures == ():
|
if signatures == ():
|
||||||
@@ -362,9 +477,10 @@ def show_call_signatures(signatures=()):
|
|||||||
if not signatures:
|
if not signatures:
|
||||||
return
|
return
|
||||||
|
|
||||||
if vim_eval("g:jedi#show_call_signatures") == '2':
|
if int(vim_eval("g:jedi#show_call_signatures")) == 2:
|
||||||
return cmdline_call_signatures(signatures)
|
return cmdline_call_signatures(signatures)
|
||||||
|
|
||||||
|
seen_sigs = []
|
||||||
for i, signature in enumerate(signatures):
|
for i, signature in enumerate(signatures):
|
||||||
line, column = signature.bracket_start
|
line, column = signature.bracket_start
|
||||||
# signatures are listed above each other
|
# signatures are listed above each other
|
||||||
@@ -378,13 +494,20 @@ def show_call_signatures(signatures=()):
|
|||||||
# TODO check if completion menu is above or below
|
# TODO check if completion menu is above or below
|
||||||
line = vim_eval("getline(%s)" % line_to_replace)
|
line = vim_eval("getline(%s)" % line_to_replace)
|
||||||
|
|
||||||
params = [p.description.replace('\n', '') for p in signature.params]
|
# Descriptions are usually looking like `param name`, remove the param.
|
||||||
|
params = [p.description.replace('\n', '').replace('param ', '', 1)
|
||||||
|
for p in signature.params]
|
||||||
try:
|
try:
|
||||||
# *_*PLACEHOLDER*_* makes something fat. See after/syntax file.
|
# *_*PLACEHOLDER*_* makes something fat. See after/syntax file.
|
||||||
params[signature.index] = '*_*%s*_*' % params[signature.index]
|
params[signature.index] = '*_*%s*_*' % params[signature.index]
|
||||||
except (IndexError, TypeError):
|
except (IndexError, TypeError):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
# Skip duplicates.
|
||||||
|
if params in seen_sigs:
|
||||||
|
continue
|
||||||
|
seen_sigs.append(params)
|
||||||
|
|
||||||
# This stuff is reaaaaally a hack! I cannot stress enough, that
|
# This stuff is reaaaaally a hack! I cannot stress enough, that
|
||||||
# this is a stupid solution. But there is really no other yet.
|
# this is a stupid solution. But there is really no other yet.
|
||||||
# There is no possibility in VIM to draw on the screen, but there
|
# There is no possibility in VIM to draw on the screen, but there
|
||||||
@@ -424,7 +547,7 @@ def show_call_signatures(signatures=()):
|
|||||||
@catch_and_print_exceptions
|
@catch_and_print_exceptions
|
||||||
def cmdline_call_signatures(signatures):
|
def cmdline_call_signatures(signatures):
|
||||||
def get_params(s):
|
def get_params(s):
|
||||||
return [p.description.replace('\n', '') for p in s.params]
|
return [p.description.replace('\n', '').replace('param ', '', 1) for p in s.params]
|
||||||
|
|
||||||
def escape(string):
|
def escape(string):
|
||||||
return string.replace('"', '\\"').replace(r'\n', r'\\n')
|
return string.replace('"', '\\"').replace(r'\n', r'\\n')
|
||||||
@@ -448,7 +571,7 @@ def cmdline_call_signatures(signatures):
|
|||||||
max_msg_len = int(vim_eval('&columns')) - 12
|
max_msg_len = int(vim_eval('&columns')) - 12
|
||||||
if int(vim_eval('&ruler')):
|
if int(vim_eval('&ruler')):
|
||||||
max_msg_len -= 18
|
max_msg_len -= 18
|
||||||
max_msg_len -= len(signatures[0].call_name) + 2 # call name + parentheses
|
max_msg_len -= len(signatures[0].name) + 2 # call name + parentheses
|
||||||
|
|
||||||
if max_msg_len < (1 if params else 0):
|
if max_msg_len < (1 if params else 0):
|
||||||
return
|
return
|
||||||
@@ -483,7 +606,7 @@ def cmdline_call_signatures(signatures):
|
|||||||
_, column = signatures[0].bracket_start
|
_, column = signatures[0].bracket_start
|
||||||
spaces = min(int(vim_eval('g:jedi#first_col +'
|
spaces = min(int(vim_eval('g:jedi#first_col +'
|
||||||
'wincol() - col(".")')) +
|
'wincol() - col(".")')) +
|
||||||
column - len(signatures[0].call_name),
|
column - len(signatures[0].name),
|
||||||
max_num_spaces) * ' '
|
max_num_spaces) * ' '
|
||||||
|
|
||||||
if index is not None:
|
if index is not None:
|
||||||
@@ -494,33 +617,46 @@ def cmdline_call_signatures(signatures):
|
|||||||
'echohl jediFat | echon "%s" | '
|
'echohl jediFat | echon "%s" | '
|
||||||
'echohl jediFunction | echon "%s" | '
|
'echohl jediFunction | echon "%s" | '
|
||||||
'echohl None | echon ")"'
|
'echohl None | echon ")"'
|
||||||
% (spaces, signatures[0].call_name,
|
% (spaces, signatures[0].name,
|
||||||
left + ', ' if left else '',
|
left + ', ' if left else '',
|
||||||
center, ', ' + right if right else ''))
|
center, ', ' + right if right else ''))
|
||||||
else:
|
else:
|
||||||
vim_command(' echon "%s" | '
|
vim_command(' echon "%s" | '
|
||||||
'echohl Function | echon "%s" | '
|
'echohl Function | echon "%s" | '
|
||||||
'echohl None | echon "(%s)"'
|
'echohl None | echon "(%s)"'
|
||||||
% (spaces, signatures[0].call_name, text))
|
% (spaces, signatures[0].name, text))
|
||||||
|
|
||||||
|
|
||||||
@_check_jedi_availability(show_error=True)
|
@_check_jedi_availability(show_error=True)
|
||||||
@catch_and_print_exceptions
|
@catch_and_print_exceptions
|
||||||
def rename():
|
def rename():
|
||||||
if not int(vim.eval('a:0')):
|
if not int(vim.eval('a:0')):
|
||||||
|
# Need to save the cursor position before insert mode
|
||||||
|
cursor = vim.current.window.cursor
|
||||||
|
changenr = vim.eval('changenr()') # track undo tree
|
||||||
vim_command('augroup jedi_rename')
|
vim_command('augroup jedi_rename')
|
||||||
vim_command('autocmd InsertLeave <buffer> call jedi#rename(1)')
|
vim_command('autocmd InsertLeave <buffer> call jedi#rename'
|
||||||
|
'({}, {}, {})'.format(cursor[0], cursor[1], changenr))
|
||||||
vim_command('augroup END')
|
vim_command('augroup END')
|
||||||
|
|
||||||
vim_command("let s:jedi_replace_orig = expand('<cword>')")
|
vim_command("let s:jedi_replace_orig = expand('<cword>')")
|
||||||
|
line = vim_eval('getline(".")')
|
||||||
vim_command('normal! diw')
|
vim_command('normal! diw')
|
||||||
vim_command("let s:jedi_changedtick = b:changedtick")
|
if re.match(r'\w+$', line[cursor[1]:]):
|
||||||
|
# In case the deleted word is at the end of the line we need to
|
||||||
|
# move the cursor to the end.
|
||||||
|
vim_command('startinsert!')
|
||||||
|
else:
|
||||||
vim_command('startinsert')
|
vim_command('startinsert')
|
||||||
|
|
||||||
else:
|
else:
|
||||||
# Remove autocommand.
|
# Remove autocommand.
|
||||||
vim_command('autocmd! jedi_rename InsertLeave')
|
vim_command('autocmd! jedi_rename InsertLeave')
|
||||||
|
|
||||||
|
args = vim.eval('a:000')
|
||||||
|
cursor = tuple(int(x) for x in args[:2])
|
||||||
|
changenr = args[2]
|
||||||
|
|
||||||
# Get replacement, if there is something on the cursor.
|
# Get replacement, if there is something on the cursor.
|
||||||
# This won't be the case when the user ends insert mode right away,
|
# This won't be the case when the user ends insert mode right away,
|
||||||
# and `<cword>` would pick up the nearest word instead.
|
# and `<cword>` would pick up the nearest word instead.
|
||||||
@@ -529,13 +665,7 @@ def rename():
|
|||||||
else:
|
else:
|
||||||
replace = None
|
replace = None
|
||||||
|
|
||||||
cursor = vim.current.window.cursor
|
vim_command('undo {}'.format(changenr))
|
||||||
|
|
||||||
# Undo new word, but only if something was changed, which is not the
|
|
||||||
# case when ending insert mode right away.
|
|
||||||
if vim_eval('b:changedtick != s:jedi_changedtick') == '1':
|
|
||||||
vim_command('normal! u') # Undo new word.
|
|
||||||
vim_command('normal! u') # Undo diw.
|
|
||||||
|
|
||||||
vim.current.window.cursor = cursor
|
vim.current.window.cursor = cursor
|
||||||
|
|
||||||
@@ -561,43 +691,40 @@ def do_rename(replace, orig=None):
|
|||||||
saved_tab = int(vim_eval('tabpagenr()'))
|
saved_tab = int(vim_eval('tabpagenr()'))
|
||||||
saved_win = int(vim_eval('winnr()'))
|
saved_win = int(vim_eval('winnr()'))
|
||||||
|
|
||||||
temp_rename = goto(mode="related_name", no_output=True)
|
temp_rename = usages(visuals=False)
|
||||||
# Sort the whole thing reverse (positions at the end of the line
|
# Sort the whole thing reverse (positions at the end of the line
|
||||||
# must be first, because they move the stuff before the position).
|
# must be first, because they move the stuff before the position).
|
||||||
temp_rename = sorted(temp_rename, reverse=True,
|
temp_rename = sorted(temp_rename, reverse=True,
|
||||||
key=lambda x: (x.module_path, x.start_pos))
|
key=lambda x: (x.module_path, x.line, x.column))
|
||||||
buffers = set()
|
buffers = set()
|
||||||
for r in temp_rename:
|
for r in temp_rename:
|
||||||
if r.in_builtin_module():
|
if r.in_builtin_module():
|
||||||
continue
|
continue
|
||||||
|
|
||||||
if os.path.abspath(vim.current.buffer.name) != r.module_path:
|
if os.path.abspath(vim.current.buffer.name) != r.module_path:
|
||||||
|
assert r.module_path is not None
|
||||||
result = new_buffer(r.module_path)
|
result = new_buffer(r.module_path)
|
||||||
if not result:
|
if not result:
|
||||||
echo_highlight("Jedi-vim: failed to create buffer window for {}!".format(r.module_path))
|
echo_highlight('Failed to create buffer window for %s!' % (
|
||||||
|
r.module_path))
|
||||||
continue
|
continue
|
||||||
|
|
||||||
buffers.add(vim.current.buffer.name)
|
buffers.add(vim.current.buffer.name)
|
||||||
|
|
||||||
# Save view.
|
|
||||||
saved_view = vim_eval('string(winsaveview())')
|
|
||||||
|
|
||||||
# Replace original word.
|
# Replace original word.
|
||||||
vim.current.window.cursor = r.start_pos
|
r_line = vim.current.buffer[r.line - 1]
|
||||||
vim_command('normal! c{:d}l{}'.format(len(orig), replace))
|
vim.current.buffer[r.line - 1] = (r_line[:r.column] + replace +
|
||||||
|
r_line[r.column + len(orig):])
|
||||||
# Restore view.
|
|
||||||
vim_command('call winrestview(%s)' % saved_view)
|
|
||||||
|
|
||||||
# Restore previous tab and window.
|
# Restore previous tab and window.
|
||||||
vim_command('tabnext {:d}'.format(saved_tab))
|
vim_command('tabnext {0:d}'.format(saved_tab))
|
||||||
vim_command('{:d}wincmd w'.format(saved_win))
|
vim_command('{0:d}wincmd w'.format(saved_win))
|
||||||
|
|
||||||
if len(buffers) > 1:
|
if len(buffers) > 1:
|
||||||
echo_highlight('Jedi did {:d} renames in {:d} buffers!'.format(
|
echo_highlight('Jedi did {0:d} renames in {1:d} buffers!'.format(
|
||||||
len(temp_rename), len(buffers)))
|
len(temp_rename), len(buffers)))
|
||||||
else:
|
else:
|
||||||
echo_highlight('Jedi did {:d} renames!'.format(len(temp_rename)))
|
echo_highlight('Jedi did {0:d} renames!'.format(len(temp_rename)))
|
||||||
|
|
||||||
|
|
||||||
@_check_jedi_availability(show_error=True)
|
@_check_jedi_availability(show_error=True)
|
||||||
@@ -607,13 +734,13 @@ def py_import():
|
|||||||
args = shsplit(vim.eval('a:args'))
|
args = shsplit(vim.eval('a:args'))
|
||||||
import_path = args.pop()
|
import_path = args.pop()
|
||||||
text = 'import %s' % import_path
|
text = 'import %s' % import_path
|
||||||
scr = jedi.Script(text, 1, len(text), '')
|
scr = jedi.Script(text, 1, len(text), '', environment=get_environment())
|
||||||
try:
|
try:
|
||||||
completion = scr.goto_assignments()[0]
|
completion = scr.goto_assignments()[0]
|
||||||
except IndexError:
|
except IndexError:
|
||||||
echo_highlight('Cannot find %s in sys.path!' % import_path)
|
echo_highlight('Cannot find %s in sys.path!' % import_path)
|
||||||
else:
|
else:
|
||||||
if completion.in_builtin_module():
|
if completion.column is None: # Python modules always have a line number.
|
||||||
echo_highlight('%s is a builtin module.' % import_path)
|
echo_highlight('%s is a builtin module.' % import_path)
|
||||||
else:
|
else:
|
||||||
cmd_args = ' '.join([a.replace(' ', '\\ ') for a in args])
|
cmd_args = ' '.join([a.replace(' ', '\\ ') for a in args])
|
||||||
@@ -630,7 +757,7 @@ def py_import_completions():
|
|||||||
comps = []
|
comps = []
|
||||||
else:
|
else:
|
||||||
text = 'import %s' % argl
|
text = 'import %s' % argl
|
||||||
script = jedi.Script(text, 1, len(text), '')
|
script = jedi.Script(text, 1, len(text), '', environment=get_environment())
|
||||||
comps = ['%s%s' % (argl, c.complete) for c in script.completions()]
|
comps = ['%s%s' % (argl, c.complete) for c in script.completions()]
|
||||||
vim.command("return '%s'" % '\n'.join(comps))
|
vim.command("return '%s'" % '\n'.join(comps))
|
||||||
|
|
||||||
@@ -638,9 +765,9 @@ def py_import_completions():
|
|||||||
@catch_and_print_exceptions
|
@catch_and_print_exceptions
|
||||||
def new_buffer(path, options='', using_tagstack=False):
|
def new_buffer(path, options='', using_tagstack=False):
|
||||||
# options are what you can to edit the edit options
|
# options are what you can to edit the edit options
|
||||||
if vim_eval('g:jedi#use_tabs_not_buffers') == '1':
|
if int(vim_eval('g:jedi#use_tabs_not_buffers')) == 1:
|
||||||
_tabnew(path, options)
|
_tabnew(path, options)
|
||||||
elif not vim_eval('g:jedi#use_splits_not_buffers') == '1':
|
elif not vim_eval('g:jedi#use_splits_not_buffers') in [1, '1']:
|
||||||
user_split_option = vim_eval('g:jedi#use_splits_not_buffers')
|
user_split_option = vim_eval('g:jedi#use_splits_not_buffers')
|
||||||
split_options = {
|
split_options = {
|
||||||
'top': 'topleft split',
|
'top': 'topleft split',
|
||||||
@@ -649,15 +776,19 @@ def new_buffer(path, options='', using_tagstack=False):
|
|||||||
'bottom': 'botright split',
|
'bottom': 'botright split',
|
||||||
'winwidth': 'vs'
|
'winwidth': 'vs'
|
||||||
}
|
}
|
||||||
if user_split_option == 'winwidth' and vim.current.window.width <= 2 * int(vim_eval("&textwidth ? &textwidth : 80")):
|
if (user_split_option == 'winwidth' and
|
||||||
|
vim.current.window.width <= 2 * int(vim_eval(
|
||||||
|
"&textwidth ? &textwidth : 80"))):
|
||||||
split_options['winwidth'] = 'sp'
|
split_options['winwidth'] = 'sp'
|
||||||
if user_split_option not in split_options:
|
if user_split_option not in split_options:
|
||||||
print('g:jedi#use_splits_not_buffers value is not correct, valid options are: %s' % ','.join(split_options.keys()))
|
print('Unsupported value for g:jedi#use_splits_not_buffers: {0}. '
|
||||||
|
'Valid options are: {1}.'.format(
|
||||||
|
user_split_option, ', '.join(split_options.keys())))
|
||||||
else:
|
else:
|
||||||
vim_command(split_options[user_split_option] + " %s" % escape_file_path(path))
|
vim_command(split_options[user_split_option] + " %s" % escape_file_path(path))
|
||||||
else:
|
else:
|
||||||
if vim_eval("!&hidden && &modified") == '1':
|
if int(vim_eval("!&hidden && &modified")) == 1:
|
||||||
if vim_eval("bufname('%')") is None:
|
if not vim_eval("bufname('%')"):
|
||||||
echo_highlight('Cannot open a new buffer, use `:set hidden` or save your buffer')
|
echo_highlight('Cannot open a new buffer, use `:set hidden` or save your buffer')
|
||||||
return False
|
return False
|
||||||
else:
|
else:
|
||||||
@@ -666,9 +797,9 @@ def new_buffer(path, options='', using_tagstack=False):
|
|||||||
return True
|
return True
|
||||||
vim_command('edit %s %s' % (options, escape_file_path(path)))
|
vim_command('edit %s %s' % (options, escape_file_path(path)))
|
||||||
# sometimes syntax is being disabled and the filetype not set.
|
# sometimes syntax is being disabled and the filetype not set.
|
||||||
if vim_eval('!exists("g:syntax_on")') == '1':
|
if int(vim_eval('!exists("g:syntax_on")')) == 1:
|
||||||
vim_command('syntax enable')
|
vim_command('syntax enable')
|
||||||
if vim_eval("&filetype != 'python'") == '1':
|
if int(vim_eval("&filetype != 'python'")) == 1:
|
||||||
vim_command('set filetype=python')
|
vim_command('set filetype=python')
|
||||||
return True
|
return True
|
||||||
|
|
||||||
@@ -681,7 +812,7 @@ def _tabnew(path, options=''):
|
|||||||
:param options: `:tabnew` options, read vim help.
|
:param options: `:tabnew` options, read vim help.
|
||||||
"""
|
"""
|
||||||
path = os.path.abspath(path)
|
path = os.path.abspath(path)
|
||||||
if vim_eval('has("gui")') == '1':
|
if int(vim_eval('has("gui")')) == 1:
|
||||||
vim_command('tab drop %s %s' % (options, escape_file_path(path)))
|
vim_command('tab drop %s %s' % (options, escape_file_path(path)))
|
||||||
return
|
return
|
||||||
|
|
||||||
87
pythonx/jedi_vim_debug.py
Normal file
87
pythonx/jedi_vim_debug.py
Normal file
@@ -0,0 +1,87 @@
|
|||||||
|
"""Used in jedi-vim's jedi#debug_info()"""
|
||||||
|
import sys
|
||||||
|
|
||||||
|
import vim
|
||||||
|
from jedi_vim import PythonToVimStr
|
||||||
|
|
||||||
|
|
||||||
|
def echo(msg):
|
||||||
|
vim.command('echo %r' % PythonToVimStr(msg))
|
||||||
|
|
||||||
|
|
||||||
|
def echo_error(msg):
|
||||||
|
vim.command('echohl ErrorMsg')
|
||||||
|
echo(msg)
|
||||||
|
vim.command('echohl None')
|
||||||
|
|
||||||
|
|
||||||
|
def format_exc_info(exc_info=None, tb_indent=2):
|
||||||
|
import traceback
|
||||||
|
|
||||||
|
if exc_info is None:
|
||||||
|
exc_info = sys.exc_info()
|
||||||
|
|
||||||
|
exc_msg = traceback.format_exception_only(exc_info[0], exc_info[1])
|
||||||
|
lines = ''.join(exc_msg).rstrip('\n').split('\n')
|
||||||
|
|
||||||
|
lines.append('Traceback (most recent call last):')
|
||||||
|
tb = traceback.format_tb(exc_info[2])
|
||||||
|
lines.extend(''.join(tb).rstrip('\n').split('\n'))
|
||||||
|
|
||||||
|
indent = ' ' * tb_indent
|
||||||
|
return '{0}'.format(('\n' + indent).join(lines))
|
||||||
|
|
||||||
|
|
||||||
|
def display_debug_info():
|
||||||
|
echo(' - global sys.version: `{0}`'.format(
|
||||||
|
', '.join([x.strip()
|
||||||
|
for x in sys.version.split('\n')])))
|
||||||
|
echo(' - global site module: `{0}`'.format(__import__('site').__file__))
|
||||||
|
|
||||||
|
try:
|
||||||
|
import jedi_vim
|
||||||
|
except Exception:
|
||||||
|
echo_error('ERROR: could not import jedi_vim: {0}'.format(
|
||||||
|
format_exc_info()))
|
||||||
|
return
|
||||||
|
|
||||||
|
if jedi_vim.jedi is None:
|
||||||
|
if hasattr(jedi_vim, 'jedi_import_error'):
|
||||||
|
error_msg = format_exc_info(jedi_vim.jedi_import_error)
|
||||||
|
else:
|
||||||
|
error_msg = 'unknown error'
|
||||||
|
echo_error('ERROR: could not import the "jedi" Python module: {0}'.format(
|
||||||
|
error_msg))
|
||||||
|
else:
|
||||||
|
echo('\n##### Jedi\n\n - path: `{0}`'.format(jedi_vim.jedi.__file__))
|
||||||
|
echo(' - version: {0}'.format(jedi_vim.jedi.__version__))
|
||||||
|
|
||||||
|
try:
|
||||||
|
environment = jedi_vim.get_environment(use_cache=False)
|
||||||
|
except AttributeError:
|
||||||
|
script_evaluator = jedi_vim.jedi.Script('')._evaluator
|
||||||
|
try:
|
||||||
|
sys_path = script_evaluator.project.sys_path
|
||||||
|
except AttributeError:
|
||||||
|
sys_path = script_evaluator.sys_path
|
||||||
|
else:
|
||||||
|
echo('\n##### Jedi environment: {0}\n\n'.format(environment))
|
||||||
|
echo(' - executable: {0}'.format(environment.executable))
|
||||||
|
try:
|
||||||
|
sys_path = environment.get_sys_path()
|
||||||
|
except Exception:
|
||||||
|
echo_error('ERROR: failed to get sys path from environment: {0}'.format(
|
||||||
|
format_exc_info()))
|
||||||
|
return
|
||||||
|
|
||||||
|
echo(' - sys_path:')
|
||||||
|
for p in sys_path:
|
||||||
|
echo(' - `{0}`'.format(p))
|
||||||
|
|
||||||
|
if environment:
|
||||||
|
echo('\n##### Known environments\n\n')
|
||||||
|
for environment in jedi_vim.get_known_environments():
|
||||||
|
echo(' - {0} ({1})\n'.format(
|
||||||
|
environment,
|
||||||
|
environment.executable,
|
||||||
|
))
|
||||||
1
pythonx/parso
Submodule
1
pythonx/parso
Submodule
Submodule pythonx/parso added at c0ace63a69
5
setup.cfg
Normal file
5
setup.cfg
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
[tool:pytest]
|
||||||
|
testpaths = test
|
||||||
|
|
||||||
|
[flake8]
|
||||||
|
max-line-length = 100
|
||||||
@@ -1,63 +0,0 @@
|
|||||||
let g:jedi#completions_command = 'X'
|
|
||||||
source plugin/jedi.vim
|
|
||||||
|
|
||||||
describe 'completions'
|
|
||||||
before
|
|
||||||
new
|
|
||||||
set filetype=python
|
|
||||||
end
|
|
||||||
|
|
||||||
after
|
|
||||||
bd!
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'smart import'
|
|
||||||
exec "normal ifrom os "
|
|
||||||
Expect getline('.') == 'from os import '
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'no smart import after space'
|
|
||||||
exec "normal! ifrom os "
|
|
||||||
exec "normal a "
|
|
||||||
Expect getline('.') == 'from os '
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'import'
|
|
||||||
" X is the completion command
|
|
||||||
normal oimporX
|
|
||||||
Expect getline('.') == 'import'
|
|
||||||
normal a subproX
|
|
||||||
Expect getline('.') == 'import subprocess'
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'exception'
|
|
||||||
normal oIndentationErrX
|
|
||||||
Expect getline('.') == 'IndentationError'
|
|
||||||
normal a().filenaX
|
|
||||||
Expect getline('.') == 'IndentationError().filename'
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'dot_open'
|
|
||||||
normal oraisX ImpXErrX()
|
|
||||||
Expect getline('.') == 'raise ImportError()'
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'cycling through entries'
|
|
||||||
" testing select_first doesn't seem to work in ex mode
|
|
||||||
execute "normal oraise impX\<C-n>\<C-n>\<C-n>"
|
|
||||||
Expect getline('.') == 'raise ImportWarning'
|
|
||||||
let g:jedi#popup_select_first = 0
|
|
||||||
execute "normal oraise impX\<C-n>\<C-n>\<C-n>"
|
|
||||||
Expect getline('.') == 'raise ImportWarning'
|
|
||||||
let g:jedi#popup_select_first = 1
|
|
||||||
|
|
||||||
" -longest completes the first one
|
|
||||||
set completeopt -=longest
|
|
||||||
execute "normal oraise baseX"
|
|
||||||
Expect getline('.') == 'raise BaseException'
|
|
||||||
set completeopt +=longest
|
|
||||||
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
" vim: et:ts=4:sw=4
|
|
||||||
65
test/test_integration.py
Normal file
65
test/test_integration.py
Normal file
@@ -0,0 +1,65 @@
|
|||||||
|
"""Runs tests from ./vspec in vim-vspec."""
|
||||||
|
import os
|
||||||
|
import subprocess
|
||||||
|
try:
|
||||||
|
from urllib.request import urlretrieve
|
||||||
|
except ImportError:
|
||||||
|
from urllib import urlretrieve
|
||||||
|
import zipfile
|
||||||
|
|
||||||
|
import pytest
|
||||||
|
|
||||||
|
vspec_version = '1.8.1'
|
||||||
|
|
||||||
|
VSPEC_URL = 'https://github.com/kana/vim-vspec/archive/%s.zip' % vspec_version
|
||||||
|
root = os.path.dirname(os.path.dirname(__file__))
|
||||||
|
CACHE_FOLDER = os.path.join(root, 'build')
|
||||||
|
VSPEC_FOLDER = os.path.join(CACHE_FOLDER, 'vim-vspec-%s' % vspec_version)
|
||||||
|
VSPEC_RUNNER = os.path.join(VSPEC_FOLDER, 'bin/vspec')
|
||||||
|
TEST_DIR = os.path.join(root, 'test', 'vspec')
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.fixture(scope='session')
|
||||||
|
def install_vspec(request):
|
||||||
|
if not os.path.isdir(CACHE_FOLDER):
|
||||||
|
os.mkdir(CACHE_FOLDER)
|
||||||
|
|
||||||
|
if not os.path.exists(VSPEC_FOLDER):
|
||||||
|
name, hdrs = urlretrieve(VSPEC_URL)
|
||||||
|
z = zipfile.ZipFile(name)
|
||||||
|
for n in z.namelist():
|
||||||
|
dest = os.path.join(CACHE_FOLDER, n)
|
||||||
|
destdir = os.path.dirname(dest)
|
||||||
|
if not os.path.isdir(destdir):
|
||||||
|
os.makedirs(destdir)
|
||||||
|
data = z.read(n)
|
||||||
|
if not os.path.isdir(dest):
|
||||||
|
with open(dest, 'wb') as f:
|
||||||
|
f.write(data)
|
||||||
|
z.close()
|
||||||
|
os.chmod(VSPEC_RUNNER, 0o777)
|
||||||
|
|
||||||
|
|
||||||
|
def get_vspec_tests():
|
||||||
|
for f in os.listdir(TEST_DIR):
|
||||||
|
yield os.path.relpath(os.path.join(TEST_DIR, f))
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.parametrize('path', get_vspec_tests())
|
||||||
|
def test_integration(install_vspec, path):
|
||||||
|
output = subprocess.check_output(
|
||||||
|
[VSPEC_RUNNER, '.', VSPEC_FOLDER, os.path.relpath(path, root)],
|
||||||
|
cwd=root,
|
||||||
|
)
|
||||||
|
had_ok = False
|
||||||
|
for line in output.splitlines():
|
||||||
|
if (line.startswith(b'not ok') or
|
||||||
|
line.startswith(b'Error') or
|
||||||
|
line.startswith(b'Bail out!')):
|
||||||
|
pytest.fail(u"{0} failed:\n{1}".format(
|
||||||
|
path, output.decode('utf-8')), pytrace=False)
|
||||||
|
if not had_ok and line.startswith(b'ok'):
|
||||||
|
had_ok = True
|
||||||
|
if not had_ok:
|
||||||
|
pytest.fail(u"{0} failed: no 'ok' found:\n{1}".format(
|
||||||
|
path, output.decode('utf-8')), pytrace=False)
|
||||||
8
test/vimrc
Normal file
8
test/vimrc
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
" Minimal vimrc to use jedi-vim.
|
||||||
|
"
|
||||||
|
" Not used anywhere yet, but allows for easy testing.
|
||||||
|
let script_dir = fnamemodify(expand('<sfile>'), ':h:h')
|
||||||
|
let &runtimepath = script_dir.','.&runtimepath.','.script_dir.'/after'
|
||||||
|
|
||||||
|
syntax on
|
||||||
|
filetype plugin indent on
|
||||||
131
test/vspec/completions.vim
Normal file
131
test/vspec/completions.vim
Normal file
@@ -0,0 +1,131 @@
|
|||||||
|
let g:jedi#completions_command = 'X'
|
||||||
|
source plugin/jedi.vim
|
||||||
|
|
||||||
|
describe 'completions'
|
||||||
|
before
|
||||||
|
new
|
||||||
|
set filetype=python
|
||||||
|
end
|
||||||
|
|
||||||
|
after
|
||||||
|
" default
|
||||||
|
let g:jedi#popup_select_first = 1
|
||||||
|
bd!
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'longest in completeopt'
|
||||||
|
" This gets set up with Vim only on VimEnter.
|
||||||
|
if has('nvim')
|
||||||
|
Expect stridx(&completeopt, 'longest') > -1
|
||||||
|
else
|
||||||
|
Expect stridx(&completeopt, 'longest') == -1
|
||||||
|
doautocmd VimEnter
|
||||||
|
Expect stridx(&completeopt, 'longest') > -1
|
||||||
|
endif
|
||||||
|
|
||||||
|
" Do not use it for following tests.
|
||||||
|
set completeopt-=longest
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'no smart import by default'
|
||||||
|
exec "normal ifrom os "
|
||||||
|
Expect getline('.') == 'from os '
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'import'
|
||||||
|
" X is the completion command
|
||||||
|
normal oimporX
|
||||||
|
Expect getline('.') == 'import'
|
||||||
|
normal a subproX
|
||||||
|
Expect getline('.') == 'import subprocess'
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'exception'
|
||||||
|
normal oIndentationErrX
|
||||||
|
Expect getline('.') == 'IndentationError'
|
||||||
|
|
||||||
|
" Do not remap keys (".") here, otherwise this triggers completion in
|
||||||
|
" Neovim already.
|
||||||
|
normal! a().filena
|
||||||
|
|
||||||
|
normal aX
|
||||||
|
Expect getline('.') == 'IndentationError().filename'
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'multi complete'
|
||||||
|
" NOTE: nvim results in "importErr()" here with completeopt+=longest,
|
||||||
|
" but Vim is fine.
|
||||||
|
" This is due to `pumvisible()` in jedi#complete_opened being true
|
||||||
|
" with nvim still, but it is 0 with Vim, i.e. Vim appears to close
|
||||||
|
" the pum already (with the tests).
|
||||||
|
"
|
||||||
|
" This might be a misunderstanding though, since the test might not
|
||||||
|
" expect the "import" keyword to be offered for completion?!
|
||||||
|
normal oImpXErrX()
|
||||||
|
Expect getline('.') == 'ImportError()'
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'cycling through entries popup_select_first=0'
|
||||||
|
set completeopt+=longest
|
||||||
|
let g:jedi#popup_select_first = 0
|
||||||
|
execute "normal oraise impX\<C-n>"
|
||||||
|
|
||||||
|
Expect getline('.') == 'raise ImportError'
|
||||||
|
set completeopt-=longest
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'cycling through entries popup_select_first=1'
|
||||||
|
execute "normal oraise impX\<C-n>"
|
||||||
|
Expect getline('.') == 'raise ImportWarning'
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'cycling through entries popup_select_first=1 and longest'
|
||||||
|
set completeopt+=longest
|
||||||
|
execute "normal oraise impX"
|
||||||
|
Expect getline('.') == 'raise Import'
|
||||||
|
|
||||||
|
" With Neovim pumvisible() is 1 in jedi#complete_opened, which then
|
||||||
|
" triggers the <Down>. This is not the case with Vim.
|
||||||
|
if has('nvim')
|
||||||
|
execute "normal oraise impX\<C-n>"
|
||||||
|
Expect getline('.') == 'raise ImportWarning'
|
||||||
|
|
||||||
|
execute "normal oraise impX\<C-n>\<C-n>"
|
||||||
|
Expect getline('.') == 'raise imp'
|
||||||
|
else
|
||||||
|
execute "normal oraise impX\<C-n>"
|
||||||
|
Expect getline('.') == 'raise ImportError'
|
||||||
|
|
||||||
|
execute "normal oraise impX\<C-n>\<C-n>"
|
||||||
|
Expect getline('.') == 'raise ImportWarning'
|
||||||
|
endif
|
||||||
|
set completeopt-=longest
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
describe 'smart completions'
|
||||||
|
before
|
||||||
|
new
|
||||||
|
let g:jedi#smart_auto_mappings = 1
|
||||||
|
set filetype=python
|
||||||
|
end
|
||||||
|
|
||||||
|
after
|
||||||
|
" default
|
||||||
|
let g:jedi#smart_auto_mappings = 0
|
||||||
|
bd!
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'smart import'
|
||||||
|
exec "normal ifrom os "
|
||||||
|
Expect getline('.') == 'from os import '
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'no smart import after space'
|
||||||
|
exec "normal! ifrom os "
|
||||||
|
exec "normal a "
|
||||||
|
Expect getline('.') == 'from os '
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
" vim: et:ts=4:sw=4
|
||||||
@@ -4,12 +4,11 @@ source plugin/jedi.vim
|
|||||||
|
|
||||||
describe 'completions_disabled'
|
describe 'completions_disabled'
|
||||||
before
|
before
|
||||||
new
|
|
||||||
set filetype=python
|
set filetype=python
|
||||||
end
|
end
|
||||||
|
|
||||||
after
|
after
|
||||||
bd!
|
try | %bwipeout! | catch | endtry
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'typing'
|
it 'typing'
|
||||||
@@ -6,14 +6,14 @@ describe 'documentation docstrings'
|
|||||||
end
|
end
|
||||||
|
|
||||||
after
|
after
|
||||||
bd!
|
try | %bwipeout! | catch | endtry
|
||||||
bd!
|
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'simple'
|
it 'simple'
|
||||||
|
Expect maparg('K') == ':call jedi#show_documentation()<CR>'
|
||||||
put = 'ImportError'
|
put = 'ImportError'
|
||||||
normal GK
|
normal GK
|
||||||
Expect bufname('%') == "'__doc__'"
|
Expect bufname('%') == "__doc__"
|
||||||
Expect &filetype == 'rst'
|
Expect &filetype == 'rst'
|
||||||
let content = join(getline(1,'$'), "\n")
|
let content = join(getline(1,'$'), "\n")
|
||||||
Expect stridx(content, "Import can't find module") > 0
|
Expect stridx(content, "Import can't find module") > 0
|
||||||
@@ -1,10 +1,10 @@
|
|||||||
let mapleader = '\'
|
let mapleader = '\'
|
||||||
source plugin/jedi.vim
|
source plugin/jedi.vim
|
||||||
source test/utils.vim
|
source test/_utils.vim
|
||||||
|
|
||||||
describe 'goto_simple'
|
describe 'goto simple:'
|
||||||
before
|
before
|
||||||
new " open a new split
|
new
|
||||||
set filetype=python
|
set filetype=python
|
||||||
put =[
|
put =[
|
||||||
\ 'def a(): pass',
|
\ 'def a(): pass',
|
||||||
@@ -20,99 +20,99 @@ describe 'goto_simple'
|
|||||||
bd!
|
bd!
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'goto_definitions'
|
it 'goto definitions'
|
||||||
silent normal \d
|
normal \d
|
||||||
Expect line('.') == 1
|
Expect line('.') == 2
|
||||||
"Expect col('.') == 5 " not working yet.
|
Expect col('.') == 1
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'goto_assignments'
|
it 'goto assignments'
|
||||||
silent normal \g
|
normal \g
|
||||||
Expect line('.') == 2
|
Expect line('.') == 2
|
||||||
Expect col('.') == 1
|
Expect col('.') == 1
|
||||||
|
|
||||||
" cursor before `=` means that it stays there.
|
" cursor before `=` means that it stays there.
|
||||||
silent normal \g
|
normal \g
|
||||||
Expect line('.') == 2
|
Expect line('.') == 2
|
||||||
Expect col('.') == 1
|
Expect col('.') == 1
|
||||||
|
|
||||||
" going to the last line changes it.
|
" going to the last line changes it.
|
||||||
normal! $
|
normal! $
|
||||||
silent normal \g
|
normal \g
|
||||||
Expect line('.') == 1
|
Expect line('.') == 1
|
||||||
Expect col('.') == 5
|
Expect col('.') == 5
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
describe 'goto_with_tabs'
|
describe 'goto with tabs:'
|
||||||
before
|
before
|
||||||
set filetype=python
|
set filetype=python
|
||||||
let g:jedi#use_tabs_not_buffers = 1
|
let g:jedi#use_tabs_not_buffers = 1
|
||||||
end
|
end
|
||||||
|
|
||||||
after
|
after
|
||||||
bd!
|
try | %bwipeout! | catch | endtry
|
||||||
bd!
|
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'follow_import'
|
it 'follow import'
|
||||||
put = ['import subprocess', 'subprocess']
|
put = ['import subprocess', 'subprocess']
|
||||||
silent normal G\g
|
normal G\g
|
||||||
Expect getline('.') == 'import subprocess'
|
Expect getline('.') == 'import subprocess'
|
||||||
Expect line('.') == 2
|
Expect line('.') == 2
|
||||||
Expect col('.') == 8
|
Expect col('.') == 8
|
||||||
|
|
||||||
silent normal G\d
|
normal G\d
|
||||||
Expect CurrentBufferIsModule('subprocess') == 1
|
Expect CurrentBufferIsModule('subprocess') == 1
|
||||||
Expect line('.') == 1
|
Expect line('.') == 1
|
||||||
Expect col('.') == 1
|
Expect col('.') == 1
|
||||||
Expect tabpagenr('$') == 2
|
Expect tabpagenr('$') == 2
|
||||||
Expect winnr('$') == 1
|
Expect winnr('$') == 1
|
||||||
tabprevious
|
bwipe
|
||||||
|
|
||||||
|
Expect tabpagenr('$') == 1
|
||||||
Expect bufname('%') == ''
|
Expect bufname('%') == ''
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'multi_definitions'
|
" it 'multi definitions'
|
||||||
" This used to behave differently. Now we don't have any real multi
|
" " This used to behave differently. Now we don't have any real multi
|
||||||
" definitions.
|
" " definitions.
|
||||||
|
"
|
||||||
" put = ['import tokenize']
|
" " put = ['import tokenize']
|
||||||
" silent normal G$\d
|
" " normal G$\d
|
||||||
" Expect CurrentBufferIsModule('tokenize') == 1
|
" " Expect CurrentBufferIsModule('tokenize') == 1
|
||||||
" Expect CurrentBufferIsModule('token') == 0
|
" " Expect CurrentBufferIsModule('token') == 0
|
||||||
" execute "normal \<CR>"
|
" " execute "normal \<CR>"
|
||||||
" Expect tabpagenr('$') == 2
|
" " Expect tabpagenr('$') == 2
|
||||||
" Expect winnr('$') == 1
|
" " Expect winnr('$') == 1
|
||||||
" Expect CurrentBufferIsModule('token') == 1
|
" " Expect CurrentBufferIsModule('token') == 1
|
||||||
|
"
|
||||||
" bd
|
" " bd
|
||||||
" silent normal G$\d
|
" " normal G$\d
|
||||||
" execute "normal j\<CR>"
|
" " execute "normal j\<CR>"
|
||||||
" Expect tabpagenr('$') == 2
|
" " Expect tabpagenr('$') == 2
|
||||||
" Expect winnr('$') == 1
|
" " Expect winnr('$') == 1
|
||||||
" Expect CurrentBufferIsModule('tokenize') == 1
|
" " Expect CurrentBufferIsModule('tokenize') == 1
|
||||||
end
|
" end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
describe 'goto_with_buffers'
|
describe 'goto with buffers'
|
||||||
before
|
before
|
||||||
set filetype=python
|
set filetype=python
|
||||||
let g:jedi#use_tabs_not_buffers = 0
|
let g:jedi#use_tabs_not_buffers = 0
|
||||||
end
|
end
|
||||||
|
|
||||||
after
|
after
|
||||||
bd!
|
try | %bwipeout! | catch | endtry
|
||||||
bd!
|
|
||||||
set nohidden
|
set nohidden
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'no_new_tabs'
|
it 'no new tabs'
|
||||||
put = ['import os']
|
put = ['import os']
|
||||||
normal G$
|
normal G$
|
||||||
call jedi#goto_assignments()
|
call jedi#goto_assignments()
|
||||||
python jedi_vim.goto()
|
PythonJedi jedi_vim.goto()
|
||||||
Expect CurrentBufferIsModule('os') == 0
|
Expect CurrentBufferIsModule('os') == 0
|
||||||
" Without hidden, it's not possible to open a new buffer, when the old
|
" Without hidden, it's not possible to open a new buffer, when the old
|
||||||
" one is not saved.
|
" one is not saved.
|
||||||
@@ -125,47 +125,47 @@ describe 'goto_with_buffers'
|
|||||||
Expect col('.') == 1
|
Expect col('.') == 1
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'multi_definitions'
|
" it 'multi definitions'
|
||||||
" set hidden
|
" " set hidden
|
||||||
" put = ['import tokenize']
|
" " put = ['import tokenize']
|
||||||
" silent normal G$\d
|
" " normal G$\d
|
||||||
" Expect CurrentBufferIsModule('tokenize') == 0
|
" " Expect CurrentBufferIsModule('tokenize') == 0
|
||||||
" Expect CurrentBufferIsModule('token') == 0
|
" " Expect CurrentBufferIsModule('token') == 0
|
||||||
" execute "normal \<CR>"
|
" " execute "normal \<CR>"
|
||||||
" Expect tabpagenr('$') == 1
|
" " Expect tabpagenr('$') == 1
|
||||||
" Expect winnr('$') == 1
|
" " Expect winnr('$') == 1
|
||||||
" Expect CurrentBufferIsModule('token') == 1
|
" " Expect CurrentBufferIsModule('token') == 1
|
||||||
|
"
|
||||||
" bd
|
" " bd
|
||||||
" silent normal G$\d
|
" " normal G$\d
|
||||||
" execute "normal j\<CR>"
|
" " execute "normal j\<CR>"
|
||||||
" Expect tabpagenr('$') == 1
|
" " Expect tabpagenr('$') == 1
|
||||||
" Expect winnr('$') == 1
|
" " Expect winnr('$') == 1
|
||||||
" Expect CurrentBufferIsModule('tokenize') == 1
|
" " Expect CurrentBufferIsModule('tokenize') == 1
|
||||||
end
|
" end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
describe 'goto_with_splits'
|
describe 'goto with splits'
|
||||||
before
|
before
|
||||||
|
enew!
|
||||||
set filetype=python
|
set filetype=python
|
||||||
let g:jedi#use_splits_not_buffers = 'left'
|
let g:jedi#use_splits_not_buffers = 'left'
|
||||||
end
|
end
|
||||||
|
|
||||||
after
|
after
|
||||||
bd!
|
try | %bwipeout! | catch | endtry
|
||||||
bd!
|
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'follow_import'
|
it 'follow import'
|
||||||
put = ['import subprocess', 'subprocess']
|
put = ['import subprocess', 'subprocess']
|
||||||
silent normal G\g
|
normal G\g
|
||||||
Expect getline('.') == 'import subprocess'
|
Expect getline('.') == 'import subprocess'
|
||||||
Expect line('.') == 2
|
Expect line('.') == 2
|
||||||
Expect col('.') == 8
|
Expect col('.') == 8
|
||||||
|
|
||||||
silent normal G\d
|
normal G\d
|
||||||
Expect CurrentBufferIsModule('subprocess') == 1
|
Expect CurrentBufferIsModule('subprocess') == 1
|
||||||
Expect line('.') == 1
|
Expect line('.') == 1
|
||||||
Expect col('.') == 1
|
Expect col('.') == 1
|
||||||
@@ -177,8 +177,9 @@ describe 'goto_with_splits'
|
|||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
describe 'goto_wildignore'
|
describe 'goto wildignore'
|
||||||
before
|
before
|
||||||
|
enew!
|
||||||
set filetype=python
|
set filetype=python
|
||||||
set wildignore=*,with\ spaces,*.pyc
|
set wildignore=*,with\ spaces,*.pyc
|
||||||
set hidden
|
set hidden
|
||||||
@@ -189,23 +190,22 @@ describe 'goto_wildignore'
|
|||||||
|
|
||||||
put = ['from subprocess import Popen', 'Popen']
|
put = ['from subprocess import Popen', 'Popen']
|
||||||
Expect CurrentBufferIsModule('subprocess') == 0
|
Expect CurrentBufferIsModule('subprocess') == 0
|
||||||
silent normal G
|
normal G
|
||||||
end
|
end
|
||||||
|
|
||||||
after
|
after
|
||||||
bd!
|
try | %bwipeout! | catch | endtry
|
||||||
bd!
|
|
||||||
set wildignore&vim
|
set wildignore&vim
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'restores_wildignore'
|
it 'restores wildignore'
|
||||||
let before = &wildignore
|
let before = &wildignore
|
||||||
call jedi#goto()
|
call jedi#goto()
|
||||||
Expect getline('.') =~ 'Popen'
|
Expect getline('.') =~ 'Popen'
|
||||||
Expect &wildignore == before
|
Expect &wildignore == before
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'not_using_tagstack'
|
it 'not using tagstack'
|
||||||
let g:jedi#use_tag_stack = 0
|
let g:jedi#use_tag_stack = 0
|
||||||
call jedi#goto()
|
call jedi#goto()
|
||||||
Expect CurrentBufferIsModule('subprocess') == 1
|
Expect CurrentBufferIsModule('subprocess') == 1
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
source plugin/jedi.vim
|
source plugin/jedi.vim
|
||||||
source test/utils.vim
|
source test/_utils.vim
|
||||||
|
|
||||||
describe 'pyimport'
|
describe 'pyimport'
|
||||||
before
|
before
|
||||||
@@ -7,8 +7,7 @@ describe 'pyimport'
|
|||||||
end
|
end
|
||||||
|
|
||||||
after
|
after
|
||||||
bd!
|
try | %bwipeout! | catch | endtry
|
||||||
bd!
|
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'open_tab'
|
it 'open_tab'
|
||||||
@@ -27,6 +26,10 @@ describe 'pyimport'
|
|||||||
|
|
||||||
Expect jedi#py_import_completions('subproc', 0, 0) == 'subprocess'
|
Expect jedi#py_import_completions('subproc', 0, 0) == 'subprocess'
|
||||||
Expect jedi#py_import_completions('subprocess', 0, 0) == 'subprocess'
|
Expect jedi#py_import_completions('subprocess', 0, 0) == 'subprocess'
|
||||||
Expect jedi#py_import_completions('zip', 0, 0) == "zipfile\nzipimport"
|
let g:comp = jedi#py_import_completions('zip', 0, 0)
|
||||||
|
" Sometimes zipapp is in there sometimes not, depends on Python
|
||||||
|
" version.
|
||||||
|
let g:comp = substitute(g:comp, '^zipapp\n', '', '')
|
||||||
|
Expect g:comp == "zipfile\nzipimport"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -2,23 +2,23 @@ source plugin/jedi.vim
|
|||||||
|
|
||||||
describe 'signatures'
|
describe 'signatures'
|
||||||
before
|
before
|
||||||
|
enew
|
||||||
set filetype=python
|
set filetype=python
|
||||||
end
|
end
|
||||||
|
|
||||||
after
|
after
|
||||||
bd!
|
try | %bwipeout! | catch | endtry
|
||||||
bd!
|
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'simple'
|
it 'simple'
|
||||||
normal oabs(
|
normal odef xyz(number): return
|
||||||
" equals doautocmd CursorMovedI
|
normal o
|
||||||
Python jedi_vim.show_call_signatures()
|
normal oxyz()
|
||||||
|
doautocmd CursorHoldI
|
||||||
Expect getline(1) == '=`=jedi=0, =`= (*_*number*_*) =`=jedi=`='
|
Expect getline(3) == '?!?jedi=0, ?!? (*_*number*_*) ?!?jedi?!?'
|
||||||
|
|
||||||
doautocmd InsertLeave
|
doautocmd InsertLeave
|
||||||
Expect getline(1) == ''
|
Expect getline(3) == ''
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'multiple buffers'
|
it 'multiple buffers'
|
||||||
@@ -34,19 +34,18 @@ describe 'signatures'
|
|||||||
autocmd jedi_call_signatures * <buffer>
|
autocmd jedi_call_signatures * <buffer>
|
||||||
redir END
|
redir END
|
||||||
Expect autocmds =~# 'jedi_call_signatures'
|
Expect autocmds =~# 'jedi_call_signatures'
|
||||||
bd!
|
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'simple after CursorHoldI with only parenthesis'
|
it 'simple after CursorHoldI with only parenthesis'
|
||||||
noautocmd normal o
|
noautocmd normal o
|
||||||
doautocmd CursorHoldI
|
doautocmd CursorHoldI
|
||||||
noautocmd normal iabs(
|
noautocmd normal istaticmethod()
|
||||||
doautocmd CursorHoldI
|
doautocmd CursorHoldI
|
||||||
Expect getline(1) == '=`=jedi=0, =`= (*_*number*_*) =`=jedi=`='
|
Expect getline(1) == '?!?jedi=0, ?!? (*_*f: Callable*_*) ?!?jedi?!?'
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'no signature'
|
it 'no signature'
|
||||||
normal ostr
|
exe 'normal ostr '
|
||||||
Python jedi_vim.show_call_signatures()
|
Python jedi_vim.show_call_signatures()
|
||||||
Expect getline(1, '$') == ['', 'str ']
|
Expect getline(1, '$') == ['', 'str ']
|
||||||
end
|
end
|
||||||
@@ -54,7 +53,7 @@ describe 'signatures'
|
|||||||
it 'signatures disabled'
|
it 'signatures disabled'
|
||||||
let g:jedi#show_call_signatures = 0
|
let g:jedi#show_call_signatures = 0
|
||||||
|
|
||||||
normal ostr(
|
exe 'normal ostr( '
|
||||||
Python jedi_vim.show_call_signatures()
|
Python jedi_vim.show_call_signatures()
|
||||||
Expect getline(1, '$') == ['', 'str( ']
|
Expect getline(1, '$') == ['', 'str( ']
|
||||||
|
|
||||||
@@ -65,11 +64,11 @@ describe 'signatures'
|
|||||||
let g:jedi#show_call_signatures = 2
|
let g:jedi#show_call_signatures = 2
|
||||||
call jedi#configure_call_signatures()
|
call jedi#configure_call_signatures()
|
||||||
|
|
||||||
normal oabs(
|
exe 'normal ostaticmethod( '
|
||||||
redir => msg
|
redir => msg
|
||||||
Python jedi_vim.show_call_signatures()
|
Python jedi_vim.show_call_signatures()
|
||||||
redir END
|
redir END
|
||||||
Expect msg == "\nabs(number)"
|
Expect msg == "\nstaticmethod(f: Callable)"
|
||||||
|
|
||||||
redir => msg
|
redir => msg
|
||||||
doautocmd InsertLeave
|
doautocmd InsertLeave
|
||||||
@@ -77,7 +76,7 @@ describe 'signatures'
|
|||||||
Expect msg == "\n"
|
Expect msg == "\n"
|
||||||
|
|
||||||
normal Sdef foo(a, b): pass
|
normal Sdef foo(a, b): pass
|
||||||
normal ofoo(a, b, c,
|
exe 'normal ofoo(a, b, c, '
|
||||||
redir => msg
|
redir => msg
|
||||||
Python jedi_vim.show_call_signatures()
|
Python jedi_vim.show_call_signatures()
|
||||||
redir END
|
redir END
|
||||||
@@ -95,25 +94,25 @@ describe 'signatures'
|
|||||||
return msg
|
return msg
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
let funcname = repeat('a', &columns - 30)
|
let funcname = repeat('a', &columns - (30 + (&ruler ? 18 : 0)))
|
||||||
put = 'def '.funcname.'(arg1, arg2, arg3, a, b, c):'
|
put = 'def '.funcname.'(arg1, arg2, arg3, a, b, c):'
|
||||||
put = ' pass'
|
put = ' pass'
|
||||||
execute "normal o".funcname."( "
|
execute "normal o\<BS>".funcname."( "
|
||||||
Expect Signature() == "\n".funcname."(arg1, …)"
|
Expect Signature() == "\n".funcname."(arg1, …)"
|
||||||
|
|
||||||
normal sarg1,
|
exe 'normal sarg1, '
|
||||||
Expect Signature() == "\n".funcname."(…, arg2, …)"
|
Expect Signature() == "\n".funcname."(…, arg2, …)"
|
||||||
|
|
||||||
normal sarg2, arg3,
|
exe 'normal sarg2, arg3, '
|
||||||
Expect Signature() == "\n".funcname."(…, a, b, c)"
|
Expect Signature() == "\n".funcname."(…, a, b, c)"
|
||||||
|
|
||||||
normal sa, b,
|
exe 'normal sa, b, '
|
||||||
Expect Signature() == "\n".funcname."(…, c)"
|
Expect Signature() == "\n".funcname."(…, c)"
|
||||||
|
|
||||||
g/^/d
|
g/^/d
|
||||||
put = 'def '.funcname.'('.repeat('b', 20).', arg2):'
|
put = 'def '.funcname.'('.repeat('b', 20).', arg2):'
|
||||||
put = ' pass'
|
put = ' pass'
|
||||||
execute "normal o".funcname."( "
|
execute "normal o\<BS>".funcname."( "
|
||||||
Expect Signature() == "\n".funcname."(…)"
|
Expect Signature() == "\n".funcname."(…)"
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -121,7 +120,7 @@ describe 'signatures'
|
|||||||
let g:jedi#show_call_signatures = 2
|
let g:jedi#show_call_signatures = 2
|
||||||
call jedi#configure_call_signatures()
|
call jedi#configure_call_signatures()
|
||||||
|
|
||||||
normal ostr
|
exe 'normal ostr '
|
||||||
redir => msg
|
redir => msg
|
||||||
Python jedi_vim.show_call_signatures()
|
Python jedi_vim.show_call_signatures()
|
||||||
redir END
|
redir END
|
||||||
@@ -1,2 +0,0 @@
|
|||||||
def test_integration(case, monkeypatch, pytestconfig):
|
|
||||||
case.run()
|
|
||||||
Reference in New Issue
Block a user