mirror of
https://github.com/davidhalter/jedi-vim.git
synced 2026-05-17 22:09:43 +08:00
Compare commits
31 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| a33071af6b | |||
| 89a2122ab0 | |||
| 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 | |||
| 27db7160a5 |
@@ -3,10 +3,10 @@ on: [push, pull_request]
|
||||
|
||||
jobs:
|
||||
tests:
|
||||
runs-on: ubuntu-20.04
|
||||
runs-on: ubuntu-24.04
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v2
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
submodules: recursive
|
||||
|
||||
@@ -20,44 +20,3 @@ jobs:
|
||||
|
||||
- name: Run tests
|
||||
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//./}
|
||||
|
||||
+12
-5
@@ -73,9 +73,15 @@ 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).
|
||||
- **Vim**: You need a VIM version that was compiled with Python 3 or later
|
||||
(``+python3``). You can check this from within VIM using
|
||||
``:python3 import sys; print(sys.version)``.
|
||||
|
||||
- **Neovim**: You need a python environment with ``pynvim`` installed:
|
||||
``pip install pynvim``
|
||||
|
||||
then check your environment is correctly setup from within Neovim using
|
||||
``:checkhealth provider.python``
|
||||
|
||||
Manual installation
|
||||
-------------------
|
||||
@@ -108,13 +114,13 @@ Installation with your distribution
|
||||
-----------------------------------
|
||||
|
||||
On Arch Linux, you can also install jedi-vim from official repositories as
|
||||
`vim-jedi <https://www.archlinux.org/packages/community/any/vim-jedi/>`__.
|
||||
`vim-jedi <https://archlinux.org/packages/extra/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>`__.
|
||||
`vim-jedi <https://packages.fedoraproject.org/pkgs/vim-jedi/vim-jedi/>`__.
|
||||
|
||||
Please note that this version might be quite old compared to using jedi-vim
|
||||
from Git.
|
||||
@@ -207,6 +213,7 @@ get more information. If you set them to ``""``, they are not assigned.
|
||||
let g:jedi#usages_command = "<leader>n"
|
||||
let g:jedi#completions_command = "<C-Space>"
|
||||
let g:jedi#rename_command = "<leader>r"
|
||||
let g:jedi#rename_command_keep_name = "<leader>R"
|
||||
|
||||
An example for setting up your project:
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
function! health#jedi#check() abort
|
||||
call health#report_start('jedi')
|
||||
call v:lua.vim.health.start('jedi')
|
||||
silent call jedi#debug_info()
|
||||
endfunction
|
||||
|
||||
@@ -24,6 +24,7 @@ let s:default_settings = {
|
||||
\ 'call_signatures_command': "'<leader>n'",
|
||||
\ 'usages_command': "'<leader>n'",
|
||||
\ 'rename_command': "'<leader>r'",
|
||||
\ 'rename_command_keep_name': "'<leader>R'",
|
||||
\ 'completions_enabled': 1,
|
||||
\ 'popup_on_dot': 'g:jedi#completions_enabled',
|
||||
\ 'documentation_command': "'K'",
|
||||
@@ -370,6 +371,14 @@ function! jedi#rename_visual(...) abort
|
||||
python3 jedi_vim.rename_visual()
|
||||
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
|
||||
python3 jedi_vim.completions()
|
||||
endfunction
|
||||
|
||||
+17
-4
@@ -27,8 +27,9 @@ Contents *jedi-vim-contents*
|
||||
5.4 Go to stub |g:jedi#goto_stubs_command|
|
||||
5.5. Show documentation |g:jedi#documentation_command|
|
||||
5.6. Rename variables |g:jedi#rename_command|
|
||||
5.7. Show name usages |g:jedi#usages_command|
|
||||
5.8. Open module by name |:Pyimport|
|
||||
5.7. Rename variables (Reuse name) |g:jedi#rename_command_keep_name|
|
||||
5.8. Show name usages |g:jedi#usages_command|
|
||||
5.9. Open module by name |:Pyimport|
|
||||
6. Configuration |jedi-vim-configuration|
|
||||
6.1. auto_initialization |g:jedi#auto_initialization|
|
||||
6.2. auto_vim_configuration |g:jedi#auto_vim_configuration|
|
||||
@@ -307,7 +308,19 @@ with the new one. The number of performed renames is displayed in the command
|
||||
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()`
|
||||
Default: <leader>n Show usages of a name.
|
||||
|
||||
@@ -315,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.
|
||||
|
||||
------------------------------------------------------------------------------
|
||||
5.8. Open module by name *:Pyimport*
|
||||
5.9. Open module by name *:Pyimport*
|
||||
Function: `jedi#py_import(args)`
|
||||
Default: :Pyimport e.g. `:Pyimport os` shows os.py in VIM.
|
||||
|
||||
|
||||
@@ -27,6 +27,10 @@ if g:jedi#auto_initialization
|
||||
execute 'nnoremap <buffer> '.g:jedi#rename_command.' :call jedi#rename()<CR>'
|
||||
execute 'vnoremap <buffer> '.g:jedi#rename_command.' :call jedi#rename_visual()<CR>'
|
||||
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
|
||||
if len(g:jedi#documentation_command)
|
||||
execute 'nnoremap <silent> <buffer>'.g:jedi#documentation_command.' :call jedi#show_documentation()<CR>'
|
||||
@@ -48,10 +52,10 @@ if g:jedi#auto_initialization
|
||||
" close preview if its still open after insert
|
||||
augroup jedi_preview
|
||||
if v:version > 704
|
||||
autocmd CompleteDone <buffer> * pclose
|
||||
autocmd CompleteDone <buffer> pclose
|
||||
else
|
||||
autocmd InsertLeave <buffer> * if pumvisible() == 0|pclose|endif
|
||||
autocmd CursorMovedI <buffer> * if pumvisible() == 0|pclose|endif
|
||||
autocmd InsertLeave <buffer> if pumvisible() == 0|pclose|endif
|
||||
autocmd CursorMovedI <buffer> if pumvisible() == 0|pclose|endif
|
||||
endif
|
||||
augroup END
|
||||
endif
|
||||
|
||||
+1
-1
Submodule pythonx/jedi updated: fae26fa7a4...3102215478
+22
-5
@@ -998,7 +998,7 @@ def cmdline_call_signatures(signatures):
|
||||
|
||||
@_check_jedi_availability(show_error=True)
|
||||
@catch_and_print_exceptions
|
||||
def rename():
|
||||
def rename(delete_word=True):
|
||||
if not int(vim.eval('a:0')):
|
||||
# Need to save the cursor position before insert mode
|
||||
cursor = vim.current.window.cursor
|
||||
@@ -1010,7 +1010,12 @@ def rename():
|
||||
|
||||
vim_command("let s:jedi_replace_orig = expand('<cword>')")
|
||||
line = vim_eval('getline(".")')
|
||||
vim_command('normal! diw')
|
||||
|
||||
if delete_word:
|
||||
vim_command('normal! diw')
|
||||
else:
|
||||
vim_command('normal! yiwel')
|
||||
|
||||
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.
|
||||
@@ -1042,9 +1047,17 @@ def rename():
|
||||
return do_rename(replace)
|
||||
|
||||
|
||||
def rename_visual():
|
||||
replace = vim.eval('input("Rename to: ")')
|
||||
orig = vim.eval('getline(".")[(getpos("\'<")[2]-1):getpos("\'>")[2]]')
|
||||
def rename_visual(use_selected_text_as_prompt_answer=False):
|
||||
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)
|
||||
|
||||
|
||||
@@ -1056,6 +1069,10 @@ def do_rename(replace, orig=None):
|
||||
if orig is None:
|
||||
orig = vim_eval('s:jedi_replace_orig')
|
||||
|
||||
if orig == replace:
|
||||
echo_highlight('Jedi did 0 renames.')
|
||||
return
|
||||
|
||||
# Save original window / tab.
|
||||
saved_tab = int(vim_eval('tabpagenr()'))
|
||||
saved_win = int(vim_eval('winnr()'))
|
||||
|
||||
+1
-1
Submodule pythonx/parso updated: ee5edaf22f...bfe3058441
@@ -52,19 +52,6 @@ describe 'completions'
|
||||
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
|
||||
|
||||
@@ -41,7 +41,7 @@ describe 'signatures'
|
||||
doautocmd CursorHoldI
|
||||
noautocmd normal istaticmethod()
|
||||
doautocmd CursorHoldI
|
||||
Expect getline(1) == '?!?jedi=0, ?!? (*_*f: Callable[..., Any]*_*) ?!?jedi?!?'
|
||||
Expect getline(1) == '?!?jedi=0, ?!? (*_*f: Callable[_P, _R_co]*_*) ?!?jedi?!?'
|
||||
end
|
||||
|
||||
it 'highlights correct argument'
|
||||
@@ -51,11 +51,11 @@ describe 'signatures'
|
||||
" Move to x - highlights "x".
|
||||
noautocmd normal 2h
|
||||
doautocmd CursorHoldI
|
||||
Expect getline(1) == '?!?jedi=0, ?!? (value: object, *_*format_spec: str=...*_*) ?!?jedi?!?'
|
||||
Expect getline(1) == '?!?jedi=0, ?!? (value: object, *_*format_spec: str=""*_*) ?!?jedi?!?'
|
||||
" Move left to 42 - hightlights first argument ("value").
|
||||
noautocmd normal 4h
|
||||
doautocmd CursorHoldI
|
||||
Expect getline(1) == '?!?jedi=0, ?!? (*_*value: object*_*, format_spec: str=...) ?!?jedi?!?'
|
||||
Expect getline(1) == '?!?jedi=0, ?!? (*_*value: object*_*, format_spec: str="") ?!?jedi?!?'
|
||||
end
|
||||
|
||||
it 'no signature'
|
||||
@@ -82,7 +82,7 @@ describe 'signatures'
|
||||
redir => msg
|
||||
python3 jedi_vim.show_call_signatures()
|
||||
redir END
|
||||
Expect msg == "\nstaticmethod(f: Callable[..., Any])"
|
||||
Expect msg == "\nstaticmethod(f: Callable[_P, _R_co])"
|
||||
|
||||
redir => msg
|
||||
doautocmd InsertLeave
|
||||
@@ -98,6 +98,11 @@ describe 'signatures'
|
||||
end
|
||||
|
||||
it 'command line truncation'
|
||||
" Disable autoindent so `o` opens a new line at column 0; relying on
|
||||
" `\<BS>` to strip the indent is not portable across vim/nvim defaults
|
||||
" (with `bs=eol` it joins lines instead of just removing the indent).
|
||||
setlocal noautoindent nosmartindent indentexpr=
|
||||
|
||||
let g:jedi#show_call_signatures = 2
|
||||
call jedi#configure_call_signatures()
|
||||
|
||||
@@ -111,7 +116,7 @@ describe 'signatures'
|
||||
let funcname = repeat('a', &columns - (30 + (&ruler ? 18 : 0)))
|
||||
put = 'def '.funcname.'(arg1, arg2, arg3, a, b, c):'
|
||||
put = ' pass'
|
||||
execute "normal o\<BS>".funcname."( "
|
||||
execute "normal o".funcname."( "
|
||||
Expect Signature() == "\n".funcname."(arg1, …)"
|
||||
|
||||
exe 'normal sarg1, '
|
||||
@@ -126,7 +131,7 @@ describe 'signatures'
|
||||
g/^/d
|
||||
put = 'def '.funcname.'('.repeat('b', 20).', arg2):'
|
||||
put = ' pass'
|
||||
execute "normal o\<BS>".funcname."( "
|
||||
execute "normal o".funcname."( "
|
||||
Expect Signature() == "\n".funcname."(…)"
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user