refactor the rest of the themes to use refresh. resolves #288.

This commit is contained in:
Bailey Ling 2013-09-27 21:43:32 -04:00
parent 2f3b33daae
commit a81d1cd9c7
5 changed files with 55 additions and 76 deletions

View File

@ -1,4 +1,4 @@
function! s:load_constant()
if get(g:, 'airline#themes#base16#constant', 0)
let g:airline#themes#base16#palette = {}
" Color palette
@ -60,57 +60,48 @@ function! s:load_constant()
let g:airline#themes#base16#palette.inactive_modified = {
\ 'airline_c': [s:gui_orange, '', s:cterm_orange, '', ''],
\ }
endfunction
function! s:load_dynamic()
let g:airline#themes#base16#palette = {}
let g:airline#themes#base16#palette.accents = {
\ 'red': airline#themes#get_highlight('Constant'),
\ }
let s:N1 = airline#themes#get_highlight2(['DiffText', 'bg'], ['DiffText', 'fg'], 'bold')
let s:N2 = airline#themes#get_highlight('Visual')
let s:N3 = airline#themes#get_highlight('CursorLine')
let g:airline#themes#base16#palette.normal = airline#themes#generate_color_map(s:N1, s:N2, s:N3)
let group = airline#themes#get_highlight('vimCommand')
let g:airline#themes#base16#palette.normal_modified = {
\ 'statusline': [ group[0], '', group[2], '', '' ]
\ }
let s:I1 = airline#themes#get_highlight2(['DiffAdded', 'bg'], ['DiffAdded', 'fg'], 'bold')
let s:I2 = airline#themes#get_highlight2(['DiffAdded', 'fg'], ['Normal', 'bg'])
let s:I3 = s:N3
let g:airline#themes#base16#palette.insert = airline#themes#generate_color_map(s:I1, s:I2, s:I3)
let g:airline#themes#base16#palette.insert_modified = g:airline#themes#base16#palette.normal_modified
let s:R1 = airline#themes#get_highlight2(['WarningMsg', 'bg'], ['WarningMsg', 'fg'], 'bold')
let s:R2 = s:N2
let s:R3 = s:N3
let g:airline#themes#base16#palette.replace = airline#themes#generate_color_map(s:R1, s:R2, s:R3)
let g:airline#themes#base16#palette.replace_modified = g:airline#themes#base16#palette.normal_modified
let s:V1 = airline#themes#get_highlight2(['Normal', 'bg'], ['Constant', 'fg'], 'bold')
let s:V2 = airline#themes#get_highlight2(['Constant', 'fg'], ['Normal', 'bg'])
let s:V3 = s:N3
let g:airline#themes#base16#palette.visual = airline#themes#generate_color_map(s:V1, s:V2, s:V3)
let g:airline#themes#base16#palette.visual_modified = g:airline#themes#base16#palette.normal_modified
let s:IA = airline#themes#get_highlight2(['NonText', 'fg'], ['CursorLine', 'bg'])
let g:airline#themes#base16#palette.inactive = airline#themes#generate_color_map(s:IA, s:IA, s:IA)
let g:airline#themes#base16#palette.inactive_modified = {
\ 'airline_c': [ group[0], '', group[2], '', '' ]
\ }
endfunction
if get(g:, 'airline#themes#base16#constant', 0)
call s:load_constant()
else
call s:load_dynamic()
augroup airline_base16
autocmd!
autocmd ColorScheme * call <sid>load_dynamic() | call airline#load_theme()
augroup END
function! airline#themes#base16#refresh()
let g:airline#themes#base16#palette = {}
let g:airline#themes#base16#palette.accents = {
\ 'red': airline#themes#get_highlight('Constant'),
\ }
let s:N1 = airline#themes#get_highlight2(['DiffText', 'bg'], ['DiffText', 'fg'], 'bold')
let s:N2 = airline#themes#get_highlight('Visual')
let s:N3 = airline#themes#get_highlight('CursorLine')
let g:airline#themes#base16#palette.normal = airline#themes#generate_color_map(s:N1, s:N2, s:N3)
let group = airline#themes#get_highlight('vimCommand')
let g:airline#themes#base16#palette.normal_modified = {
\ 'statusline': [ group[0], '', group[2], '', '' ]
\ }
let s:I1 = airline#themes#get_highlight2(['DiffAdded', 'bg'], ['DiffAdded', 'fg'], 'bold')
let s:I2 = airline#themes#get_highlight2(['DiffAdded', 'fg'], ['Normal', 'bg'])
let s:I3 = s:N3
let g:airline#themes#base16#palette.insert = airline#themes#generate_color_map(s:I1, s:I2, s:I3)
let g:airline#themes#base16#palette.insert_modified = g:airline#themes#base16#palette.normal_modified
let s:R1 = airline#themes#get_highlight2(['WarningMsg', 'bg'], ['WarningMsg', 'fg'], 'bold')
let s:R2 = s:N2
let s:R3 = s:N3
let g:airline#themes#base16#palette.replace = airline#themes#generate_color_map(s:R1, s:R2, s:R3)
let g:airline#themes#base16#palette.replace_modified = g:airline#themes#base16#palette.normal_modified
let s:V1 = airline#themes#get_highlight2(['Normal', 'bg'], ['Constant', 'fg'], 'bold')
let s:V2 = airline#themes#get_highlight2(['Constant', 'fg'], ['Normal', 'bg'])
let s:V3 = s:N3
let g:airline#themes#base16#palette.visual = airline#themes#generate_color_map(s:V1, s:V2, s:V3)
let g:airline#themes#base16#palette.visual_modified = g:airline#themes#base16#palette.normal_modified
let s:IA = airline#themes#get_highlight2(['NonText', 'fg'], ['CursorLine', 'bg'])
let g:airline#themes#base16#palette.inactive = airline#themes#generate_color_map(s:IA, s:IA, s:IA)
let g:airline#themes#base16#palette.inactive_modified = {
\ 'airline_c': [ group[0], '', group[2], '', '' ]
\ }
endfunction
call airline#themes#base16#refresh()
endif

