1

tl;dr:

  1. How do I override the colorscheme's cursor color in a highlight block
  2. How do I find a comprehensive list of colorscheme variables and how do I set them in general (to override a colorscheme's defaults)

I have been using Evan Schoonover's Solarized colorscheme (the dark mode) and absolutely love it. Except for one very annoying problem:

When incremental highlighting is on for / and ? searching, the cursor inside a highlighted block disappears:

cursorhighlighting problems

In the picture, the search was /te, so the highlight covers te but the cursor is setting on the t.

This is absolutely horrific for large scale search/replace n. repeat operations. I can never quite tell where my current position is.

I am unsure if this problem is related to my terminal colors (I am using urxvt with the Schoonover's solarized xresources theme and some minor adjustments (set the font, the scrollbar, etc), especially considering the fact that I have yet to see anyone complain of the same problem.

For further context: I am using i3wm in Arch Linux.

Even further context: I've been using neovim for a while, but have never used a plugin manager, and the only 'plugin' I've ever used is this colorscheme (it just resides in my ~/.config/nvim/colors directory).


Update

:verbose hi
 verbose hi
SpecialKey     xxx cterm=bold ctermfg=11 ctermbg=0 guifg=Cyan
        Last set from ~/.config/nvim/colors/solarized.vim
EndOfBuffer    xxx links to NonText
        Last set from ~/.config/nvim/colors/solarized.vim
TermCursor     xxx cterm=reverse gui=reverse
        Last set from ~/.config/nvim/colors/solarized.vim
TermCursorNC   xxx cleared
NonText        xxx cterm=bold ctermfg=11 gui=bold guifg=Blue
        Last set from ~/.config/nvim/colors/solarized.vim
Directory      xxx ctermfg=4 guifg=Cyan
        Last set from ~/.config/nvim/colors/solarized.vim
ErrorMsg       xxx cterm=reverse ctermfg=1 guifg=White guibg=Red
        Last set from ~/.config/nvim/colors/solarized.vim
IncSearch      xxx cterm=standout ctermfg=9 gui=reverse
        Last set from ~/.config/nvim/colors/solarized.vim
Search         xxx cterm=reverse ctermfg=3 guifg=Black guibg=Yellow
        Last set from ~/.config/nvim/colors/solarized.vim
MoreMsg        xxx ctermfg=4 gui=bold guifg=SeaGreen
        Last set from ~/.config/nvim/colors/solarized.vim
ModeMsg        xxx ctermfg=4 gui=bold
        Last set from ~/.config/nvim/colors/solarized.vim
LineNr         xxx ctermfg=10 ctermbg=0 guifg=Yellow
        Last set from ~/.config/nvim/colors/solarized.vim
CursorLineNr   xxx ctermfg=11 gui=bold guifg=Yellow
        Last set from ~/.config/nvim/colors/solarized.vim
Question       xxx cterm=bold ctermfg=6 gui=bold guifg=Green
        Last set from ~/.config/nvim/colors/solarized.vim
StatusLine     xxx cterm=reverse ctermfg=14 ctermbg=0 gui=bold,reverse
        Last set from ~/.config/nvim/colors/solarized.vim
StatusLineNC   xxx cterm=reverse ctermfg=11 ctermbg=0 gui=reverse
        Last set from ~/.config/nvim/colors/solarized.vim
VertSplit      xxx ctermfg=11 ctermbg=11 gui=reverse
        Last set from ~/.config/nvim/colors/solarized.vim
Title          xxx cterm=bold ctermfg=9 gui=bold guifg=Magenta
        Last set from ~/.config/nvim/colors/solarized.vim
Visual         xxx cterm=reverse ctermfg=10 ctermbg=8 guibg=DarkGrey
        Last set from ~/.config/nvim/colors/solarized.vim
VisualNC       xxx cleared
WarningMsg     xxx cterm=bold ctermfg=1 guifg=Red
        Last set from ~/.config/nvim/colors/solarized.vim

I'm convinced it would be related to these:

TermCursor     xxx cterm=reverse gui=reverse
        Last set from ~/.config/nvim/colors/solarized.vim
TermCursorNC   xxx cleared
IncSearch      xxx cterm=standout ctermfg=9 gui=reverse
        Last set from ~/.config/nvim/colors/solarized.vim
Search         xxx cterm=reverse ctermfg=3 guifg=Black guibg=Yellow
        Last set from ~/.config/nvim/colors/solarized.vim
CursorLineNr   xxx ctermfg=11 gui=bold guifg=Yellow
        Last set from ~/.config/nvim/colors/solarized.vim

Specifically the bits reading gui=reverse seem highly indicative to me, but I am unsure, and also have no idea how to set them. I tried searching through the source file, and hacking at it, but couldn't get it to load properly.

Advice?


Update 2:

I have discovered the syntax and the (semiright) variable:

  • Search is the variable that corresponds to the mode presenting my problem (IncSearch regards as-you-type searching colors (different, apparently)
  • hi Search ctermfg=<color> changes the general color of the highlight. ctermbg does nothing. The cursor seems out of the picture.
  • cterm=underline changes the highlighting mode to underline the selection, which properly changes the cursor color, but I would prefer to simply change the color of the cursor, not the mode of highlighting.

Will keep experimenting

Solved:

It seems that the nature of the problem is simply the setting of Search cterm=reverse and because of the nature of that specific setting, this is an impossible problem. ((Does no one else experience this?))

Scratch all that: solved the problem.

Search         xxx cterm=reverse ctermfg=3 guifg=Black guibg=Yellow
        Last set from ~/.config/nvim/colors/solarized.vim

essentially says to reverse the color scheme. I found that setting ctermbg did nothing for the cursor color. This was frustrating. I still don't fully understand why, if the colors are simply reversed setting ctermbg wouldn't solve the problem. Solved it anyway with a (seemingly hacky?) workaround

  1. Turn off cterm=reverse
  2. Set ctermbg to the former value of ctermfg (3)
  3. Set ctermfg to something sufficiently high contrast to read the highlighted text (it needs to be dark; I went with 8).

Command: hi Search cterm=none ctermbg=3 ctermfg=8

The cursor becomes the color of normal unhighlighted text. This makes it visible. Setting the no reverse causes the highlighted text to be difficult to read, so the ctermfgcorrects that.

I'm going to leave the answer open to someone with more understanding, who might expand on this subject for future readers. If no one answers in the next week, I'll just post this section as an answer and accept it.

  • 1
    Are you sure you have the most up-to-date version? Id check that first. – D. Ben Knoble Jan 19 at 17:58
  • Good point. Will look. – malan Jan 19 at 18:52
  • @D.BenKnoble Yup. Cloned it direct just now. – malan Jan 19 at 19:03
  • @D.BenKnoble Sorry, not clear: I do have the most up to date version and it still does it. – malan Jan 19 at 19:20
  • I dont remember the exact highlight groups, but investigating via verbose hi would help. Please add the relevant details to your question. You could also read the source and try to find the right groups/definitions. – D. Ben Knoble Jan 19 at 19:22
1

Debugging

  1. Make sure your version of the colorscheme is up-to-date (sometimes "bugs" are fixed).
  2. Run verbose hi {group} on groups involved in the highlighting problem, and try to pin down the source of the highlighting.
  3. Come up with your fix! This requires some experimenting; cf. :help :hi (apparently this link is also good).

Solution from OP

The OP decided turning off reverse solved the problem and then chose some appropriately contrasting color.

The resulting command was hi Search cterm=none ctermbg=3 ctermfg=8.

I recommend putting this in an autocommand like

augroup vimrc_colorschemes
  au!
  au ColorScheme solarized hi Search cterm=none ctermbg=3 ctermfg=8
augroup END

Finally, I'll note that Dracula (a colorscheme I use and maintain) uses the value

Search         xxx term=reverse ctermfg=0 ctermbg=11 guifg=Black guibg=Yellow
                   links to DraculaSearch

and does not hide the cursor.

  • 1
    Nice plug... :-P – malan Jan 24 at 20:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.