@@ -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 ,
@@ -413,7 +414,7 @@ function! jedi#show_call_signatures()
413414endfunction
414415
415416function ! s: show_call_signatures_delayed_cb (timer) abort
416- if getpos (' .' ) == s: show_call_signatures_delayed_pos
417+ if [ getpos (' .' ), mode ()] == s: show_call_signatures_delayed_posmode
417418 call jedi#show_call_signatures ()
418419 endif
419420endfunction
@@ -426,7 +427,7 @@ function! jedi#show_call_signatures_delayed() abort
426427 if line (' .' ) != s: show_call_signatures_last [0 ]
427428 call jedi#clear_call_signatures ()
428429 endif
429- let s: show_call_signatures_delayed_pos = getpos (' .' )
430+ let s: show_call_signatures_delayed_posmode = [ getpos (' .' ), mode ()]
430431 let s: show_call_signatures_timer = timer_start (
431432 \ g: jedi #show_call_signatures_delay,
432433 \ function (' s:show_call_signatures_delayed_cb' ))
@@ -455,6 +456,9 @@ function! jedi#configure_call_signatures(...) abort
455456 let old = s: prev_show_call_signatures
456457 let new = g: jedi #show_call_signatures
457458 endif
459+ if a: 0 > 1
460+ let g: jedi #show_call_signatures_modes = a: 2
461+ endif
458462
459463 if new == 1 && ! has (' conceal' )
460464 echohl WarningMsg
@@ -523,28 +527,56 @@ function! jedi#configure_call_signatures(...) abort
523527 " autocmd Syntax <buffer> debug call jedi#configure_call_signatures()
524528 endif
525529
526- autocmd InsertEnter <buffer> let s: show_call_signatures_last = [0 , 0 , ' ' ]
527- autocmd InsertLeave <buffer> call jedi#clear_call_signatures ()
530+ if g: jedi #show_call_signatures_modes = ~# ' i' && g: jedi #show_call_signatures_modes !~# ' n'
531+ autocmd InsertLeave <buffer> call jedi#clear_call_signatures ()
532+ endif
528533
529534 if g: jedi #show_call_signatures_delay > 0
530535 if has (' timers' )
531- autocmd InsertEnter ,CursorMovedI <buffer> call jedi#show_call_signatures_delayed ()
536+ if g: jedi #show_call_signatures_modes = ~# ' n'
537+ autocmd WinEnter ,CursorMoved <buffer> call jedi#show_call_signatures_delayed ()
538+ endif
539+ if g: jedi #show_call_signatures_modes = ~# ' i'
540+ autocmd InsertEnter ,CursorMovedI <buffer> call jedi#show_call_signatures_delayed ()
541+ elseif g: jedi #show_call_signatures_modes = ~# ' n'
542+ autocmd InsertEnter <buffer> call jedi#clear_call_signatures ()
543+ endif
532544 else
533545 autocmd InsertEnter <buffer> let b: _jedi_orig_updatetime = &updatetime
534546 \ | let &updatetime = g: jedi #show_call_signatures_delay
535547 autocmd InsertLeave <buffer> if exists (' b:_jedi_orig_updatetime' )
536548 \ | let &updatetime = b: _jedi_orig_updatetime
537549 \ | unlet b: _jedi_orig_updatetime
538550 \ | endif
539- autocmd CursorHoldI <buffer> call jedi#show_call_signatures ()
540- " Clear signatures immediately when changing lines.
541- autocmd CursorMovedI <buffer>
542- \ if line (' .' ) != s: show_call_signatures_last [0 ]
543- \ | call jedi#clear_call_signatures ()
544- \ | endif
551+
552+ if g: jedi #show_call_signatures_modes = ~# ' n'
553+ " Note: does not use g:jedi#show_call_signatures_delay!
554+ autocmd WinEnter ,CursorHold <buffer> call jedi#show_call_signatures ()
555+ " Clear signatures immediately when changing lines.
556+ autocmd CursorMoved <buffer>
557+ \ if line (' .' ) != s: show_call_signatures_last [0 ]
558+ \ | call jedi#clear_call_signatures ()
559+ \ | endif
560+ endif
561+ if g: jedi #show_call_signatures_modes = ~# ' i'
562+ autocmd CursorHoldI <buffer> call jedi#show_call_signatures ()
563+ " Clear signatures immediately when changing lines.
564+ autocmd CursorMovedI <buffer>
565+ \ if line (' .' ) != s: show_call_signatures_last [0 ]
566+ \ | call jedi#clear_call_signatures ()
567+ \ | endif
568+ endif
545569 endif
546570 else
547- autocmd CursorMovedI <buffer> call jedi#show_call_signatures ()
571+ if g: jedi #show_call_signatures_modes = ~# ' n'
572+ " Note: does not use g:jedi#show_call_signatures_delay!
573+ " Should probably have a warning, at least in the docs about that
574+ " option! (without any delay)
575+ autocmd CursorMoved <buffer> call jedi#show_call_signatures ()
576+ endif
577+ if g: jedi #show_call_signatures_modes = ~# ' i'
578+ autocmd CursorMovedI <buffer> call jedi#show_call_signatures ()
579+ endif
548580 endif
549581 augroup END
550582endfunction
0 commit comments