mirror of
https://github.com/vim-airline/vim-airline.git
synced 2024-11-25 17:57:36 +08:00
add inactive statusline funcrefs into the pipeline.
This commit is contained in:
parent
04daa66b48
commit
f6d8a981b6
|
@ -5,6 +5,7 @@ let g:airline_statusline_funcrefs = get(g:, 'airline_statusline_funcrefs', [])
|
|||
|
||||
let s:sections = ['a','b','c','gutter','x','y','z','warning']
|
||||
let s:highlighter = airline#highlighter#new()
|
||||
let s:inactive_funcrefs = []
|
||||
|
||||
function! airline#add_statusline_func(name)
|
||||
call airline#add_statusline_funcref(function(a:name))
|
||||
|
@ -21,6 +22,10 @@ function! airline#remove_statusline_func(name)
|
|||
endif
|
||||
endfunction
|
||||
|
||||
function! airline#add_inactive_statusline_func(name)
|
||||
call add(s:inactive_funcrefs, function(a:name))
|
||||
endfunction
|
||||
|
||||
function! airline#load_theme()
|
||||
call s:highlighter.load_theme()
|
||||
call airline#extensions#load_theme()
|
||||
|
@ -96,25 +101,27 @@ function! airline#update_statusline()
|
|||
for nr in filter(range(1, winnr('$')), 'v:val != winnr()')
|
||||
call setwinvar(nr, 'airline_active', 0)
|
||||
let context = { 'winnr': nr, 'active': 0 }
|
||||
let builder = airline#builder#new(context, s:highlighter)
|
||||
call setwinvar(nr, '&statusline', airline#get_statusline(builder, nr, 0))
|
||||
call s:invoke_funcrefs(context, s:inactive_funcrefs)
|
||||
endfor
|
||||
|
||||
let w:airline_active = 1
|
||||
|
||||
unlet! w:airline_render_left
|
||||
unlet! w:airline_render_right
|
||||
for section in s:sections
|
||||
unlet! w:airline_section_{section}
|
||||
endfor
|
||||
|
||||
let w:airline_active = 1
|
||||
let context = { 'winnr': winnr(), 'active': 1 }
|
||||
let builder = airline#builder#new(context, s:highlighter)
|
||||
let err = airline#util#exec_funcrefs(g:airline_statusline_funcrefs, builder)
|
||||
call s:invoke_funcrefs(context, g:airline_statusline_funcrefs)
|
||||
endfunction
|
||||
|
||||
function! s:invoke_funcrefs(context, funcrefs)
|
||||
let builder = airline#builder#new(a:context, s:highlighter)
|
||||
let err = airline#util#exec_funcrefs(a:funcrefs, builder, a:context)
|
||||
if err == 0
|
||||
call setwinvar(winnr(), '&statusline', airline#get_statusline(builder, winnr(), 1))
|
||||
call setwinvar(a:context.winnr, '&statusline', airline#get_statusline(builder, a:context.winnr, a:context.active))
|
||||
elseif err == 1
|
||||
call setwinvar(winnr(), '&statusline', builder.build())
|
||||
call setwinvar(a:context.winnr, '&statusline', builder.build())
|
||||
endif
|
||||
endfunction
|
||||
|
||||
|
|
|
@ -8,6 +8,9 @@ endfunction
|
|||
function! s:ext.add_statusline_funcref(function) dict
|
||||
call airline#add_statusline_funcref(a:function)
|
||||
endfunction
|
||||
function! s:ext.add_inactive_statusline_func(name) dict
|
||||
call airline#add_inactive_statusline_func(a:name)
|
||||
endfunction
|
||||
|
||||
let s:script_path = expand('<sfile>:p:h')
|
||||
|
||||
|
|
|
@ -302,6 +302,12 @@ statuslines to your liking. Here is an example: >
|
|||
<
|
||||
The second variable is the context, which is a dictionary containing various
|
||||
values such as whether the statusline is active or not, and the window number.
|
||||
>
|
||||
context = {
|
||||
'winnr': 'the window number for the statusline',
|
||||
'active': 'whether the window is active or not',
|
||||
}
|
||||
<
|
||||
|
||||
*airline-pipeline-return-codes*
|
||||
The pipeline accepts various return codes and can be used to determine the
|
||||
|
|
Loading…
Reference in New Issue
Block a user