|author||Tom Ryder <firstname.lastname@example.org>||2019-06-14 20:33:29 +1200|
|committer||Tom Ryder <email@example.com>||2019-06-14 20:33:29 +1200|
Refactor colorscheme select with cursorline hooks
1 files changed, 20 insertions, 17 deletions
@@ -962,29 +962,32 @@ if !exists('syntax_on')
-" 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
+" 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
- set cursorline
- colorscheme default
- set background=dark
- set nocursorline
+ if &background !=# 'dark'
+ set background=dark
" My mapping definitions begin here. I have some general personal rules for