mirror of
https://github.com/vim-airline/vim-airline.git
synced 2024-11-27 02:33:56 +08:00
improve vim-signify integration (#169).
This commit is contained in:
parent
8452029e98
commit
41159bfbc2
|
@ -8,10 +8,13 @@ let s:initialized = 0
|
||||||
function! s:init()
|
function! s:init()
|
||||||
if !s:initialized
|
if !s:initialized
|
||||||
let s:initialized = 1
|
let s:initialized = 1
|
||||||
if exists('*sy#repo#get_stats')
|
if get(g:, 'loaded_signify', 0)
|
||||||
function! s:get_hunks()
|
function! s:get_hunks()
|
||||||
let hunks = sy#repo#get_stats()
|
let hunks = sy#repo#get_stats()
|
||||||
|
if hunks[0] >= 0
|
||||||
return hunks
|
return hunks
|
||||||
|
endif
|
||||||
|
return []
|
||||||
endfunction
|
endfunction
|
||||||
elseif exists('*GitGutterGetHunkSummary')
|
elseif exists('*GitGutterGetHunkSummary')
|
||||||
function! s:get_hunks()
|
function! s:get_hunks()
|
||||||
|
@ -21,9 +24,8 @@ function! s:init()
|
||||||
return GitGutterGetHunkSummary()
|
return GitGutterGetHunkSummary()
|
||||||
endfunction
|
endfunction
|
||||||
else
|
else
|
||||||
let s:non_zero_only = 1
|
|
||||||
function! s:get_hunks()
|
function! s:get_hunks()
|
||||||
return [0, 0, 0]
|
return []
|
||||||
endfunction
|
endfunction
|
||||||
endif
|
endif
|
||||||
endif
|
endif
|
||||||
|
@ -33,11 +35,13 @@ function! airline#extensions#hunks#get_hunks()
|
||||||
call <sid>init()
|
call <sid>init()
|
||||||
let hunks = s:get_hunks()
|
let hunks = s:get_hunks()
|
||||||
let string = ''
|
let string = ''
|
||||||
|
if !empty(hunks)
|
||||||
for i in [0, 1, 2]
|
for i in [0, 1, 2]
|
||||||
if s:non_zero_only == 0 || hunks[i] > 0
|
if s:non_zero_only == 0 || hunks[i] > 0
|
||||||
let string .= printf('%s%s ', s:hunk_symbols[i], hunks[i])
|
let string .= printf('%s%s ', s:hunk_symbols[i], hunks[i])
|
||||||
endif
|
endif
|
||||||
endfor
|
endfor
|
||||||
|
endif
|
||||||
return string
|
return string
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user