Nvim-tree.lua: Suggestion: folders open and close different colors

Created on 12 Mar 2021  ·  13Comments  ·  Source: kyazdani42/nvim-tree.lua

Hi, it would be nice to have different colors for the opened folders and the default folder glyphs, like we could do in Nerdtree, like this:

2021-03-12_18-17

A different highlight group for the opened ones and for the closed ones.

Most helpful comment

yep go for it

All 13 comments

you could implement this if you wish, you've got to modify the color table (to add another group), and the highlight choice in renderer.lua :)

I'm not a lua programmer, i tried to do it but i couldn't... Even forked the repo, so if i could manage to do it i would PR. But i am not able to.

Thanks to the attention anyway.

Hi, do not close suggestions that might be realized by other people :) maybe i'll have time at some point

Oh sorry, didn't realized that, my mistake

Hey @hrqmonteiro you could do something like this

Lua variant

vim.g.nvim_tree_icons = {
    folder = {
        default = "",
        open = "",
        empty_open = "",
        empty = "",
        symlink = "",
    }
}

Viml variant

let g:nvim_tree_icons = {
    \ 'folder': {
    \   'default': "",
    \   'open': "",
    \   'empty_open': "",
    \   'empty': "",
    \   'symlink': "",
    \   }
    \ }

It will do this
image

Is this what you had in mind?

Hey @hrqmonteiro you could do something like this

Lua variant

vim.g.nvim_tree_icons = {
    folder = {
        default = "",
        open = "",
        empty_open = "",
        empty = "",
        symlink = "",
    }
}

Viml variant

let g:nvim_tree_icons = {
    \ 'folder': {
    \   'default': "",
    \   'open': "",
    \   'empty_open': "",
    \   'empty': "",
    \   'symlink': "",
    \   }
    \ }

It will do this
image

Is this what you had in mind?

Actually no, this i already have (a different icon for the closed and the open), i wanted to highlight it differently, a color for each of them, see?

I can take this too. I was thinking about highlighting currently opened files that are pretty similar to what @hrqmonteiro is looking for, maybe I can do both.

has been fixed in #258

has been fixed in #258

Okay, i was using the fork of afonsocarlos, for like a week, and i was having the folder icon changed it's color when i opened it.

Today i say what you merged, and i switched to the main repo and main branch. But just the name of the opened folder is changing color.

Why did you chose to go this way? Can't we have the folder ICON change the color?

@kyazdani42 I checked here and i think it could be the case of only condition this part:

https://github.com/kyazdani42/nvim-tree.lua/blob/090697e71fe614cc13f218fc751a651cf4fada4f/lua/nvim-tree/renderer.lua#L45-L48

To something like this:

  hl_icon = 'NvimTreeFolderIcon'
  if vim.g.nvim_tree_highlight_opened_files then hl_icon = 'NvimTreeOpenedFolderIcon' end
  table.insert(hl, {hl_icon, line, depth, depth+icon_len})

What do you think?

yep go for it

Still doesn't work.

I literally use the afonso fork on this commit because it has the option to highlight the icon instead of the text.

@hrqmonteiro we're working on that already, there's a PR in progress to improve the level of customization for opened files highlighting

Was this page helpful?
0 / 5 - 0 ratings

Related issues

cloggier picture cloggier  ·  8Comments

gmr458 picture gmr458  ·  5Comments

chinnkarahoi picture chinnkarahoi  ·  7Comments

michaelb picture michaelb  ·  5Comments

GustavoPrietoP picture GustavoPrietoP  ·  6Comments