Skip to content

Commit 1144204

Browse files
committed
fix hide/show blame on insert enter/leave
1 parent 15960b4 commit 1144204

File tree

2 files changed

+34
-4
lines changed

2 files changed

+34
-4
lines changed

autoload/blamer.vim

Lines changed: 32 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -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
280279
endfunction
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+
282301
function! 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
313341
endfunction
314342

plugin/blamer.vim

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ if exists('g:blamer_loaded')
22
finish
33
endif
44
let g:blamer_loaded = 1
5+
let g:blamer_is_initialized = 0
6+
let g:blamer_show_on_insert_leave = 0
57

68
let s:save_cpo = &cpo
79
set cpo&vim

0 commit comments

Comments
 (0)