diff options
author | Tom Ryder <tom@sanctum.geek.nz> | 2019-06-16 14:19:36 +1200 |
---|---|---|
committer | Tom Ryder <tom@sanctum.geek.nz> | 2019-06-16 14:24:11 +1200 |
commit | 615463509a033a15e9e4caad9a748be418c2ed06 (patch) | |
tree | c2a8ae9b256c9dfbaa13f6799b430be1efd299c6 | |
parent | Break up long conditions again (diff) | |
download | dotfiles-615463509a033a15e9e4caad9a748be418c2ed06.tar.gz dotfiles-615463509a033a15e9e4caad9a748be418c2ed06.zip |
Overhaul color scheme selection logic
-rw-r--r-- | vim/vimrc | 29 |
1 files changed, 22 insertions, 7 deletions
@@ -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: |