From 68442f74ac2517bfe16ba2117142d37a4b563030 Mon Sep 17 00:00:00 2001 From: Bailey Ling Date: Mon, 1 Jul 2013 22:37:15 -0400 Subject: [PATCH] condense highlight function --- plugin/airline.vim | 45 ++++++++++++++++----------------------------- 1 file changed, 16 insertions(+), 29 deletions(-) diff --git a/plugin/airline.vim b/plugin/airline.vim index cd35b9c5..544c176e 100644 --- a/plugin/airline.vim +++ b/plugin/airline.vim @@ -49,17 +49,19 @@ let s:airline_highlight_map = { \ 'inactive' : 'User9', \ } -function! s:highlight(mode, key) - let colors = s:airline_colors_{a:mode}[a:key] - let cmd = printf('hi %s %s %s %s %s %s %s', - \ s:airline_highlight_map[a:key], - \ colors[0] != '' ? 'guifg='.colors[0] : '', - \ colors[1] != '' ? 'guibg='.colors[1] : '', - \ colors[2] != '' ? 'ctermfg='.colors[2] : '', - \ colors[3] != '' ? 'ctermbg='.colors[3] : '', - \ colors[4] != '' ? 'gui='.colors[4] : '', - \ colors[4] != '' ? 'term='.colors[4] : '') - exec cmd +function! s:highlight(mode, keys) + for key in a:keys + let colors = s:airline_colors_{a:mode}[key] + let cmd = printf('hi %s %s %s %s %s %s %s', + \ s:airline_highlight_map[key], + \ colors[0] != '' ? 'guifg='.colors[0] : '', + \ colors[1] != '' ? 'guibg='.colors[1] : '', + \ colors[2] != '' ? 'ctermfg='.colors[2] : '', + \ colors[3] != '' ? 'ctermbg='.colors[3] : '', + \ colors[4] != '' ? 'gui='.colors[4] : '', + \ colors[4] != '' ? 'term='.colors[4] : '') + exec cmd + endfor endfunction function! s:update_statusline(active) @@ -95,27 +97,12 @@ endfunction function! AirlineModePrefix() let l:mode = mode() - call highlight('normal', 'statusline') - call highlight('normal', 'statusline_nc') - call highlight('normal', 'inactive') - call highlight('normal', 'mode') - call highlight('normal', 'mode_seperator') - call highlight('normal', 'info') - call highlight('normal', 'info_seperator') - call highlight('normal', 'file') + call highlight('normal', ['statusline','statusline_nc','inactive','mode','mode_seperator','info','info_seperator','file']) if l:mode ==# "i" || l:mode ==# "R" - call highlight('insert', 'statusline') - call highlight('insert', 'mode') - call highlight('insert', 'mode_seperator') - call highlight('insert', 'info') - call highlight('insert', 'info_seperator') + call highlight('insert', ['statusline','mode','mode_seperator','info','info_seperator']) elseif l:mode ==? "v" || l:mode ==# "" - call highlight('visual', 'statusline') - call highlight('visual', 'mode') - call highlight('visual', 'mode_seperator') - call highlight('visual', 'info') - call highlight('visual', 'info_seperator') + call highlight('visual', ['statusline','mode','mode_seperator','info','info_seperator']) endif if has_key(s:airline_mode_map, l:mode)