Only reset to Normal highlighting if it is actually defined
closes #1415 and similar
This commit is contained in:
parent
ac9e4092ef
commit
52663545a9
@ -87,8 +87,18 @@ function! s:CheckDefined(colors)
|
|||||||
" Checks, whether the definition of the colors is valid and is not empty or NONE
|
" Checks, whether the definition of the colors is valid and is not empty or NONE
|
||||||
" e.g. if the colors would expand to this:
|
" e.g. if the colors would expand to this:
|
||||||
" hi airline_c ctermfg=NONE ctermbg=NONE
|
" hi airline_c ctermfg=NONE ctermbg=NONE
|
||||||
" that means to clear that highlighting group, therefore, add a special term=NONE
|
" that means to clear that highlighting group, therefore, fallback to Normal
|
||||||
" argument
|
" highlighting group for the cterm values
|
||||||
|
|
||||||
|
" This only works, if the Normal highlighting group is actually defined, so
|
||||||
|
" return early, if it has been cleared
|
||||||
|
if !exists("g:airline#highlighter#normal_fg_hi")
|
||||||
|
let g:airline#highlighter#normal_fg_hi = synIDattr(synIDtrans(hlID('Normal')), 'fg', 'cterm')
|
||||||
|
endif
|
||||||
|
if empty(g:airline#highlighter#normal_fg_hi)
|
||||||
|
return a:colors
|
||||||
|
endif
|
||||||
|
|
||||||
for val in a:colors
|
for val in a:colors
|
||||||
if !empty(val) && val !=# 'NONE'
|
if !empty(val) && val !=# 'NONE'
|
||||||
return a:colors
|
return a:colors
|
||||||
@ -96,7 +106,7 @@ function! s:CheckDefined(colors)
|
|||||||
endfor
|
endfor
|
||||||
" this adds the bold attribute to the term argument of the :hi command,
|
" this adds the bold attribute to the term argument of the :hi command,
|
||||||
" but at least this makes sure, the group will be defined
|
" but at least this makes sure, the group will be defined
|
||||||
let fg = synIDattr(synIDtrans(hlID('Normal')), 'fg', 'cterm')
|
let fg = g:airline#highlighter#normal_fg_hi
|
||||||
let bg = synIDattr(synIDtrans(hlID('Normal')), 'bg', 'cterm')
|
let bg = synIDattr(synIDtrans(hlID('Normal')), 'bg', 'cterm')
|
||||||
return a:colors[0:1] + [fg, bg] + [a:colors[4]]
|
return a:colors[0:1] + [fg, bg] + [a:colors[4]]
|
||||||
endfunction
|
endfunction
|
||||||
|
@ -53,6 +53,7 @@ endfunction
|
|||||||
|
|
||||||
function! s:on_colorscheme_changed()
|
function! s:on_colorscheme_changed()
|
||||||
call s:init()
|
call s:init()
|
||||||
|
unlet! g:airline#highlighter#normal_fg_hi
|
||||||
let g:airline_gui_mode = airline#init#gui_mode()
|
let g:airline_gui_mode = airline#init#gui_mode()
|
||||||
if !s:theme_in_vimrc
|
if !s:theme_in_vimrc
|
||||||
call airline#switch_matching_theme()
|
call airline#switch_matching_theme()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user