add gitgutter integration.

This commit is contained in:
Bailey Ling
2013-08-18 21:02:33 +00:00
parent 8f0401580b
commit dad0d5a8d8
5 changed files with 47 additions and 4 deletions

View File

@@ -128,6 +128,10 @@ function! airline#extensions#load()
call airline#extensions#undotree#init(s:ext)
endif
if g:airline_enable_hunks && exists('*GitGutterGetHunks')
call airline#extensions#hunks#init(s:ext)
endif
if g:airline_enable_tagbar && exists(':TagbarToggle')
call airline#extensions#tagbar#init(s:ext)
endif

View File

@@ -0,0 +1,31 @@
" MIT License. Copyright (c) 2013 Bailey Ling.
" vim: et ts=2 sts=2 sw=2
function! airline#extensions#hunks#get_hunks()
try
" throws an error when first entering a buffer, so we gotta swallow it
silent! let hunks = GitGutterGetHunks()
let added = 0
let removed = 0
let changed = 0
for hunk in hunks
let diff = hunk[3] - hunk[1]
if diff > 0
let added += diff
elseif diff < 0
let removed -= diff
else
let changed += 1
endif
endfor
return printf('+%s ~%s -%s', added, changed, removed)
catch
return ''
endtry
return ''
endfunction
function! airline#extensions#hunks#init(ext)
let g:airline_section_b .= '%{airline#extensions#hunks#get_hunks()} '
endfunction