gruvbox-community / gruvbox

Retro groove color scheme for Vim - community maintained edition
MIT License
801 stars 62 forks source link

Support changing background #62

Closed rbong closed 5 years ago

rbong commented 5 years ago

I prefer my background to be #000000. You rejected #102 saying:

I would try to provide alternative solution to overload any gruvbox color

I would like this feature.

Using the workaround (mentioned in #74) "works" but is fragile; switching colorscheme or changing background causes the change to be lost:

colorscheme gruvbox
highlight Normal guibg=0 ctermbg=0

It would be nice to have "official" support for this.

:robot: This issue has been automatically copied from morhetz#135 :robot:

rbong commented 5 years ago

You should now be able to overwrite the background color using:

let g:gruvbox_colors = { 'bg0': ['#000000', 0] }

edit: If you are using 0 as the second parameter as shown here, and you have not run set termguicolors, your terminal will use whatever color you have configured as your terminal background color, or color 0. The same is generally true for colors 0-15. Before responding to this issue with problems setting custom colors, please make sure that your terminal is either configured to use the colors you want, or use a terminal with true color support and ensure termguicolors is set (recommended).

danglduy commented 5 years ago

You should now be able to overwrite the background color using:

let g:gruvbox_colors = { 'bg0': ['#000000', 0] }

Hi,

I tried using this but it doesn't work, the background remains the same. Any additional requirement? Env: Ubuntu 16.04 LTS, kitty terminal, tmux, neovim 0.3.8 from neovim ppa.

Can you confirm this work with the latest source?

rbong commented 5 years ago

@danglduy thank you for pointing that out. It turns out it was broken when setting both the GUI and terminal colors at the same time (['#000000', 0] instead of just #000000 or 0). It should now be fixed after you update. This is quite a large change in terms of lines touched so please let me know if you have any more problems.

edit: If you are using 0 as the second parameter as shown here, and you have not run set termguicolors, your terminal will use whatever color you have configured as your terminal background color, or color 0. The same is generally true for colors 0-15. Before responding to this issue with problems setting custom colors, please make sure that your terminal is either configured to use the colors you want, or use a terminal with true color support and ensure termguicolors is set (recommended).

danglduy commented 5 years ago

@danglduy thank you for pointing that out. It turns out it was broken when setting both the GUI and terminal colors at the same time (['#000000', 0] instead of just #000000 or 0). It should now be fixed after you update. This is quite a large change in terms of lines touched so please let me know if you have any more problems.

Thank you so much for the fix. I updated then it now works.

ericdorsey commented 5 years ago

Just to confirm, this is the newest source file I should be using with this fix?

https://github.com/gruvbox-community/gruvbox/blob/master/colors/gruvbox.vim

I replaced my ~/.vim/colors/gruvbox.vim with that file (which still says last updated 12 Aug 2017 even though the commit was 8 days ago -- https://github.com/gruvbox-community/gruvbox/blob/master/colors/gruvbox.vim#L6)

With this, I still get a non black "hazy" background:

let g:gruvbox_colors = { 'bg0': ['#000000', 0] }

Only thing that works to get the black background is using the rbong workaround above (https://github.com/gruvbox-community/gruvbox/issues/62#issue-449350934) of:

highlight Normal ctermbg=0

Env. Info:

$ vim --version
VIM - Vi IMproved 8.1 (2018 May 18, compiled Jul 22 2019 12:27:31)
Included patches: 1-1729

And Ubuntu 18.04.2 LTS

rbong commented 5 years ago

@ericdorsey make sure you are setting g:gruvbox_colors before running colorscheme gruvbox. Please post a minimal config if it still happens.

ericdorsey commented 5 years ago

@rbong By set g:gruvbox_colors, do you mean I should have set g:gruvbox_colors in my ~/.vimrc?

If so, I get this when adding that before colorscheme gruvbox:

E518: Unknown option: g:gruvbox_colors

Here's what is hopefully relevant form my ~/.vimrc:

set t_Co=256
set background=dark

set g:gruvbox_colors  "<--- Here's where I tried adding 
colorscheme gruvbox

if g:colors_name == "gruvbox"
let g:gruvbox_contrast_dark = 'hard'
let g:gruvbox_colors = { 'bg0': ['#000000', 0] }
endif
rbong commented 5 years ago

@ericdorsey set is for builtin options. You want to declare all gruvbox option variables before colorscheme gruvbox.

set t_Co=256
set background=dark

let g:gruvbox_contrast_dark = 'hard'
let g:gruvbox_colors = { 'bg0': ['#000000', 0] }
colorscheme gruvbox

edit: If you are using 0 as the second parameter as shown here, and you have not run set termguicolors, your terminal will use whatever color you have configured as your terminal background color, or color 0. The same is generally true for colors 0-15. Before responding to this issue with problems setting custom colors, please make sure that your terminal is either configured to use the colors you want, or use a terminal with true color support and ensure termguicolors is set (recommended).

ericdorsey commented 5 years ago

@rbong Ahh, perfect -- thank you so much! That was it exactly. Working now w/ the black background I wanted with:

let g:gruvbox_contrast_dark = 'hard'
let g:gruvbox_colors = { 'bg0': ['#000000', 0] }
colorscheme gruvbox

And no highlight Normal ctermbg=0 needed any longer.

Thank you!

tonebender commented 4 years ago

This does not work for me. Using: let g:gruvbox_contrast_dark = 'hard' let g:gruvbox_colors = { 'bg0': ['#000000', 0] } colorscheme gruvbox let g:airline#extensions#tabline#enabled = 1 let g:airline_theme='light' if has('gui_running') colorscheme ancient set guifont=Monospace\ 10 else set background=dark endif

(Moving the gruvbox lines to the end of this block does not help)

I've also tried editing ~/.vim/bundle/gruvbox/colors/gruvbox.vim, changing the palette section: " fill it with absolute colors "let s:gb.dark0_hard = ['#1d2021', 234] " 29-32-33 "let s:gb.dark0 = ['#282828', 235] " 40-40-40 "let s:gb.dark0_soft = ['#32302f', 236] " 50-48-47 "let s:gb.dark1 = ['#3c3836', 237] " 60-56-54 "let s:gb.dark2 = ['#504945', 239] " 80-73-69 "let s:gb.dark3 = ['#665c54', 241] " 102-92-84 "let s:gb.dark4 = ['#7c6f64', 243] " 124-111-100 "let s:gb.dark4_256 = ['#7c6f64', 243] " 124-111-100

let s:gb.dark0_hard = ['#000000', 0] " 29-32-33 let s:gb.dark0 = ['#000000', 0] " 40-40-40 let s:gb.dark0_soft = ['#000000', 0] " 50-48-47 let s:gb.dark1 = ['#000000', 0] " 60-56-54 let s:gb.dark2 = ['#000000', 0] " 80-73-69 let s:gb.dark3 = ['#000000', 0] " 102-92-84 let s:gb.dark4 = ['#000000', 0] " 124-111-100 let s:gb.dark4_256 = ['#000000', 0] " 124-111-100

Does not make any difference. I get the greyish background every time.

Any ideas?

rbong commented 4 years ago

@tonebender since you are using 0 for the ASCII color and you don't have termguicolors enabled, the background color is going to be whatever is configured for your terminal.

EasterPeanut commented 4 years ago
let g:gruvbox_contrast_dark = 'hard'
let g:gruvbox_colors = { 'bg0': ['#000000', 0] }
colorscheme gruvbox

this does not work for me in neovim, am I missing something?

rbong commented 4 years ago

@EasterPeanut check the setting termguicolors, and make sure your terminal supports true colors (you can tell if set termguicolors/setnotermguicolors changes the colors while using gruvbox). If set termguicolors is not set, ASCII color 0 defaults to whatever you have your terminal's background color set to. This is the most likely case as far as I can tell.

Let me know if this clarifies the issue or if something else is going wrong.

EasterPeanut commented 4 years ago

Yeah, have set termguicolors as well, so I have:

set termguicolors

call plug#begin('~/.vim/plugged')

Plug 'morhetz/gruvbox'

call plug#end()

let g:gruvbox_contrast_dark = 'hard'
let g:gruvbox_colors = { 'bg0': ['#000000', 0] }
colorscheme gruvbox

But the background will not turn black. Though it will with the workaround :highlight normal ctermbg=0 guibg=#000000.

Oh and I verified that set termguicolors works with:

you can tell if set termguicolors/setnotermguicolors changes the colors while using gruvbox

rbong commented 4 years ago

@EasterPeanut

Plug 'morhetz/gruvbox'

This change has not yet been merged into morhetz/gruvbox, you'll have to change it to:

Plug 'gruvbox-community/gruvbox'

EasterPeanut commented 4 years ago

Ah my bad, I thought I was looking at the issues of ' morhetz/gruvbox'. It works with the community edition :D