nvim-tree / nvim-tree.lua

A file explorer tree for neovim written in lua
Other
7.24k stars 609 forks source link

Background color #245

Closed ziulev closed 3 years ago

ziulev commented 3 years ago

Is it possible to set a custom background color only for the tree?

kyazdani42 commented 3 years ago

hum used to be the case but i did not manage to do it. I'm pushing a fix to set back the winhighlight (don't know why it wasn't set anymore). I'm going to investigate because i cannot manage to override the link from the plugin in my configs ...

kyazdani42 commented 3 years ago

well i have no clue why, but i cannot manage to set NvimTreeNormal in my configs (but i can in the plugin source), the group is always cleared no matter where i put i in my config. I'll come back here if i can understand why this happens ...

hrqmonteiro commented 3 years ago

I was wondering that as well. NvimTreNormal makes no difference whatsoever.

I was able to change it setting this autocmd, in case it helps you:

autocmd ColorScheme * highlight highlight NvimTreeBg guibg=#2B4252
autocmd FileType NvimTree setlocal winhighlight=Normal:NvimTreeBg

2021-03-31_22-11

kyazdani42 commented 3 years ago

this was fixed in the view refactoring, you can now set NvimTreeNormal and it works fine :)

akinsho commented 3 years ago

@kyazdani42 I just tried this out, I'd been using a similar winhighlight override for a while anyway. From looking at the current implementation though it seems to set winhighlight like

EndOfBuffer:NvimTreeEndOfBuffer,Normal:NvimTreeNormal,CursorLine:NvimTreeCursorLine,VertSplit:NvimTreeVertSplit,SignColumn:Normal

This means that for me anyway I see that signcolumn is highlighted the same as the normal buffer but not the same as the rest of the tree. I think SignColumn:Normal should be SignColumn:NvimTreeNormal.

kyazdani42 commented 3 years ago

indeed, just fixed that in latest master

yamatsum commented 3 years ago

When I open a new tab from nvim-tree after setting as below, the background color of the new tab is strange(same as NvimTreeNormal) vim.cmd("autocmd Colorscheme * highlight NvimTreeNormal guibg=#21252B guifg=#9da5b3")

kyazdani42 commented 3 years ago

@yamatsum this is another issue that i don't know how to tackle but bothers me too, you can follow that in #290

kirill-martynov commented 11 months ago

When I open a new tab from nvim-tree after setting as below, the background color of the new tab is strange(same as NvimTreeNormal) vim.cmd("autocmd Colorscheme * highlight NvimTreeNormal guibg=#21252B guifg=#9da5b3")

@kyazdani42 Same issue happening with me, I'am using default settings for nvim-tree

  -- nvim-tree
  {
    "nvim-tree/nvim-tree.lua",
    dependencies = {
      "nvim-tree/nvim-web-devicons",
    },
    config = function()
      -- disable netrw at the very start of your init.lua
      vim.g.loaded_netrw = 1
      vim.g.loaded_netrwPlugin = 1

      require("nvim-tree").setup({
        view = { side = "right", width = 50 },
        update_focused_file = { enable = true, update_cwd = false },

        renderer = {
          highlight_modified = "all",
          highlight_git = true,

          root_folder_label = false,

          icons = { webdev_colors = false, show = { folder_arrow = false } },
          indent_markers = { enable = true },
        },
      })
    end,
  },

https://github.com/nvim-tree/nvim-tree.lua/assets/70448489/2dc99286-19e5-459f-9fb0-b4c4b4ea8cc8

I don't know to fix it, it happens randomly, but i think mostly after I'm trying to open in a new tab from nvim-tree

alex-courtis commented 11 months ago

Have you got any other plugins or automation that may alter NvimTreeNormal ? It might be a race condition.

Are you setting NvimTreeNormalNC to match? That might explain the window switching behaviour.

Can you :hi NvimTreeNormalNC and :hi NvimTreeNormal to see what's happened when this behaviour occurs?

subhranildas commented 2 months ago

Here is a long and late reply .. just keep these two lines if you are using tokyonight .. and you will be set .. every thing will stay transparent.

vim.cmd("autocmd VimEnter hi NvimTreeNormal guibg=NONE" ) vim.cmd("autocmd VimEnter hi NvimTreeNormalNC guibg=NONE" )

Cheers !!!

maleksware commented 1 month ago

The issue @kirill-martynov is facing seems to be replicatable with the following: open Nvim, toggle the tree, open the file in split view (C-v by default). It will open to the right of the default Nvim empty buffer. Then open another file from the tree with CR. Close both windows with wq and then open any file from the tree - it will have a different colorscheme. Tested on Neovim, nvim-tree and catppuccin.nvim from master as of the day of writing.

I could not replicate the colorscheme change if I closed the window with the empty buffer first. This is probably connected to the cause of the issue.

No idea why this might be happening.

alex-courtis commented 1 month ago

Unfortunately I can't replicate this one; I'm not quite sure what/where/how fast the flicker is.

@maleksware can you please raise a new Bug Report with a minimal reproducer that we can also share with lualine.

In the meantime I'm watching