akinsho / bufferline.nvim

A snazzy bufferline for Neovim
GNU General Public License v3.0
3.57k stars 198 forks source link

[Bug]: Colors not updated when colorscheme is changed #490

Closed 4e554c4c closed 2 years ago

4e554c4c commented 2 years ago

Is there an existing issue for this?

What happened?

I change my colorscheme twice a day (when the sun rises and sets) in neovim this amounts to loading a colorscheme.lua file with the lines

vim.o.background = dark | light
vim.cmd [[colorscheme <colorscheme>-dark | light]]

however, bufferline's colors do not change, even when the rest of my colors change

What did you expect to happen?

I expect the bufferline colors to change along with other neovim colors

Config

bufferline config:

require('bufferline').setup {
  options = {
    close_icon = '',
    diagnostics = "nvim_lsp",
  },
}

Additional Information

termguicolors are set in my config (:set termguicolors returns termguicolors) and i do not modify any of the bufferline highlights or colors, which i believe is the recommended configuration.

commit

c4dd9b4de03b891f648b098c25e4dc1bc48a13e5

akinsho commented 2 years ago

@4e554c4c I'm not sure exactly how you have neovim configured, but when I run :colorscheme <value> with bufferline this correctly updates the colours. Can you confirm that you are not using any theme that is manually manipulating bufferline's colours and that you are not yourself outside the setup function?

4e554c4c commented 2 years ago

I'll try to come up with a MWE, thanks for trying to reproduce

akinsho commented 2 years ago

@4e554c4c any news on this? I'm regularly switching themes and this works fine for me

akinsho commented 2 years ago

I'm going to close this out since there's been not response. Feel free to post a minimal example that reproduces this issue and if I can reproduce I'll re-open this

4e554c4c commented 2 years ago

sorry! was on vacation for a week with no internet.

back at my computer and I figured out two oddities that might be causing this issue

first, my init.lua loads colorschemes before plugin configurations. e.g. it loads colorscheme.lua:

vim.opt.background = light
vim.cmd([[colorscheme base16-atelier-forest-light]])

before running require 'bufferline'.setup{}.

I've replicated this in vim -u NORC as follows:

colorscheme base16-atelier-forest-light
lua require 'bufferline'.setup{}
colorscheme base16-atelier-forest

the following works (loading colorscheme.lua after my plugin configuration)

lua require 'bufferline'.setup{}
colorscheme base16-atelier-forest-light
colorscheme base16-atelier-forest

second, i can't replicate this with non-base16 themes (e.g. built-in themes like "morning" or "blue") i suspect this is because nvim-base16 uses GUI colors instead of cterm colors.

akinsho commented 2 years ago

@4e554c4c it's right/desirable for your colorscheme to be loaded before bufferline. Bufferline works by sampling colours from your theme to create its own colors so if the theme is set too late then it might not pick those up. Secondly, I'm not sure if I understand the exact workflow that isn't working. The workflow that is designed to work is that a user loads a colorscheme as normal and if at a later date you change it then it should update. Can you please ensure you've tested with other colorschemes (excluding the defaults) to see that this isn't some behaviour of nvim-base16 specifically

4e554c4c commented 2 years ago

tested with gruvbox (and gruvbox.nvim for another lua colorscheme) base16 -> gruvbox works gruvbox -> base16 doesn't

so this is probably related to the base16.nvim repo, I'll go report there and see if they have any insight

4e554c4c commented 2 years ago

base16 issue closed. they suggest I debug how bufferline reloads themes. i'll work on that when i get the time.

4e554c4c commented 2 years ago

works as of v2.7!