diff --git a/README.mkd b/README.mkd index 2e72a95..c38ed23 100644 --- a/README.mkd +++ b/README.mkd @@ -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. diff --git a/plugin/gitgutter.vim b/plugin/gitgutter.vim index dcb77a3..f30b6d5 100644 --- a/plugin/gitgutter.vim +++ b/plugin/gitgutter.vim @@ -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()