Add option to show call signatures in command line

This commit is contained in:
Jacob Niehus
2014-10-19 14:35:11 -07:00
parent 0ce1af78b2
commit cfd71a6b54
5 changed files with 113 additions and 4 deletions

View File

@@ -155,10 +155,60 @@ endfunction
function! jedi#configure_call_signatures()
if g:jedi#show_call_signatures == 2 " Command line call signatures
" Need to track changes to avoid multiple undo points for a single edit
let b:normaltick = b:changedtick
autocmd TextChanged,InsertLeave,BufWinEnter <buffer> let b:normaltick = b:changedtick
endif
autocmd InsertEnter <buffer> let g:jedi#first_col = s:save_first_col()
autocmd InsertLeave <buffer> Python jedi_vim.clear_call_signatures()
autocmd CursorMovedI <buffer> Python jedi_vim.show_call_signatures()
endfunction
" Determine where the current window is on the screen for displaying call
" signatures in the correct column.
function! s:save_first_col()
let gutterwidth = &fdc + &number * max([&numberwidth, len(line('$')) + 1])
if bufname('%') ==# '[Command Line]' | return gutterwidth + 1 | endif
if winnr('$') == 1 | return gutterwidth | endif
let l:eventignore = &eventignore
set eventignore=all
let startwin = winnr()
let startaltwin = winnr('#')
let winwidth = winwidth(0)
try
wincmd h
let win_on_left = winnr() == startwin
if win_on_left
return gutterwidth
else
" Walk left and count up window widths until hitting the edge
execute startwin."wincmd w"
let width = 0
let winnr = winnr()
wincmd h
while winnr != winnr()
let width += winwidth(0) + 1 " Extra column for window divider
let winnr = winnr()
wincmd h
endwhile
return width + gutterwidth
endif
finally
let &eventignore = l:eventignore
execute startaltwin."wincmd w"
execute startwin."wincmd w"
" If the event that triggered InsertEnter made a change (e.g. open a
" new line, substitude a word), join that change with the rest of this
" edit.
if b:normaltick != b:changedtick
undojoin
endif
endtry
endfunction
" Helper function instead of `python vim.eval()`, and `.command()` because
" these also return error definitions.
function! jedi#_vim_exceptions(str, is_eval)