vim/colorschemes

hi MatchParen hard to follow

craigmac opened this issue · 16 comments

Jotting this down from my phone while I remember, so no screenshots, but several of the themes (the ones that only define term,cterm,gui=reverse) make working with matchparen functionality confusing because it's often difficult to see where your cursor actually is (requires cursor to be inverse I believe, might not happen with say a solid green cursor).

Thanks. Could you add the relevant screenshots when you have the time?

First those that work how I would expect (cursor position doesn't move, and it's clear/clear-ish where your actual cursor is currently):

default:
default

desert:
desert

elflord:
elflord

evening:
evening

industry:
industry

koehler:
koehler

murphy:
murphy

pablo:
pablo

quiet:
quiet

ron:
ron

slate:
slate

torte:
torte

Now the ones that don't work/or could be improved:

blue:
blue

darkblue:
darkblue

delek:
delek

peachpuff:
peachpuff

habamax
habamax

lunaperche
lunaperche

morning
morning

shine
shine

zellner
zellner

These were done with this vimrc:

filetype plugin indent on
syntax on
set nocompatible
set backspace=indent,eol,start
set incsearch
set laststatus=2
set mouse=nvi
set ruler
set showcmd
set wildmenu
set wildoptions+=pum

And started with vim -u vimrc-minimal. Terminal is alacritty and vim build is 9.0.1476 huge version w/o GUI compiled from source on macOS 12.6.5.

habamax uses different matchparen (the same as quiet and wildcharm) since several weeks ago just because of that issue:
image

and yeah the ones with reverse are quite hard to follow if your cursor is reversed too.

We can't really do anything about default but I agree, the others need work. Thank you for spotting this.

Hmm… all the colorschemes you flagged as "not working" seem perfectly fine to me:

Capture d’écran 2023-05-01 à 19 20 54

Capture d’écran 2023-05-01 à 19 22 25

Capture d’écran 2023-05-01 à 19 22 44

Capture d’écran 2023-05-01 à 19 23 04

Capture d’écran 2023-05-01 à 19 23 20

Capture d’écran 2023-05-01 à 19 23 34

Capture d’écran 2023-05-01 à 19 23 50

Capture d’écran 2023-05-01 à 19 24 14

Capture d’écran 2023-05-01 à 19 24 35

Well, zellner's MatchParen's background happens to be almost the same as my terminal cursor's but that's irrelevant to the case.

Terminal.app, 256c.

It is only when your cursor is reversed. As if in gvim you set cursor gui to reverse.

The remakes are all fine. From what I see, only a bunch of new ones have gui=reverse for Cursor:

(standard input):68:colors/quiet.vim:57:  hi Cursor guifg=NONE guibg=NONE gui=reverse ctermfg=NONE ctermbg=NONE cterm=reverse
(standard input):81:colors/quiet.vim:127:  hi Cursor guifg=NONE guibg=NONE gui=reverse ctermfg=NONE ctermbg=NONE cterm=reverse
(standard input):109:colors/wildcharm.vim:66:  hi Cursor guifg=#ffffff guibg=#000000 gui=reverse cterm=reverse
(standard input):110:colors/wildcharm.vim:67:  hi lCursor guifg=#ff5fff guibg=#000000 gui=reverse cterm=reverse
(standard input):115:colors/wildcharm.vim:140:  hi Cursor guifg=#000000 guibg=#ffffff gui=reverse cterm=reverse
(standard input):116:colors/wildcharm.vim:141:  hi lCursor guifg=#ff00ff guibg=#000000 gui=reverse cterm=reverse
(standard input):139:colors/sorbet.vim:57:hi Cursor guifg=NONE guibg=NONE gui=reverse ctermfg=NONE ctermbg=NONE cterm=reverse
(standard input):153:colors/retrobox.vim:64:  hi Cursor guifg=NONE guibg=NONE gui=reverse ctermfg=NONE ctermbg=NONE cterm=reverse
(standard input):161:colors/retrobox.vim:115:  hi CursorIM guifg=NONE guibg=NONE gui=reverse ctermfg=NONE ctermbg=NONE cterm=reverse
(standard input):163:colors/retrobox.vim:155:  hi Cursor guifg=NONE guibg=NONE gui=reverse ctermfg=NONE ctermbg=NONE cterm=reverse
(standard input):171:colors/retrobox.vim:206:  hi CursorIM guifg=NONE guibg=NONE gui=reverse ctermfg=NONE ctermbg=NONE cterm=reverse
(standard input):207:colors/lunaperche.vim:137:  hi Cursor guifg=NONE guibg=NONE gui=reverse ctermfg=NONE ctermbg=NONE cterm=reverse
(standard input):208:colors/lunaperche.vim:138:  hi lCursor guifg=#ff5fff guibg=#000000 gui=reverse cterm=reverse
(standard input):214:colors/lunaperche.vim:227:  hi Cursor guifg=NONE guibg=NONE gui=reverse ctermfg=NONE ctermbg=NONE cterm=reverse
(standard input):215:colors/lunaperche.vim:228:  hi lCursor guifg=#ff00ff guibg=#000000 gui=reverse cterm=reverse

