mirror of
https://github.com/airblade/vim-gitgutter.git
synced 2025-11-08 11:33:48 -05:00
@@ -21,6 +21,10 @@ endfunction
|
|||||||
function! gitgutter#process_buffer(bufnr, force) abort
|
function! gitgutter#process_buffer(bufnr, force) abort
|
||||||
" NOTE a:bufnr is not necessarily the current buffer.
|
" NOTE a:bufnr is not necessarily the current buffer.
|
||||||
|
|
||||||
|
if gitgutter#utility#getbufvar(a:bufnr, 'enabled', -1) == -1
|
||||||
|
call gitgutter#utility#setbufvar(a:bufnr, 'enabled', g:gitgutter_enabled)
|
||||||
|
endif
|
||||||
|
|
||||||
if gitgutter#utility#is_active(a:bufnr)
|
if gitgutter#utility#is_active(a:bufnr)
|
||||||
|
|
||||||
if has('patch-7.4.1559')
|
if has('patch-7.4.1559')
|
||||||
@@ -55,12 +59,11 @@ endfunction
|
|||||||
|
|
||||||
|
|
||||||
function! gitgutter#disable() abort
|
function! gitgutter#disable() abort
|
||||||
" get list of all buffers (across all tabs)
|
|
||||||
for bufnr in range(1, bufnr('$') + 1)
|
for bufnr in range(1, bufnr('$') + 1)
|
||||||
if buflisted(bufnr)
|
if buflisted(bufnr)
|
||||||
let file = expand('#'.bufnr.':p')
|
let file = expand('#'.bufnr.':p')
|
||||||
if !empty(file)
|
if !empty(file)
|
||||||
call s:clear(bufnr)
|
call gitgutter#buffer_disable(bufnr)
|
||||||
endif
|
endif
|
||||||
endif
|
endif
|
||||||
endfor
|
endfor
|
||||||
@@ -69,8 +72,16 @@ function! gitgutter#disable() abort
|
|||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! gitgutter#enable() abort
|
function! gitgutter#enable() abort
|
||||||
|
for bufnr in range(1, bufnr('$') + 1)
|
||||||
|
if buflisted(bufnr)
|
||||||
|
let file = expand('#'.bufnr.':p')
|
||||||
|
if !empty(file)
|
||||||
|
call gitgutter#buffer_enable(bufnr)
|
||||||
|
endif
|
||||||
|
endif
|
||||||
|
endfor
|
||||||
|
|
||||||
let g:gitgutter_enabled = 1
|
let g:gitgutter_enabled = 1
|
||||||
call gitgutter#all(1)
|
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! gitgutter#toggle() abort
|
function! gitgutter#toggle() abort
|
||||||
@@ -82,23 +93,24 @@ function! gitgutter#toggle() abort
|
|||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
|
|
||||||
function! gitgutter#buffer_disable() abort
|
function! gitgutter#buffer_disable(...) abort
|
||||||
let bufnr = bufnr('')
|
let bufnr = a:0 ? a:1 : bufnr('')
|
||||||
call gitgutter#utility#setbufvar(bufnr, 'enabled', 0)
|
call gitgutter#utility#setbufvar(bufnr, 'enabled', 0)
|
||||||
call s:clear(bufnr)
|
call s:clear(bufnr)
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! gitgutter#buffer_enable() abort
|
function! gitgutter#buffer_enable(...) abort
|
||||||
let bufnr = bufnr('')
|
let bufnr = a:0 ? a:1 : bufnr('')
|
||||||
call gitgutter#utility#setbufvar(bufnr, 'enabled', 1)
|
call gitgutter#utility#setbufvar(bufnr, 'enabled', 1)
|
||||||
call gitgutter#process_buffer(bufnr, 1)
|
call gitgutter#process_buffer(bufnr, 1)
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! gitgutter#buffer_toggle() abort
|
function! gitgutter#buffer_toggle(...) abort
|
||||||
if gitgutter#utility#getbufvar(bufnr(''), 'enabled', 1)
|
let bufnr = a:0 ? a:1 : bufnr('')
|
||||||
call gitgutter#buffer_disable()
|
if gitgutter#utility#getbufvar(bufnr, 'enabled', 1)
|
||||||
|
call gitgutter#buffer_disable(bufnr)
|
||||||
else
|
else
|
||||||
call gitgutter#buffer_enable()
|
call gitgutter#buffer_enable(bufnr)
|
||||||
endif
|
endif
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
|
|||||||
@@ -48,8 +48,7 @@ endfunction
|
|||||||
" Returns truthy when the buffer's file should be processed; and falsey when it shouldn't.
|
" Returns truthy when the buffer's file should be processed; and falsey when it shouldn't.
|
||||||
" This function does not and should not make any system calls.
|
" This function does not and should not make any system calls.
|
||||||
function! gitgutter#utility#is_active(bufnr) abort
|
function! gitgutter#utility#is_active(bufnr) abort
|
||||||
return g:gitgutter_enabled &&
|
return gitgutter#utility#getbufvar(a:bufnr, 'enabled') &&
|
||||||
\ gitgutter#utility#getbufvar(a:bufnr, 'enabled', 1) &&
|
|
||||||
\ !pumvisible() &&
|
\ !pumvisible() &&
|
||||||
\ s:is_file_buffer(a:bufnr) &&
|
\ s:is_file_buffer(a:bufnr) &&
|
||||||
\ s:exists_file(a:bufnr) &&
|
\ s:exists_file(a:bufnr) &&
|
||||||
|
|||||||
Reference in New Issue
Block a user