update separator colors when mode changes

This commit is contained in:
Bailey Ling 2013-08-16 01:42:30 +00:00
parent 47c80c31da
commit af7dfc8677
2 changed files with 15 additions and 9 deletions

View File

@ -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)

View File

@ -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