diff --git a/autoload/airline.vim b/autoload/airline.vim index c4c5186..29a9d01 100644 --- a/autoload/airline.vim +++ b/autoload/airline.vim @@ -95,7 +95,8 @@ endfunction function! airline#update_statusline() for nr in filter(range(1, winnr('$')), 'v:val != winnr()') call setwinvar(nr, 'airline_active', 0) - let builder = airline#builder#new(0, s:highlighter) + let context = { 'winnr': nr, 'active': 0 } + let builder = airline#builder#new(context, s:highlighter) call setwinvar(nr, '&statusline', airline#get_statusline(builder, nr, 0)) endfor @@ -107,7 +108,8 @@ function! airline#update_statusline() unlet! w:airline_section_{section} endfor - let builder = airline#builder#new(1, s:highlighter) + 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) if err == 0 call setwinvar(winnr(), '&statusline', airline#get_statusline(builder, winnr(), 1)) diff --git a/autoload/airline/builder.vim b/autoload/airline/builder.vim index 2c3266d..04467a6 100644 --- a/autoload/airline/builder.vim +++ b/autoload/airline/builder.vim @@ -24,16 +24,15 @@ function! s:prototype.add_raw(text) endfunction function! s:prototype.build() - if !self._active + if !self._context.active let self._line = substitute(self._line, '%#.\{-}\ze#', '\0_inactive', 'g') endif return self._line endfunction -function! airline#builder#new(active, highlighter) +function! airline#builder#new(context, highlighter) let builder = copy(s:prototype) - let builder._sections = [] - let builder._active = a:active + let builder._context = a:context let builder._highlighter = a:highlighter let builder._side = 1 let builder._curgroup = '' diff --git a/doc/airline.txt b/doc/airline.txt index 8ed4263..dcc86a2 100644 --- a/doc/airline.txt +++ b/doc/airline.txt @@ -300,6 +300,9 @@ statuslines to your liking. Here is an example: > return -1 endfunction < +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. + *airline-pipeline-return-codes* The pipeline accepts various return codes and can be used to determine the next action. The following are the supported codes: >