Update only visible buffers on FocusGained and TabEnter.

This commit is contained in:
Andy Stewart
2013-04-02 11:37:37 +02:00
parent 15dc21aca5
commit 93288afef8
2 changed files with 9 additions and 14 deletions

View File

@@ -63,7 +63,7 @@ nmap <silent> ]h :<C-U>execute v:count1 . "GitGutterNextHunk"<CR>
nmap <silent> [h :<C-U>execute v:count1 . "GitGutterPrevHunk"<CR>
```
Finally, you can force vim-gitgutter to update its signs across all buffers with `:GitGutterAll`.
Finally, you can force vim-gitgutter to update its signs across all visible buffers with `:GitGutterAll`.
See the customisation section below for how to change the defaults.
@@ -81,7 +81,7 @@ You can customise:
* Whether or not signs are shown (defaults to yes)
* Whether or not line highlighting is on initially (defaults to off)
* Whether or not vim-gitgutter runs on `BufEnter` (defaults to yes)
* Whether or not vim-gitgutter runs for all buffers on `FocusGained` (defaults to yes)
* Whether or not vim-gitgutter runs for all visible buffers on `FocusGained` (defaults to yes)
Please note that vim-gitgutter won't override any colours or highlights you've set in your colorscheme.
@@ -173,7 +173,7 @@ let g:gitgutter_on_bufenter = 0
If you turn it off, vim-gitgutter will instead run every time you read or write a buffer.
#### To stop vim-gitgutter running for all buffers on `FocusGained`
#### To stop vim-gitgutter running for all visible buffers on `FocusGained`
This is on by default but causes a noticeable lag for some people. To turn it off, add this to your `~/.vimrc`:

View File

@@ -114,14 +114,6 @@ function! s:buffers()
return filter(range(1, bufnr('$')), 'buflisted(v:val)')
endfunction
function! s:visible_buffers()
let visible = []
for i in range(tabpagenr('$'))
call extend(visible, tabpagebuflist(i + 1))
endfor
return visible
endfunction
" }}}
" Highlights and signs {{{
@@ -399,7 +391,7 @@ endfunction
" Public interface {{{
function! GitGutterAll()
let buffer_ids = g:gitgutter_on_bufenter ? s:visible_buffers() : s:buffers()
let buffer_ids = g:gitgutter_on_bufenter ? tabpagebuflist() : s:buffers()
for buffer_id in buffer_ids
call GitGutter(expand('#' . buffer_id . ':p'))
endfor
@@ -524,9 +516,12 @@ augroup gitgutter
else
autocmd BufReadPost,BufWritePost,FileReadPost,FileWritePost * call GitGutter(s:current_file())
endif
if g:gitgutter_all_on_focusgained && !has('gui_win32')
if g:gitgutter_all_on_focusgained
if !has('gui_win32')
autocmd FocusGained * call GitGutterAll()
endif
autocmd TabEnter * call GitGutterAll()
endif
augroup END
" }}}