mirror of
https://github.com/airblade/vim-gitgutter.git
synced 2025-11-08 11:33:48 -05:00
Allow user to turn GitGutter off and on.
This commit is contained in:
@@ -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.
|
||||
|
||||
@@ -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()
|
||||
|
||||
Reference in New Issue
Block a user