fix load regression errors with recent theme changes

This commit is contained in:
Bailey Ling 2016-01-30 15:17:19 -05:00
parent c34b29beb4
commit ffe0fafa2d
2 changed files with 16 additions and 13 deletions

View File

@ -71,14 +71,20 @@ endfunction
function! airline#switch_matching_theme()
if exists('g:colors_name')
let existing = g:airline_theme
try
let palette = g:airline#themes#{g:colors_name}#palette
silent call airline#switch_theme(g:colors_name)
call airline#switch_theme(g:colors_name)
return 1
catch
for map in items(g:airline_theme_map)
if match(g:colors_name, map[0]) > -1
silent call airline#switch_theme(map[1])
try
let palette = g:airline#themes#{map[1]}#palette
call airline#switch_theme(map[1])
catch
call airline#switch_theme(existing)
endtry
return 1
endif
endfor

View File

@ -8,7 +8,6 @@ let g:loaded_airline = 1
let s:airline_initialized = 0
function! s:init()
let s:airline_theme_defined = exists('g:airline_theme')
if s:airline_initialized
return
endif
@ -17,18 +16,18 @@ function! s:init()
call airline#extensions#load()
call airline#init#sections()
if !s:airline_theme_defined
let g:airline_theme = 'dark'
let s:airline_theme_defined = 1
endif
if s:airline_theme_defined || !airline#switch_matching_theme()
let s:theme_in_vimrc = exists('g:airline_theme')
if s:theme_in_vimrc
try
let palette = g:airline#themes#{g:airline_theme}#palette
catch
echom 'Could not resolve airline theme "' . g:airline_theme . '". Themes have been migrated to github.com/vim-airline/vim-airline-themes.'
let g:airline_theme = 'dark'
endtry
call airline#switch_theme(g:airline_theme)
silent call airline#switch_theme(g:airline_theme)
else
let g:airline_theme = 'dark'
silent call s:on_colorscheme_changed()
endif
silent doautocmd User AirlineAfterInit
@ -44,10 +43,8 @@ endfunction
function! s:on_colorscheme_changed()
call s:init()
if !s:airline_theme_defined
if airline#switch_matching_theme()
return
endif
if !s:theme_in_vimrc
call airline#switch_matching_theme()
endif
" couldn't find a match, or theme was defined, just refresh