integrate changesPlugin for displaying hunks

This commit is contained in:
Christian Brabandt 2014-05-22 07:47:31 +02:00
parent 44bf6fd1c5
commit f2ae2bd7d0
3 changed files with 18 additions and 2 deletions

View File

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

View File

@ -1,7 +1,7 @@
" MIT License. Copyright (c) 2013-2014 Bailey Ling. " MIT License. Copyright (c) 2013-2014 Bailey Ling.
" vim: et ts=2 sts=2 sw=2 " vim: et ts=2 sts=2 sw=2
if !get(g:, 'loaded_signify', 0) && !get(g:, 'loaded_gitgutter', 0) if !get(g:, 'loaded_signify', 0) && !get(g:, 'loaded_gitgutter', 0) && !get(g:, 'loaded_changes', 0)
finish finish
endif endif
@ -27,6 +27,19 @@ function! s:get_hunks_gitgutter()
return GitGutterGetHunkSummary() return GitGutterGetHunkSummary()
endfunction endfunction
function! s:get_hunks_changes()
if !get(b:, 'changes_view_enabled', 0) || s:is_branch_empty()
return []
endif
let hunks = changes#GetStats()
for i in hunks
if i > 0
return hunks
endif
endfor
return []
endfunction
function! s:get_hunks_empty() function! s:get_hunks_empty()
return '' return ''
endfunction endfunction
@ -38,6 +51,8 @@ function! s:get_hunks()
let s:source_func = 's:get_hunks_signify' let s:source_func = 's:get_hunks_signify'
elseif exists('*GitGutterGetHunkSummary') elseif exists('*GitGutterGetHunkSummary')
let s:source_func = 's:get_hunks_gitgutter' let s:source_func = 's:get_hunks_gitgutter'
elseif exists('*changes#GetStats')
let s:source_func = 's:get_hunks_changes'
else else
let s:source_func = 's:get_hunks_empty' let s:source_func = 's:get_hunks_empty'
endif endif

View File

@ -317,6 +317,7 @@ csv.vim <https://github.com/chrisbra/csv.vim>
------------------------------------- *airline-hunks* ------------------------------------- *airline-hunks*
vim-gitgutter <https://github.com/airblade/vim-gitgutter> vim-gitgutter <https://github.com/airblade/vim-gitgutter>
vim-signify <https://github.com/mhinz/vim-signify> vim-signify <https://github.com/mhinz/vim-signify>
changesPlugin <https://github.com/chrisbra/changesPlugin>
* enable/disable showing a summary of changed hunks under source control. > * enable/disable showing a summary of changed hunks under source control. >
let g:airline#extensions#hunks#enabled = 1 let g:airline#extensions#hunks#enabled = 1