romgrk / barbar.nvim

The neovim tabline plugin.
2.3k stars 85 forks source link

Question: Highlight group for Filetype Icon background #624

Open fenghourun opened 1 week ago

fenghourun commented 1 week ago

The highlight groups for the background color of the file-type icons doesn't seem to be working for me, but only for the current tab for some reason.

Screenshot 2024-10-26 at 4 23 34 PM

I have the following highlight groups set using {bg = some_color}

Here's the options I'm passing into barbar

  barbar.setup {
    icons = {
      filetype = {
        custom_colors = false,
        enabled = true
      },
      separator_at_end = false
    }
  }

Could this have something to do with background=light ?

romgrk commented 5 days ago

We generate the icon HL group here: https://github.com/romgrk/barbar.nvim/blob/31b6951c53a59bccfa91bf3984ed1510a940c836/lua/barbar/icons.lua#L22-L26

What's the output of :hi BufferCurrent?
Alternatively, what's the output of :=require('barbar.utils.highlight').bg_or_default({'BufferCurrent'}, 'none')?

fenghourun commented 5 days ago

We generate the icon HL group here:

https://github.com/romgrk/barbar.nvim/blob/31b6951c53a59bccfa91bf3984ed1510a940c836/lua/barbar/icons.lua#L22-L26

What's the output of :hi BufferCurrent? Alternatively, what's the output of :=require('barbar.utils.highlight').bg_or_default({'BufferCurrent'}, 'none')?

Screenshot 2024-10-30 at 3 24 15 PM

The output of :hi BufferCurrent seems to be in line with what I would want (light background)

Here's the output of the second command

{
  cterm = "none",
  gui = 1974305
}

I should mentioned that I also have an OptionSet autocmd that tries to re-apply my highlight groups when a background change is detected. Maybe this is part of the issue? Though I'm using other plugins that depend on nvim-devicons which doesn't seem to be affected by this issue

Iron-E commented 5 days ago

I should mentioned that I also have an OptionSet autocmd that tries to re-apply my highlight groups when a background change is detected. Maybe this is part of the issue?

Can you post a snippet? It might be related due to how ordering of autocmd's work. Or we might need to listen to OptionSet ourselves and set up the highlights again 🤔

fenghourun commented 5 days ago

I should mentioned that I also have an OptionSet autocmd that tries to re-apply my highlight groups when a background change is detected. Maybe this is part of the issue?

Can you post a snippet? It might be related due to how ordering of autocmd's work. Or we might need to listen to OptionSet ourselves and set up the highlights again 🤔

Sure thing!

  vim.api.nvim_create_autocmd("OptionSet", {
    pattern = "background",
    callback = function()
      set_colorscheme()
      config_lualine()
      config_ibl()
    end
  })

The function set_colorscheme() is composed of a series of vim.api.nvim_set_hl(...) calls for various plugins. I also have config_lualine() here which does something along the lines of

require('lualine').setup {
-- setup colors here
}

which I found was needed for me to get highlights switching properly with the background option for plugins which accepted theme options as part of the setup function