fix solarized theme being out of sync (#288).
This commit is contained in:
parent
9d3c6506da
commit
2f3b33daae
@ -26,6 +26,18 @@ function! airline#add_inactive_statusline_func(name)
|
|||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! airline#load_theme()
|
function! airline#load_theme()
|
||||||
|
if exists('*airline#themes#{g:airline_theme}#refresh')
|
||||||
|
call airline#themes#{g:airline_theme}#refresh()
|
||||||
|
endif
|
||||||
|
|
||||||
|
let palette = g:airline#themes#{g:airline_theme}#palette
|
||||||
|
call airline#themes#patch(palette)
|
||||||
|
|
||||||
|
if exists('g:airline_theme_patch_func')
|
||||||
|
let Fn = function(g:airline_theme_patch_func)
|
||||||
|
call Fn(palette)
|
||||||
|
endif
|
||||||
|
|
||||||
call airline#highlighter#load_theme()
|
call airline#highlighter#load_theme()
|
||||||
call airline#extensions#load_theme()
|
call airline#extensions#load_theme()
|
||||||
endfunction
|
endfunction
|
||||||
@ -40,15 +52,8 @@ function! airline#switch_theme(name)
|
|||||||
return
|
return
|
||||||
else
|
else
|
||||||
let g:airline_theme = 'dark'
|
let g:airline_theme = 'dark'
|
||||||
let palette = g:airline#themes#dark#palette
|
|
||||||
endif
|
endif
|
||||||
endtry
|
endtry
|
||||||
call airline#themes#patch(palette)
|
|
||||||
|
|
||||||
if exists('g:airline_theme_patch_func')
|
|
||||||
let Fn = function(g:airline_theme_patch_func)
|
|
||||||
call Fn(palette)
|
|
||||||
endif
|
|
||||||
|
|
||||||
let w:airline_lastmode = ''
|
let w:airline_lastmode = ''
|
||||||
call airline#update_statusline()
|
call airline#update_statusline()
|
||||||
|
@ -28,7 +28,6 @@ function! s:prototype.add_section(group, contents)
|
|||||||
let content_parts = split(a:contents, '__accent')
|
let content_parts = split(a:contents, '__accent')
|
||||||
for cpart in content_parts
|
for cpart in content_parts
|
||||||
let accent = matchstr(cpart, '_\zs[^#]*\ze')
|
let accent = matchstr(cpart, '_\zs[^#]*\ze')
|
||||||
call airline#highlighter#add_accent(a:group, accent)
|
|
||||||
call add(contents, cpart)
|
call add(contents, cpart)
|
||||||
endfor
|
endfor
|
||||||
let line = join(contents, a:group)
|
let line = join(contents, a:group)
|
||||||
|
@ -94,28 +94,6 @@ function! airline#highlighter#add_separator(from, to, inverse)
|
|||||||
call <sid>exec_separator({}, a:from, a:to, a:inverse, '')
|
call <sid>exec_separator({}, a:from, a:to, a:inverse, '')
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! airline#highlighter#add_accent(group, accent)
|
|
||||||
let p = g:airline#themes#{g:airline_theme}#palette
|
|
||||||
if exists('p.accents')
|
|
||||||
if has_key(p.accents, a:accent)
|
|
||||||
for kvp in items(p)
|
|
||||||
let mode_colors = kvp[1]
|
|
||||||
if has_key(mode_colors, a:group)
|
|
||||||
let colors = copy(mode_colors[a:group])
|
|
||||||
if p.accents[a:accent][0] != ''
|
|
||||||
let colors[0] = p.accents[a:accent][0]
|
|
||||||
endif
|
|
||||||
if p.accents[a:accent][2] != ''
|
|
||||||
let colors[2] = p.accents[a:accent][2]
|
|
||||||
endif
|
|
||||||
let colors[4] = get(p.accents[a:accent], 4, '')
|
|
||||||
let mode_colors[a:group.'_'.a:accent] = colors
|
|
||||||
endif
|
|
||||||
endfor
|
|
||||||
endif
|
|
||||||
endif
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
function! airline#highlighter#highlight_modified_inactive(bufnr)
|
function! airline#highlighter#highlight_modified_inactive(bufnr)
|
||||||
if getbufvar(a:bufnr, '&modified')
|
if getbufvar(a:bufnr, '&modified')
|
||||||
let colors = exists('g:airline#themes#{g:airline_theme}#palette.inactive_modified.airline_c')
|
let colors = exists('g:airline#themes#{g:airline_theme}#palette.inactive_modified.airline_c')
|
||||||
@ -131,6 +109,8 @@ function! airline#highlighter#highlight_modified_inactive(bufnr)
|
|||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! airline#highlighter#highlight(modes)
|
function! airline#highlighter#highlight(modes)
|
||||||
|
let p = g:airline#themes#{g:airline_theme}#palette
|
||||||
|
|
||||||
" draw the base mode, followed by any overrides
|
" draw the base mode, followed by any overrides
|
||||||
let mapped = map(a:modes, 'v:val == a:modes[0] ? v:val : a:modes[0]."_".v:val')
|
let mapped = map(a:modes, 'v:val == a:modes[0] ? v:val : a:modes[0]."_".v:val')
|
||||||
let suffix = a:modes[0] == 'inactive' ? '_inactive' : ''
|
let suffix = a:modes[0] == 'inactive' ? '_inactive' : ''
|
||||||
@ -138,7 +118,24 @@ function! airline#highlighter#highlight(modes)
|
|||||||
if exists('g:airline#themes#{g:airline_theme}#palette[mode]')
|
if exists('g:airline#themes#{g:airline_theme}#palette[mode]')
|
||||||
let dict = g:airline#themes#{g:airline_theme}#palette[mode]
|
let dict = g:airline#themes#{g:airline_theme}#palette[mode]
|
||||||
for kvp in items(dict)
|
for kvp in items(dict)
|
||||||
call airline#highlighter#exec(kvp[0].suffix, kvp[1])
|
let mode_colors = kvp[1]
|
||||||
|
call airline#highlighter#exec(kvp[0].suffix, mode_colors)
|
||||||
|
|
||||||
|
for accent in keys(p.accents)
|
||||||
|
let colors = copy(mode_colors)
|
||||||
|
if p.accents[accent][0] != ''
|
||||||
|
let colors[0] = p.accents[accent][0]
|
||||||
|
endif
|
||||||
|
if p.accents[accent][2] != ''
|
||||||
|
let colors[2] = p.accents[accent][2]
|
||||||
|
endif
|
||||||
|
if len(colors) >= 5
|
||||||
|
let colors[4] = get(p.accents[accent], 4, '')
|
||||||
|
else
|
||||||
|
call add(colors, get(p.accents[accent], 4, ''))
|
||||||
|
endif
|
||||||
|
call airline#highlighter#exec(kvp[0].suffix.'_'.accent, colors)
|
||||||
|
endfor
|
||||||
endfor
|
endfor
|
||||||
|
|
||||||
" TODO: optimize this
|
" TODO: optimize this
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
let g:airline#themes#solarized#palette = {}
|
let g:airline#themes#solarized#palette = {}
|
||||||
|
|
||||||
function! s:generate()
|
function! airline#themes#solarized#refresh()
|
||||||
""""""""""""""""""""""""""""""""""""""""""""""""
|
""""""""""""""""""""""""""""""""""""""""""""""""
|
||||||
" Options
|
" Options
|
||||||
""""""""""""""""""""""""""""""""""""""""""""""""
|
""""""""""""""""""""""""""""""""""""""""""""""""
|
||||||
@ -169,8 +169,5 @@ function! s:generate()
|
|||||||
\ s:N2[0].g, s:N2[1].g, s:N2[0].t, s:N2[1].t, s:N2[2]]
|
\ s:N2[0].g, s:N2[1].g, s:N2[0].t, s:N2[1].t, s:N2[2]]
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
call s:generate()
|
call airline#themes#solarized#refresh()
|
||||||
augroup airline_solarized
|
|
||||||
autocmd!
|
|
||||||
autocmd ColorScheme * call <sid>generate() | call airline#load_theme()
|
|
||||||
augroup END
|
|
||||||
|
@ -11,10 +11,10 @@ describe 'highlighter'
|
|||||||
|
|
||||||
it 'should populate accent colors'
|
it 'should populate accent colors'
|
||||||
Expect exists('g:airline#themes#dark#palette.normal.airline_c_red') to_be_false
|
Expect exists('g:airline#themes#dark#palette.normal.airline_c_red') to_be_false
|
||||||
Expect exists('g:airline#themes#dark#palette.insert.airline_c_red') to_be_false
|
Expect hlID('airline_c_red') == 0
|
||||||
call airline#highlighter#add_accent('airline_c', 'red')
|
call airline#themes#patch(g:airline#themes#dark#palette)
|
||||||
Expect exists('g:airline#themes#dark#palette.normal.airline_c_red') to_be_true
|
call airline#highlighter#highlight(['normal'])
|
||||||
Expect exists('g:airline#themes#dark#palette.insert.airline_c_red') to_be_true
|
Expect hlID('airline_c_red') != 0
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user