diff --git a/autoload/airline.vim b/autoload/airline.vim index 1b712e9c..48af180b 100644 --- a/autoload/airline.vim +++ b/autoload/airline.vim @@ -52,22 +52,6 @@ function! airline#highlight(modes) endfor endfunction -function! airline#update_externals() - let g:airline_externals_bufferline = g:airline_enable_bufferline && exists('*bufferline#get_status_string') - \ ? '%{bufferline#refresh_status()}'.bufferline#get_status_string() : "%f%m" - let g:airline_externals_syntastic = g:airline_enable_syntastic && exists('*SyntasticStatuslineFlag') - \ ? '%{SyntasticStatuslineFlag()}' : '' - 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 - " for 7.2 compatibility function! s:getwinvar(winnr, key, ...) let winvals = getwinvar(a:winnr, '') @@ -102,7 +86,7 @@ function! s:get_statusline(winnr, active) let gutter = s:getwinvar(a:winnr, 'airline_section_gutter', get(g:, 'airline_section_gutter', '')) let sl.=gutter != '' \ ? gutter - \ : '%#warningmsg#'.g:airline_externals_syntastic.l:file_flag_color."%{&ro ? g:airline_readonly_symbol : ''}".l:status_color + \ : g:airline_externals_syntastic.l:file_flag_color."%{&ro ? g:airline_readonly_symbol : ''}".l:status_color else let sl.=l:status_color.' %f%m' endif diff --git a/autoload/airline/extensions.vim b/autoload/airline/extensions.vim index daae58c0..995b92fe 100644 --- a/autoload/airline/extensions.vim +++ b/autoload/airline/extensions.vim @@ -9,6 +9,22 @@ 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_bufferline = g:airline_enable_bufferline && exists('*bufferline#get_status_string') + \ ? '%{bufferline#refresh_status()}'.bufferline#get_status_string() : "%f%m" + let g:airline_externals_syntastic = g:airline_enable_syntastic && exists('*SyntasticStatuslineFlag') + \ ? '%#warningmsg#%{SyntasticStatuslineFlag()}' : '' + 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 + function! airline#extensions#apply_window_overrides() if &buftype == 'quickfix' let w:airline_section_a = 'Quickfix' @@ -108,7 +124,10 @@ function! airline#extensions#load() let g:bufferline_separator = ' ' endif + call add(g:airline_window_override_funcrefs, function('airline#extensions#update_external_values')) call add(g:airline_window_override_funcrefs, function('airline#extensions#apply_window_overrides')) call add(g:airline_exclude_funcrefs, function('airline#extensions#is_excluded_window')) + + call airline#extensions#update_external_values() endfunction diff --git a/plugin/airline.vim b/plugin/airline.vim index 643e1938..4f92ce02 100644 --- a/plugin/airline.vim +++ b/plugin/airline.vim @@ -51,7 +51,6 @@ function! s:on_window_changed() let s:active_winnr = winnr() if !s:airline_initialized call airline#extensions#load() - call airline#update_externals() 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}') @@ -86,9 +85,9 @@ endfunction command! -nargs=? -complete=customlist,get_airline_themes AirlineTheme call airline_theme() augroup airline - au! + autocmd! autocmd ColorScheme * call airline#highlight(['normal']) - autocmd WinEnter,BufWinEnter,FileType,BufUnload * call on_window_changed() - autocmd ShellCmdPost * call airline#update_externals() + autocmd WinEnter,BufWinEnter,FileType,BufUnload,ShellCmdPost * + \ call on_window_changed() autocmd CursorMoved * call sync_active_winnr() augroup END