From a90a39b4aa6a4aa85dd588f683f0c829a58c0b7b Mon Sep 17 00:00:00 2001 From: Christian Brabandt Date: Wed, 23 Apr 2014 00:13:16 +0200 Subject: [PATCH] new NrrwRgn integration --- autoload/airline/extensions.vim | 4 ++++ autoload/airline/extensions/nrrwrgn.vim | 24 ++++++++++++++++++++++++ doc/airline.txt | 5 +++++ 3 files changed, 33 insertions(+) create mode 100644 autoload/airline/extensions/nrrwrgn.vim diff --git a/autoload/airline/extensions.vim b/autoload/airline/extensions.vim index 50506316..461d1c35 100644 --- a/autoload/airline/extensions.vim +++ b/autoload/airline/extensions.vim @@ -207,6 +207,10 @@ function! airline#extensions#load() call airline#extensions#promptline#init(s:ext) endif + if get(g:, 'airline#extensions#nrrwrgn#enabled', 1) && exists(':NR') == 2 + call airline#extensions#nrrwrgn#init(s:ext) + endif + if !get(g:, 'airline#extensions#disable_rtp_load', 0) " load all other extensions, which are not part of the default distribution. " (autoload/airline/extensions/*.vim outside of our s:script_path). diff --git a/autoload/airline/extensions/nrrwrgn.vim b/autoload/airline/extensions/nrrwrgn.vim new file mode 100644 index 00000000..22815987 --- /dev/null +++ b/autoload/airline/extensions/nrrwrgn.vim @@ -0,0 +1,24 @@ +" MIT License. Copyright (c) 2013-2014 Bailey Ling. +" vim: et ts=2 sts=2 sw=2 + +if !get(g:, 'loaded_nrrw_rgn', 0) + finish +endif + +function! airline#extensions#nrrwrgn#apply(...) + if exists(":WidenRegion") == 2 + let spc = g:airline_symbols.space + call a:1.add_section('airline_a', printf('%s[Narrowed%s#%d]', spc, spc, b:nrrw_instn)) + if exists('*airline#extensions#branch#get_head') + call a:1.add_section('airline_b', spc.'%{airline#extensions#branch#get_head()}'.spc) + endif + let bufname=(get(b:, 'orig_buf', 0) ? bufname(b:orig_buf) : substitute(bufname('%'), '^Nrrwrgn_\zs.*\ze_\d\+$', submatch(0), '')) + call a:1.add_section('airline_c', spc.bufname.spc) + call a:1.split() + return 1 + endif +endfunction + +function! airline#extensions#nrrwrgn#init(ext) + call a:ext.add_statusline_func('airline#extensions#nrrwrgn#apply') +endfunction diff --git a/doc/airline.txt b/doc/airline.txt index f8206346..ec43ac0c 100644 --- a/doc/airline.txt +++ b/doc/airline.txt @@ -492,6 +492,11 @@ promptline let airline#extensions#promptline#color_template = 'visual' let airline#extensions#promptline#color_template = 'replace' < +------------------------------------- *airline-nrrwrgn* +NrrwRgn + +* enable/disable NrrwRgn integration > + let g:airline#extensions#nrrwrgn#enabled = 1 ============================================================================== ADVANCED CUSTOMIZATION *airline-advanced-customization*