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):
Now the ones that don't work/or could be improved:
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.
We can't really do anything about default
but I agree, the others need work. Thank you for spotting this.
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 ofMatchParen
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 viareverse
, which becomes "bright color on general background color" by way of thereverse
of the cursor.
- parenthesis is green on black
- current parenthesis is reversed to black on green thanks to
MatchParen
beingreverse
(explicitly or not) - current parenthesis is reversed back to green on black thanks to
Cursor
or terminal cursor being explicitlyreverse
- current parenthesis is highlighted like regular parenthesis
- cursor is not highlighted
- 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.
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)
-
Vim in MATE terminal (which uses libvte) both dark mode and light mode
-
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