From a1db013d3f77feca219df1fdd568768380432a80 Mon Sep 17 00:00:00 2001 From: Jerome Reybert Date: Thu, 19 Jan 2017 13:57:36 +0100 Subject: [PATCH] Add vimagit extension --- README.md | 6 ++++- autoload/airline/extensions.vim | 6 +++++ autoload/airline/extensions/vimagit.vim | 30 +++++++++++++++++++++++++ doc/airline.txt | 6 +++++ 4 files changed, 47 insertions(+), 1 deletion(-) create mode 100644 autoload/airline/extensions/vimagit.vim diff --git a/README.md b/README.md index 451f8ad7..a3c4e89c 100644 --- a/README.md +++ b/README.md @@ -12,7 +12,7 @@ Lean & mean status/tabline for vim that's light as air. [undotree][17], [nerdtree][18], [tagbar][19], [vim-gitgutter][29], [vim-signify][30], [quickfixsigns][39], [syntastic][5], [eclim][34], [lawrencium][21], [virtualenv][31], [tmuxline][35], [taboo.vim][37], - [ctrlspace][38], [vim-bufmru][47] and more. + [ctrlspace][38], [vim-bufmru][47], [vimagit][50] and more. * 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. * Extensive suite of themes for popular color schemes including [solarized][23] (dark and light), [tomorrow][24] (all variants), [base16][32] (all variants), [molokai][25], [jellybeans][26] and others. @@ -84,6 +84,9 @@ vim-airline integrates with a variety of plugins out of the box. These extensio #### hunks ([vim-gitgutter][29] & [vim-signify][30]) ![image](https://f.cloud.github.com/assets/306502/995185/73fc7054-09b9-11e3-9d45-618406c6ed98.png) +#### [vimagit][50] +![vim-airline-vimagit-demo](https://cloud.githubusercontent.com/assets/533068/22107273/2ea85ba0-de4d-11e6-9fa8-331103b88df4.gif) + #### [virtualenv][31] ![image](https://f.cloud.github.com/assets/390964/1022566/cf81f830-0d98-11e3-904f-cf4fe3ce201e.png) @@ -248,3 +251,4 @@ MIT License. Copyright (c) 2013-2016 Bailey Ling. [47]: https://github.com/mildred/vim-bufmru [48]: https://github.com/ierton/xkb-switch [49]: https://github.com/vovkasm/input-source-switcher +[50]: https://github.com/jreybert/vimagit diff --git a/autoload/airline/extensions.vim b/autoload/airline/extensions.vim index 6025767f..d7c8a33d 100644 --- a/autoload/airline/extensions.vim +++ b/autoload/airline/extensions.vim @@ -183,6 +183,12 @@ function! airline#extensions#load() call add(loaded_ext, 'hunks') endif + if get(g:, 'airline#extensions#vimagit#enabled', 1) + \ && (exists('g:loaded_magit')) + call airline#extensions#vimagit#init(s:ext) + call add(loaded_ext, 'vimagit') + endif + if get(g:, 'airline#extensions#tagbar#enabled', 1) \ && exists(':TagbarToggle') call airline#extensions#tagbar#init(s:ext) diff --git a/autoload/airline/extensions/vimagit.vim b/autoload/airline/extensions/vimagit.vim new file mode 100644 index 00000000..400792ef --- /dev/null +++ b/autoload/airline/extensions/vimagit.vim @@ -0,0 +1,30 @@ +" MIT License. Copyright (c) 2016 Jerome Reybert +" vim: et ts=2 sts=2 sw=2 + +" This plugin replace the whole section_a when in vimagit buffer +scriptencoding utf-8 + +if !get(g:, 'loaded_magit', 0) + finish +endif + +function! airline#extensions#vimagit#init(ext) + call a:ext.add_statusline_func('airline#extensions#vimagit#apply') +endfunction + +function! airline#extensions#vimagit#get_mode() + if ( b:magit_current_commit_mode == '' ) + return "STAGING" + elseif ( b:magit_current_commit_mode == 'CC' ) + return "COMMIT" + elseif ( b:magit_current_commit_mode == 'CA' ) + return "AMEND" + else + return "???" +endfunction + +function! airline#extensions#vimagit#apply(...) + if ( &filetype == 'magit' ) + let w:airline_section_a = '%{airline#extensions#vimagit#get_mode()}' + endif +endfunction diff --git a/doc/airline.txt b/doc/airline.txt index ae2e737d..be3b56bb 100644 --- a/doc/airline.txt +++ b/doc/airline.txt @@ -420,6 +420,12 @@ quickfixsigns * set hunk count symbols. > let g:airline#extensions#hunks#hunk_symbols = ['+', '~', '-'] < +------------------------------------- *airline-vimagit* +vimagit + +* enable/disable vimagit integration > + let g:airline#extensions#vimagit#enabled = 1 +< ------------------------------------- *airline-ctrlp* ctrlp