@@ -27,6 +27,7 @@ let s:default_settings = {
2727 \ ' documentation_command' : " 'K'" ,
2828 \ ' show_call_signatures' : 1 ,
2929 \ ' show_call_signatures_delay' : 500 ,
30+ \ ' show_call_signatures_modes' : " 'i'" ,
3031 \ ' call_signature_escape' : " '?!?'" ,
3132 \ ' auto_close_doc' : 1 ,
3233 \ ' max_doc_height' : 30 ,
@@ -425,7 +426,7 @@ function! jedi#show_call_signatures()
425426endfunction
426427
427428function ! s: show_call_signatures_delayed_cb (timer) abort
428- if getpos (' .' ) == s: show_call_signatures_delayed_pos
429+ if [ getpos (' .' ), mode ()] == s: show_call_signatures_delayed_posmode
429430 call jedi#show_call_signatures ()
430431 endif
431432endfunction
@@ -438,7 +439,7 @@ function! jedi#show_call_signatures_delayed() abort
438439 if line (' .' ) != s: show_call_signatures_last [0 ]
439440 call jedi#clear_call_signatures ()
440441 endif
441- let s: show_call_signatures_delayed_pos = getpos (' .' )
442+ let s: show_call_signatures_delayed_posmode = [ getpos (' .' ), mode ()]
442443 let s: show_call_signatures_timer = timer_start (
443444 \ g: jedi #show_call_signatures_delay,
444445 \ function (' s:show_call_signatures_delayed_cb' ))
@@ -467,6 +468,9 @@ function! jedi#configure_call_signatures(...) abort
467468 let old = s: prev_show_call_signatures
468469 let new = g: jedi #show_call_signatures
469470 endif
471+ if a: 0 > 1
472+ let g: jedi #show_call_signatures_modes = a: 2
473+ endif
470474
471475 if new == 1 && ! has (' conceal' )
472476 echohl WarningMsg
@@ -535,28 +539,56 @@ function! jedi#configure_call_signatures(...) abort
535539 " autocmd Syntax <buffer> debug call jedi#configure_call_signatures()
536540 endif
537541
538- autocmd InsertEnter <buffer> let s: show_call_signatures_last = [0 , 0 , ' ' ]
539- autocmd InsertLeave <buffer> call jedi#clear_call_signatures ()
542+ if g: jedi #show_call_signatures_modes = ~# ' i' && g: jedi #show_call_signatures_modes !~# ' n'
543+ autocmd InsertLeave <buffer> call jedi#clear_call_signatures ()
544+ endif
540545
541546 if g: jedi #show_call_signatures_delay > 0
542547 if has (' timers' )
543- autocmd InsertEnter ,CursorMovedI <buffer> call jedi#show_call_signatures_delayed ()
548+ if g: jedi #show_call_signatures_modes = ~# ' n'
549+ autocmd WinEnter ,CursorMoved <buffer> call jedi#show_call_signatures_delayed ()
550+ endif
551+ if g: jedi #show_call_signatures_modes = ~# ' i'
552+ autocmd InsertEnter ,CursorMovedI <buffer> call jedi#show_call_signatures_delayed ()
553+ elseif g: jedi #show_call_signatures_modes = ~# ' n'
554+ autocmd InsertEnter <buffer> call jedi#clear_call_signatures ()
555+ endif
544556 else
545557 autocmd InsertEnter <buffer> let b: _jedi_orig_updatetime = &updatetime
546558 \ | let &updatetime = g: jedi #show_call_signatures_delay
547559 autocmd InsertLeave <buffer> if exists (' b:_jedi_orig_updatetime' )
548560 \ | let &updatetime = b: _jedi_orig_updatetime
549561 \ | unlet b: _jedi_orig_updatetime
550562 \ | endif
551- autocmd CursorHoldI <buffer> call jedi#show_call_signatures ()
552- " Clear signatures immediately when changing lines.
553- autocmd CursorMovedI <buffer>
554- \ if line (' .' ) != s: show_call_signatures_last [0 ]
555- \ | call jedi#clear_call_signatures ()
556- \ | endif
563+
564+ if g: jedi #show_call_signatures_modes = ~# ' n'
565+ " Note: does not use g:jedi#show_call_signatures_delay!
566+ autocmd WinEnter ,CursorHold <buffer> call jedi#show_call_signatures ()
567+ " Clear signatures immediately when changing lines.
568+ autocmd CursorMoved <buffer>
569+ \ if line (' .' ) != s: show_call_signatures_last [0 ]
570+ \ | call jedi#clear_call_signatures ()
571+ \ | endif
572+ endif
573+ if g: jedi #show_call_signatures_modes = ~# ' i'
574+ autocmd CursorHoldI <buffer> call jedi#show_call_signatures ()
575+ " Clear signatures immediately when changing lines.
576+ autocmd CursorMovedI <buffer>
577+ \ if line (' .' ) != s: show_call_signatures_last [0 ]
578+ \ | call jedi#clear_call_signatures ()
579+ \ | endif
580+ endif
557581 endif
558582 else
559- autocmd CursorMovedI <buffer> call jedi#show_call_signatures ()
583+ if g: jedi #show_call_signatures_modes = ~# ' n'
584+ " Note: does not use g:jedi#show_call_signatures_delay!
585+ " Should probably have a warning, at least in the docs about that
586+ " option! (without any delay)
587+ autocmd CursorMoved <buffer> call jedi#show_call_signatures ()
588+ endif
589+ if g: jedi #show_call_signatures_modes = ~# ' i'
590+ autocmd CursorMovedI <buffer> call jedi#show_call_signatures ()
591+ endif
560592 endif
561593 augroup END
562594endfunction
0 commit comments