vim / colorschemes

colorschemes for Vim
276 stars 23 forks source link

Fix broken terminal background if colorscheme is called from vimrc for gui vim #199

Closed habamax closed 2 years ago

habamax commented 2 years ago

Fixes #198 and https://github.com/vim/vim/issues/10793

craigmac commented 2 years ago

Using fix_terminal branch blue.vim under Terminal.app (using apprentice palette set at terminal emulator level). All looks ok I think? I've echoed hi Normal and the results of :echo term_getansicolors(2) here:

Screen Shot 2022-07-26 at 9 30 11 AM

MacVim result with (no vimrc present, as you can see by attempting :e $MY<C-d> and single colorscheme blue in ~/.vim/gvimrc:

Screen Shot 2022-07-26 at 10 01 46 AM

Background is working now, but some things are still unreadable, like my @mbp hostname (even when selected with mouse) is hidden. It's not really in a usable state.

The :echo term_getansicolors(2) in the pic shows that it's using the right palette defined in blue.vim, but maybe it's bright/bold thing that :term is trying to do? Because the palette is right but it seems to be making different choices from that palette? If nothing comes to mind I might have to get into term_scrape() et al. and discover what values it's choosing. I've noticed the exact same thing in apprentice as well. With apprentice it's at least usable, but I see from colortest it's using what looks like the hardcoded xterm palette.

Left side: MacVim latest (9.0.0065 based), no vimrc, only ~/.vim/gvimrc with colorscheme apprentice. The correct background now gets set, but it seems it's using the colors from the 'system colors' shown in the 256colortest.pl script, rather than the apprentice palette. An :echo term_getansicolors(2) confirms this (show in echo area).

Right side: Terminal.app with emulator palette set to apprentice colors for first 0-15 ANSI, along with the colortest output to show what it should look like in the left-side :term, but doesn't.

Screen Shot 2022-07-26 at 10 13 10 AM
habamax commented 2 years ago

Well, I didn't try to fix anything related to ansi colors, so it shouldn't matter here. In general, term in terminal.app and term in gvim would be most probably different.

What I mean, it should be discussed/fixed separately.

Thanks for checking!

craigmac commented 2 years ago

I'll open separate issue for that then

craigmac commented 2 years ago

Left side: Terminal.app with apprentice palette, simple dir listing to show colors.

Right side: Terminal.app with apprentice palette again, this time running a full screen :terminal inside Vim (with the patch from this PR applied to my local apprentice):

Screen Shot 2022-07-26 at 10 52 56 AM

Odd how in Terminal.app the colors are slightly brighter than the :term colors. Any idea how that could be? I turned off Terminal.app settings that I though might be causing issues like "Use bold fonts" and "Use bright colors for bold text" but it's still slightly brighter variations in Terminal.app. Do you think this is likely some kind of off-by-one/rounding thing happening in vim's terminal implementation here?

It's usable as is, but some other colorschemes not so much. Thanks for the help!

romainl commented 2 years ago

@craigmac could you keep the discussion relevant to this project by sticking to the built-in colorschemes, please? Apprentice uses the same techniques as those used here but not everyone involved in this project has it on their system. Desert or Darkblue would be better examples.

As for the difference in brightness, Terminal.app internally converts the colors you give it to a different color space so using the color swatch to set color 12 to #336699 doesn't actually give you a proper #336699. Strangely enough, Vim correctly gives us a proper #336699 in the current color space, which is something I can't explain.

¯\_(ツ)_/¯

habamax commented 2 years ago

@lifepillar has merged PR that fix colorscheme generation. Let me merge this one too.