diff --git a/autoload/airline/extensions.vim b/autoload/airline/extensions.vim index 891007d..9efa679 100644 --- a/autoload/airline/extensions.vim +++ b/autoload/airline/extensions.vim @@ -18,11 +18,6 @@ function! airline#extensions#apply_left_override(section1, section2) let w:airline_left_only = 1 endfunction -function! airline#extensions#update_external_values() - let g:airline_externals_tagbar = g:airline_enable_tagbar && exists(':Tagbar') - \ ? '%(%{tagbar#currenttag("%s","")} '.g:airline_right_alt_sep.' %)' : '' -endfunction - function! airline#extensions#apply_window_overrides() if &buftype == 'quickfix' let w:airline_section_a = 'Quickfix' @@ -114,6 +109,10 @@ function! airline#extensions#load() call airline#extensions#commandt#init(s:ext) endif + if get(g:, 'loaded_tagbar', 0) + call airline#extensions#tagbar#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 @@ -126,7 +125,6 @@ function! airline#extensions#load() call airline#extensions#bufferline#init(s:ext) endif - call add(g:airline_statusline_funcrefs, function('airline#extensions#update_external_values')) call add(g:airline_statusline_funcrefs, function('airline#extensions#apply_window_overrides')) call add(g:airline_exclude_funcrefs, function('airline#extensions#is_excluded_window')) diff --git a/autoload/airline/extensions/tagbar.vim b/autoload/airline/extensions/tagbar.vim new file mode 100644 index 0000000..8131652 --- /dev/null +++ b/autoload/airline/extensions/tagbar.vim @@ -0,0 +1,11 @@ +" MIT license. Copyright (c) 2013 Bailey Ling. +" vim: ts=2 sts=2 sw=2 fdm=indent + +function! airline#extensions#tagbar#apply() + let w:airline_section_x = '%(%{tagbar#currenttag("%s","")} '.g:airline_right_alt_sep.' %)'.g:airline_section_x +endfunction + +function! airline#extensions#tagbar#init(ext) + call a:ext.add_statusline_funcref(function('airline#extensions#tagbar#apply')) +endfunction + diff --git a/plugin/airline.vim b/plugin/airline.vim index 745f214..e637ce6 100644 --- a/plugin/airline.vim +++ b/plugin/airline.vim @@ -48,6 +48,14 @@ call s:check_defined('g:airline_mode_map', { \ '' : 'V-BLOCK', \ }) +call s:check_defined('g:airline_section_a', '%{g:airline_current_mode_text}') +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', "%{strlen(&filetype)>0?&filetype:''}") +call s:check_defined('g:airline_section_y', "%{strlen(&fenc)>0?&fenc:''}%{strlen(&ff)>0?'['.&ff.']':''}") +call s:check_defined('g:airline_section_z', '%3p%% '.g:airline_linecolumn_prefix.'%3l:%3c') + let s:airline_initialized = 0 let s:active_winnr = -1 function! s:on_window_changed() @@ -55,13 +63,6 @@ function! s:on_window_changed() if !s:airline_initialized 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', '') - 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:''}") - call s:check_defined('g:airline_section_y', "%{strlen(&fenc)>0?&fenc:''}%{strlen(&ff)>0?'['.&ff.']':''}") - call s:check_defined('g:airline_section_z', '%3p%% '.g:airline_linecolumn_prefix.'%3l:%3c') let s:airline_initialized = 1 endif call airline#update_statusline()