aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Ryder <tom@sanctum.geek.nz>2019-06-16 14:19:36 +1200
committerTom Ryder <tom@sanctum.geek.nz>2019-06-16 14:24:11 +1200
commit615463509a033a15e9e4caad9a748be418c2ed06 (patch)
treec2a8ae9b256c9dfbaa13f6799b430be1efd299c6
parentBreak up long conditions again (diff)
downloaddotfiles-615463509a033a15e9e4caad9a748be418c2ed06.tar.gz
dotfiles-615463509a033a15e9e4caad9a748be418c2ed06.zip
Overhaul color scheme selection logic
-rw-r--r--vim/vimrc29
1 files changed, 22 insertions, 7 deletions
diff --git a/vim/vimrc b/vim/vimrc
index 0a95d1a9..ccb3782f 100644
--- a/vim/vimrc
+++ b/vim/vimrc
@@ -981,19 +981,34 @@ autocmd vimrc ColorScheme sahara
" We'll have Vim try to use my 'sahara' fork of the 'desert256' color scheme.
" If we fail to load the color scheme, for whatever reason, suppress the
-" error, and ensure a dark background for the default color scheme.
+" error, and default to a dark background (if not already) for the the default
+" color scheme in the absence of guidance otherwise from a COLORFGBG
+" environment variable or a t_RB terminal response. Vim otherwise defaults to
+" 'light', which is less likely in my case.
"
" There's also a very simple grayscale color scheme I occasionally use instead
" called 'juvenile', which is included as a Git submodule with this dotfiles
" distribution.
"
-try
+
+" Use 'dark' as my default value for 'background', in the absence of an
+" environment variable COLORFGBG or a response in v:termrbgresp that would set
+" it specifically.
+"
+if !exists('$COLORFGBG') && (
+ \ !exists('v:termrbgresp')
+ \ || v:termrbgresp ==# ''
+ \ )
+ set background=dark
+endif
+
+" If the background seems to be dark, and my custom sahara.vim color scheme
+" looks to be available, load it.
+"
+if &background ==# 'dark'
+ \ && globpath(&runtimepath, 'colors/sahara.vim') !=# ''
colorscheme sahara
-catch
- if &background !=# 'dark'
- set background=dark
- endif
-endtry
+endif
" My mapping definitions begin here. I have some general personal rules for
" approaches to mappings: