From 9c960875fe5433f26bfe67ee789a1e67aee147ee Mon Sep 17 00:00:00 2001 From: Bailey Ling Date: Tue, 6 Aug 2013 03:07:01 +0000 Subject: [PATCH] extract fugitive/lawrencium --- autoload/airline/extensions.vim | 11 ++++------- autoload/airline/extensions/branch.vim | 16 ++++++++++++++++ plugin/airline.vim | 2 +- 3 files changed, 21 insertions(+), 8 deletions(-) create mode 100644 autoload/airline/extensions/branch.vim diff --git a/autoload/airline/extensions.vim b/autoload/airline/extensions.vim index d2534cb..891007d 100644 --- a/autoload/airline/extensions.vim +++ b/autoload/airline/extensions.vim @@ -19,13 +19,6 @@ function! airline#extensions#apply_left_override(section1, section2) endfunction function! airline#extensions#update_external_values() - let g:airline_externals_branch = g:airline_enable_branch - \ ? (exists('*fugitive#head') && strlen(fugitive#head()) > 0 - \ ? g:airline_branch_prefix.fugitive#head() - \ : exists('*lawrencium#statusline') && strlen(lawrencium#statusline()) > 0 - \ ? g:airline_branch_prefix.lawrencium#statusline() - \ : '') - \ : '' let g:airline_externals_tagbar = g:airline_enable_tagbar && exists(':Tagbar') \ ? '%(%{tagbar#currenttag("%s","")} '.g:airline_right_alt_sep.' %)' : '' endfunction @@ -121,6 +114,10 @@ function! airline#extensions#load() call airline#extensions#commandt#init(s:ext) endif + if g:airline_enable_branch && (get(g:, 'loaded_fugitive', 0) || get(g:, 'loaded_lawrencium', 0)) + call airline#extensions#branch#init(s:ext) + endif + if g:airline_enable_syntastic && get(g:, 'loaded_syntastic_plugin') call airline#extensions#syntastic#init(s:ext) endif diff --git a/autoload/airline/extensions/branch.vim b/autoload/airline/extensions/branch.vim new file mode 100644 index 0000000..08a0687 --- /dev/null +++ b/autoload/airline/extensions/branch.vim @@ -0,0 +1,16 @@ +" MIT license. Copyright (c) 2013 Bailey Ling. +" vim: ts=2 sts=2 sw=2 fdm=indent + +function! airline#extensions#branch#apply() + let w:airline_section_b = + \ exists('*fugitive#head') && strlen(fugitive#head()) > 0 + \ ? g:airline_branch_prefix.fugitive#head() + \ : exists('*lawrencium#statusline') && strlen(lawrencium#statusline()) > 0 + \ ? g:airline_branch_prefix.lawrencium#statusline() + \ : '' +endfunction + +function! airline#extensions#branch#init(ext) + call a:ext.add_statusline_funcref(function('airline#extensions#branch#apply')) +endfunction + diff --git a/plugin/airline.vim b/plugin/airline.vim index 537b2b1..745f214 100644 --- a/plugin/airline.vim +++ b/plugin/airline.vim @@ -56,7 +56,7 @@ function! s:on_window_changed() call airline#extensions#load() call airline#load_theme(g:airline_theme) call s:check_defined('g:airline_section_a', '%{g:airline_current_mode_text}') - call s:check_defined('g:airline_section_b', '%{g:airline_externals_branch}') + call s:check_defined('g:airline_section_b', '') call s:check_defined('g:airline_section_c', '%f%m') call s:check_defined('g:airline_section_gutter', '') call s:check_defined('g:airline_section_x', g:airline_externals_tagbar."%{strlen(&filetype)>0?&filetype:''}")