nvim-tree.lua icon indicating copy to clipboard operation
nvim-tree.lua copied to clipboard

User Defined Icons and Highlight Groups

Open WilliamWelsh opened this issue 3 years ago • 9 comments

Is your feature request related to a problem? Please describe. I think it would be really great if you could have custom folder icon colors & custom folder icons depending on the name of the folder. For example, all of my folders are grey, but I would love if I could make node_modules folders green, pages folders orange, dist folders a light red, you get the idea. I think being able to change the icons too would be a bonus.

Describe the solution you'd like I think a few main highlight groups for popular folders would be great, such as NvimTreeNodeModulesFolder, NvimTreeUtilsFolder, NvimTreeLuaFolder, and NvimTreeStylesFolder, and maybe some more. What I think would be absolutely perfect would be being able to dynamically add them for whatever name the user wants by setting it up the config, something like

nvim_tree.setup({
   folder_overrides = {
      { name: "lua", iconColor: "#000000", icon: " " }
   }
})

Describe alternatives you've considered N/A

Additional context In this picture you can see the node_modules folder is set to a green folder icon, and types has blue folder icon. This is what I think would be awesome as a feature. CleanShot 2022-08-13 at 23 03 31

WilliamWelsh avatar Aug 14 '22 03:08 WilliamWelsh

name can be a vim.regex

Icon and name colour would be separate highlight groups.

A convention-over-configuration approach would be best, something like UserLua to match NvimTreeUserLuaFolder, NvimTreeUserLuaIcon and possibly NvimTreeUserLuaFile.

alex-courtis avatar Aug 14 '22 03:08 alex-courtis

i want a implematation of this

TheElegantCoding avatar Nov 03 '22 02:11 TheElegantCoding

what's about this: https://github.com/uiwjs/file-icons

image

cathaysia avatar Jul 22 '23 00:07 cathaysia

file-icons looks to provide the same functionality as nvim-web-devicons which nvim-tree uses.

It doesn't appear to provide the per-directory colouring and isn't written in lua, so it's not something we could use.

alex-courtis avatar Jul 23 '23 06:07 alex-courtis

On reflection, I don't think this is functionality that nvim-tree should provide; nvim-web-devicons should provide this functionality.

Please raise a feature request at https://github.com/nvim-tree/nvim-web-devicons with a proposed override_ setup option pattern.

alex-courtis avatar Jul 23 '23 06:07 alex-courtis

On reflection, I don't think this is functionality that nvim-tree should provide; nvim-web-devicons should provide this functionality.

Please raise a feature request at https://github.com/nvim-tree/nvim-web-devicons with a proposed override_ setup option pattern.

https://github.com/nvim-tree/nvim-web-devicons/issues/105

we don't manage folders in this repository unfortunately. This would depend on the plugin you are using.

BrunoKrugel avatar Sep 15 '23 13:09 BrunoKrugel

+1 would be a nice feat to have

rodhash avatar Feb 11 '24 12:02 rodhash

In terms of nvim-web-devicons it is now possible to override icons at runtime and setup time.

Following #2415 this is more of a possibility for nvim-tree only:

  • highlighting is additive and could be applied in the usual precedence: base < USER < git < opened < modified < bookmarked < diagnostics < copied < cut
  • A new Decorator could be added to handle user icons / highlights

User configuration needed:

  1. icon glyphs, may be from nvim-web-devicons
  2. highlight groups to cover both HL and icons
  3. mechanism to match files/folders to the above

Rather than complex configuration, a simple function is preferable. Something like:

---User defined highlighting and icon
---@param node Node cutdown
---@return string|nil node_hl highlight group for the node name
---@return string|nil icon_glyph glyph to replace the node's icon
---@return string|nil icon_hl highlight group for the icon
local function(node)
  ---

alex-courtis avatar Feb 12 '24 04:02 alex-courtis