sainnhe / gruvbox-material

Gruvbox with Material Palette
MIT License
1.96k stars 166 forks source link

Change cursorline highlight color in neo-tree to make it more visible #215

Closed mksonkar closed 1 month ago

mksonkar commented 1 month ago

The highlight color of the cursorline in neo-tree is barely visible. It makes it hard to notice which file is currently highlighted or open. I've searched the documentation, but can't find a way to change the color. image Current behaviour: The highlight color of cursorline in neo-tree is barely visible. Expected behaviour: The default highlight color should be a bit darker to make it visible clearly.

antoineco commented 1 month ago

Do you happen to know whether Neotree supports overriding the cursorline highlight just for its filetype? If not, it is necessary to leverage Neovim's 'winhighlight' feature to obtain the desired result, possibly via an autocommand.

antoineco commented 1 month ago

I just looked at Neo-tree's code and it seems like the plugin exposes some event handlers for doing what I suggested earlier.

Could you please try adding this to your Neo-tree configuration and report whether the cursorline changes only in its windows?

require("neo-tree").setup({
  event_handlers = {
    {
      event = "neo_tree_buffer_enter",
      handler = function()
        -- just a silly example to try the event
        vim.cmd 'set winhighlight=CursorLine:Normal'
      end
    }
  }
})
mksonkar commented 1 month ago

Hey, thanks for your response!

I added the mentioned configuration to neo-tree. The highlight color seems to be gone completely, but now there's a black vertical bar just before the file name, on the tree structure of the highlighted file. Also, now that I compare it to the previous screenshot, the background of neo-tree seems to have changed as well. 2024-09-30-130718_1468x658_scrot

antoineco commented 1 month ago

@raknos13 thanks for reporting back!

I found the time to test it myself, here are my findings:

  1. The issue occurs with or without the 'cursorline' being set in your Neovim configuration, because Neo-tree sets the 'cursorline' option by default inside its windows.
  2. The reason why my suggestion didn't work is because Neo-tree already sets the 'winhighlight' option:
    # :set winhighlight?
    winhighlight=Normal:NeoTreeNormal,NormalNC:NeoTreeNormalNC,SignColumn:NeoTreeSignColumn,CursorLine:NeoTreeCursorLine,FloatBorder:NeoTreeFloatBorder,StatusLine:NeoTreeStatusLine,StatusLineNC:NeoTreeStatusLineNC,VertSplit:NeoTreeVertSplit,EndOfBuffer:NeoTreeEndOfBuffer,WinSeparator:NeoTreeWinSeparator

The good news is that the CursorLine highlight group is already overriden by a highlight group named NeoTreeCursorLine inside Neo-tree windows. We do not currently have any customization for this highlight group because the default works well in dark mode, but I am going to add a customization for light mode.

Thanks for reporting 👍

mksonkar commented 1 month ago

Yes, you are correct, dark mode doesn't have this issue, and the highlight is visible clearly.

Thank you for your time and valuable contributions to this wonderful colorscheme!