ellisonleao / gruvbox.nvim

Lua port of the most famous vim colorscheme
MIT License
1.96k stars 210 forks source link

Problem with changing background color #16

Closed roland-5 closed 2 years ago

roland-5 commented 3 years ago

Issue created, after reddit comment:

I like hard version of dark mode, but want to have black background.

vim.g.gruvbox_contrast_dark = "hard"
vim.cmd("let g:gruvbox_colors = { 'dark0_hard': ['#000000', 0] }")
vim.o.background = "dark"
vim.cmd([[colorscheme gruvbox]])

I tried also

vim.cmd("let g:gruvbox_colors = { 'bg0': ['#000000', 0] }")

But neither variant works. Is there working version of this command, or it's disable for your port (or is better way to do this with lua, than vim.cmd)?

vim.g.gruvbox_colors = "bg0: ['#000000', 0]"

Doesn't do anything either.

ellisonleao commented 3 years ago

hey @syntezoid thanks for the issue

It's kinda strange because i dont see that behaviour on my side

ive tested 2 scenarios:

default dark mode

  vim.g.gruvbox_contrast_dark = "hard"
  vim.cmd([[colorscheme gruvbox]])

This uses #282828 as bg color

Screenshot from 2021-02-26 13-25-30

  -- skipping custom contrast setting
  vim.cmd([[colorscheme gruvbox]])

This uses #1d2021 as bg color

Screenshot from 2021-02-26 13-27-10

Let me know if it makes sense

roland-5 commented 3 years ago

@ellisonleao Hi,

vim.o.background = "dark"
vim.cmd([[colorscheme gruvbox]])

It's a medium (default dark) mode and it's background color isn't #282828?

hanuka

vim.g.gruvbox_contrast_dark = "hard"
vim.o.background = "dark"
vim.cmd([[colorscheme gruvbox]])

I prefer hard mode version of dark mode, which if I understand background color is #1d2021.

