From a74f73043be2eb355e96311f5a4d01a915e024fe Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Mon, 6 Nov 2017 09:41:52 +1300 Subject: Make background detection return not set value This approach allows more flexibility from the caller's side. --- vim/autoload/detect_background.vim | 7 +++++-- vim/config/syntax.vim | 6 ++++-- 2 files changed, 9 insertions(+), 4 deletions(-) (limited to 'vim') diff --git a/vim/autoload/detect_background.vim b/vim/autoload/detect_background.vim index e4fee199..9758f8d3 100644 --- a/vim/autoload/detect_background.vim +++ b/vim/autoload/detect_background.vim @@ -3,6 +3,9 @@ " light backgrounds; we'll default to choosing a dark background unless we " find some reason *not* to. " +" Return the string to which we think the option should be set, to allow the +" caller to use it as they see fit. +" " Author: Tom Ryder " License: Same as Vim itself " @@ -27,9 +30,9 @@ function! detect_background#DetectBackground() abort if l:bg ==# 'default' \ || l:bg ==# '7' \ || l:bg ==# '15' - set background=light + return 'light' else - set background=dark + return 'dark' endif endfunction diff --git a/vim/config/syntax.vim b/vim/config/syntax.vim index 8cb1228b..f1116528 100644 --- a/vim/config/syntax.vim +++ b/vim/config/syntax.vim @@ -5,9 +5,11 @@ if has('syntax') silent! syntax enable silent! syntax sync minlines=100 - " If we can, detect a light background, but default to a dark one + " If we can, detect a light background, but default to a dark one. This is + " only because it's more likely the author of this configuration will be + " using one. if has('eval') && v:version >= 701 - silent! call detect_background#DetectBackground() + silent! let &background = detect_background#DetectBackground() else set background=dark endif -- cgit v1.2.3