]> Tony Duckles's Git Repositories (git.nynim.org) - dotfiles.git/blob - .vim/bundle/airlinetheme-map/plugin/airlinetheme-map.vim
.bashrc: Add python pip --user path after finalizing $PATH
[dotfiles.git] / .vim / bundle / airlinetheme-map / plugin / airlinetheme-map.vim
1 " Customize which :AirlineTheme to use for specific colorscheme's based on
2 " caller-supplied mapping table.
3
4 " -------------------------------------------------------------------------
5 " CONFIGURATION:
6 "
7 " * Dict providing the mapping table of colorscheme -> airline theme
8 " overrides >
9 " let g:colorscheme_airlinetheme_map = { ... }
10 "
11 " * Default airline theme to use when no specific entry found in the
12 " mapping table [and no airline theme which exactly matches current
13 " colorscheme] >
14 " let g:colorscheme_airlinetheme_default = [str]
15 " -------------------------------------------------------------------------
16
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
22 autocmd!
23 autocmd VimEnter * silent! call <SID>on_init()
24 augroup END
25
26 function! s:on_init()
27 augroup airlinetheme_map
28 autocmd!
29 autocmd ColorScheme * call <SID>on_colorscheme_change()
30 augroup END
31 call <SID>on_colorscheme_change()
32 endfunction
33
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]
39 :AirlineRefresh
40 else
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
46 :AirlineRefresh
47 endif
48 endif
49 endfunction