mirror of
https://github.com/vim-airline/vim-airline.git
synced 2024-11-23 06:13:40 +08:00
Make themes#generate_color_map robust against undefined highlights
This commit is contained in:
parent
61c95d4103
commit
216bcf1088
|
@ -15,18 +15,19 @@ function! airline#themes#generate_color_map(section1, section2, section3, file)
|
|||
endfunction
|
||||
|
||||
function! s:get_syn(group, what)
|
||||
return synIDattr(synIDtrans(hlID(a:group)), a:what)
|
||||
let color = synIDattr(synIDtrans(hlID(a:group)), a:what)
|
||||
if empty(color) || color == -1
|
||||
let color = synIDattr(synIDtrans(hlID('Normal')), a:what)
|
||||
endif
|
||||
if empty(color) || color == -1
|
||||
let color = a:what ==# 'fg' ? 0 : 1
|
||||
endif
|
||||
return color
|
||||
endfunction
|
||||
|
||||
function! s:get_array(fg, bg, opts)
|
||||
let fg = a:fg
|
||||
let bg = a:bg
|
||||
if fg == '' || fg < 0
|
||||
let fg = s:get_syn('Normal', 'fg')
|
||||
endif
|
||||
if bg == '' || bg < 0
|
||||
let bg = s:get_syn('Normal', 'bg')
|
||||
endif
|
||||
return has('gui_running')
|
||||
\ ? [ fg, bg, '', '', join(a:opts, ',') ]
|
||||
\ : [ '', '', fg, bg, join(a:opts, ',') ]
|
||||
|
|
Loading…
Reference in New Issue
Block a user