2013-08-18 21:02:33 +00:00
|
|
|
" MIT License. Copyright (c) 2013 Bailey Ling.
|
|
|
|
" vim: et ts=2 sts=2 sw=2
|
|
|
|
|
|
|
|
function! airline#extensions#hunks#get_hunks()
|
2013-08-19 13:22:24 +00:00
|
|
|
if &ft == 'gitcommit'
|
|
|
|
return ''
|
|
|
|
endif
|
|
|
|
|
2013-08-18 21:18:21 +00:00
|
|
|
if get(g:, 'gitgutter_initialised', 0) && get(g:, 'gitgutter_enabled', 0)
|
2013-08-18 21:02:33 +00:00
|
|
|
let added = 0
|
|
|
|
let removed = 0
|
|
|
|
let changed = 0
|
2013-08-18 21:18:21 +00:00
|
|
|
let hunks = GitGutterGetHunks()
|
2013-08-18 21:02:33 +00:00
|
|
|
for hunk in hunks
|
2013-08-18 21:18:21 +00:00
|
|
|
if hunk[1] == 0 && hunk[3] > 0
|
|
|
|
let added += hunk[3]
|
|
|
|
elseif hunk[1] > 0 && hunk[3] == 0
|
|
|
|
let removed += hunk[1]
|
|
|
|
elseif hunk[1] > 0 && hunk[3] > 0
|
|
|
|
if hunk[1] == hunk[3]
|
|
|
|
let changed += hunk[3]
|
|
|
|
elseif hunk[1] < hunk[3]
|
|
|
|
let changed += hunk[1]
|
|
|
|
let added += (hunk[3] - hunk[1])
|
|
|
|
elseif hunk[1] > hunk[3]
|
|
|
|
let changed += hunk[3]
|
|
|
|
let removed += (hunk[1] - hunk[3])
|
|
|
|
endif
|
2013-08-18 21:02:33 +00:00
|
|
|
endif
|
|
|
|
endfor
|
2013-08-18 21:18:21 +00:00
|
|
|
return printf('+%s ~%s -%s ', added, changed, removed)
|
|
|
|
endif
|
2013-08-18 21:02:33 +00:00
|
|
|
return ''
|
|
|
|
endfunction
|
|
|
|
|
|
|
|
function! airline#extensions#hunks#init(ext)
|
2013-08-18 21:18:21 +00:00
|
|
|
let g:airline_section_b .= '%{airline#extensions#hunks#get_hunks()}'
|
2013-08-18 21:02:33 +00:00
|
|
|
endfunction
|
|
|
|
|