From a22e4ff2daaf7379f5ee1346e9c6639cb6eb4653 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Fri, 14 Jun 2019 20:33:29 +1200 Subject: Refactor colorscheme select with cursorline hooks --- vim/vimrc | 37 ++++++++++++++++++++----------------- 1 file 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 -- cgit v1.2.3