diff --git a/README.md b/README.md index c1b3ab63..8ca436d8 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/autoload/airline/extensions.vim b/autoload/airline/extensions.vim index 40d0a0b8..7eed17d7 100644 --- a/autoload/airline/extensions.vim +++ b/autoload/airline/extensions.vim @@ -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 diff --git a/autoload/airline/extensions/hunks.vim b/autoload/airline/extensions/hunks.vim new file mode 100644 index 00000000..805ed13c --- /dev/null +++ b/autoload/airline/extensions/hunks.vim @@ -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 + diff --git a/doc/airline.txt b/doc/airline.txt index df3f8fc9..5af112b0 100644 --- a/doc/airline.txt +++ b/doc/airline.txt @@ -199,13 +199,19 @@ tagbar *airline-csv* 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 + +* enable/disable detecting changed hunks under source control. > + let g:airline_enable_hunks = 1 +< ============================================================================== FUNCREFS *airline-funcrefs* diff --git a/plugin/airline.vim b/plugin/airline.vim index 5ab46116..36345d10 100644 --- a/plugin/airline.vim +++ b/plugin/airline.vim @@ -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)