@neutaaaaan and @habamax could you propose an alternative Cursor?

@romainl I can.

The issue is that many terminals (excluding the one you use, terminal.app) can have reversed cursor -- xterm, urxvt, alacritty, gnome-terminal, konsole, etc. And for those I know only 1 approach that would work -- use something like @neutaaaaan came up with in quiet -- bright bold, alien to main palette, fg color.

wildcharm should be immune to this as it uses the same color as quiet.
retrobox and lunaperche -- I will have a look into gui

well, I am probably wrong about "1 approach I know", another solution might be not to reverse matchparen

I need to wrap my head around this.

  • When the cursor is on one of a pair or parentheses/brackets/whatever, both halves of the pair are highlighted with MatchParen.
  • If the cursor has explicit background color and foreground color, which is the case for all remakes in GUI, then there is no issue.
  • If :hi Cursor gui=reverse guibg=NONE guifg=NONE (for some of the new ones) or if the terminal emulator uses a dumb reverse cursor (alacritty), then the highlight of MatchParen is reversed.
  • The cursor is not visible anymore because MatchParen is usually some kind of "general background color on bright color", either via explicit bg/fg or via reverse, which becomes "bright color on general background color" by way of the reverse of the cursor.
  1. parenthesis is green on black
  2. current parenthesis is reversed to black on green thanks to MatchParen being reverse (explicitly or not)
  3. current parenthesis is reversed back to green on black thanks to Cursor or terminal cursor being explicitly reverse
  4. current parenthesis is highlighted like regular parenthesis
  5. cursor is not highlighted
  6. user looses any notion of "current"

That sounds like a compelling argument against using a reverse cursor, if you ask me.

FWIW, iTerm has a "smart box cursor color" option for the cursor that falls back to the terminal's bg and fg when a reverse of the actual colors at the cursor location would make it invisible.

A plain "reverse" cursor is shortsighted.

That sounds like a compelling argument against using a reverse cursor, if you ask me.

It also affects other parts, like if your syntax close enough to visual or visual is reversed too:

cursor is on indent of last line, koehler:
image

retrobox, cursor is on m in name:
image

ron, cursor is on r in bookmarks:
image

I'll take a look at this next weekend. At home using urxvt and tmux I haven't noticed anything wrong. Same at work using hyper and tmux.

Not at my computer for the next week, but it could be an Alacritty issue? alacritty/alacritty#2398

I am having this problem with lunaperche on:

  • MacVim r178 only in dark mode (light mode is readable)

    • image
    • image
  • Vim in MATE terminal (which uses libvte) both dark mode and light mode

    • image
    • image
  • Vim in Terminal.app is fine because it always overrides the cursor color with the one from the Terminal.app profile.

Cursor is always on the opening parenthesis.

I worked around it by overriding MatchParen with the bg color from Visual:

hi MatchParen guifg=NONE guibg=#005f87

fixed lunaperche:

image