View File

@ -1,6 +1,7 @@
let g:airline#themes#jellybeans#palette = {}
function! s:generate()
" The name of the function must be 'refresh'.
function! airline#themes#jellybeans#refresh()
" This theme is an example of how to use helper functions to extract highlight
" values from the corresponding colorscheme. It was written in a hurry, so it
" is very minimalistic. If you are a jellybeans user and want to make updates,
@ -47,8 +48,5 @@ function! s:generate()
let g:airline#themes#jellybeans#palette.inactive_modified = g:airline#themes#jellybeans#palette.normal_modified
endfunction
call s:generate()
augroup airline_jellybeans
autocmd!
autocmd ColorScheme * call <sid>generate()
augroup END
call airline#themes#jellybeans#refresh()

View File

@ -1,6 +1,6 @@
let g:airline#themes#monochrome#palette = {}
function! s:load()
function! airline#themes#monochrome#refresh()
let s:SL = airline#themes#get_highlight('StatusLine')
let g:airline#themes#monochrome#palette.normal = airline#themes#generate_color_map(s:SL, s:SL, s:SL)
let g:airline#themes#monochrome#palette.insert = g:airline#themes#monochrome#palette.normal
@ -11,8 +11,5 @@ function! s:load()
let g:airline#themes#monochrome#palette.inactive = airline#themes#generate_color_map(s:SLNC, s:SLNC, s:SLNC)
endfunction
call s:load()
augroup airline_monochrome
autocmd!
autocmd ColorScheme * call <sid>load()
augroup END
call airline#themes#monochrome#refresh()

View File

@ -1,6 +1,6 @@
let g:airline#themes#tomorrow#palette = {}
function! s:generate()
function! airline#themes#tomorrow#refresh()
let g:airline#themes#tomorrow#palette.accents = {
\ 'red': airline#themes#get_highlight('Constant'),
\ }
@ -40,8 +40,5 @@ function! s:generate()
\ }
endfunction
call s:generate()
augroup airline_tomorrow
autocmd!
autocmd ColorScheme * call <sid>generate() | call airline#load_theme()
augroup END
call airline#themes#tomorrow#refresh()

View File

@ -1,6 +1,6 @@
let g:airline#themes#zenburn#palette = {}
function! s:generate()
function! airline#themes#zenburn#refresh()
let g:airline#themes#zenburn#palette.accents = {
\ 'red': airline#themes#get_highlight('Constant'),
\ }
@ -40,9 +40,5 @@ function! s:generate()
\ }
endfunction
call s:generate()
augroup airline_zenburn
autocmd!
autocmd ColorScheme * call <sid>generate()
augroup END
call airline#themes#zenburn#refresh()