Skip to content

Commit

Permalink
Add a goto_stubs command
Browse files Browse the repository at this point in the history
  • Loading branch information
davidhalter committed Jun 16, 2019
1 parent 23c14f6 commit 9c9a513
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 0 deletions.
5 changes: 5 additions & 0 deletions autoload/jedi.vim
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ let s:default_settings = {
\ 'goto_command': "'<leader>d'",
\ 'goto_assignments_command': "'<leader>g'",
\ 'goto_definitions_command': "''",
\ 'goto_stubs_command': "'<leader>s'",
\ 'completions_command': "'<C-Space>'",
\ 'call_signatures_command': "'<leader>n'",
\ 'usages_command': "'<leader>n'",
Expand Down Expand Up @@ -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()
Expand Down
3 changes: 3 additions & 0 deletions ftplugin/python/jedi.vim
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ if g:jedi#auto_initialization
if len(g:jedi#goto_definitions_command)
execute 'nnoremap <buffer> '.g:jedi#goto_definitions_command.' :call jedi#goto_definitions()<CR>'
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)
execute 'nnoremap <buffer> '.g:jedi#usages_command.' :call jedi#usages()<CR>'
endif
Expand Down
5 changes: 5 additions & 0 deletions plugin/jedi.vim
Original file line number Diff line number Diff line change
Expand Up @@ -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

This comment has been minimized.

Copy link
@blueyed

blueyed Jun 16, 2019

Collaborator

Overly indented.


" 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
Expand Down
2 changes: 2 additions & 0 deletions pythonx/jedi_vim.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.")
Expand Down

2 comments on commit 9c9a513

@richin13
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey, this commit broke my jedi-vim installation:

Error detected while processing /home/ricardo/.vim/plugged/jedi-vim/ftplugin/python/jedi.vim:
line   19:
E121: Undefined variable: g:jedi#goto_stubs_command
E116: Invalid arguments for function len
E15: Invalid expression: len(g:jedi#goto_stubs_command)

I tried looking at the docs about this new option but couldn't find anything 😢

@blueyed
Copy link
Collaborator

@blueyed blueyed commented on 9c9a513 Jul 5, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just for reference: let's follow up in #932.

Please sign in to comment.