I wanted to have black (#000000) background color, instead of default #1d2021 for hard version.

I tried to create command, which change it's bg color to black vim.cmd("let g:gruvbox_colors = { 'dark0_hard': ['#000000', 0] }") But it didn't change nothing. I can edit manualy ~/.local/share/nvim/site/pack/packer/start/gruvbox.nvim/lua/gruvbox/init.lua but then I can't update gruvbox.nvim because of this manualy interversion.

ellisonleao commented 3 years ago

ah, i see the problem, sorry for the miscommunication, the problem is that we still dont support the full palette override as the main script does, so you can just rely on the g:gruvbox_ configs for now, which seems to be working with the current backgrounds as expected.

I will keep this issue opened until we support that

justintime4tea commented 3 years ago

If your terminal emulator supports customizing the background (I use Alacritty and semi-transparent BG) you can have some control over your BG by setting the "cterm fg/bg" and "gui fg/bg" to NONE. The BG should now be whatever your terminal emulator supports. Not precisely a solution but I hope it helps!

hi! Normal ctermbg=NONE guibg=NONE
hi! NonText ctermbg=NONE guibg=NONE guifg=NONE ctermfg=NONE
roland-5 commented 3 years ago

@justintime4tea When I add these line, I see this error [2021-06-10 10:32:57.797006482] [ERROR] [alacritty_config_derive] Unable to load config "/home/syntezoid/.config/alacritty/alacritty.yml": Config error: while parsing a block mapping, did not find expected key at line 817 column 1

justintime4tea commented 3 years ago

@justintime4tea When I add these line, I see this error [2021-06-10 10:32:57.797006482] [ERROR] [alacritty_config_derive] Unable to load config "/home/syntezoid/.config/alacritty/alacritty.yml": Config error: while parsing a block mapping, did not find expected key at line 817 column 1

These are to be added to your vim configuration (some dot vim file either init or one you source from init) not to be added to alacritty.

roland-5 commented 3 years ago

Och, ok. sorry for misunderstanding. Hmm I added those line, but do something wrong, because, nothing changed cat ~/.config/nvim/init.lua

-- prevent typo when pressing `wq` or `q`
vim.cmd[[
  cnoreabbrev <expr> W ((getcmdtype() is# ':' && getcmdline() is# 'W')?('w'):('W'))
  cnoreabbrev <expr> Q ((getcmdtype() is# ':' && getcmdline() is# 'Q')?('q'):('Q'))
  cnoreabbrev <expr> WQ ((getcmdtype() is# ':' && getcmdline() is# 'WQ')?('wq'):('WQ'))
  cnoreabbrev <expr> Wq ((getcmdtype() is# ':' && getcmdline() is# 'Wq')?('wq'):('Wq'))
]]

--vim.cmd("setlocal spell spelllang=pl")

-- change cwd to current directory
vim.cmd("cd %:p:h")

-- load plugin manager first
require("plugins._packer")

vim.cmd("hi! Normal ctermbg=NONE guibg=NONE")
vim.cmd("hi! NonText ctermbg=NONE guibg=NONE guifg=NONE ctermfg=NONE")

-- plugin for colors HEX, rgb etc
vim.cmd('set termguicolors')
require'colorizer'.setup()

-- theme
vim.g.gruvbox_contrast_dark = "hard"
--vim.g.gruvbox_colors = "bg0: ['#000000', 0]"
vim.o.background = "dark"
vim.cmd([[colorscheme gruvbox]])

-- Example config in Lua
--vim.g.tokyonight_style = "night"
--vim.g.tokyonight_italic_functions = true
--vim.g.tokyonight_sidebars = { "qf", "vista_kind", "terminal", "packer" }
-- Change the "hint" color to the "orange" color, and make the "error" color bright red
--vim.g.tokyonight_colors = { bg = "#000000" }
-- Load the colorscheme
--vim.cmd[[colorscheme tokyonight]]

require'telescope'.load_extension('zoxide')

vim.cmd('autocmd BufWritePost plugins.lua PackerCompile')

local function setup_servers()
  require'lspinstall'.setup()
  local servers = require'lspinstall'.installed_servers()
  for _, server in pairs(servers) do
    require'lspconfig'[server].setup{}
  end
end

setup_servers()

-- Automatically reload after `:LspInstall <server>` so we don't have to restart neovim
require'lspinstall'.post_install_hook = function ()
  setup_servers() -- reload installed servers
  vim.cmd("bufdo e") -- this triggers the FileType autocmd that starts the server
end

-- telescope
require('telescope').setup{
  defaults = {
    vimgrep_arguments = {
      'rg',
      '--color=never',
      '--no-heading',
      '--with-filename',
      '--line-number',
      '--column',
      '--smart-case'
    },
    prompt_position = "bottom",
    prompt_prefix = "> ",
    selection_caret = "> ",
    entry_prefix = "  ",
    initial_mode = "insert",
    selection_strategy = "reset",
    sorting_strategy = "descending",
    layout_strategy = "horizontal",
    layout_defaults = {
      horizontal = {
        mirror = false,
      },
      vertical = {
        mirror = false,
      },
    },
    file_sorter =  require'telescope.sorters'.get_fuzzy_file,
    file_ignore_patterns = {},
    generic_sorter =  require'telescope.sorters'.get_generic_fuzzy_sorter,
    shorten_path = true,
    winblend = 0,
    width = 0.75,
    preview_cutoff = 120,
    results_height = 1,
    results_width = 0.8,
    border = {},
    borderchars = { '─', '│', '─', '│', '╭', '╮', '╯', '╰' },
    color_devicons = true,
    use_less = true,
    set_env = { ['COLORTERM'] = 'truecolor' }, -- default = nil,
    file_previewer = require'telescope.previewers'.vim_buffer_cat.new,
    grep_previewer = require'telescope.previewers'.vim_buffer_vimgrep.new,
    qflist_previewer = require'telescope.previewers'.vim_buffer_qflist.new,

    -- Developer configurations: Not meant for general override
    buffer_previewer_maker = require'telescope.previewers'.buffer_previewer_maker
  }
}
justintime4tea commented 3 years ago

You probably need to do that after loading your color scheme. I imagine those would be set by a color scheme hence "overriding" your cmd and resulting in no change.

Also you can try running them in vim (using :) prior to using them in your unit to confirm it works for you and then add to init.

mxkrsv commented 3 years ago

@justintime4tea it works if executed manually, but does nothing when placed in config file, even if execute 'colorscheme gruvbox' is at the beginning and execute 'hi! Normal ctermbg=NONE guibg=NONE' is at the end.

ellisonleao commented 2 years ago

hey guys, i've just pushed a new config system, which i hope to solve this issue. Unfortunately the overrides are just for the highlight groups now. Can you check latest README and see if it will solve the issues for now?

roland-5 commented 2 years ago

Before update ps_20220629002112

vim.opt.background = "dark" -- or "light" for light mode
vim.g.gruvbox_contrast_dark = "hard"
vim.cmd([[colorscheme gruvbox]])

After update ps_20220629002115

vim.o.background = "dark" -- or "light" for light mode
-- setup must be called before loading the colorscheme
-- Default options:
require("gruvbox").setup({
  undercurl = true,
  underline = true,
  bold = true,
  italic = true, -- will make italic comments and special strings
  invert_selection = false,
  invert_signs = false,
  invert_tabline = false,
  invert_intend_guides = false,
  contrast = "hard", -- can be "hard" or "light"
  overrides = {
    },
})
vim.cmd([[colorscheme gruvbox]])

Why colors are so different? Is actual hard contrast not the same as old?

Edit. Nevermind, you pushed to master fix for this.

roland-5 commented 2 years ago

Hmm, if I search for something, it's not correctly highlighted: Before update ps_20220629002955

And after update ps_20220629002942

ellisonleao commented 2 years ago

Hey @roland-rollo thanks for raising the issue. Can you open another issue so we can track there please?

ellisonleao commented 2 years ago

hey @roland-rollo just fixed the issue here

roland-5 commented 2 years ago

Yup, highlight it's fixed. Thanks, mate!

For your question about changing background color. I don't know how. :P For dark hard version it's originally located in gruvbox.nvim/lua/gruvbox/palette.lua as dark0_hard = "#1d2021" but I tried few option without result.

  overrides = {
      dark0_hard = {bg = "#ff9900"}
    },
  overrides = {
      GruvboxBg1 = {bg = "#ff9900"}
    },
 overrides = {
      bg0 = {bg = "#ff9900"}
    },
roland-5 commented 2 years ago

I'm dumb...

  overrides = {
      Normal = {bg = "#000000"}
  },

Is the answer.