mirror of
https://github.com/vim-airline/vim-airline-themes.git
synced 2024-12-12 21:33:41 +08:00
improve performance with accent cache (#326).
This commit is contained in:
parent
de1d1e365e
commit
99b7cdf334
|
@ -3,6 +3,7 @@
|
||||||
|
|
||||||
let s:is_win32term = (has('win32') || has('win64')) && !has('gui_running')
|
let s:is_win32term = (has('win32') || has('win64')) && !has('gui_running')
|
||||||
let s:separators = {}
|
let s:separators = {}
|
||||||
|
let s:accents = {}
|
||||||
|
|
||||||
function! s:gui2cui(rgb, fallback)
|
function! s:gui2cui(rgb, fallback)
|
||||||
if a:rgb == ''
|
if a:rgb == ''
|
||||||
|
@ -94,6 +95,10 @@ 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(accent)
|
||||||
|
let s:accents[a:accent] = 1
|
||||||
|
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')
|
||||||
|
@ -121,7 +126,10 @@ function! airline#highlighter#highlight(modes)
|
||||||
let mode_colors = kvp[1]
|
let mode_colors = kvp[1]
|
||||||
call airline#highlighter#exec(kvp[0].suffix, mode_colors)
|
call airline#highlighter#exec(kvp[0].suffix, mode_colors)
|
||||||
|
|
||||||
for accent in keys(p.accents)
|
for accent in keys(s:accents)
|
||||||
|
if !has_key(p.accents, accent)
|
||||||
|
continue
|
||||||
|
endif
|
||||||
let colors = copy(mode_colors)
|
let colors = copy(mode_colors)
|
||||||
if p.accents[accent][0] != ''
|
if p.accents[accent][0] != ''
|
||||||
let colors[0] = p.accents[accent][0]
|
let colors[0] = p.accents[accent][0]
|
||||||
|
|
|
@ -6,6 +6,7 @@ let s:spc = g:airline_symbols.space
|
||||||
|
|
||||||
function! s:wrap_accent(part, value)
|
function! s:wrap_accent(part, value)
|
||||||
if exists('a:part.accent')
|
if exists('a:part.accent')
|
||||||
|
call airline#highlighter#add_accent(a:part.accent)
|
||||||
return '%#__accent_'.(a:part.accent).'#'.a:value.'%#__restore__#'
|
return '%#__accent_'.(a:part.accent).'#'.a:value.'%#__restore__#'
|
||||||
endif
|
endif
|
||||||
return a:value
|
return a:value
|
||||||
|
|
|
@ -13,6 +13,7 @@ describe 'highlighter'
|
||||||
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 hlID('airline_c_red') == 0
|
Expect hlID('airline_c_red') == 0
|
||||||
call airline#themes#patch(g:airline#themes#dark#palette)
|
call airline#themes#patch(g:airline#themes#dark#palette)
|
||||||
|
call airline#highlighter#add_accent('red')
|
||||||
call airline#highlighter#highlight(['normal'])
|
call airline#highlighter#highlight(['normal'])
|
||||||
Expect hlID('airline_c_red') != 0
|
Expect hlID('airline_c_red') != 0
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue
Block a user