Allow user to turn GitGutter off and on.

This commit is contained in:
Andy Stewart
2013-02-26 09:35:04 +01:00
parent e989037f84
commit 0c16f257d6
2 changed files with 22 additions and 1 deletions

View File

@@ -26,6 +26,13 @@ git clone git://github.com/airblade/vim-gitgutter.git
```
### Usage
You don't have to do anything: it just works.
You can turn vim-gitgutter off with `:call DisableGitGutter()` and on again with `:call EnableGitGutter()`. If you do this often I suggest adding mappings for these.
### FAQ
> The colours in the sign column are weird.

View File

@@ -5,6 +5,8 @@ let g:loaded_gitgutter = 1
" Initialisation {{{
let s:gitgutter_enabled = 1
function! s:init()
if !exists('g:gitgutter_initialised')
call s:define_highlights()
@@ -40,6 +42,10 @@ endfunction
" Utility {{{
function! s:is_gitgutter_enabled()
return s:gitgutter_enabled
endfunction
function! s:current_file()
return expand("%:p")
endfunction
@@ -215,7 +221,7 @@ endfunction
" Public interface {{{
function! GitGutter()
if s:exists_current_file() && s:is_in_a_git_repo() && s:is_tracked_by_git()
if s:is_gitgutter_enabled() && s:exists_current_file() && s:is_in_a_git_repo() && s:is_tracked_by_git()
call s:init()
let diff = s:run_diff()
let hunks = s:parse_diff(diff)
@@ -227,6 +233,14 @@ function! GitGutter()
endif
endfunction
function! DisableGitGutter()
let s:gitgutter_enabled = 0
endfunction
function! EnableGitGutter()
let s:gitgutter_enabled = 1
endfunction
augroup gitgutter
autocmd!
autocmd BufReadPost,BufWritePost,FileReadPost,FileWritePost * call GitGutter()