Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't define color palette solely in Xresources with g:gruvbox_termcolors = 16 #130

Open
danijar opened this issue Aug 23, 2016 · 6 comments
Milestone

Comments

@danijar
Copy link

danijar commented Aug 23, 2016

I would like to have Xresources as the single place to define my system-wide color palette and have Vim use that by setting let g:gruvbox_termcolors = 16. However:

  1. Currently I have to specify set background=dark or set background=light in my Vim configuration, depending on the Xresources color scheme. Otherwise, the cursor line has the opposite color.
  2. The Vim background color does not perfectly match the background color in Xresources, which is what I would assume when using let g:gruvbox_termcolors = 16.

So I can't just change the Xresources colors to change my color scheme, but also have to edit the Vim configuration. Is there a way around these two issues?

@danijar danijar changed the title Must set background in Vim settings even when g:gruvbox_termcolors = 16 Can't define color palette solely in Xresources with g:gruvbox_termcolors = 16 Aug 23, 2016
@morhetz
Copy link
Owner

morhetz commented Aug 23, 2016

@danijar That's really nice feature to have which I've been thinking about recently too.
I'll try to make a test branch for that.

@danijar
Copy link
Author

danijar commented Aug 23, 2016

Thanks. For the background color, gruvbox seems to use color0 rather than background from Xresources. For Vim to have the same background color as my terminal, I have to set both to the same value. But then black text becomes invisible.

@morhetz
Copy link
Owner

morhetz commented Aug 23, 2016

Well, actually it shouldn't
But I got to check this

@danijar
Copy link
Author

danijar commented Dec 22, 2016

@morhetz how's this going? I'd really like this to happen, any way I can help?

@rbong
Copy link

rbong commented Jun 2, 2019

For anyone still curious about this, Vim automatically sets background based on your terminal background color on startup if you haven't already set it, so you should only be able to set colors using just your .Xresources (save the background issue). However gruvbox does set the value of background so this will not currently work: source

@rbong
Copy link

rbong commented Jun 2, 2019

Sorry for the double post, I've been looking into the other issue. Unfortunately it looks like the color0/background confusion is more difficult to solve.

Vim can only get the colors 0-15 through 16 color terminal codes. The 'fg' and 'bg' colors are based on the Normal highlight group and you can't just set NONE for foreground and use fg and bg or clear Normal.

Notice that the terminal has colors 0-15 which makes 16 colors, the full 16 color palette, not including foreground and background. Foreground and background in a real 16 color terminal would just be set to 0 (black) or 15 (white). So there is not a color code specifically for the color you set to your foreground or background color.

You would normally be expected to set Normal to the desired 16 color, 256 color, or hex color code depending on how many colors your terminal supports corresponding to your shell's configured foreground and background if you want them to match.

See :help ctermfg, and the link posted above (notice 0 is used for bg0).
For proof try :hi clear, :hi Normal ctermfg=NONE ctermbg=NONE, :hi Visual ctermbg=bg. You will get a BG unknown error even if v:termrbgresp and $COLORFGBG are set.

You will have to set color0 to the background color if you want gruvbox to have the correct background. Perhaps gruvbox-contrib could contain alternative 16 color versions for Xresources files and terminal configurations. Looks like all of the gruvbox terminal config files are supposed to have matching foreground/background/color0/color15, but some don't. Some use a removed color or use light/hard background variations without any indication. If your colors look off, check your color0/color15/foreground/background against the official palette.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants