From 615463509a033a15e9e4caad9a748be418c2ed06 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Sun, 16 Jun 2019 14:19:36 +1200 Subject: Overhaul color scheme selection logic --- vim/vimrc | 29 ++++++++++++++++++++++------- 1 file 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: -- cgit v1.2.3