support vim-signify as a hunk source.

This commit is contained in:
Bailey Ling
2013-08-20 15:43:26 +00:00
parent 35db000651
commit a04d7c277a
4 changed files with 32 additions and 7 deletions

View File

@@ -129,7 +129,7 @@ function! airline#extensions#load()
endif
if (get(g:, 'airline#extensions#hunks#enabled', 1) && get(g:, 'airline_enable_hunks', 1))
\ && exists('*GitGutterGetHunkSummary')
\ && (exists('g:loaded_signify') || exists('g:loaded_gitgutter'))
call airline#extensions#hunks#init(s:ext)
endif

View File

@@ -4,11 +4,34 @@
let s:non_zero_only = get(g:, 'airline#extensions#hunks#non_zero_only', 0)
let s:hunk_symbols = get(g:, 'airline#extensions#hunks#hunk_symbols', ['+', '~', '-'])
function! airline#extensions#hunks#get_hunks()
if get(g:, 'gitgutter_enabled', 0) == 0
return ''
let s:initialized = 0
function! s:init()
if !s:initialized
let s:initialized = 1
if exists('*sy#repo#get_stats')
function! s:get_hunks()
let hunks = sy#repo#get_stats()
return hunks
endfunction
elseif exists('*GitGutterGetHunkSummary')
function! s:get_hunks()
if !get(g:, 'gitgutter_enabled', 0)
return ''
endif
return GitGutterGetHunkSummary()
endfunction
else
let s:non_zero_only = 1
function! s:get_hunks()
return [0, 0, 0]
endfunction
endif
endif
let hunks = GitGutterGetHunkSummary()
endfunction
function! airline#extensions#hunks#get_hunks()
call <sid>init()
let hunks = s:get_hunks()
let string = ''
for i in [0, 1, 2]
if s:non_zero_only == 0 || hunks[i] > 0