mirror of
https://github.com/davidhalter/jedi-vim.git
synced 2025-12-07 03:04:30 +08:00
Compare commits
65 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
eebf7d2863 | ||
|
|
c3f9b751f3 | ||
|
|
9679051ad4 | ||
|
|
0efafede57 | ||
|
|
7c331a1b64 | ||
|
|
f4e0dbc183 | ||
|
|
344814c214 | ||
|
|
a06395549f | ||
|
|
9c2f9c63d3 | ||
|
|
382d8a48d0 | ||
|
|
4ad1f2fc3d | ||
|
|
130ce7fb79 | ||
|
|
907b6837a9 | ||
|
|
9bd79ee41a | ||
|
|
2c188fea29 | ||
|
|
b82da7d2b5 | ||
|
|
c87947e760 | ||
|
|
338af171ea | ||
|
|
c0c01ede07 | ||
|
|
42c2af1812 | ||
|
|
1198e4cfa3 | ||
|
|
c5d5d2e3b4 | ||
|
|
0d245f3287 | ||
|
|
be483a2dcb | ||
|
|
f286f9e4b6 | ||
|
|
e073385976 | ||
|
|
6b8013c480 | ||
|
|
c381156dd4 | ||
|
|
28a6765ecc | ||
|
|
df261c0a3e | ||
|
|
40c7f6d09d | ||
|
|
8c7161f4e9 | ||
|
|
27db7160a5 | ||
|
|
e82d07faa1 | ||
|
|
50dfac448a | ||
|
|
0a27795d76 | ||
|
|
32d05f7742 | ||
|
|
873ee9325d | ||
|
|
08ad42efed | ||
|
|
f5aad68bec | ||
|
|
2c99d7377f | ||
|
|
7d2fc14f4f | ||
|
|
e1afc904e4 | ||
|
|
64c92771be | ||
|
|
030211555d | ||
|
|
ab2550ef29 | ||
|
|
7ac81cb880 | ||
|
|
6812ce11b7 | ||
|
|
81002ed6e7 | ||
|
|
81e1e9ca34 | ||
|
|
8763462331 | ||
|
|
760120240f | ||
|
|
6e6738758f | ||
|
|
ff9a0afbda | ||
|
|
088469a8ee | ||
|
|
8730095b89 | ||
|
|
5d4615707f | ||
|
|
960eaa8053 | ||
|
|
acd9182131 | ||
|
|
04c708cbfc | ||
|
|
91312f1755 | ||
|
|
e02fa9dc10 | ||
|
|
d7be014c54 | ||
|
|
e96eba9f53 | ||
|
|
e4daf7a74c |
47
.github/workflows/ci.yml
vendored
47
.github/workflows/ci.yml
vendored
@@ -1,12 +1,12 @@
|
|||||||
name: ci
|
name: ci
|
||||||
on: push
|
on: [push, pull_request]
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
tests:
|
tests:
|
||||||
runs-on: ubuntu-20.04
|
runs-on: ubuntu-24.04
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout code
|
- name: Checkout code
|
||||||
uses: actions/checkout@v2
|
uses: actions/checkout@v4
|
||||||
with:
|
with:
|
||||||
submodules: recursive
|
submodules: recursive
|
||||||
|
|
||||||
@@ -20,44 +20,3 @@ jobs:
|
|||||||
|
|
||||||
- name: Run tests
|
- name: Run tests
|
||||||
run: 'make test'
|
run: 'make test'
|
||||||
|
|
||||||
code-quality:
|
|
||||||
runs-on: ubuntu-20.04
|
|
||||||
steps:
|
|
||||||
- name: Checkout code
|
|
||||||
uses: actions/checkout@v2
|
|
||||||
with:
|
|
||||||
submodules: recursive
|
|
||||||
|
|
||||||
- name: Run tests
|
|
||||||
run: |
|
|
||||||
vim --version
|
|
||||||
make check
|
|
||||||
|
|
||||||
coverage:
|
|
||||||
runs-on: ubuntu-20.04
|
|
||||||
|
|
||||||
steps:
|
|
||||||
- name: Checkout code
|
|
||||||
uses: actions/checkout@v2
|
|
||||||
with:
|
|
||||||
submodules: recursive
|
|
||||||
|
|
||||||
- name: Install dependencies
|
|
||||||
run: |
|
|
||||||
sudo add-apt-repository ppa:neovim-ppa/stable -y
|
|
||||||
sudo apt-get update -q
|
|
||||||
sudo apt-get install neovim -y
|
|
||||||
|
|
||||||
sudo pip install pynvim pytest-cov
|
|
||||||
sudo pip list
|
|
||||||
nvim --version
|
|
||||||
|
|
||||||
- name: Run tests
|
|
||||||
run: |
|
|
||||||
make --keep-going test_coverage BUILD_VIRTUAL_ENV=$VIRTUAL_ENV
|
|
||||||
|
|
||||||
- name: Upload coverage data
|
|
||||||
run: |
|
|
||||||
coverage xml
|
|
||||||
bash <(curl -s https://codecov.io/bash) -X fix -f coverage.xml -F py${TRAVIS_PYTHON_VERSION//./}
|
|
||||||
|
|||||||
@@ -53,5 +53,9 @@ Tommy Allen (@tweekmonster)
|
|||||||
Mingliang (@Aulddays)
|
Mingliang (@Aulddays)
|
||||||
Brian Mego (@brianmego)
|
Brian Mego (@brianmego)
|
||||||
Stevan Milic (@stevanmilic) <stevan.milic@yahoo.com>
|
Stevan Milic (@stevanmilic) <stevan.milic@yahoo.com>
|
||||||
|
Konstantin Glukhov (@Konstantin-Glukhov)
|
||||||
|
Seungchan An (@SeungChan92) <dev.issea1015@gmail.com>
|
||||||
|
Thomas Blauth (@ThomasBlauth) <thomas.blauth@protonmail.com>
|
||||||
|
James Cherti (@jamescherti)
|
||||||
|
|
||||||
@something are github user names.
|
@something are github user names.
|
||||||
|
|||||||
34
README.rst
34
README.rst
@@ -73,9 +73,15 @@ Installation
|
|||||||
|
|
||||||
Requirements
|
Requirements
|
||||||
------------
|
------------
|
||||||
You need a VIM version that was compiled with Python 2.7 or later
|
- **Vim**: You need a VIM version that was compiled with Python 3 or later
|
||||||
(``+python`` or ``+python3``). You can check this from within VIM using
|
(``+python3``). You can check this from within VIM using
|
||||||
``:python3 import sys; print(sys.version)`` (use ``:python`` for Python 2).
|
``:python3 import sys; print(sys.version)``.
|
||||||
|
|
||||||
|
- **Neovim**: You need a python environment with ``pynvim`` installed:
|
||||||
|
``pip install pynvim``
|
||||||
|
|
||||||
|
then check your environment is correctly setup from within Neovim using
|
||||||
|
``:checkhealth provider.python``
|
||||||
|
|
||||||
Manual installation
|
Manual installation
|
||||||
-------------------
|
-------------------
|
||||||
@@ -108,13 +114,13 @@ Installation with your distribution
|
|||||||
-----------------------------------
|
-----------------------------------
|
||||||
|
|
||||||
On Arch Linux, you can also install jedi-vim from official repositories as
|
On Arch Linux, you can also install jedi-vim from official repositories as
|
||||||
`vim-jedi <https://www.archlinux.org/packages/community/any/vim-jedi/>`__.
|
`vim-jedi <https://archlinux.org/packages/extra/any/vim-jedi/>`__.
|
||||||
It is also available on
|
It is also available on
|
||||||
`Debian (≥8) <https://packages.debian.org/vim-python-jedi>`__ and
|
`Debian (≥8) <https://packages.debian.org/vim-python-jedi>`__ and
|
||||||
`Ubuntu (≥14.04) <http://packages.ubuntu.com/vim-python-jedi>`__ as
|
`Ubuntu (≥14.04) <http://packages.ubuntu.com/vim-python-jedi>`__ as
|
||||||
vim-python-jedi.
|
vim-python-jedi.
|
||||||
On Fedora Linux, it is available as
|
On Fedora Linux, it is available as
|
||||||
`vim-jedi <https://apps.fedoraproject.org/packages/vim-jedi>`__.
|
`vim-jedi <https://packages.fedoraproject.org/pkgs/vim-jedi/vim-jedi/>`__.
|
||||||
|
|
||||||
Please note that this version might be quite old compared to using jedi-vim
|
Please note that this version might be quite old compared to using jedi-vim
|
||||||
from Git.
|
from Git.
|
||||||
@@ -207,12 +213,20 @@ get more information. If you set them to ``""``, they are not assigned.
|
|||||||
let g:jedi#usages_command = "<leader>n"
|
let g:jedi#usages_command = "<leader>n"
|
||||||
let g:jedi#completions_command = "<C-Space>"
|
let g:jedi#completions_command = "<C-Space>"
|
||||||
let g:jedi#rename_command = "<leader>r"
|
let g:jedi#rename_command = "<leader>r"
|
||||||
|
let g:jedi#rename_command_keep_name = "<leader>R"
|
||||||
|
|
||||||
A few examples of setting up your project:
|
An example for setting up your project:
|
||||||
|
|
||||||
.. code-block:: vim
|
.. code-block:: vim
|
||||||
|
|
||||||
let g:jedi#environment_path = "<leader>d"
|
let g:jedi#environment_path = "/usr/bin/python3.9"
|
||||||
|
|
||||||
|
jedi-vim tries its best to guess your virtual env. If you want to work with a
|
||||||
|
specific virtual environment however, you can point jedi-vim towards it:
|
||||||
|
|
||||||
|
.. code-block:: vim
|
||||||
|
|
||||||
|
let g:jedi#environment_path = "venv"
|
||||||
|
|
||||||
Finally, if you don't want completion, but all the other features, use:
|
Finally, if you don't want completion, but all the other features, use:
|
||||||
|
|
||||||
@@ -223,6 +237,12 @@ Finally, if you don't want completion, but all the other features, use:
|
|||||||
FAQ
|
FAQ
|
||||||
===
|
===
|
||||||
|
|
||||||
|
I want to use Jedi with a Python 2 Environment, but it's not listed under "Known environments"
|
||||||
|
----------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
Starting with version 0.18.0 Jedi dropped support for Python 2.
|
||||||
|
|
||||||
|
|
||||||
I don't want the docstring window to popup during completion
|
I don't want the docstring window to popup during completion
|
||||||
------------------------------------------------------------
|
------------------------------------------------------------
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
function! health#jedi#check() abort
|
function! health#jedi#check() abort
|
||||||
call health#report_start('jedi')
|
call v:lua.vim.health.start('jedi')
|
||||||
silent call jedi#debug_info()
|
silent call jedi#debug_info()
|
||||||
endfunction
|
endfunction
|
||||||
|
|||||||
@@ -24,6 +24,7 @@ let s:default_settings = {
|
|||||||
\ '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'",
|
||||||
|
\ 'rename_command_keep_name': "'<leader>R'",
|
||||||
\ 'completions_enabled': 1,
|
\ 'completions_enabled': 1,
|
||||||
\ 'popup_on_dot': 'g:jedi#completions_enabled',
|
\ 'popup_on_dot': 'g:jedi#completions_enabled',
|
||||||
\ 'documentation_command': "'K'",
|
\ 'documentation_command': "'K'",
|
||||||
@@ -36,8 +37,10 @@ let s:default_settings = {
|
|||||||
\ 'quickfix_window_height': 10,
|
\ 'quickfix_window_height': 10,
|
||||||
\ 'force_py_version': "'auto'",
|
\ 'force_py_version': "'auto'",
|
||||||
\ 'environment_path': "'auto'",
|
\ 'environment_path': "'auto'",
|
||||||
|
\ 'added_sys_path': '[]',
|
||||||
\ 'project_path': "'auto'",
|
\ 'project_path': "'auto'",
|
||||||
\ 'smart_auto_mappings': 0,
|
\ 'smart_auto_mappings': 0,
|
||||||
|
\ 'case_insensitive_completion': 1,
|
||||||
\ 'use_tag_stack': 1
|
\ 'use_tag_stack': 1
|
||||||
\ }
|
\ }
|
||||||
|
|
||||||
@@ -368,6 +371,14 @@ function! jedi#rename_visual(...) abort
|
|||||||
python3 jedi_vim.rename_visual()
|
python3 jedi_vim.rename_visual()
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
|
function! jedi#rename_keep_name(...) abort
|
||||||
|
python3 jedi_vim.rename(delete_word=False)
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
function! jedi#rename_visual_keep_name(...) abort
|
||||||
|
python3 jedi_vim.rename_visual(use_selected_text_as_prompt_answer=True)
|
||||||
|
endfunction
|
||||||
|
|
||||||
function! jedi#completions(findstart, base) abort
|
function! jedi#completions(findstart, base) abort
|
||||||
python3 jedi_vim.completions()
|
python3 jedi_vim.completions()
|
||||||
endfunction
|
endfunction
|
||||||
@@ -506,7 +517,7 @@ function! jedi#goto_window_on_enter() abort
|
|||||||
if l:data.bufnr
|
if l:data.bufnr
|
||||||
" close goto_window buffer
|
" close goto_window buffer
|
||||||
normal! ZQ
|
normal! ZQ
|
||||||
python3 jedi_vim.new_buffer(vim.eval('bufname(l:data.bufnr)'))
|
python3 jedi_vim.set_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
|
||||||
|
|||||||
@@ -27,8 +27,9 @@ Contents *jedi-vim-contents*
|
|||||||
5.4 Go to stub |g:jedi#goto_stubs_command|
|
5.4 Go to stub |g:jedi#goto_stubs_command|
|
||||||
5.5. Show documentation |g:jedi#documentation_command|
|
5.5. Show documentation |g:jedi#documentation_command|
|
||||||
5.6. Rename variables |g:jedi#rename_command|
|
5.6. Rename variables |g:jedi#rename_command|
|
||||||
5.7. Show name usages |g:jedi#usages_command|
|
5.7. Rename variables (Reuse name) |g:jedi#rename_command_keep_name|
|
||||||
5.8. Open module by name |:Pyimport|
|
5.8. Show name usages |g:jedi#usages_command|
|
||||||
|
5.9. Open module by name |:Pyimport|
|
||||||
6. Configuration |jedi-vim-configuration|
|
6. Configuration |jedi-vim-configuration|
|
||||||
6.1. auto_initialization |g:jedi#auto_initialization|
|
6.1. auto_initialization |g:jedi#auto_initialization|
|
||||||
6.2. auto_vim_configuration |g:jedi#auto_vim_configuration|
|
6.2. auto_vim_configuration |g:jedi#auto_vim_configuration|
|
||||||
@@ -45,6 +46,11 @@ Contents *jedi-vim-contents*
|
|||||||
6.13. smart_auto_mappings |g:jedi#smart_auto_mappings|
|
6.13. smart_auto_mappings |g:jedi#smart_auto_mappings|
|
||||||
6.14. use_tag_stack |g:jedi#use_tag_stack|
|
6.14. use_tag_stack |g:jedi#use_tag_stack|
|
||||||
6.15. environment_path |g:jedi#environment_path|
|
6.15. environment_path |g:jedi#environment_path|
|
||||||
|
|b:jedi_environment_path|
|
||||||
|
6.16. added_sys_path |g:jedi#added_sys_path|
|
||||||
|
|b:jedi_added_sys_path|
|
||||||
|
6.17. case_insensitive_completion |g:jedi#case_insensitive_completion|
|
||||||
|
|b:jedi_case_insensitive_completion|
|
||||||
7. Testing |jedi-vim-testing|
|
7. Testing |jedi-vim-testing|
|
||||||
8. Contributing |jedi-vim-contributing|
|
8. Contributing |jedi-vim-contributing|
|
||||||
9. License |jedi-vim-license|
|
9. License |jedi-vim-license|
|
||||||
@@ -302,7 +308,19 @@ with the new one. The number of performed renames is displayed in the command
|
|||||||
line.
|
line.
|
||||||
|
|
||||||
------------------------------------------------------------------------------
|
------------------------------------------------------------------------------
|
||||||
5.7. `g:jedi#usages_command` *g:jedi#usages_command*
|
5.7. `g:jedi#rename_command_keep_name` *g:jedi#rename_command_keep_name*
|
||||||
|
Function: `jedi#rename()`
|
||||||
|
Default: <leader>R Rename variables
|
||||||
|
(This key mapping does not delete the word under the cursor)
|
||||||
|
|
||||||
|
Jedi-vim keeps the word currently under the cursor, moves the cursor to the end
|
||||||
|
of the word, and puts Vim in insert mode, where the user is expected to enter
|
||||||
|
the new variable name. Upon leaving 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 line.
|
||||||
|
|
||||||
|
------------------------------------------------------------------------------
|
||||||
|
5.8. `g:jedi#usages_command` *g:jedi#usages_command*
|
||||||
Function: `jedi#usages()`
|
Function: `jedi#usages()`
|
||||||
Default: <leader>n Show usages of a name.
|
Default: <leader>n Show usages of a name.
|
||||||
|
|
||||||
@@ -310,7 +328,7 @@ The quickfix window is populated with a list of all names which point to the
|
|||||||
definition of the name under the cursor.
|
definition of the name under the cursor.
|
||||||
|
|
||||||
------------------------------------------------------------------------------
|
------------------------------------------------------------------------------
|
||||||
5.8. Open module by name *:Pyimport*
|
5.9. Open module by name *:Pyimport*
|
||||||
Function: `jedi#py_import(args)`
|
Function: `jedi#py_import(args)`
|
||||||
Default: :Pyimport e.g. `:Pyimport os` shows os.py in VIM.
|
Default: :Pyimport e.g. `:Pyimport os` shows os.py in VIM.
|
||||||
|
|
||||||
@@ -344,7 +362,8 @@ Default: 1 (Perform automatic initialization)
|
|||||||
------------------------------------------------------------------------------
|
------------------------------------------------------------------------------
|
||||||
6.2. `g:jedi#auto_vim_configuration` *g:jedi#auto_vim_configuration*
|
6.2. `g:jedi#auto_vim_configuration` *g:jedi#auto_vim_configuration*
|
||||||
|
|
||||||
Jedi-vim sets 'completeopt' to `menuone,longest,preview` by default, if
|
Jedi-vim sets 'completeopt' to `menuone,longest` and `popup` (for Vim version
|
||||||
|
numbers higher than 8.1.1882) respectively `preview` by default, if
|
||||||
'completeopt' is not changed from Vim's default.
|
'completeopt' is not changed from Vim's default.
|
||||||
It also remaps <Ctrl-C> to <Esc> in insert mode.
|
It also remaps <Ctrl-C> to <Esc> in insert mode.
|
||||||
|
|
||||||
@@ -383,13 +402,15 @@ Default: 1 (Automatically select first completion entry)
|
|||||||
------------------------------------------------------------------------------
|
------------------------------------------------------------------------------
|
||||||
6.5. `g:jedi#auto_close_doc` *g:jedi#auto_close_doc*
|
6.5. `g:jedi#auto_close_doc` *g:jedi#auto_close_doc*
|
||||||
|
|
||||||
When doing completion, jedi-vim shows the docstring of the currently selected
|
When doing completion and jedi-vim shows the docstring of the currently selected
|
||||||
item in a preview window. By default, this window is being closed after
|
item in a preview (not a popup) window, this window is being closed after
|
||||||
insertion of a completion item.
|
insertion of a completion item.
|
||||||
|
|
||||||
Set this to 0 to leave the preview window open even after leaving insert mode.
|
Set this to 0 to leave the preview window open even after leaving insert mode.
|
||||||
This could be useful if you want to browse longer docstrings.
|
This could be useful if you want to browse longer docstrings.
|
||||||
|
|
||||||
|
This setting is ignored if a popup instead of a preview window is used.
|
||||||
|
|
||||||
Options: 0 or 1
|
Options: 0 or 1
|
||||||
Default: 1 (Automatically close preview window upon leaving insert mode)
|
Default: 1 (Automatically close preview window upon leaving insert mode)
|
||||||
|
|
||||||
@@ -509,6 +530,7 @@ Default: 1 (enabled by default)
|
|||||||
|
|
||||||
------------------------------------------------------------------------------
|
------------------------------------------------------------------------------
|
||||||
6.15. `g:jedi#environment_path` *g:jedi#environment_path*
|
6.15. `g:jedi#environment_path` *g:jedi#environment_path*
|
||||||
|
*b:jedi_environment_path*
|
||||||
|
|
||||||
To use a specific virtualenv or a specific Python version it is possible to
|
To use a specific virtualenv or a specific Python version it is possible to
|
||||||
set an interpreter.
|
set an interpreter.
|
||||||
@@ -516,8 +538,36 @@ set an interpreter.
|
|||||||
Both setting the directory and setting a project is working.
|
Both setting the directory and setting a project is working.
|
||||||
|
|
||||||
Examples: "/usr/bin/python3.9", "venv", "../venv", "../venv/bin/python"
|
Examples: "/usr/bin/python3.9", "venv", "../venv", "../venv/bin/python"
|
||||||
|
|
||||||
|
The buffer-local variable `b:jedi_environment_path` can be used to override the
|
||||||
|
global variable `g:jedi#environment_path`.
|
||||||
|
|
||||||
Default: "auto"
|
Default: "auto"
|
||||||
|
|
||||||
|
------------------------------------------------------------------------------
|
||||||
|
6.16. `g:jedi#added_sys_path` *g:jedi#added_sys_path*
|
||||||
|
*b:jedi_added_sys_path*
|
||||||
|
|
||||||
|
To add extra sys_path.
|
||||||
|
|
||||||
|
The buffer-local variable `b:jedi_added_sys_path` can be used to add
|
||||||
|
additional extra sys_path.
|
||||||
|
|
||||||
|
Examples: ["../site-packages"]
|
||||||
|
Default: []
|
||||||
|
|
||||||
|
------------------------------------------------------------------------------
|
||||||
|
6.17. `g:jedi#case_insensitive_completion` *g:jedi#case_insensitive_completion*
|
||||||
|
*b:jedi_case_insensitive_completion*
|
||||||
|
|
||||||
|
0 to disable case insensitive completion.
|
||||||
|
1 to enable case insensitive completion (default).
|
||||||
|
|
||||||
|
The buffer-local variable `b:jedi_case_insensitive_completion` can be used to
|
||||||
|
override the global variable `g:jedi#case_insensitive_completion`.
|
||||||
|
|
||||||
|
Default: 1
|
||||||
|
|
||||||
==============================================================================
|
==============================================================================
|
||||||
7. Testing *jedi-vim-testing*
|
7. Testing *jedi-vim-testing*
|
||||||
|
|
||||||
|
|||||||
@@ -27,6 +27,10 @@ if g:jedi#auto_initialization
|
|||||||
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
|
||||||
|
if len(g:jedi#rename_command_keep_name)
|
||||||
|
execute 'nnoremap <buffer> '.g:jedi#rename_command_keep_name.' :call jedi#rename_keep_name()<CR>'
|
||||||
|
execute 'vnoremap <buffer> '.g:jedi#rename_command_keep_name.' :call jedi#rename_visual_keep_name()<CR>'
|
||||||
|
endif
|
||||||
" documentation/pydoc
|
" documentation/pydoc
|
||||||
if len(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>'
|
||||||
@@ -44,10 +48,15 @@ if g:jedi#auto_initialization
|
|||||||
inoremap <silent> <buffer> <space> <C-R>=jedi#smart_auto_mappings()<CR>
|
inoremap <silent> <buffer> <space> <C-R>=jedi#smart_auto_mappings()<CR>
|
||||||
end
|
end
|
||||||
|
|
||||||
if g:jedi#auto_close_doc
|
if g:jedi#auto_close_doc && (&g:completeopt =~# '\<preview\>' && &g:completeopt !~# '\<popup\>')
|
||||||
" close preview if its still open after insert
|
" close preview if its still open after insert
|
||||||
augroup jedi_preview
|
augroup jedi_preview
|
||||||
autocmd! InsertLeave <buffer> if pumvisible() == 0|pclose|endif
|
if v:version > 704
|
||||||
|
autocmd CompleteDone <buffer> pclose
|
||||||
|
else
|
||||||
|
autocmd InsertLeave <buffer> if pumvisible() == 0|pclose|endif
|
||||||
|
autocmd CursorMovedI <buffer> if pumvisible() == 0|pclose|endif
|
||||||
|
endif
|
||||||
augroup END
|
augroup END
|
||||||
endif
|
endif
|
||||||
endif
|
endif
|
||||||
|
|||||||
@@ -33,7 +33,12 @@ if get(g:, 'jedi#auto_vim_configuration', 1)
|
|||||||
redir END
|
redir END
|
||||||
endif
|
endif
|
||||||
if len(split(completeopt, '\n')) == 1
|
if len(split(completeopt, '\n')) == 1
|
||||||
set completeopt=menuone,longest,preview
|
set completeopt=menuone,longest
|
||||||
|
if v:version > 801 || (v:version == 801 && has('patch-8.1.1882'))
|
||||||
|
set completeopt+=popup
|
||||||
|
else
|
||||||
|
set completeopt+=preview
|
||||||
|
endif
|
||||||
endif
|
endif
|
||||||
endfunction
|
endfunction
|
||||||
if has('nvim')
|
if has('nvim')
|
||||||
|
|||||||
Submodule pythonx/jedi updated: 4b5b2e791b...41e9e957e7
@@ -4,12 +4,14 @@ The Python parts of the Jedi library for VIM. It is mostly about communicating
|
|||||||
with VIM.
|
with VIM.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
from typing import Optional
|
||||||
import traceback # for exception output
|
import traceback # for exception output
|
||||||
import re
|
import re
|
||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
from shlex import split as shsplit
|
from shlex import split as shsplit
|
||||||
from contextlib import contextmanager
|
from contextlib import contextmanager
|
||||||
|
from pathlib import Path
|
||||||
try:
|
try:
|
||||||
from itertools import zip_longest
|
from itertools import zip_longest
|
||||||
except ImportError:
|
except ImportError:
|
||||||
@@ -216,11 +218,18 @@ _current_project_cache = None, None
|
|||||||
|
|
||||||
|
|
||||||
def get_project():
|
def get_project():
|
||||||
vim_environment_path = vim_eval("g:jedi#environment_path")
|
vim_environment_path = vim_eval(
|
||||||
|
"get(b:, 'jedi_environment_path', g:jedi#environment_path)"
|
||||||
|
)
|
||||||
vim_project_path = vim_eval("g:jedi#project_path")
|
vim_project_path = vim_eval("g:jedi#project_path")
|
||||||
|
|
||||||
|
vim_added_sys_path = vim_eval("get(g:, 'jedi#added_sys_path', [])")
|
||||||
|
vim_added_sys_path += vim_eval("get(b:, 'jedi_added_sys_path', [])")
|
||||||
|
|
||||||
global _current_project_cache
|
global _current_project_cache
|
||||||
cache_key = dict(project_path=vim_project_path, environment_path=vim_environment_path)
|
cache_key = dict(project_path=vim_project_path,
|
||||||
|
environment_path=vim_environment_path,
|
||||||
|
added_sys_path=vim_added_sys_path)
|
||||||
if cache_key == _current_project_cache[0]:
|
if cache_key == _current_project_cache[0]:
|
||||||
return _current_project_cache[1]
|
return _current_project_cache[1]
|
||||||
|
|
||||||
@@ -234,7 +243,9 @@ def get_project():
|
|||||||
else:
|
else:
|
||||||
project_path = vim_project_path
|
project_path = vim_project_path
|
||||||
|
|
||||||
project = jedi.Project(project_path, environment_path=environment_path)
|
project = jedi.Project(project_path,
|
||||||
|
environment_path=environment_path,
|
||||||
|
added_sys_path=vim_added_sys_path)
|
||||||
|
|
||||||
_current_project_cache = cache_key, project
|
_current_project_cache = cache_key, project
|
||||||
return project
|
return project
|
||||||
@@ -283,7 +294,9 @@ def load_project():
|
|||||||
project.save()
|
project.save()
|
||||||
|
|
||||||
global _current_project_cache
|
global _current_project_cache
|
||||||
cache_key = dict(project_path=path, environment_path=env_path)
|
cache_key = dict(project_path=path,
|
||||||
|
environment_path=env_path,
|
||||||
|
added_sys_path=[])
|
||||||
_current_project_cache = cache_key, project
|
_current_project_cache = cache_key, project
|
||||||
|
|
||||||
|
|
||||||
@@ -314,6 +327,10 @@ def get_pos(column=None):
|
|||||||
@_check_jedi_availability(show_error=False)
|
@_check_jedi_availability(show_error=False)
|
||||||
@catch_and_print_exceptions
|
@catch_and_print_exceptions
|
||||||
def completions():
|
def completions():
|
||||||
|
jedi.settings.case_insensitive_completion = \
|
||||||
|
bool(int(vim_eval("get(b:, 'jedi_case_insensitive_completion', "
|
||||||
|
"g:jedi#case_insensitive_completion)")))
|
||||||
|
|
||||||
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.
|
||||||
@@ -343,7 +360,9 @@ def completions():
|
|||||||
completions = script.complete(*get_pos(column))
|
completions = script.complete(*get_pos(column))
|
||||||
signatures = script.get_signatures(*get_pos(column))
|
signatures = script.get_signatures(*get_pos(column))
|
||||||
|
|
||||||
add_info = "preview" in vim.eval("&completeopt").split(",")
|
add_info = \
|
||||||
|
any(option in vim.eval("&completeopt").split(",")
|
||||||
|
for option in ("preview", "popup"))
|
||||||
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),
|
||||||
@@ -418,21 +437,22 @@ def _goto_specific_name(n, options=''):
|
|||||||
if n.is_keyword:
|
if n.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)."
|
name = 'Namespaces' if n.type == 'namespace' else 'Builtin modules'
|
||||||
% (n.full_name or n.name))
|
echo_highlight(
|
||||||
|
"%s cannot be displayed (%s)."
|
||||||
|
% (name, n.full_name or n.name)
|
||||||
|
)
|
||||||
else:
|
else:
|
||||||
using_tagstack = int(vim_eval('g:jedi#use_tag_stack')) == 1
|
using_tagstack = int(vim_eval('g:jedi#use_tag_stack')) == 1
|
||||||
module_path = str(n.module_path or '')
|
result = set_buffer(n.module_path, options=options,
|
||||||
if module_path != vim.current.buffer.name:
|
|
||||||
result = new_buffer(module_path, options=options,
|
|
||||||
using_tagstack=using_tagstack)
|
using_tagstack=using_tagstack)
|
||||||
if not result:
|
if not result:
|
||||||
return []
|
return []
|
||||||
if (using_tagstack and module_path and
|
if (using_tagstack and n.module_path and
|
||||||
os.path.exists(module_path)):
|
n.module_path.exists()):
|
||||||
tagname = n.name
|
tagname = n.name
|
||||||
with tempfile('{0}\t{1}\t{2}'.format(
|
with tempfile('{0}\t{1}\t{2}'.format(
|
||||||
tagname, module_path, 'call cursor({0}, {1})'.format(
|
tagname, n.module_path, 'call cursor({0}, {1})'.format(
|
||||||
n.line, n.column + 1))) as f:
|
n.line, n.column + 1))) as f:
|
||||||
old_tags = vim.eval('&tags')
|
old_tags = vim.eval('&tags')
|
||||||
old_wildignore = vim.eval('&wildignore')
|
old_wildignore = vim.eval('&wildignore')
|
||||||
@@ -978,7 +998,7 @@ def cmdline_call_signatures(signatures):
|
|||||||
|
|
||||||
@_check_jedi_availability(show_error=True)
|
@_check_jedi_availability(show_error=True)
|
||||||
@catch_and_print_exceptions
|
@catch_and_print_exceptions
|
||||||
def rename():
|
def rename(delete_word=True):
|
||||||
if not int(vim.eval('a:0')):
|
if not int(vim.eval('a:0')):
|
||||||
# Need to save the cursor position before insert mode
|
# Need to save the cursor position before insert mode
|
||||||
cursor = vim.current.window.cursor
|
cursor = vim.current.window.cursor
|
||||||
@@ -990,7 +1010,12 @@ def rename():
|
|||||||
|
|
||||||
vim_command("let s:jedi_replace_orig = expand('<cword>')")
|
vim_command("let s:jedi_replace_orig = expand('<cword>')")
|
||||||
line = vim_eval('getline(".")')
|
line = vim_eval('getline(".")')
|
||||||
|
|
||||||
|
if delete_word:
|
||||||
vim_command('normal! diw')
|
vim_command('normal! diw')
|
||||||
|
else:
|
||||||
|
vim_command('normal! yiwel')
|
||||||
|
|
||||||
if re.match(r'\w+$', line[cursor[1]:]):
|
if re.match(r'\w+$', line[cursor[1]:]):
|
||||||
# In case the deleted word is at the end of the line we need to
|
# In case the deleted word is at the end of the line we need to
|
||||||
# move the cursor to the end.
|
# move the cursor to the end.
|
||||||
@@ -1022,9 +1047,17 @@ def rename():
|
|||||||
return do_rename(replace)
|
return do_rename(replace)
|
||||||
|
|
||||||
|
|
||||||
def rename_visual():
|
def rename_visual(use_selected_text_as_prompt_answer=False):
|
||||||
replace = vim.eval('input("Rename to: ")')
|
orig = vim.eval('getline(".")[(getpos("\'<")[2]-1):getpos("\'>")[2]'
|
||||||
orig = vim.eval('getline(".")[(getpos("\'<")[2]-1):getpos("\'>")[2]]')
|
'-((&selection ==# "exclusive") ? 2 : 1)]')
|
||||||
|
|
||||||
|
input_text = ""
|
||||||
|
if use_selected_text_as_prompt_answer:
|
||||||
|
input_text = orig
|
||||||
|
|
||||||
|
replace = vim.eval(
|
||||||
|
'input("Rename to:", "{}")'.format(PythonToVimStr(input_text))
|
||||||
|
)
|
||||||
do_rename(replace, orig)
|
do_rename(replace, orig)
|
||||||
|
|
||||||
|
|
||||||
@@ -1036,6 +1069,10 @@ def do_rename(replace, orig=None):
|
|||||||
if orig is None:
|
if orig is None:
|
||||||
orig = vim_eval('s:jedi_replace_orig')
|
orig = vim_eval('s:jedi_replace_orig')
|
||||||
|
|
||||||
|
if orig == replace:
|
||||||
|
echo_highlight('Jedi did 0 renames.')
|
||||||
|
return
|
||||||
|
|
||||||
# Save original window / tab.
|
# Save original window / tab.
|
||||||
saved_tab = int(vim_eval('tabpagenr()'))
|
saved_tab = int(vim_eval('tabpagenr()'))
|
||||||
saved_win = int(vim_eval('winnr()'))
|
saved_win = int(vim_eval('winnr()'))
|
||||||
@@ -1050,13 +1087,9 @@ def do_rename(replace, orig=None):
|
|||||||
if r.in_builtin_module():
|
if r.in_builtin_module():
|
||||||
continue
|
continue
|
||||||
|
|
||||||
module_path = r.module_path
|
result = set_buffer(r.module_path)
|
||||||
if os.path.abspath(vim.current.buffer.name) != str(module_path):
|
|
||||||
assert module_path is not None
|
|
||||||
result = new_buffer(module_path)
|
|
||||||
if not result:
|
if not result:
|
||||||
echo_highlight('Failed to create buffer window for %s!' % (
|
echo_highlight('Failed to create buffer window for %s!' % (r.module_path))
|
||||||
module_path))
|
|
||||||
continue
|
continue
|
||||||
|
|
||||||
buffers.add(vim.current.buffer.name)
|
buffers.add(vim.current.buffer.name)
|
||||||
@@ -1103,7 +1136,17 @@ def py_import_completions():
|
|||||||
|
|
||||||
|
|
||||||
@catch_and_print_exceptions
|
@catch_and_print_exceptions
|
||||||
def new_buffer(path, options='', using_tagstack=False):
|
def set_buffer(path: Optional[Path], options='', using_tagstack=False):
|
||||||
|
"""
|
||||||
|
Opens a new buffer if we have to or does nothing. Returns True in case of
|
||||||
|
success.
|
||||||
|
"""
|
||||||
|
path = str(path or '')
|
||||||
|
# Check both, because it might be an empty string
|
||||||
|
if path in (vim.current.buffer.name, os.path.abspath(vim.current.buffer.name)):
|
||||||
|
return True
|
||||||
|
|
||||||
|
path = relpath(path)
|
||||||
# options are what you can to edit the edit options
|
# options are what you can to edit the edit options
|
||||||
if int(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)
|
||||||
@@ -1151,7 +1194,6 @@ def _tabnew(path, options=''):
|
|||||||
|
|
||||||
:param options: `:tabnew` options, read vim help.
|
:param options: `:tabnew` options, read vim help.
|
||||||
"""
|
"""
|
||||||
path = os.path.abspath(path)
|
|
||||||
if int(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
|
||||||
@@ -1166,7 +1208,7 @@ def _tabnew(path, options=''):
|
|||||||
# don't know why this happens :-)
|
# don't know why this happens :-)
|
||||||
pass
|
pass
|
||||||
else:
|
else:
|
||||||
if buf_path == path:
|
if os.path.abspath(buf_path) == os.path.abspath(path):
|
||||||
# tab exists, just switch to that tab
|
# tab exists, just switch to that tab
|
||||||
vim_command('tabfirst | tabnext %i' % (tab_nr + 1))
|
vim_command('tabfirst | tabnext %i' % (tab_nr + 1))
|
||||||
# Goto the buffer's window.
|
# Goto the buffer's window.
|
||||||
|
|||||||
Submodule pythonx/parso updated: ef90bba3b3...be9f5a401f
@@ -52,19 +52,6 @@ describe 'completions'
|
|||||||
Expect getline('.') == 'IndentationError().filename'
|
Expect getline('.') == 'IndentationError().filename'
|
||||||
end
|
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'
|
it 'cycling through entries popup_select_first=0'
|
||||||
set completeopt+=longest
|
set completeopt+=longest
|
||||||
let g:jedi#popup_select_first = 0
|
let g:jedi#popup_select_first = 0
|
||||||
|
|||||||
@@ -47,18 +47,15 @@ describe 'signatures'
|
|||||||
it 'highlights correct argument'
|
it 'highlights correct argument'
|
||||||
noautocmd normal o
|
noautocmd normal o
|
||||||
doautocmd CursorHoldI
|
doautocmd CursorHoldI
|
||||||
noautocmd normal iprint(42, sep="X", )
|
noautocmd normal iformat(42, "x")
|
||||||
" Move to "=" - hightlights "sep=...".
|
" Move to x - highlights "x".
|
||||||
noautocmd normal 5h
|
noautocmd normal 2h
|
||||||
doautocmd CursorHoldI
|
doautocmd CursorHoldI
|
||||||
Expect getline(1) =~# '\V\^?!?jedi=0, ?!? (*values: object, *_*sep: Optional[Text]=...*_*'
|
Expect getline(1) == '?!?jedi=0, ?!? (value: object, *_*format_spec: str=...*_*) ?!?jedi?!?'
|
||||||
" Move left to "=" - hightlights first argument ("values").
|
" Move left to 42 - hightlights first argument ("value").
|
||||||
" NOTE: it is arguable that maybe "sep=..." should be highlighted
|
noautocmd normal 4h
|
||||||
" still, but this tests for the cache to be "busted", and that
|
|
||||||
" fresh results are retrieved from Jedi.
|
|
||||||
noautocmd normal h
|
|
||||||
doautocmd CursorHoldI
|
doautocmd CursorHoldI
|
||||||
Expect getline(1) =~# '\V\^?!?jedi=0, ?!? (*_**values: object*_*, sep: Optional[Text]=...,'
|
Expect getline(1) == '?!?jedi=0, ?!? (*_*value: object*_*, format_spec: str=...) ?!?jedi?!?'
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'no signature'
|
it 'no signature'
|
||||||
|
|||||||
Reference in New Issue
Block a user