From 216bcf1088375fb64ad60b591673e0fc992102a3 Mon Sep 17 00:00:00 2001 From: Leszek Swirski Date: Mon, 5 Aug 2013 18:44:12 +0100 Subject: [PATCH] Make themes#generate_color_map robust against undefined highlights --- autoload/airline/themes.vim | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/autoload/airline/themes.vim b/autoload/airline/themes.vim index 668f8eb4..c7a571ae 100644 --- a/autoload/airline/themes.vim +++ b/autoload/airline/themes.vim @@ -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, ',') ]