From 9c9a513aafcc563f8e9e930a3ea99ed4ad21f31b Mon Sep 17 00:00:00 2001 From: Dave Halter Date: Sun, 16 Jun 2019 09:39:50 +0200 Subject: [PATCH] Add a goto_stubs command --- autoload/jedi.vim | 5 +++++ ftplugin/python/jedi.vim | 3 +++ plugin/jedi.vim | 5 +++++ pythonx/jedi_vim.py | 2 ++ 4 files changed, 15 insertions(+) diff --git a/autoload/jedi.vim b/autoload/jedi.vim index dd6d7cc..4432d1a 100644 --- a/autoload/jedi.vim +++ b/autoload/jedi.vim @@ -19,6 +19,7 @@ let s:default_settings = { \ 'goto_command': "'d'", \ 'goto_assignments_command': "'g'", \ 'goto_definitions_command': "''", + \ 'goto_stubs_command': "'s'", \ 'completions_command': "''", \ 'call_signatures_command': "'n'", \ 'usages_command': "'n'", @@ -287,6 +288,10 @@ function! jedi#goto_definitions() abort PythonJedi jedi_vim.goto(mode="definition") endfunction +function! jedi#goto_stubs() abort + PythonJedi jedi_vim.goto(mode="stubs") +endfunction + function! jedi#usages() abort call jedi#remove_usages() PythonJedi jedi_vim.usages() diff --git a/ftplugin/python/jedi.vim b/ftplugin/python/jedi.vim index 0708a5b..7156844 100644 --- a/ftplugin/python/jedi.vim +++ b/ftplugin/python/jedi.vim @@ -16,6 +16,9 @@ if g:jedi#auto_initialization if len(g:jedi#goto_definitions_command) execute 'nnoremap '.g:jedi#goto_definitions_command.' :call jedi#goto_definitions()' endif + if len(g:jedi#goto_stubs_command) + execute 'nnoremap '.g:jedi#goto_stubs_command.' :call jedi#goto_stubs()' + endif if len(g:jedi#usages_command) execute 'nnoremap '.g:jedi#usages_command.' :call jedi#usages()' endif diff --git a/plugin/jedi.vim b/plugin/jedi.vim index 9245bba..2f8e124 100644 --- a/plugin/jedi.vim +++ b/plugin/jedi.vim @@ -15,6 +15,11 @@ if get(g:, 'jedi#auto_vim_configuration', 1) " jedi-vim really needs, otherwise jedi-vim cannot start. 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. " This gets done on VimEnter, since otherwise Vim fails to restore the " screen. Neovim is not affected, this is likely caused by using diff --git a/pythonx/jedi_vim.py b/pythonx/jedi_vim.py index 71dbf20..382d5c9 100644 --- a/pythonx/jedi_vim.py +++ b/pythonx/jedi_vim.py @@ -304,6 +304,8 @@ def goto(mode="goto"): definitions = script.goto_definitions() elif mode == "assignment": definitions = script.goto_assignments() + elif mode == "stubs": + definitions = script.goto_assignments(follow_imports=True, only_stubs=True) if not definitions: echo_highlight("Couldn't find any definitions for this.")