From bcba04e20c00c0b8631bf5a33865bbe2de76ccf6 Mon Sep 17 00:00:00 2001 From: Bailey Ling Date: Sun, 18 Aug 2013 04:56:38 +0000 Subject: [PATCH] account for empty vimrc with no colorscheme set. --- autoload/airline.vim | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/autoload/airline.vim b/autoload/airline.vim index 9c9258e5..5e66ba48 100644 --- a/autoload/airline.vim +++ b/autoload/airline.vim @@ -21,18 +21,20 @@ function! airline#switch_theme(name) endfunction function! airline#switch_matching_theme() - let v:errmsg = '' - silent! let palette = g:airline#themes#{g:colors_name}#palette - if empty(v:errmsg) - call airline#switch_theme(g:colors_name) - return 1 - else - for map in items(g:airline_theme_map) - if match(g:colors_name, map[0]) > -1 - call airline#switch_theme(map[1]) - return 1 - endif - endfor + if exists('g:colors_name') + let v:errmsg = '' + silent! let palette = g:airline#themes#{g:colors_name}#palette + if empty(v:errmsg) + call airline#switch_theme(g:colors_name) + return 1 + else + for map in items(g:airline_theme_map) + if match(g:colors_name, map[0]) > -1 + call airline#switch_theme(map[1]) + return 1 + endif + endfor + endif endif return 0 endfunction