refactor colorschemes to overwrite a base instead of replacing

This commit is contained in:
Bailey Ling 2013-07-06 00:29:41 +00:00
parent 233cf1b5b9
commit c18a741f93
2 changed files with 30 additions and 25 deletions

View File

@ -19,9 +19,9 @@ let g:airline#themes#simple#normal = {
\ 'file': [ '#ff0000' , '#080808' , 160 , s:bg , '' ] ,
\ 'inactive': [ '#4e4e4e' , '#080808' , 239 , s:bg , '' ] ,
\ }
let g:airline#themes#simple#normal_modified = copy(g:airline#themes#simple#normal)
let g:airline#themes#simple#normal_modified.info_separator = [ '#080808' , '#080808' , s:bg , s:bg , '' ]
let g:airline#themes#simple#normal_modified.statusline = [ '#df0000' , '#080808' , 160 , s:bg , '' ]
let g:airline#themes#simple#normal_modified = {
\ 'statusline': [ '#df0000' , '#080808' , 160 , s:bg , '' ] ,
\ }
let s:I1 = [ '#5fff00' , '#080808' , 82 , s:bg ]
let s:I2 = [ '#ff5f00' , '#080808' , 202 , s:bg ]

View File

@ -44,23 +44,27 @@ let s:airline_highlight_map = {
\ }
let s:airline_highlight_groups = keys(s:airline_highlight_map)
function! s:highlight(mode)
for key in s:airline_highlight_groups
if exists('g:airline#themes#{g:airline_theme}#{a:mode}[key]')
let colors = g:airline#themes#{g:airline_theme}#{a:mode}[key]
if s:is_win32term
let colors = map(colors, 'v:val != "" && v:val > 128 ? v:val - 128 : v:val')
function! s:highlight(modes)
" always draw the base mode, and then override any/all of the colors with _override
let mapped = map(a:modes, 'v:val == a:modes[0] ? v:val : a:modes[0]."_".v:val')
for mode in mapped
for key in s:airline_highlight_groups
if exists('g:airline#themes#{g:airline_theme}#{mode}[key]')
let colors = g:airline#themes#{g:airline_theme}#{mode}[key]
if s:is_win32term
let colors = map(colors, 'v:val != "" && v:val > 128 ? v:val - 128 : v:val')
endif
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
endif
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
endif
endfor
endfor
endfunction
@ -131,19 +135,20 @@ function! s:update_statusline(active)
call setwinvar(winnr(), '&statusline', sl)
endfunction
let s:lastmode = ''
let s:lastmode = []
let g:airline_current_mode_text = ''
function! AirlineUpdateHighlight()
let l:m = mode()
let l:mode = 'normal'
if l:m ==# "i" || l:m ==# "R"
let l:mode = 'insert'
let l:mode = ['insert']
elseif l:m ==? "v" || l:m ==# ""
let l:mode = 'visual'
let l:mode = ['visual']
else
let l:mode = ['normal']
endif
if g:airline_modified_detection && &modified
let l:mode .= '_modified'
call add(l:mode, 'modified')
endif
if s:lastmode != l:mode
@ -157,7 +162,7 @@ endfunction
augroup airline
au!
autocmd VimEnter,ColorScheme * call <sid>highlight('normal')
autocmd VimEnter,ColorScheme * call <sid>highlight(['normal'])
autocmd WinLeave * call <sid>update_statusline(0)
autocmd VimEnter,WinEnter,BufWinEnter * call <sid>update_statusline(1)
augroup END