condense highlight function

This commit is contained in:
Bailey Ling 2013-07-01 22:37:15 -04:00
parent 80a9d1a276
commit 68442f74ac

View File

@ -49,17 +49,19 @@ let s:airline_highlight_map = {
\ 'inactive' : 'User9', \ 'inactive' : 'User9',
\ } \ }
function! s:highlight(mode, key) function! s:highlight(mode, keys)
let colors = s:airline_colors_{a:mode}[a:key] for key in a:keys
let cmd = printf('hi %s %s %s %s %s %s %s', let colors = s:airline_colors_{a:mode}[key]
\ s:airline_highlight_map[a:key], let cmd = printf('hi %s %s %s %s %s %s %s',
\ colors[0] != '' ? 'guifg='.colors[0] : '', \ s:airline_highlight_map[key],
\ colors[1] != '' ? 'guibg='.colors[1] : '', \ colors[0] != '' ? 'guifg='.colors[0] : '',
\ colors[2] != '' ? 'ctermfg='.colors[2] : '', \ colors[1] != '' ? 'guibg='.colors[1] : '',
\ colors[3] != '' ? 'ctermbg='.colors[3] : '', \ colors[2] != '' ? 'ctermfg='.colors[2] : '',
\ colors[4] != '' ? 'gui='.colors[4] : '', \ colors[3] != '' ? 'ctermbg='.colors[3] : '',
\ colors[4] != '' ? 'term='.colors[4] : '') \ colors[4] != '' ? 'gui='.colors[4] : '',
exec cmd \ colors[4] != '' ? 'term='.colors[4] : '')
exec cmd
endfor
endfunction endfunction
function! s:update_statusline(active) function! s:update_statusline(active)
@ -95,27 +97,12 @@ endfunction
function! AirlineModePrefix() function! AirlineModePrefix()
let l:mode = mode() let l:mode = mode()
call <sid>highlight('normal', 'statusline') call <sid>highlight('normal', ['statusline','statusline_nc','inactive','mode','mode_seperator','info','info_seperator','file'])
call <sid>highlight('normal', 'statusline_nc')
call <sid>highlight('normal', 'inactive')
call <sid>highlight('normal', 'mode')
call <sid>highlight('normal', 'mode_seperator')
call <sid>highlight('normal', 'info')
call <sid>highlight('normal', 'info_seperator')
call <sid>highlight('normal', 'file')
if l:mode ==# "i" || l:mode ==# "R" if l:mode ==# "i" || l:mode ==# "R"
call <sid>highlight('insert', 'statusline') call <sid>highlight('insert', ['statusline','mode','mode_seperator','info','info_seperator'])
call <sid>highlight('insert', 'mode')
call <sid>highlight('insert', 'mode_seperator')
call <sid>highlight('insert', 'info')
call <sid>highlight('insert', 'info_seperator')
elseif l:mode ==? "v" || l:mode ==# "" elseif l:mode ==? "v" || l:mode ==# ""
call <sid>highlight('visual', 'statusline') call <sid>highlight('visual', ['statusline','mode','mode_seperator','info','info_seperator'])
call <sid>highlight('visual', 'mode')
call <sid>highlight('visual', 'mode_seperator')
call <sid>highlight('visual', 'info')
call <sid>highlight('visual', 'info_seperator')
endif endif
if has_key(s:airline_mode_map, l:mode) if has_key(s:airline_mode_map, l:mode)