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

@ -7,7 +7,7 @@ Lean & mean statusline for vim that's light as air.
# Features
* tiny core written with extensibility in mind ([open/closed principle][8]).
* integrates with a variety of plugins, including: [vim-bufferline][6], [fugitive][4], [unite][9], [ctrlp][10], [minibufexpl][15], [gundo][16], [undotree][17], [nerdtree][18], [tagbar][19], [syntastic][5] and [lawrencium][21].
* integrates with a variety of plugins, including: [vim-bufferline][6], [fugitive][4], [unite][9], [ctrlp][10], [minibufexpl][15], [gundo][16], [undotree][17], [nerdtree][18], [tagbar][19], [vim-gitgutter][29], [syntastic][5] and [lawrencium][21].
* looks good with regular fonts and provides configuration points so you can use unicode or powerline symbols.
* optimized for speed; it loads in under a millisecond.
* fully customizable; if you know a little `statusline` syntax you can tweak it to your needs.
@ -135,3 +135,4 @@ MIT license. Copyright (c) 2013 Bailey Ling.
[26]: https://github.com/nanotech/jellybeans.vim
[27]: https://github.com/bling/vim-airline/wiki/FAQ
[28]: https://github.com/chrisbra/csv.vim
[29]: https://github.com/airblade/vim-gitgutter

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

View File

@ -199,13 +199,19 @@ tagbar <https://github.com/majutsushi/>
*airline-csv*
csv.vim <https://github.com/chrisbra/csv.vim>
* enable/disable csv integration for displaying the current column.
* enable/disable csv integration for displaying the current column. >
let g:airline_enable_csv = 1
>
<
* change how columns are displayed. >
let g:airline#extensions#csv#column_display = 'Number' (default)
let g:airline#extensions#csv#column_display = 'Name'
>
<
*airline-hunks*
vim-gitgutter <https://github.com/airblade/vim-gitgutter>
* enable/disable detecting changed hunks under source control. >
let g:airline_enable_hunks = 1
<
==============================================================================
FUNCREFS *airline-funcrefs*

View File

@ -21,6 +21,7 @@ call s:check_defined('g:airline_enable_branch', 1)
call s:check_defined('g:airline_enable_syntastic', 1)
call s:check_defined('g:airline_enable_tagbar', 1)
call s:check_defined('g:airline_enable_csv', 1)
call s:check_defined('g:airline_enable_hunks', 1)
call s:check_defined('g:airline_detect_iminsert', 0)
call s:check_defined('g:airline_detect_modified', 1)
call s:check_defined('g:airline_detect_paste', 1)