move updating external values into extensions

This commit is contained in:
Bailey Ling 2013-08-03 10:59:34 -04:00
parent c655bdc233
commit 257a9f2ed9
3 changed files with 23 additions and 21 deletions

View File

@ -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

View File

@ -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

View File

@ -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,<sid>get_airline_themes AirlineTheme call <sid>airline_theme(<f-args>)
augroup airline
au!
autocmd!
autocmd ColorScheme * call airline#highlight(['normal'])
autocmd WinEnter,BufWinEnter,FileType,BufUnload * call <sid>on_window_changed()
autocmd ShellCmdPost * call airline#update_externals()
autocmd WinEnter,BufWinEnter,FileType,BufUnload,ShellCmdPost *
\ call <sid>on_window_changed()
autocmd CursorMoved * call <sid>sync_active_winnr()
augroup END