I just recently discovered two VIM plugins that I find very useful, namely vim-sunset (http://vimawesome.com/plugin/sunset) and vim-airline (http://vimawesome.com/plugin/vim-airline-sad-beautiful-tragic). Changing the colorscheme with vim-sunset was easy, but I would like it to also change the colors in my airline. I have tried to achieve this via
function! Sunset_daytime_callback()
" Version 1
let g:airline_theme = 'airline_theme_light'
" Version 2
colorscheme vim_colorscheme_light
autocmd ColorScheme * :AirlineTheme airline_theme_light
" Version 3
autocmd ColorScheme * :AirlineTheme airline_theme_light
colorscheme vim_colorscheme_light
endfunction
(same thing for Sunset_nighttime_callback()
)
The problems are the following:
airline_theme
is correctly set, but it doesn't update. Also, I couldn't find any function in the airline documentation mentioning how to "redraw" with the new parameters.Sunset_daytime_callback()
twice in order to update the powerline too:AirlineTheme
is not ready yet when the .vimrc
is first executedIs there a (possibly elegant) solution how to get this to work? Did I maybe just miss a function in the airline plugin that just redraws the line?
Thanks for your help!
Ok, so I found a solution myself: the key is to check whether or not the airline-plugin is already loaded when trying to set the airline colorscheme. Now it looks something like this:
function! Sunset_daytime_callback()
" This Works :)
colorscheme vim_colorscheme_light
if exists(':AirlineTheme') " check if the plugin is loaded
:AirlineTheme light
else
let g:airline_theme = 'light'
endif
endfunction