Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

User Defined Icons and Highlight Groups #1508

Closed
WilliamWelsh opened this issue Aug 14, 2022 · 10 comments
Closed

User Defined Icons and Highlight Groups #1508

WilliamWelsh opened this issue Aug 14, 2022 · 10 comments
Labels
feature request PR please nvim-tree team does not have the bandwidth to implement; a PR will be gratefully appreciated QOL Quality Of Life Improvement

Comments

@WilliamWelsh
Copy link

WilliamWelsh commented Aug 14, 2022

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

@alex-courtis
Copy link
Member

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 alex-courtis added the PR please nvim-tree team does not have the bandwidth to implement; a PR will be gratefully appreciated label Aug 14, 2022
@alex-courtis alex-courtis added the QOL Quality Of Life Improvement label Oct 31, 2022
@TheElegantCoding

This comment was marked as duplicate.

@cathaysia
Copy link

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

image

@alex-courtis
Copy link
Member

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
Copy link
Member

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.

@BrunoKrugel
Copy link

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.

nvim-tree/nvim-web-devicons#105

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

@rodhash

This comment was marked as duplicate.

@alex-courtis
Copy link
Member

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 alex-courtis reopened this Feb 12, 2024
@alex-courtis alex-courtis changed the title Custom colors/icons based on folder names User Defined Icons and Highlight Groups Feb 12, 2024
@cl1ckname

This comment was marked as duplicate.

@alex-courtis
Copy link
Member

Tracked at #2948

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature request PR please nvim-tree team does not have the bandwidth to implement; a PR will be gratefully appreciated QOL Quality Of Life Improvement
Projects
None yet
Development

No branches or pull requests

7 participants