aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Ryder <tom@sanctum.geek.nz>2019-06-14 20:33:29 +1200
committerTom Ryder <tom@sanctum.geek.nz>2019-06-14 20:33:29 +1200
commita22e4ff2daaf7379f5ee1346e9c6639cb6eb4653 (patch)
tree8958164724ff102734d384481f3f0909573954af
parentd63860cac06d84e9cd6ec62129e4c86dc978c81e (diff)
downloaddotfiles-a22e4ff2daaf7379f5ee1346e9c6639cb6eb4653.tar.gz
Refactor colorscheme select with cursorline hooks
-rw-r--r--vim/vimrc37
1 files changed, 20 insertions, 17 deletions
diff --git a/vim/vimrc b/vim/vimrc
index 16745df7..6dd64c2c 100644
--- a/vim/vimrc
+++ b/vim/vimrc
@@ -962,29 +962,32 @@ if !exists('syntax_on')
syntax enable
endif
-" We'll have Vim try to use my 'sahara' fork of the 'desert256' color scheme,
-" and if it manages to do so without errors, turn on the 'cursorline' feature,
-" since the scheme configures it and 'cursorcolumn' to be a very dark gray
-" that doesn't stand out too much against a black background. Aside from the
-" aforementioned experiment with monochrome terminals, I exclusively use dark
-" backgrounds.
-"
+" Before we attempt to pick a syntax highlighting color scheme, we'll set up
+" a couple of hooks for colorscheme loading. In this case, we turn
+" 'cursorline' on if my 'sahara' colorscheme is loaded, since I've configured
+" it to be a very dark gray that doesn't stand out too much against a black
+" background. For any other colorscheme, turn the option off, because it
+" almost always stands out too much for my liking.
+"
+autocmd vimrc ColorScheme *
+ \ set nocursorline
+autocmd vimrc ColorScheme sahara
+ \ set cursorline
+
+" 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 reset the syntax highlighting, 'background', and 'cursorline' for
-" dark-background default colors. I used it for years; it looks and works
-" just fine.
+" error, and ensure a dark background for the default colorscheme.
"
-" 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.
+" 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
colorscheme sahara
- set cursorline
catch
- colorscheme default
- set background=dark
- set nocursorline
+ if &background !=# 'dark'
+ set background=dark
+ endif
endtry
" My mapping definitions begin here. I have some general personal rules for