highlighter: do not error out, if defined hi-color does not exist
if a color definition is being used, that Vim does not seem to recognize, instead of erroring out fallback to a hard-coded value of grey. Otherwise we do have potentially a bad user experience for throwing too many error messages at the user in very short time, which may prevent him from doing the actual work (as just happened to me) Grey should always be defined and it should be rather easy to spot (I hope). Also just mention for what group this happens. This should give the user a clue, where and when this happens (so he may be able to adjust the theme).
This commit is contained in:
parent
ed60e1d369
commit
70b06be4b0
|
@ -119,7 +119,15 @@ function! airline#highlighter#exec(group, colors) abort
|
||||||
let colors = s:CheckDefined(colors)
|
let colors = s:CheckDefined(colors)
|
||||||
if old_hi != new_hi || !s:hl_group_exists(a:group)
|
if old_hi != new_hi || !s:hl_group_exists(a:group)
|
||||||
let cmd = printf('hi %s%s', a:group, s:GetHiCmd(colors))
|
let cmd = printf('hi %s%s', a:group, s:GetHiCmd(colors))
|
||||||
|
try
|
||||||
exe cmd
|
exe cmd
|
||||||
|
catch /^Vim\%((\a\+)\)\=:E421:/ " color definition not found
|
||||||
|
let group=matchstr(v:exception, '\w\+\ze=')
|
||||||
|
let color=matchstr(v:exception, '=\zs\w\+')
|
||||||
|
let cmd=substitute(cmd, color, 'grey', 'g')
|
||||||
|
exe cmd
|
||||||
|
call airline#util#warning('color definition for group ' . a:group . ' not found, using grey as fallback')
|
||||||
|
endtry
|
||||||
if has_key(s:hl_groups, a:group)
|
if has_key(s:hl_groups, a:group)
|
||||||
let s:hl_groups[a:group] = colors
|
let s:hl_groups[a:group] = colors
|
||||||
endif
|
endif
|
||||||
|
|
Loading…
Reference in New Issue