@@ -220,9 +220,9 @@ function! blamer#Show() abort
220220 return
221221 endif
222222
223- if mode () == ' i' && s: blamer_show_in_insert_modes == 0
224- return
225- endif
223+ " if mode() == 'i' && s:blamer_show_in_insert_modes == 0
224+ " return
225+ " endif
226226
227227 for line_number in l: line_numbers
228228 let l: message = blamer#GetMessage (l: file_path , line_number, ' +1' )
@@ -274,16 +274,40 @@ function! blamer#Disable() abort
274274 endif
275275
276276 let g: blamer_enabled = 0
277- autocmd ! blamer
278277 call timer_stop (s: blamer_timer_id )
279278 let s: blamer_timer_id = -1
280279endfunction
281280
281+ function ! blamer#EnableOnInsertLeave () abort
282+ if g: blamer_show_on_insert_leave == 0
283+ return
284+ endif
285+
286+ let g: blamer_show_on_insert_leave = 0
287+ call blamer#Enable ()
288+ call blamer#Show ()
289+ endfunction
290+
291+ function ! blamer#DisableOnInsertEnter () abort
292+ if g: blamer_enabled == 0
293+ return
294+ endif
295+
296+ let g: blamer_show_on_insert_leave = 1
297+ call blamer#Disable ()
298+ call blamer#Hide ()
299+ endfunction
300+
282301function ! blamer#Init () abort
283302 if g: blamer_enabled == 0
284303 return
285304 endif
286305
306+ if g: blamer_is_initialized == 1
307+ return
308+ endif
309+ let g: blamer_is_initialized = 1
310+
287311 if s: missing_popup_feature
288312 echohl ErrorMsg
289313 echomsg ' [blamer.nvim] Needs popup feature.'
@@ -309,6 +333,10 @@ function! blamer#Init() abort
309333 augroup blamer
310334 autocmd !
311335 autocmd BufEnter ,BufWritePost ,CursorMoved * :call blamer#Refresh ()
336+ if s: blamer_show_in_insert_modes == 0
337+ autocmd InsertEnter * :call blamer#DisableOnInsertEnter ()
338+ autocmd InsertLeave * :call blamer#EnableOnInsertLeave ()
339+ endif
312340 augroup END
313341endfunction
314342
0 commit comments