File rename autocommands don't respect g:gitgutter_enabled.
tjakway opened this issue · 3 comments
What is the latest commit SHA in your installed vim-gitgutter?
2ee95686c5944f99b42dd04fec005b30497006de
HEAD as of today.
What vim/nvim version are you on?
v0.9.2-dev-14+g06d137681
Neovim: the tip of the release-0.9 branch as of today.
File rename autocommands don't respect g:gitgutter_enabled.
The relevant lines in plugin/gitgutter.vim:
autocmd BufFilePre * GitGutterBufferDisable
autocmd BufFilePost * GitGutterBufferEnable
I prefer to leave git gutter off until I explicitly turn it on. In my vimrc:
let g:gitgutter_enabled=0
nmap <F7> :GitGutterToggle<CR>
I ran across this when I added this snippet from tpope/vim-fugitive#147 (comment) to my vimrc:
function! MyFollowSymlink(...) abort
let fname = a:0 ? a:1 : expand('%')
if getftype(fname) != 'link'
return
endif
let resolvedfile = fnameescape(resolve(fname))
exec 'file ' . resolvedfile
endfunction
command! FollowSymlink call MyFollowSymlink()
And then called FollowSymlink while editing my vimrc and git gutter enabled itself.
Whenever a file is renamed (such as by following a symlink) the autocommand will run. This isn't obvious unless the new path is in a git directory (since you won't see anything) but overwriting the user's buffer settings is still not nice.
overwriting the user's buffer settings is still not nice
This is a bit melodramatic. It's a small bug, not a deliberate plot.
Those autocommands were added about four years ago so gitgutter would keep working across file renames via :saveas
(#551). In retrospect they should be aware of whether or not the buffer was enabled.
I will fix this when I can make some time.
overwriting the user's buffer settings is still not nice
This is a bit melodramatic. It's a small bug, not a deliberate plot.
Of course. I just meant this is probably not ideal.
I've commented those lines out in my checkout, which is sufficient for me for now.
I overreacted, I'm sorry.