vim/colorschemes

sample_spell.vim review

gdupras opened this issue · 18 comments

The Normal, String, and Comment groups are the ones that are most often spell checked so the Spell groups should look good on those.

For this review, I used sample_spell.vim as modified in PR #154.

For each colorscheme, I looked at three environments:

  • gVim:

    gvim --clean -S colors/blue.vim -S colors/tools/sample_spell.vim

  • 256c:

    vim --clean -S colors/blue.vim -S colors/tools/sample_spell.vim

  • termguicolors:

    vim --clean -c "set termguicolors" -S colors/blue.vim -S colors/tools/sample_spell.vim

The above commands are typed in Konsole, on Kubuntu. &t_Co is 256 by default in this terminal.

There is clearly something very wrong with termguicolors. The other two environments look fine for the most part but will still need some small tweaks.

blue.vim

gVim

blue_gvim

  • SpellLocal looks like String.

256c

blue_256c

  • SpellLocal looks like String.

termguicolors

blue_termguicolors

  • Bad SpellCap and SpellBad.

  • SpellLocal does not match gVim version.

darkblue.vim

gVim

darkblue_gvim

  • OK

256c

darkblue_256c

  • OK

termguicolors

darkblue_termguicolors

  • Bad SpellRare and SpellBad.

delek.vim

gVim

delek_gvim

  • SpellBad looks like Comment.

256c

delek_256c

  • SpellBad looks like Comment.

termguicolors

delek_termguicolors

  • Bad SpellCap, SpellLocal, SpellRare, and SpellBad.

desert.vim

gVim

desert_gvim

  • SpellRare looks like String.

256c

desert_256c

  • SpellRare looks like String.

termguicolors

desert_termguicolors

  • SpellBad does not match gVim version.

elflord.vim

gVim

elflord_gvim

  • SpellCap is too dark.

  • SpellRare looks like String.

256c

elflord_256c

  • SpellCap is too dark.

  • SpellRare looks like String.

termguicolors

elflord_terguicolors

  • Bad SpellCap, SpellLocal, SpellRare, and SpellBad.

evening.vim

gVim

evening_gvim

  • OK

256c

evening_256c

  • OK

termguicolors

evening_termguicolors

  • Bad SpellCap, SpellLocal, and SpellBad.

industry.vim

gVim

industry_gvim

  • SpellRare looks like String.

256c

industry_256c

  • SpellRare looks like String.

termguicolors

industry_termguicolors

  • Bad SpellLocal, SpellRare, and SpellBad.

koehler.vim

gVim

koehler_gvim

  • SpellCap is too dark.

256c

koehler_256c

  • SpellCap is too dark.

termguicolors

koehler_termguicolors

  • Bad SpellCap, SpellLocal, SpellRare, and SpellBad.

morning.vim

gVim

morning_gvim

  • SpellCap looks like String.

256c

morning_256c

  • SpellCap looks like String.

  • SpellLocal and SpellBad are very similar.

termguicolors

morning_termguicolors

  • Bad SpellCap, SpellRare, and SpellBad.

  • SpellLocals does not match gVim version.

murphy.vim

gVim

murphy_gvim

  • SpellCap looks like Comment.

256c

murphy_256c

  • SpellCap looks like Comment.

termguicolors

murphy_termguicolors

  • Bad SpellCap, SpellRare, and SpellBad.

pablo.vim

gVim

pablo_gvim

  • SpellRare looks like String.

256c

pablo_256c

  • SpellRare looks like String.

termguicolors

pablo_termguicolors

  • Bad SpellLocal, SpellRare, SpellBad.

  • SpellCap does not match gVim version.

peachpuff.vim

gVim

peachpuff_gvim

  • OK

256c

peachpuff_256c

  • OK

termguicolors

peachpuff_termguicolors

  • Bad SpellCap, SpellLocal, and SpellBad.

  • SpellRare does not match gVim version.

ron.vim

gVim

ron_gvim

  • SpellCap is too dark.

256c

ron_256c

  • Normal and String look the same

  • SpellCap is too dark.

termguicolors

ron_termguicolors

  • Normal and String look the same

  • Bad SpellCap, SpellLocal, SpellRare, and SpellBad.

shine.vim

gVim

shine_gvim

  • OK

256c

shine_256c

  • OK

termguicolors

shine_termguicolors

  • Bad SpellCap, SpellLocal, SpellRare, and SpellBad.

slate.vim

gVim

slate_gvim

  • OK

256c

slate_256c

  • OK

termguicolors

slate_termguicolors

  • Bad SpellCap and SpellBad.

torte.vim

gVim

torte_gvim

  • OK

256c

torte_256c

  • OK

termguicolors

torte_termguicolors

  • Bad SpellLocal, SpellRare, and SpellBad.

  • SpellCap does not match gVim version.

zellner.vim

gVim

zellner_gvim

  • SpellBad looks like Comment.

  • SpellRare looks like String.

256c

zellner_256c

  • SpellBad looks like Comment.

  • SpellRare looks like String.

  • SpellLocal and SpellBad look very similar.

termguicolors

zellner_termguicolors

  • Bad SpellCap, SpellRare, and SpellBad.

  • SpellLocal does not match gVim version.

Thank you for this thorough report. I will take a look at it right now.

Let's see… the default colors are:

Case cterm light cterm dark gui light gui dark
Cap lightblue blue X11 blue X11 blue
Local cyan cyan X11 darkcyan X11 cyan
Rare lightmagenta magenta X11 magenta X11 magenta
Bad lightred red X11 red X11 red

