diff --git a/vimrc b/vimrc index a57b9e3..ac109ed 100644 --- a/vimrc +++ b/vimrc @@ -79,7 +79,7 @@ let g:quickfix_pane_height = 20 """""""""""""" " COLORS """""""""""""" -let g:campo_default_bg_mode = 'dark' " Start vim with the dark theme. Set to 'light' for the light theme. +let g:campo_light_dark_mode = 'dark' " Start vim with the dark theme. Set to 'light' for the light theme. let g:campo_dark_theme = 'campo-dark-simple' "'campo-dark-blue' let g:campo_light_theme = 'campo-light-simple' "'campo-light' let g:campo_theme_use_rainbow_parens = 1 @@ -126,7 +126,6 @@ let g:campo_directories_to_force_stripping_trailing_whitespace = [] " e.g. let g:campo_files_to_force_stripping_trailing_whitespace = ['/z/modules/test.h', '/d/build/config.h'] let g:campo_files_to_force_stripping_trailing_whitespace = [] - """""""""""""" " SEARCH """""""""""""" @@ -956,7 +955,7 @@ let g:clojure_fuzzy_indent_blacklist = ['-fn$', '\v^with-%(meta|out-str|loading- let g:rainbow_active = 1 " Always on let s:light_rainbow = ['red', 'green', 'magenta', 'cyan', 'yellow', 'white', 'gray', 'blue'] let s:dark_rainbow = ['darkblue', 'red', 'black', 'darkgreen', 'darkyellow', 'darkred', 'darkgray'] -let s:rainbow_theme = g:campo_default_bg_mode +let s:rainbow_theme = g:campo_light_dark_mode function! UpdateRainbowConf() let g:rainbow_conf = { @@ -1045,12 +1044,21 @@ set statusline=%<%f\ (%{&ft})\ %-4(%m%)%=%-19(%3l,%02c%03V%) exec "autocmd ColorScheme " . g:campo_dark_theme . " call ReloadRainbow()" exec "autocmd ColorScheme " . g:campo_light_theme . " call ReloadRainbow()" -" Switch between light and dark themes. -noremap l :call ChangeBgTheme('light', 0) -noremap ll :call ChangeBgTheme('dark', 0) +" Toggle between light and dark themes. +noremap l :call ToggleLightDarkTheme() -function! ChangeBgTheme(bg, onlySetTheme) - if a:bg =~ 'light' +let s:current_light_dark_mode = g:campo_light_dark_mode + +function! ToggleLightDarkTheme() + if s:current_light_dark_mode == 'light' + call ChangeLightDarkMode('dark', 0) + else + call ChangeLightDarkMode('light', 0) + endif +endfunction + +function! ChangeLightDarkMode(mode, onlySetTheme) + if a:mode == 'light' let s:rainbow_theme = 'light' let s:theme = g:campo_light_theme exe 'colorscheme ' . s:theme @@ -1065,15 +1073,18 @@ function! ChangeBgTheme(bg, onlySetTheme) exe 'colorscheme ' . s:theme endif + let s:current_light_dark_mode = a:mode + if !a:onlySetTheme - exec 'AirlineTheme' a:bg + exec 'AirlineTheme' a:mode endif endfunction -if g:campo_default_bg_mode =~ 'light' - call ChangeBgTheme('light', 1) +" Set the intial light/dark mode. +if g:campo_light_dark_mode =~ 'light' + call ChangeLightDarkMode('light', 1) else - call ChangeBgTheme('dark', 1) + call ChangeLightDarkMode('dark', 1) endif