mirror of
https://github.com/vim-airline/vim-airline.git
synced 2026-01-03 10:03:25 +08:00
support vim-signify as a hunk source.
This commit is contained in:
@@ -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
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user