romgrk / barbar.nvim

The neovim tabline plugin.
2.16k stars 81 forks source link

Question: how to customize/override default highlights? #578

Closed linrongbin16 closed 1 month ago

linrongbin16 commented 1 month ago

Hi, I'm using 'apprentice' colorscheme (actually I use a lot of colorschemes, switch from one to another), with barbar it looks like:

image

You can see, the lua file type icon color (blue) and the buffer index in the active/current buffer don't have a good contrast with background color.

I think I need to customize/override the default color for the background color, which should be BufferCurrent or BufferDefaultCurrent.

romgrk commented 1 month ago

You'd need to check the documentation for nvim-web-devicons, we use the colors they export directly.

linrongbin16 commented 1 month ago

hi @romgrk,

actually I want to define the BufferCurrentDefault highlight group.

I found the set_default_link API is using default option: https://github.com/romgrk/barbar.nvim/blob/5880baa3bf6b262ee3c465519fce3e71a6045dec/lua/barbar/utils/highlight.lua#L188

which means if I define BufferCurrentDefault before loading this plugin, then I could override this color.

[nvim_set_hl()](https://neovim.io/doc/user/api.html#nvim_set_hl())

romgrk commented 1 month ago

My bad, thought you wanted to fix the icon color.

Iron-E commented 1 month ago

The *Default highlights are not meant to be overridden— those are just the defaults. I would suggest something like this:

-- run `callback` after a colorscheme is loaded
vim.api.nvim_create_autocmd('ColorScheme', {
  pattern = 'apprentice', -- after apprentice loads specifically
  callback = function()
    vim.api.nvim_set_hl(0,
      'BufferCurrent', -- or any other hl group
      { --[[ the definition of the group here ]] }
    )

    -- vim.api.nvim_set_hl(…)
  end,
})
linrongbin16 commented 1 month ago

The *Default highlights are not meant to be overridden— those are just the defaults. I would suggest something like this:

-- run `callback` after a colorscheme is loaded
vim.api.nvim_create_autocmd('ColorScheme', {
  pattern = 'apprentice', -- after apprentice loads specifically
  callback = function()
    vim.api.nvim_set_hl(0,
      'BufferCurrent', -- or any other hl group
      { --[[ the definition of the group here ]] }
    )

    -- vim.api.nvim_set_hl(…)
  end,
})

thank you, I will try