mirror of
https://github.com/davidhalter/jedi-vim.git
synced 2025-12-06 10:54:22 +08:00
deprecate a lot of old definitions how to use functions, use instead the names of jedi functions
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
if g:jedi#show_function_definition == 1 && has('conceal')
|
||||
if g:jedi#show_call_signatures == 1 && has('conceal')
|
||||
" conceal is normal for vim >= 7.3
|
||||
|
||||
let e = g:jedi#function_definition_escape
|
||||
|
||||
@@ -11,7 +11,7 @@ function! jedi#get_definition()
|
||||
endfunction
|
||||
|
||||
|
||||
function! jedi#related_names()
|
||||
function! jedi#usages()
|
||||
Python jedi_vim.goto(is_related_name=True)
|
||||
endfunction
|
||||
|
||||
@@ -43,10 +43,10 @@ function! jedi#disable_debugging()
|
||||
endfunction
|
||||
|
||||
" ------------------------------------------------------------------------
|
||||
" show_pydoc
|
||||
" show_documentation
|
||||
" ------------------------------------------------------------------------
|
||||
function! jedi#show_pydoc()
|
||||
Python jedi_vim.show_pydoc()
|
||||
function! jedi#show_documentation()
|
||||
Python jedi_vim.show_documentation()
|
||||
if bufnr("__doc__") > 0
|
||||
" If the __doc__ buffer is open in the current window, jump to it
|
||||
silent execute "sbuffer ".bufnr("__doc__")
|
||||
@@ -158,7 +158,7 @@ function! jedi#do_popup_on_dot()
|
||||
return 1
|
||||
endfunc
|
||||
|
||||
function! jedi#configure_call_signature()
|
||||
function! jedi#configure_call_signatures()
|
||||
autocmd InsertLeave <buffer> Python jedi_vim.clear_call_signatures()
|
||||
autocmd CursorMovedI <buffer> call jedi#show_call_signatures()
|
||||
endfunction
|
||||
|
||||
@@ -11,7 +11,7 @@ if g:jedi#auto_initialization
|
||||
setlocal omnifunc=jedi#completions
|
||||
|
||||
" map ctrl+space for autocompletion
|
||||
if g:jedi#autocompletion_command == "<C-Space>"
|
||||
if g:jedi#completions_command == "<C-Space>"
|
||||
" in terminals, <C-Space> sometimes equals <Nul>
|
||||
inoremap <expr> <Nul> pumvisible() \|\| &omnifunc == '' ?
|
||||
\ "\<lt>C-n>" :
|
||||
@@ -19,19 +19,19 @@ if g:jedi#auto_initialization
|
||||
\ "\"\\<lt>c-n>\\<lt>c-p>\\<lt>c-n>\" :" .
|
||||
\ "\" \\<lt>bs>\\<lt>C-n>\"\<CR>"
|
||||
endif
|
||||
execute "inoremap <buffer>".g:jedi#autocompletion_command." <C-X><C-O>"
|
||||
execute "inoremap <buffer>".g:jedi#completions_command." <C-X><C-O>"
|
||||
|
||||
" goto / get_definition / related_names
|
||||
execute "noremap <buffer>".g:jedi#goto_command." :call jedi#goto()<CR>"
|
||||
execute "noremap <buffer>".g:jedi#get_definition_command." :call jedi#get_definition()<CR>"
|
||||
execute "noremap <buffer>".g:jedi#related_names_command." :call jedi#related_names()<CR>"
|
||||
execute "noremap <buffer>".g:jedi#goto_assignments_command." :call jedi#goto()<CR>"
|
||||
execute "noremap <buffer>".g:jedi#goto_definitions_command." :call jedi#get_definition()<CR>"
|
||||
execute "noremap <buffer>".g:jedi#usages_command." :call jedi#related_names()<CR>"
|
||||
" rename
|
||||
execute "noremap <buffer>".g:jedi#rename_command." :call jedi#rename()<CR>"
|
||||
" pydoc
|
||||
execute "nnoremap <silent> <buffer>".g:jedi#pydoc." :call jedi#show_pydoc()<CR>"
|
||||
" documentation/pydoc
|
||||
execute "nnoremap <silent> <buffer>".g:jedi#documentation_command." :call jedi#show_documentation()<CR>"
|
||||
|
||||
if g:jedi#show_function_definition == 1 && has('conceal')
|
||||
call jedi#configure_call_signature()
|
||||
if g:jedi#show_call_signatures == 1 && has('conceal')
|
||||
call jedi#configure_call_signatures()
|
||||
endif
|
||||
end
|
||||
|
||||
|
||||
@@ -17,21 +17,45 @@ if exists("g:loaded_jedi") || &cp
|
||||
endif
|
||||
let g:loaded_jedi = 1
|
||||
|
||||
|
||||
" ------------------------------------------------------------------------
|
||||
" deprecations
|
||||
" ------------------------------------------------------------------------
|
||||
|
||||
let s:deprecations = {
|
||||
\ 'get_definition_command': 'goto_definitions_command',
|
||||
\ 'goto_command': 'goto_assignments_command',
|
||||
\ 'pydoc': 'documentation_command',
|
||||
\ 'related_names_command': 'usages_command',
|
||||
\ 'autocompletion_command': 'completions_command',
|
||||
\ 'show_function_definition': 'show_call_signatures',
|
||||
}
|
||||
|
||||
for [key, val] in items(s:settings)
|
||||
if exists('g:jedi#'.key)
|
||||
echom "'g:jedi#".key."' is deprecated. Please use 'g:jedi#".value."' instead. Sorry for the inconvenience."
|
||||
exe 'let g:jedi#'.val.' = g:jedi#'.key
|
||||
end
|
||||
endfor
|
||||
|
||||
|
||||
" ------------------------------------------------------------------------
|
||||
" defaults for jedi-vim
|
||||
" ------------------------------------------------------------------------
|
||||
|
||||
let s:settings = {
|
||||
\ 'use_tabs_not_buffers': 1,
|
||||
\ 'auto_initialization': 1,
|
||||
\ 'auto_vim_configuration': 1,
|
||||
\ 'goto_command': "'<leader>g'",
|
||||
\ 'autocompletion_command': "'<C-Space>'",
|
||||
\ 'get_definition_command': "'<leader>d'",
|
||||
\ 'related_names_command': "'<leader>n'",
|
||||
\ 'goto_assignments_command': "'<leader>g'",
|
||||
\ 'completions_command': "'<C-Space>'",
|
||||
\ 'goto_definitions_command': "'<leader>d'",
|
||||
\ 'call_signatures_command': "'<leader>n'",
|
||||
\ 'usages_command': "'<leader>n'",
|
||||
\ 'rename_command': "'<leader>r'",
|
||||
\ 'popup_on_dot': 1,
|
||||
\ 'pydoc': "'K'",
|
||||
\ 'show_function_definition': 1,
|
||||
\ 'documentation_command': "'K'",
|
||||
\ 'show_call_signatures': 1,
|
||||
\ 'call_signature_escape': "'≡'",
|
||||
\ 'auto_close_doc': 1,
|
||||
\ 'popup_select_first': 1,
|
||||
@@ -52,7 +76,7 @@ if g:jedi#auto_initialization
|
||||
" this is only here because in some cases the VIM library adds their
|
||||
" autocompletion as a default, which may cause problems, depending on the
|
||||
" order of invocation.
|
||||
autocmd FileType Python setlocal omnifunc=jedi#completions switchbuf=useopen " needed for pydoc
|
||||
autocmd FileType Python setlocal omnifunc=jedi#completions switchbuf=useopen " needed for documentation/pydoc
|
||||
endif
|
||||
|
||||
fun! Pyimport(cmd, args)
|
||||
|
||||
@@ -161,7 +161,7 @@ def goto(is_definition=False, is_related_name=False, no_output=False):
|
||||
return definitions
|
||||
|
||||
|
||||
def show_pydoc():
|
||||
def show_documentation():
|
||||
script = get_script()
|
||||
try:
|
||||
definitions = script.goto_definitions()
|
||||
@@ -200,7 +200,7 @@ def clear_call_signatures():
|
||||
|
||||
|
||||
def show_call_signatures(call_def=None, completion_lines=0):
|
||||
if vim.eval("has('conceal') && g:jedi#show_function_definition") == '0':
|
||||
if vim.eval("has('conceal') && g:jedi#show_call_signatures") == '0':
|
||||
return
|
||||
try:
|
||||
if call_def == None:
|
||||
|
||||
Reference in New Issue
Block a user