Merge pull request #977 from vim-airline/theme-fix

fix load regression errors with recent theme changes
This commit is contained in:
Bailey Ling 2016-01-31 08:43:55 -05:00
commit 8c860b7045
2 changed files with 16 additions and 13 deletions

View File

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

View File

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