improve bufferline integration; revert to default in inactive splits.
This commit is contained in:
parent
2413babe8b
commit
14dacaab68
@ -70,7 +70,7 @@ function! s:get_section(winnr, key, ...)
|
||||
return empty(text) ? '' : prefix.text.suffix
|
||||
endfunction
|
||||
|
||||
function! s:get_statusline(winnr, active)
|
||||
function! airline#get_statusline(winnr, active)
|
||||
let l:mode_color = a:active ? "%#Al2#" : "%#Al2_inactive#"
|
||||
let l:mode_sep_color = a:active ? "%#Al3#" : "%#Al3_inactive#"
|
||||
let l:info_color = a:active ? "%#Al4#" : "%#Al4_inactive#"
|
||||
@ -137,11 +137,9 @@ function! airline#update_statusline()
|
||||
return
|
||||
endif
|
||||
|
||||
for nr in range(1, winnr('$'))
|
||||
if nr != winnr() && getwinvar(nr, 'airline_active')
|
||||
call setwinvar(nr, '&statusline', s:get_statusline(nr, 0))
|
||||
call setwinvar(nr, 'airline_active', 0)
|
||||
endif
|
||||
for nr in filter(range(1, winnr('$')), 'v:val != winnr()')
|
||||
call setwinvar(nr, 'airline_active', 0)
|
||||
call setwinvar(nr, '&statusline', airline#get_statusline(nr, 0))
|
||||
endfor
|
||||
|
||||
let w:airline_active = 1
|
||||
@ -153,7 +151,7 @@ function! airline#update_statusline()
|
||||
endfor
|
||||
call airline#exec_funcrefs(g:airline_statusline_funcrefs, 0)
|
||||
|
||||
call setwinvar(winnr(), '&statusline', s:get_statusline(winnr(), 1))
|
||||
call setwinvar(winnr(), '&statusline', airline#get_statusline(winnr(), 1))
|
||||
endfunction
|
||||
|
||||
function! airline#update_highlight()
|
||||
|
@ -1,6 +1,21 @@
|
||||
" MIT license. Copyright (c) 2013 Bailey Ling.
|
||||
" MIT License. Copyright (c) 2013 Bailey Ling.
|
||||
" vim: ts=2 sts=2 sw=2 fdm=indent
|
||||
|
||||
function! airline#extensions#bufferline#apply()
|
||||
" revert to default in non-active splits
|
||||
for nr in filter(range(1, winnr('$')), 'v:val != winnr()')
|
||||
if matchstr(getwinvar(nr, '&statusline'), '%{bufferline') != ''
|
||||
call setwinvar(nr, 'airline_section_c', '%f%m')
|
||||
call setwinvar(nr, '&statusline', airline#get_statusline(nr, 0))
|
||||
endif
|
||||
endfor
|
||||
|
||||
" check for other plugin overrides first
|
||||
if !exists('w:airline_section_c')
|
||||
let w:airline_section_c = '%{bufferline#refresh_status()}'.bufferline#get_status_string()
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! airline#extensions#bufferline#init(ext)
|
||||
highlight AlBl_active gui=bold cterm=bold term=bold
|
||||
highlight link AlBl_inactive Al6
|
||||
@ -11,6 +26,6 @@ function! airline#extensions#bufferline#init(ext)
|
||||
let g:bufferline_separator = ' '
|
||||
|
||||
if g:airline_section_c == '%f%m'
|
||||
let g:airline_section_c = '%{bufferline#refresh_status()}'.bufferline#get_status_string()
|
||||
call a:ext.add_statusline_funcref(function('airline#extensions#bufferline#apply'))
|
||||
endif
|
||||
endfunction
|
||||
|
Loading…
Reference in New Issue
Block a user