Add a goto_stubs command

This commit is contained in:
Dave Halter
2019-06-16 09:39:50 +02:00
parent 23c14f6826
commit 9c9a513aaf
4 changed files with 15 additions and 0 deletions

View File

@@ -19,6 +19,7 @@ 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'",
@@ -287,6 +288,10 @@ function! jedi#goto_definitions() abort
PythonJedi jedi_vim.goto(mode="definition") PythonJedi jedi_vim.goto(mode="definition")
endfunction endfunction
function! jedi#goto_stubs() abort
PythonJedi jedi_vim.goto(mode="stubs")
endfunction
function! jedi#usages() abort function! jedi#usages() abort
call jedi#remove_usages() call jedi#remove_usages()
PythonJedi jedi_vim.usages() PythonJedi jedi_vim.usages()

View File

@@ -16,6 +16,9 @@ if g:jedi#auto_initialization
if len(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 len(g:jedi#goto_stubs_command)
execute 'nnoremap <buffer> '.g:jedi#goto_stubs_command.' :call jedi#goto_stubs()<CR>'
endif
if len(g:jedi#usages_command) if len(g:jedi#usages_command)
execute 'nnoremap <buffer> '.g:jedi#usages_command.' :call jedi#usages()<CR>' execute 'nnoremap <buffer> '.g:jedi#usages_command.' :call jedi#usages()<CR>'
endif endif

View File

@@ -15,6 +15,11 @@ if get(g:, 'jedi#auto_vim_configuration', 1)
" jedi-vim really needs, otherwise jedi-vim cannot start. " jedi-vim really needs, otherwise jedi-vim cannot start.
filetype plugin on filetype plugin on
augroup jedi_pyi
au!
autocmd BufNewFile,BufRead *.pyi set filetype=python
augroup END
" Change completeopt, but only if it was not set already. " Change completeopt, but only if it was not set already.
" This gets done on VimEnter, since otherwise Vim fails to restore the " This gets done on VimEnter, since otherwise Vim fails to restore the
" screen. Neovim is not affected, this is likely caused by using " screen. Neovim is not affected, this is likely caused by using

View File

@@ -304,6 +304,8 @@ def goto(mode="goto"):
definitions = script.goto_definitions() definitions = script.goto_definitions()
elif mode == "assignment": elif mode == "assignment":
definitions = script.goto_assignments() definitions = script.goto_assignments()
elif mode == "stubs":
definitions = script.goto_assignments(follow_imports=True, only_stubs=True)
if not definitions: if not definitions:
echo_highlight("Couldn't find any definitions for this.") echo_highlight("Couldn't find any definitions for this.")