1 " Customize which :AirlineTheme to use for specific colorscheme's based on
2 " caller-supplied mapping table.
4 " -------------------------------------------------------------------------
7 " * Dict providing the mapping table of colorscheme -> airline theme
9 " let g:colorscheme_airlinetheme_map = { ... }
11 " * Default airline theme to use when no specific entry found in the
12 " mapping table [and no airline theme which exactly matches current
14 " let g:colorscheme_airlinetheme_default = [str]
15 " -------------------------------------------------------------------------
17 " Use a ColorScheme autocmd to automatically switch :AirlineTheme based on
18 " the new colorscheme. Defer adding the ColorScheme autocmd until the
19 " VimEnter event so that our ColorScheme autocmd hook will be 'last' in the
20 " 'autocmd ColorScheme' stack.
21 augroup airlinetheme_map_afterinit
23 autocmd VimEnter * silent! call <SID>on_init()
27 augroup airlinetheme_map
29 autocmd ColorScheme * call <SID>on_colorscheme_change()
31 call <SID>on_colorscheme_change()
34 function! s:on_colorscheme_change()
35 " if there's an AirlineTheme override for this colorscheme, use that
36 if exists('g:colorscheme_airlinetheme_map') &&
37 \ has_key(g:colorscheme_airlinetheme_map, g:colors_name)
38 let g:airline_theme=g:colorscheme_airlinetheme_map[g:colors_name]
41 " if there's an exact-match AirlineTheme for the current colorscheme,
42 " use that; else use the user-defined default AirlineTheme (if any)
43 if exists('g:colorscheme_airlinetheme_default') &&
44 \ g:airline_theme != g:colors_name
45 let g:airline_theme=g:colorscheme_airlinetheme_default