Skip to content

Commit

Permalink
Add opt-out configuration for BufEnter and FocusGained.
Browse files Browse the repository at this point in the history
  • Loading branch information
airblade committed Mar 15, 2013
1 parent 04be163 commit 677dac4
Show file tree
Hide file tree
Showing 3 changed files with 59 additions and 4 deletions.
22 changes: 22 additions & 0 deletions README.mkd
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,8 @@ You can customise:
* Line highlights
* Whether or not vim-gitgutter is on initially (defaults to on)
* 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)

Please note that vim-gitgutter won't override any colours or highlights you've set in your colorscheme.

Expand Down Expand Up @@ -133,6 +135,26 @@ Add `let g:gitgutter_enabled = 0` to your `~/.vimrc`.
Add `let g:gitgutter_highlight_lines = 1` to your `~/.vimrc`.


#### To stop vim-gitgutter running on `BufEnter`

This is on by default but causes a noticeable lag for some people. To turn it off, add this to your ~/.vimrc`:

```
let g:gitgutter_on_bufenter = 0
```


#### To stop vim-gitgutter running for all 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`:

```
let g:gitgutter_all_on_focusgained = 0
```

Note that this is always off with gVim on Windows due to a Vim/shell bug causing an infinite loop.


### FAQ

> Why are the colours in the sign column weird?
Expand Down
28 changes: 25 additions & 3 deletions doc/gitgutter.txt
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,9 @@ You can customise:
- Line highlights
- Whether or not vim-gitgutter is on initially (defaults to on)
- 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)

Please note that vim-gitgutter won't override any colours or highlights you've
set in your colorscheme.
Expand Down Expand Up @@ -147,7 +150,6 @@ LINE HIGHLIGHTS

Similarly to the signs' colours, set up the following highlight groups in your
colorscheme or |vimrc|:

>
GitGutterAddLine " default: links to DiffAdd
GitGutterChangeLine " default: links to DiffChange
Expand All @@ -157,11 +159,31 @@ colorscheme or |vimrc|:

TO TURN OFF VIM-GITGUTTER BY DEFAULT

Add `let g:gitgutter_enabled = 0` to your |vimrc|.
Add to your |vimrc|
>
let g:gitgutter_enabled = 0
<

TO TURN ON LINE HIGHLIGHTING BY DEFAULT

Add `let g:gitgutter_highlight_lines = 1` to your |vimrc|.
Add to your |vimrc|
>
let g:gitgutter_highlight_lines = 1
<

TO STOP VIM-GITGUTTER RUNNING ON |BUFENTER|

Add to your |vimrc|
>
let g:gitgutter_on_bufenter = 0
<

TO STOP VIM-GITGUTTER RUNNING ON |FOCUSGAINED|

Add to your |vimrc|
>
let g:gitgutter_all_on_focusgained = 0
<


===============================================================================
Expand Down
13 changes: 12 additions & 1 deletion plugin/gitgutter.vim
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,14 @@ if !exists('g:gitgutter_sign_column_always')
let g:gitgutter_sign_column_always = 0
endif

if !exists('g:gitgutter_on_bufenter')
let g:gitgutter_on_bufenter = 1
endif

if !exists('g:gitgutter_all_on_focusgained')
let g:gitgutter_all_on_focusgained = 1
endif

let s:file = ''

function! s:init()
Expand Down Expand Up @@ -500,7 +508,10 @@ endfunction
augroup gitgutter
autocmd!
autocmd BufReadPost,BufWritePost,FileReadPost,FileWritePost * call GitGutter(s:current_file())
if !has('gui_win32')
if g:gitgutter_on_bufenter
autocmd BufEnter * call GitGutter(s:current_file())
endif
if g:gitgutter_all_on_focusgained && !has('gui_win32')
autocmd FocusGained * call GitGutterAll()
endif
augroup END
Expand Down

0 comments on commit 677dac4

Please sign in to comment.