Skip to content

Commit

Permalink
Declare similar autocmds next to each other
Browse files Browse the repository at this point in the history
  • Loading branch information
airblade committed Jun 1, 2023
1 parent 250112f commit 8d659d3
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions plugin/gitgutter.vim
Original file line number Diff line number Diff line change
Expand Up @@ -296,9 +296,6 @@ augroup gitgutter

autocmd User FugitiveChanged call gitgutter#all(1)

autocmd BufFilePre * let b:gitgutter_was_enabled = gitgutter#utility#getbufvar(expand('<abuf>'), 'enabled') | GitGutterBufferDisable
autocmd BufFilePost * if b:gitgutter_was_enabled | GitGutterBufferEnable | endif | unlet b:gitgutter_was_enabled

" Handle all buffers when focus is gained, but only after it was lost.
" FocusGained gets triggered on startup with Neovim at least already.
" Therefore this tracks also if it was lost before.
Expand All @@ -312,6 +309,8 @@ augroup gitgutter

autocmd ColorScheme * call gitgutter#highlight#define_highlights()

autocmd BufFilePre * let b:gitgutter_was_enabled = gitgutter#utility#getbufvar(expand('<abuf>'), 'enabled') | GitGutterBufferDisable
autocmd BufFilePost * if b:gitgutter_was_enabled | GitGutterBufferEnable | endif | unlet b:gitgutter_was_enabled
" Disable during :vimgrep
autocmd QuickFixCmdPre *vimgrep* let b:gitgutter_was_enabled = gitgutter#utility#getbufvar(expand('<abuf>'), 'enabled') | GitGutterBufferDisable
autocmd QuickFixCmdPost *vimgrep* if b:gitgutter_was_enabled | GitGutterBufferEnable | endif | unlet b:gitgutter_was_enabled
Expand Down

0 comments on commit 8d659d3

Please sign in to comment.