12 Commits

Author SHA1 Message Date
Dave Halter
338af171ea Merge pull request #1112 from jgb/master
update jedi to v0.19.0
2023-07-31 22:39:54 +00:00
Jan Geboers
c0c01ede07 update jedi to v0.19.0 2023-07-31 10:12:14 +02:00
Dave Halter
42c2af1812 Merge pull request #1106 from jgb/master
update jedi to v0.18.2
2023-04-11 15:55:50 +00:00
Jan Geboers
1198e4cfa3 update jedi to v0.18.2 2023-04-11 10:27:08 +02:00
Dave Halter
c5d5d2e3b4 Merge pull request #1105 from hawkins/patch-1
Remove mention of Python 2.7 support in installation instructions
2023-04-10 21:25:51 +00:00
Josh Hawkins
0d245f3287 Remove mention of Python 2.7 support in installation instructions 2023-04-10 14:13:51 -04:00
Dave Halter
be483a2dcb Merge pull request #1097 from jamescherti/rename-that-do-not-delete-word
Add a keyboard mapping to rename  variables/functions/classes without deleting the word under the cursor
2022-12-28 19:46:41 +00:00
James Cherti
f286f9e4b6 Key mapping <Leader>R: Rename vars/functions/classes without deleting the word under the cursor
This pull request also adds the support for 'set selection=exclusive' to
the function 'rename_visual()' (bug fix).

'<Leader>R' in Normal mode:
---------------------------
Jedi-vim keeps the word 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.

'<Leader>R' in Visual mode:
---------------------------
Use the selected text as the default answer to the prompt.
2022-12-26 13:43:42 -05:00
Dave Halter
e073385976 Merge pull request #1088 from Jakuje/patch-1
Update link to Fedora package
2022-12-24 23:40:23 +00:00
Dave Halter
6b8013c480 Merge pull request #1095 from Konfekt/popup
fix typo
2022-11-23 09:11:09 +00:00
Konfekt
c381156dd4 fix typo 2022-11-23 08:23:42 +01:00
Jakub Jelen
27db7160a5 Update link to Fedora packages 2022-05-30 20:27:13 +02:00
6 changed files with 61 additions and 17 deletions

View File

@@ -73,9 +73,9 @@ Installation
Requirements Requirements
------------ ------------
You need a VIM version that was compiled with Python 2.7 or later 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)``.
Manual installation Manual installation
------------------- -------------------
@@ -114,7 +114,7 @@ It is also available on
`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,6 +207,7 @@ 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"
An example for setting up your project: An example for setting up your project:

View File

@@ -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'",
@@ -370,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

View File

@@ -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|
@@ -307,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.
@@ -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. 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.

View File

@@ -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>'
@@ -48,10 +52,10 @@ if g:jedi#auto_initialization
" close preview if its still open after insert " close preview if its still open after insert
augroup jedi_preview augroup jedi_preview
if v:version > 704 if v:version > 704
autocmd CompleteDone <buffer> * pclose autocmd CompleteDone <buffer> pclose
else else
autocmd InsertLeave <buffer> * if pumvisible() == 0|pclose|endif autocmd InsertLeave <buffer> if pumvisible() == 0|pclose|endif
autocmd CursorMovedI <buffer> * if pumvisible() == 0|pclose|endif autocmd CursorMovedI <buffer> if pumvisible() == 0|pclose|endif
endif endif
augroup END augroup END
endif endif

View File

@@ -998,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
@@ -1010,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.
@@ -1042,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)
@@ -1056,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()'))