rebelot / kanagawa.nvim

NeoVim dark colorscheme inspired by the colors of the famous painting by Katsushika Hokusai.
MIT License
4.13k stars 175 forks source link

WinBar highlight group overwrite works randomly #81

Open boltlessengineer opened 1 year ago

boltlessengineer commented 1 year ago

I found overriding WinBar highlighting group works randomly. Even I override WinBar to { bg = '#000000' }, WinBar hlgroup appears to be { fg = '#c8c093' } most cases.

How to reproduce:

  1. Create test.lua file (this would be minimal init.lua file)
    
    vim.o.termguicolors = true
    require('kanagawa').setup {
    overrides = {
    WinBar = { bg = '#000000' },
    }
    }
    vim.cmd('colorscheme kanagawa')

-- some keymaps for making test easy vim.keymap.set('n', '', function() vim.o.winbar = [[%f]] end) vim.keymap.set('n', 'q', ':q')


2. Run nvim with following command

nvim -u test.lua --no-plugin nvim -u test.lua --no-plugin nvim -u test.lua --no-plugin ...



3. See `WinBar` highlight group overriding doesn't apply in most cases

<img width="722" alt="image" src="https://user-images.githubusercontent.com/60088301/197401586-34151270-e98b-494e-aa46-6449de2700d6.png">

<img width="722" alt="image" src="https://user-images.githubusercontent.com/60088301/197401600-3b2c5ed7-631a-4e55-be78-f1edc5fa4df3.png">

I checked both neovim v0.8.0 and v0.9.0, but result was same.
Also, I'm pretty curious why this only happens for hlgroup `WinBar`. (`StatusLine` works fine)
rebelot commented 1 year ago

hmm I'm sorry but I can't reproduce. Do you have any plugins that interact with the winbar?

rebelot commented 1 year ago

sorry, I was indeed able to reproduce, like 1 out of 10 restarts does not apply the winbar override... I really wouldn't know how to debug this...

But you don't need to use override at all... I wonder if this could be reproduced with the following snippet

require'kanagawa'.setup({...})
vim.cmd("colorscheme kanagawa")
vim.cmd("hi WinBar guibg=gray")
vim.cmd("hi WinBarNC guibg=black")
CoderLadFahim commented 8 months ago

This solved the problem right away.

Lovely theme by the way. I really admire the dragon variant, I love the old terminal look that it provides, it makes it seem like I'm using Bram's old vim again, unlike the contemporary hipster garbage like catpucchin and a few others.

dzirtusss commented 3 weeks ago

The problem is here: https://github.com/rebelot/kanagawa.nvim/blob/master/lua/kanagawa/highlights/editor.lua#L142-L145

There is a WinBar (correct case) and Winbar (not correct case), so when you do override (properly), there are appear 2 records in the lua table, and I guess they are applied with some randomness.

I have totally same story with Statusline and StatusLine, actually having Statusline as not correct override in local config.

IMO this is coming from the fact that despite highlights are case-sensitive e.g. StatusLine I can do hi sTaTusLine guibg=#123456 and it will apply it to the StatusLine existing highlight, not creating new highlight and/or raising error.

Which ^^^ totally explains "random" behaviour.

In my case after appying proper case, all randomness have gone as it was my config bug. For WinBar this needs a code fix, as it is bug in the repo.

Except fixing the bug, maybe worth checking repo as there might be similar wrong case occurances somewhere

dzirtusss commented 3 weeks ago

As well maybe override method need to be more robust to handle even wrong cases vs creating 2 rows in the table. At least it might print warning message on load for such, which is not hard.