f4z3r / gruvbox-material.nvim

Material Gruvbox colorscheme for Neovim written in Lua
MIT License
41 stars 5 forks source link

Background Transparency #5

Closed Parilia closed 6 months ago

Parilia commented 7 months ago

Backgroundtransparency does not seem to work

vim.g.gruvbox_material_transparent_background = 1

Is set and doesnt seem to work

f4z3r commented 7 months ago

@Parilia can be you please provide an example screenshot that showcases the issue? Does this issue apply to the background generally, or only to specific parts (such as the sign column)?

Parilia commented 7 months ago

Background in general Screenshot_20240401_141257

f4z3r commented 7 months ago

Hi @Parilia , I implemented a small fix for it. I will merge this later today.

Please note that this plugin will not support all the options you have defined above in your config. Feel free to open issues for them if you really want them in this repo.

On a side note: I took over this repo only a few weeks back. I am planning on updating the code a little so that it is easier to add future fixes and potential additions. This will also include a more "lua-oriented" configuration where values are provided directly to the setup function instead of globally defined variables.

Parilia commented 7 months ago

alright, cool thank you for the fix. if I can I would like to help where I can

f4z3r commented 7 months ago

alright, cool thank you for the fix. if I can I would like to help where I can

Thanks. I will try to setup some issues on the project to track a bit what I think makes sense (and add info to the milestone). If you want to help, feel free to grab something or submit a PR 👍🏽

dot-1q commented 6 months ago

@f4z3r I'm now starting to see this issue again after the code refactor.

Screenshot 2024-05-11 at 18 21 14

My config:

return {
  {
    'f4z3r/gruvbox-material.nvim',
    enabled = true,
    lazy = false,
    priority = 1000,
    opts = {
      background = {
        transparent = true, -- set the background to transparent
      },
      float = {
        force_background = true, -- force background on floats even when background.transparent is set
        background_color = nil, -- set color for float backgrounds. If nil, uses the default color set
        -- by the color scheme
      },
    },
  },
}
Parilia commented 6 months ago

I have no issues with the dark theme

f4z3r commented 6 months ago

@dot-1q if you are talking about the floating window having a background, you need to set the float.force_background to false.

dot-1q commented 6 months ago

The issue still stands. Changing the transparency (background or float) in the options has no effect on the final transparency value for me.

return {
  {
    'f4z3r/gruvbox-material.nvim',
    enabled = true,
    lazy = false,
    priority = 1000,
    opts = {
      background = {
        transparent = true, -- set the background to transparent
      },
      float = {
        force_background = false, -- force background on floats even when background.transparent is set
        background_color = nil, -- set color for float backgrounds. If nil, uses the default color set
        -- by the color scheme
      },
    },
  },
}
f4z3r commented 6 months ago

Mhhh ok, I will try to have a look at it tomorrow. When you go into the floating window and enter :Inspect, what do you get?

dot-1q commented 6 months ago

I get this:

Screenshot 2024-05-11 at 22 02 52

While on this, changing Italics to false doesn't disable italics. I wonder if this is something related to reading the user configs. As you can see, I disabled Italics but in the screenshot they're enabled.

Screenshot 2024-05-11 at 22 03 41
f4z3r commented 6 months ago

Mhhh this is very strange. No matter if I set the background to light or dark it seems to work for me:

image

with config:

require("gruvbox-material").setup({
  background = {
    transparent = true,
  },
  float = {
    force_background = true,
  },
})

and:

image

with configuration:

require("gruvbox-material").setup({
  background = {
    transparent = true,
  },
  float = {
    force_background = false,
  },
})

Do you override NormalFloat somewhere?

dot-1q commented 6 months ago

I do not, at least that I'm aware of. But more than that, I'm not able to configure any of the colorscheme options. I'm using lazynvim, and the plugin file is:

return {
  {
    'f4z3r/gruvbox-material.nvim',
    name = 'gruvbox-material',
    lazy = false,
    priority = 1000,
    config = function()
      require('gruvbox-material').setup {
        italics = false, -- enable italics in general
        contrast = 'medium', -- set contrast, can be any of "hard", "medium", "soft"
        comments = {
          italics = false, -- enable italic comments
        },
        background = {
          transparent = true, -- set the background to transparent
        },
        float = {
          force_background = false, -- force background on floats even when background.transparent is set
          background_color = nil, -- set color for float backgrounds. If nil, uses the default color set
          -- by the color scheme
        },
      }
    end,
  },
}

I've tried through the opts = {} way, and replacing config with init to no avail. After this line I've added:

  print(vim.print(cfg))
  print("-----------")

And this is the result:

Screenshot 2024-05-12 at 18 40 24

Seems like its being called more than once and overriding my options. I don't know if this is of any help.

f4z3r commented 6 months ago

Puh, seems to be an "issue" with lazy-nvim. I have no experience with it. Maybe @Parilia can help? He uses lazy-nvim as far as I know.

Parilia commented 6 months ago

My configs are in my init.lua and are:

{
    'f4z3r/gruvbox-material.nvim',
    name = 'gruvbox-material',
    lazy = false,
    priority = 1000,
    opts = {
      italics = false,
      comments = { italics = false },
      background = { transparent = true },
      float = {
        force_background = false,
        background_color = nil,
      },
    },
  }

Could it perhaps have something to do with your terminal ? If i set my terminal to not be transparent then none of neovim is.

f4z3r commented 6 months ago

Ah, I think I know what the problem is. @dot-1q you use auto-dark-mode right? Do you configure it with:

return {
  "f-person/auto-dark-mode.nvim",
  config = {
    update_interval = 1000,
    set_dark_mode = function()
      vim.api.nvim_set_option("background", "dark")
      vim.cmd("colorscheme gruvbox-material")
    end,
    set_light_mode = function()
      vim.api.nvim_set_option("background", "light")
      vim.cmd("colorscheme gruvbox-material")
    end,
  },
}

If you do, every call to colorscheme gruvbox-material will call the setup function with default arguments. What you want to do instead is to call require("gruvbox-material").setup(...) in the callbacks. So have:

return {
  "f-person/auto-dark-mode.nvim",
  config = {
    update_interval = 1000,
    set_dark_mode = function()
      vim.api.nvim_set_option("background", "dark")
      require("gruvbox-material").setup({ your opts})
    end,
    set_light_mode = function()
      vim.api.nvim_set_option("background", "light")
      require("gruvbox-material").setup({ your opts})
    end,
  },
}
dot-1q commented 6 months ago

That actually solves my problem yes! Thank you very much! Although it is strange indeed, since while i was testing i remember disabling that plugin via enabled=false, so i'm not sure why loading the color scheme again explicitly solves the issue. Thanks for debugging my setup!