Skip to content

Commit 7d5c64c

Browse files
author
George Sofianos
committed
update git user info on buffer enter
1 parent 724da91 commit 7d5c64c

File tree

1 file changed

+15
-3
lines changed

1 file changed

+15
-3
lines changed

autoload/blamer.vim

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -287,6 +287,20 @@ function! blamer#Hide() abort
287287
endif
288288
endfunction
289289

290+
function! blamer#UpdateGitUserConfig() abort
291+
let l:dir_path = shellescape(s:substitute_path_separator(expand('%:h')))
292+
let s:blamer_user_name = s:Head(split(system('git -C ' . l:dir_path . ' config --get user.name'), '\n'))
293+
let s:blamer_user_email = s:Head(split(system('git -C ' . l:dir_path . ' config --get user.email'), '\n'))
294+
endfunction
295+
296+
function! blamer#BufferEnter() abort
297+
if g:blamer_enabled == 0
298+
return
299+
endif
300+
301+
call blamer#UpdateGitUserConfig()
302+
endfunction
303+
290304
function! blamer#Refresh() abort
291305
if g:blamer_enabled == 0
292306
return
@@ -353,11 +367,9 @@ function! blamer#Init() abort
353367
return
354368
endif
355369

356-
let s:blamer_user_name = s:Head(split(system('git config --get user.name'), '\n'))
357-
let s:blamer_user_email = s:Head(split(system('git config --get user.email'), '\n'))
358-
359370
augroup blamer
360371
autocmd!
372+
autocmd BufEnter * :call blamer#BufferEnter()
361373
autocmd BufEnter,BufWritePost,CursorMoved * :call blamer#Refresh()
362374
if s:blamer_show_in_insert_modes == 0
363375
autocmd InsertEnter * :call blamer#DisableOnInsertEnter()

0 commit comments

Comments
 (0)