mirror of
https://github.com/vim-airline/vim-airline-themes.git
synced 2024-12-05 00:13:34 +08:00
refactor colorschemes to overwrite a base instead of replacing
This commit is contained in:
parent
233cf1b5b9
commit
c18a741f93
|
@ -19,9 +19,9 @@ let g:airline#themes#simple#normal = {
|
||||||
\ 'file': [ '#ff0000' , '#080808' , 160 , s:bg , '' ] ,
|
\ 'file': [ '#ff0000' , '#080808' , 160 , s:bg , '' ] ,
|
||||||
\ 'inactive': [ '#4e4e4e' , '#080808' , 239 , 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 = {
|
||||||
let g:airline#themes#simple#normal_modified.info_separator = [ '#080808' , '#080808' , s:bg , s:bg , '' ]
|
\ '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:I1 = [ '#5fff00' , '#080808' , 82 , s:bg ]
|
||||||
let s:I2 = [ '#ff5f00' , '#080808' , 202 , s:bg ]
|
let s:I2 = [ '#ff5f00' , '#080808' , 202 , s:bg ]
|
||||||
|
|
|
@ -44,23 +44,27 @@ let s:airline_highlight_map = {
|
||||||
\ }
|
\ }
|
||||||
let s:airline_highlight_groups = keys(s:airline_highlight_map)
|
let s:airline_highlight_groups = keys(s:airline_highlight_map)
|
||||||
|
|
||||||
function! s:highlight(mode)
|
function! s:highlight(modes)
|
||||||
for key in s:airline_highlight_groups
|
" always draw the base mode, and then override any/all of the colors with _override
|
||||||
if exists('g:airline#themes#{g:airline_theme}#{a:mode}[key]')
|
let mapped = map(a:modes, 'v:val == a:modes[0] ? v:val : a:modes[0]."_".v:val')
|
||||||
let colors = g:airline#themes#{g:airline_theme}#{a:mode}[key]
|
for mode in mapped
|
||||||
if s:is_win32term
|
for key in s:airline_highlight_groups
|
||||||
let colors = map(colors, 'v:val != "" && v:val > 128 ? v:val - 128 : v:val')
|
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
|
endif
|
||||||
let cmd = printf('hi %s %s %s %s %s %s %s',
|
endfor
|
||||||
\ 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
|
endfunction
|
||||||
|
|
||||||
|
@ -131,19 +135,20 @@ function! s:update_statusline(active)
|
||||||
call setwinvar(winnr(), '&statusline', sl)
|
call setwinvar(winnr(), '&statusline', sl)
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
let s:lastmode = ''
|
let s:lastmode = []
|
||||||
let g:airline_current_mode_text = ''
|
let g:airline_current_mode_text = ''
|
||||||
function! AirlineUpdateHighlight()
|
function! AirlineUpdateHighlight()
|
||||||
let l:m = mode()
|
let l:m = mode()
|
||||||
let l:mode = 'normal'
|
|
||||||
if l:m ==# "i" || l:m ==# "R"
|
if l:m ==# "i" || l:m ==# "R"
|
||||||
let l:mode = 'insert'
|
let l:mode = ['insert']
|
||||||
elseif l:m ==? "v" || l:m ==# ""
|
elseif l:m ==? "v" || l:m ==# ""
|
||||||
let l:mode = 'visual'
|
let l:mode = ['visual']
|
||||||
|
else
|
||||||
|
let l:mode = ['normal']
|
||||||
endif
|
endif
|
||||||
|
|
||||||
if g:airline_modified_detection && &modified
|
if g:airline_modified_detection && &modified
|
||||||
let l:mode .= '_modified'
|
call add(l:mode, 'modified')
|
||||||
endif
|
endif
|
||||||
|
|
||||||
if s:lastmode != l:mode
|
if s:lastmode != l:mode
|
||||||
|
@ -157,7 +162,7 @@ endfunction
|
||||||
|
|
||||||
augroup airline
|
augroup airline
|
||||||
au!
|
au!
|
||||||
autocmd VimEnter,ColorScheme * call <sid>highlight('normal')
|
autocmd VimEnter,ColorScheme * call <sid>highlight(['normal'])
|
||||||
autocmd WinLeave * call <sid>update_statusline(0)
|
autocmd WinLeave * call <sid>update_statusline(0)
|
||||||
autocmd VimEnter,WinEnter,BufWinEnter * call <sid>update_statusline(1)
|
autocmd VimEnter,WinEnter,BufWinEnter * call <sid>update_statusline(1)
|
||||||
augroup END
|
augroup END
|
||||||
|
|
Loading…
Reference in New Issue
Block a user