diff --git a/README.md b/README.md index fc21bb7..c1b3ab6 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ Lean & mean statusline for vim that's light as air. # Features -* tiny core (under 200 lines), written with extensibility in mind ([open/closed principle][8]). +* tiny core written with extensibility in mind ([open/closed principle][8]). * integrates with a variety of plugins, including: [vim-bufferline][6], [fugitive][4], [unite][9], [ctrlp][10], [minibufexpl][15], [gundo][16], [undotree][17], [nerdtree][18], [tagbar][19], [syntastic][5] and [lawrencium][21]. * looks good with regular fonts and provides configuration points so you can use unicode or powerline symbols. * optimized for speed; it loads in under a millisecond. diff --git a/autoload/airline.vim b/autoload/airline.vim index fb82d11..013a446 100644 --- a/autoload/airline.vim +++ b/autoload/airline.vim @@ -4,10 +4,6 @@ let s:sections = ['a','b','c','gutter','x','y','z','warning'] let s:highlighter = airline#highlighter#new() -function! airline#get_highlighter() - return s:highlighter -endfunction - function! airline#reload_highlight() call s:highlighter.highlight(['inactive']) call s:highlighter.highlight(['normal']) @@ -23,7 +19,6 @@ function! airline#load_theme(name) call airline#check_mode() endfunction - function! s:get_section(winnr, key, ...) let text = airline#util#getwinvar(a:winnr, 'airline_section_'.a:key, g:airline_section_{a:key}) let [prefix, suffix] = [get(a:000, 0, '%( '), get(a:000, 1, ' %)')] diff --git a/autoload/airline/builder.vim b/autoload/airline/builder.vim index db590d8..1332b04 100644 --- a/autoload/airline/builder.vim +++ b/autoload/airline/builder.vim @@ -27,7 +27,6 @@ function! airline#builder#new(active, highlighter) let line = '%{airline#check_mode()}' let side = 0 let prev_group = '' - let separator_groups = [] for section in self._sections if section[0] == '|' let side = 1 @@ -41,13 +40,10 @@ function! airline#builder#new(active, highlighter) endif if prev_group != '' - let sep = side == 0 - \ ? [self._group(section[0]), self._group(prev_group)] - \ : [self._group(prev_group), self._group(section[0])] - call add(separator_groups, sep) + call self._highlighter.add_separator(self._group(prev_group), self._group(section[0])) let line .= side == 0 - \ ? '%#'.self._group(section[0].'_to_'.prev_group).'#' - \ : '%#'.self._group(prev_group.'_to_'.section[0]).'#' + \ ? '%#'.self._group(section[0]).'_to_'.self._group(prev_group).'#' + \ : '%#'.self._group(prev_group).'_to_'.self._group(section[0]).'#' let line .= side == 0 \ ? self._active ? g:airline_left_sep : g:airline_left_alt_sep \ : self._active ? g:airline_right_sep : g:airline_right_alt_sep @@ -59,7 +55,6 @@ function! airline#builder#new(active, highlighter) return { \ 'statusline': line, - \ 'separator_groups': separator_groups, \ } endfunction diff --git a/autoload/airline/highlighter.vim b/autoload/airline/highlighter.vim index 284ab51..016192e 100644 --- a/autoload/airline/highlighter.vim +++ b/autoload/airline/highlighter.vim @@ -10,13 +10,13 @@ function! airline#highlighter#exec(group, colors) endif exec printf('hi %s %s %s %s %s %s %s %s', \ a:group, - \ colors[0] != '' ? 'guifg='.colors[0] : '', - \ colors[1] != '' ? 'guibg='.colors[1] : '', - \ colors[2] != '' ? 'ctermfg='.colors[2] : '', - \ colors[3] != '' ? 'ctermbg='.colors[3] : '', - \ len(colors) > 4 && colors[4] != '' ? 'gui='.colors[4] : '', - \ len(colors) > 4 && colors[4] != '' ? 'cterm='.colors[4] : '', - \ len(colors) > 4 && colors[4] != '' ? 'term='.colors[4] : '') + \ get(colors, 0, '') != '' ? 'guifg='.colors[0] : '', + \ get(colors, 1, '') != '' ? 'guibg='.colors[1] : '', + \ get(colors, 2, '') != '' ? 'ctermfg='.colors[2] : '', + \ get(colors, 3, '') != '' ? 'ctermbg='.colors[3] : '', + \ get(colors, 4, '') != '' ? 'gui='.colors[4] : '', + \ get(colors, 4, '') != '' ? 'cterm='.colors[4] : '', + \ get(colors, 4, '') != '' ? 'term='.colors[4] : '') endfunction function! airline#highlighter#exec_separator(from, to) @@ -30,9 +30,13 @@ function! airline#highlighter#exec_separator(from, to) return group endfunction - function! airline#highlighter#new() let highlighter = {} + let highlighter._separators = [] + + function! highlighter.add_separator(from, to) + call add(self._separators, [a:from, a:to]) + endfunction function! highlighter.highlight(modes) " draw the base mode, followed by any overrides @@ -46,7 +50,9 @@ function! airline#highlighter#new() endfor endif endfor - for sep in w:airline_current_info.separator_groups + + " synchronize separator colors + for sep in self._separators call airline#highlighter#exec_separator(sep[0].suffix, sep[1].suffix) endfor endfunction