From af7dfc8677c94df3db636a666e2ed8d13e392194 Mon Sep 17 00:00:00 2001 From: Bailey Ling Date: Fri, 16 Aug 2013 01:42:30 +0000 Subject: [PATCH] update separator colors when mode changes --- autoload/airline.vim | 13 ++++++++----- autoload/airline/builder.vim | 11 +++++++---- 2 files changed, 15 insertions(+), 9 deletions(-) diff --git a/autoload/airline.vim b/autoload/airline.vim index 7a87cf62..5a2dc855 100644 --- a/autoload/airline.vim +++ b/autoload/airline.vim @@ -39,6 +39,7 @@ function! airline#load_theme(name) let g:airline_theme = a:name let inactive_colors = g:airline#themes#{g:airline_theme}#inactive "also lazy loads the theme let w:airline_lastmode = '' + call airline#update_statusline() call airline#reload_highlight() call airline#update_highlight() endfunction @@ -55,9 +56,9 @@ function! airline#highlight(modes) endfor endif endfor - if exists('w:airline_current_builder') - call w:airline_current_builder.refresh_separator_highlights() - endif + for sep in w:airline_current_info.separator_groups + call airline#themes#exec_highlight_separator(sep[0], sep[1]) + endfor endfunction " for 7.2 compatibility @@ -74,7 +75,6 @@ endfunction function! airline#get_statusline(winnr, active) let builder = airline#builder#new(a:active) - call setwinvar(a:winnr, 'airline_current_builder', builder) if s:getwinvar(a:winnr, 'airline_render_left', a:active || (!a:active && !g:airline_inactive_collapse)) call builder.add_section('Al2', s:get_section(a:winnr, 'a').'%{g:airline_detect_paste && &paste ? g:airline_paste_symbol." " : ""}') @@ -94,7 +94,10 @@ function! airline#get_statusline(winnr, active) call builder.add_raw('%)') endif endif - return builder.build() + + let info = builder.build() + call setwinvar(a:winnr, 'airline_current_info', info) + return info.statusline endfunction function! airline#exec_funcrefs(list, break_early) diff --git a/autoload/airline/builder.vim b/autoload/airline/builder.vim index ced5f032..0a48e600 100644 --- a/autoload/airline/builder.vim +++ b/autoload/airline/builder.vim @@ -4,7 +4,6 @@ function! airline#builder#new(active) let builder = {} let builder._sections = [] - let builder._separator_groups = [] let builder._active = a:active function! builder.split(gutter) @@ -33,6 +32,7 @@ function! airline#builder#new(active) let line = '%{airline#update_highlight()}' let side = 0 let prev_group = '' + let separator_groups = [] for section in self._sections if section[0] == '|' let side = 1 @@ -47,7 +47,7 @@ function! airline#builder#new(active) if prev_group != '' let sep = side == 0 ? [section[0], prev_group] : [prev_group, section[0]] - call add(self._separator_groups, sep) + call add(separator_groups, sep) let line .= side == 0 \ ? self._group(section[0].'_to_'.prev_group) \ : self._group(prev_group.'_to_'.section[0]) @@ -59,8 +59,11 @@ function! airline#builder#new(active) let line .= self._group(section[0]).section[1] let prev_group = section[0] endfor - call self.refresh_separator_highlights() - return line + + return { + \ 'statusline': line, + \ 'separator_groups': separator_groups, + \ } endfunction return builder