move updating external values into extensions
This commit is contained in:
parent
c655bdc233
commit
257a9f2ed9
|
@ -52,22 +52,6 @@ function! airline#highlight(modes)
|
||||||
endfor
|
endfor
|
||||||
endfunction
|
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
|
" for 7.2 compatibility
|
||||||
function! s:getwinvar(winnr, key, ...)
|
function! s:getwinvar(winnr, key, ...)
|
||||||
let winvals = getwinvar(a:winnr, '')
|
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 gutter = s:getwinvar(a:winnr, 'airline_section_gutter', get(g:, 'airline_section_gutter', ''))
|
||||||
let sl.=gutter != ''
|
let sl.=gutter != ''
|
||||||
\ ? 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
|
else
|
||||||
let sl.=l:status_color.' %f%m'
|
let sl.=l:status_color.' %f%m'
|
||||||
endif
|
endif
|
||||||
|
|
|
@ -9,6 +9,22 @@ function! airline#extensions#apply_left_override(section1, section2)
|
||||||
let w:airline_left_only = 1
|
let w:airline_left_only = 1
|
||||||
endfunction
|
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()
|
function! airline#extensions#apply_window_overrides()
|
||||||
if &buftype == 'quickfix'
|
if &buftype == 'quickfix'
|
||||||
let w:airline_section_a = 'Quickfix'
|
let w:airline_section_a = 'Quickfix'
|
||||||
|
@ -108,7 +124,10 @@ function! airline#extensions#load()
|
||||||
let g:bufferline_separator = ' '
|
let g:bufferline_separator = ' '
|
||||||
endif
|
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_window_override_funcrefs, function('airline#extensions#apply_window_overrides'))
|
||||||
call add(g:airline_exclude_funcrefs, function('airline#extensions#is_excluded_window'))
|
call add(g:airline_exclude_funcrefs, function('airline#extensions#is_excluded_window'))
|
||||||
|
|
||||||
|
call airline#extensions#update_external_values()
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
|
|
|
@ -51,7 +51,6 @@ function! s:on_window_changed()
|
||||||
let s:active_winnr = winnr()
|
let s:active_winnr = winnr()
|
||||||
if !s:airline_initialized
|
if !s:airline_initialized
|
||||||
call airline#extensions#load()
|
call airline#extensions#load()
|
||||||
call airline#update_externals()
|
|
||||||
call airline#load_theme(g:airline_theme)
|
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_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', '%{g:airline_externals_branch}')
|
||||||
|
@ -86,9 +85,9 @@ endfunction
|
||||||
command! -nargs=? -complete=customlist,<sid>get_airline_themes AirlineTheme call <sid>airline_theme(<f-args>)
|
command! -nargs=? -complete=customlist,<sid>get_airline_themes AirlineTheme call <sid>airline_theme(<f-args>)
|
||||||
|
|
||||||
augroup airline
|
augroup airline
|
||||||
au!
|
autocmd!
|
||||||
autocmd ColorScheme * call airline#highlight(['normal'])
|
autocmd ColorScheme * call airline#highlight(['normal'])
|
||||||
autocmd WinEnter,BufWinEnter,FileType,BufUnload * call <sid>on_window_changed()
|
autocmd WinEnter,BufWinEnter,FileType,BufUnload,ShellCmdPost *
|
||||||
autocmd ShellCmdPost * call airline#update_externals()
|
\ call <sid>on_window_changed()
|
||||||
autocmd CursorMoved * call <sid>sync_active_winnr()
|
autocmd CursorMoved * call <sid>sync_active_winnr()
|
||||||
augroup END
|
augroup END
|
||||||
|
|
Loading…
Reference in New Issue