mirror of
https://github.com/airblade/vim-gitgutter.git
synced 2025-11-09 12:03: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
|
### FAQ
|
||||||
|
|
||||||
> The colours in the sign column are weird.
|
> The colours in the sign column are weird.
|
||||||
|
|||||||
@@ -5,6 +5,8 @@ let g:loaded_gitgutter = 1
|
|||||||
|
|
||||||
" Initialisation {{{
|
" Initialisation {{{
|
||||||
|
|
||||||
|
let s:gitgutter_enabled = 1
|
||||||
|
|
||||||
function! s:init()
|
function! s:init()
|
||||||
if !exists('g:gitgutter_initialised')
|
if !exists('g:gitgutter_initialised')
|
||||||
call s:define_highlights()
|
call s:define_highlights()
|
||||||
@@ -40,6 +42,10 @@ endfunction
|
|||||||
|
|
||||||
" Utility {{{
|
" Utility {{{
|
||||||
|
|
||||||
|
function! s:is_gitgutter_enabled()
|
||||||
|
return s:gitgutter_enabled
|
||||||
|
endfunction
|
||||||
|
|
||||||
function! s:current_file()
|
function! s:current_file()
|
||||||
return expand("%:p")
|
return expand("%:p")
|
||||||
endfunction
|
endfunction
|
||||||
@@ -215,7 +221,7 @@ endfunction
|
|||||||
" Public interface {{{
|
" Public interface {{{
|
||||||
|
|
||||||
function! GitGutter()
|
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()
|
call s:init()
|
||||||
let diff = s:run_diff()
|
let diff = s:run_diff()
|
||||||
let hunks = s:parse_diff(diff)
|
let hunks = s:parse_diff(diff)
|
||||||
@@ -227,6 +233,14 @@ function! GitGutter()
|
|||||||
endif
|
endif
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
|
function! DisableGitGutter()
|
||||||
|
let s:gitgutter_enabled = 0
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
function! EnableGitGutter()
|
||||||
|
let s:gitgutter_enabled = 1
|
||||||
|
endfunction
|
||||||
|
|
||||||
augroup gitgutter
|
augroup gitgutter
|
||||||
autocmd!
|
autocmd!
|
||||||
autocmd BufReadPost,BufWritePost,FileReadPost,FileWritePost * call GitGutter()
|
autocmd BufReadPost,BufWritePost,FileReadPost,FileWritePost * call GitGutter()
|
||||||
|
|||||||
Reference in New Issue
Block a user