condense highlight function
This commit is contained in:
parent
80a9d1a276
commit
68442f74ac
@ -49,10 +49,11 @@ 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 colors = s:airline_colors_{a:mode}[key]
|
||||||
let cmd = printf('hi %s %s %s %s %s %s %s',
|
let cmd = printf('hi %s %s %s %s %s %s %s',
|
||||||
\ s:airline_highlight_map[a:key],
|
\ s:airline_highlight_map[key],
|
||||||
\ colors[0] != '' ? 'guifg='.colors[0] : '',
|
\ colors[0] != '' ? 'guifg='.colors[0] : '',
|
||||||
\ colors[1] != '' ? 'guibg='.colors[1] : '',
|
\ colors[1] != '' ? 'guibg='.colors[1] : '',
|
||||||
\ colors[2] != '' ? 'ctermfg='.colors[2] : '',
|
\ colors[2] != '' ? 'ctermfg='.colors[2] : '',
|
||||||
@ -60,6 +61,7 @@ function! s:highlight(mode, key)
|
|||||||
\ colors[4] != '' ? 'gui='.colors[4] : '',
|
\ colors[4] != '' ? 'gui='.colors[4] : '',
|
||||||
\ colors[4] != '' ? 'term='.colors[4] : '')
|
\ colors[4] != '' ? 'term='.colors[4] : '')
|
||||||
exec cmd
|
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)
|
||||||
|
Loading…
Reference in New Issue
Block a user