I think we should try to stick with those as much as possible and only deviate when strictly necessary. Maybe not the values but… their spirit : blues for cap, cyans for local, magentas for rare, and reds for bad.

FWIW, here are the default values as established in xterm's source:

Name X11 name Hex Equiv 256c index Equiv 256c hex
blue blue2 #0000ee 21 #0000ff
lightblue rgb:5c/5c/ff #5c5cff 63 #5f5fff
cyan cyan3 #00cdcd 44 #00d7d7
magenta magenta3 #cd00cd 164 #d700d7
lightmagenta magenta #ff00ff 201 #ff00ff
red red3 #cd0000 160 #d70000
lightred red #ff0000 196 #ff0000

and the default values as established in rgb.txt:

Name Hex value Equiv 256c index Equiv 256c hex
blue #0000ff 21 #0000ff
cyan #00ffff 51 #00ffff
darkcyan #008b8b 30 #008787
magenta #ff00ff 201 #ff00ff
red #ff0000 196 #ff0000

And here is the default "spelling" palette, normalized for 256c: https://color.hailpixel.com/#5F5FFF,0000FF,00D7D7,008787,FF00FF,D700D7,FF0000,D70000

@gdupras FWIW, I can reproduce the termguicolors issue but it goes away after a ^L or some visual selection so it looks more like a redrawing issue to me than like a real issue with these colorschemes.

Maybe that's something worth investigating in its own right.

Hmm, weird. I cannot reproduce the termguicolors issue in cmd.exe on Windows 10. I'll have to try again in Konsole later today once I get back home.

With Konsole, the termguicolors issue does not go away with ^L or with a visual selection.

With a visual section, the problematic Spell groups don't even change colors. Here's an example with blue.vim:

Screenshot_20220411_201725

I have no idea what is causing this.

I also have similar troubles with my own Apprentice in iTerm with termguicolors enabled.

Before ^L:

Capture d’écran 2022-04-12 à 08 51 26

After some random click with the mouse to put the window into focus:

Capture d’écran 2022-04-12 à 08 54 43

After ^L:

Capture d’écran 2022-04-12 à 08 53 21

This is puzzling.

Here is a reduced version of Apprentice with only the strict necessary for testing sample_spell.vim:
spellingbee.vim.txt

How it looks in 256c:
Capture d’écran 2022-04-12 à 09 28 08

How it looks in GUI:
Capture d’écran 2022-04-12 à 09 29 16

How it looks with set termguicolors:
Capture d’écran 2022-04-12 à 09 31 01

And after ^L:
Capture d’écran 2022-04-12 à 09 31 39

Note that I recently switched to colortemplate. In case that was relevant, I dug out the last official release of Apprentice (note to self: It's freaking old, I should make a new one), which was written differently, and the result is the same.

FWIW, I also tried with a very popular colorscheme, nord.vim, and spell highlighting is also broken, though slightly differently:

Capture d’écran 2022-04-12 à 09 46 33

  • Hypothesis number 1: something is broken upstream.
  • Hypothesis number 2: sample_spell.vim is broken.

I can reproduce it in iTerm2 with my own color schemes (which do not visually distinguish among the different spelling errors).

WWDC16

At startup:
Screenshot 2022-04-12 at 20 27 21

After CTRL-L:

Screenshot 2022-04-12 at 20 27 37

WWDC17

At startup:

Screenshot 2022-04-12 at 20 30 41

After CTRL-L:

Screenshot 2022-04-12 at 20 30 57

FWIW, a vimrc containing only these lines:

set termguicolors
set spell
call setline(1, 'couleur')

is enough to reproduce the issue with:

vim --clean -S spellingbee.vim -S vimrc

but not with:

vim --clean -S spellingbee.vim -u vimrc

I propose to change the command to run the spelling test to:

vim --clean -S colors/blue.vim -u colors/tools/sample_spell.vim

unless there is a valid reason for the current syntax. Note -u instead of -S.

Edit: Ah, I see, linked groups are not linked if sample_spell.vim is loaded first.

Calling the sample with -u is a good idea. I think a truecolors-enabled variant of sample_spell.vim might be in order.

Maybe something like this could be added to sample_spell.vim:

set rtp^=.
execute "colo" $COLORSCHEME

Then call it with:

$ COLORSCHEME=blue vim --clean -u colors/tools/sample_spell.vim

Still not perfect, but just to point out another possibility.

Edit: Or this:

set rtp^=.
execute "colo" c

to be called as follows:

$ vim --clean -u colors/tools/sample_spell.vim --cmd 'let c="blue"'

I think a truecolors-enabled variant of sample_spell.vim might be in order.

Now I see that nothing of what I have proposed above prevents the issue when termguicolors is set. I need to look at it with a fresh mind. Maybe it is something worth reporting upstream.

I don't know whether you mean that a different script is needed for termguicolors. I'd try to stick with one script for all use cases.

@gdupras I think I have fixed all the fixable issues. Could you check it out?

Yes, I will take a look.

The issues with termguicolors have been fixed upstream in 8.2.4775 and 8.2.4777.

Good news, thanks.

Sorry, I never had time for a full review but I did notice that in koehler.vim, the color of guifg and guisp do not match for SpellCap:

koehler

guisp should probably be made the same color as guifg.

Indeed it should.

Last bug fixed in master.