Skip to content

feat: Add icons by pattern and better env support#649

Open
rokbot wants to merge 1 commit into
nvim-tree:masterfrom
rokbot:feat/icons-by-pattern
Open

feat: Add icons by pattern and better env support#649
rokbot wants to merge 1 commit into
nvim-tree:masterfrom
rokbot:feat/icons-by-pattern

Conversation

@rokbot

@rokbot rokbot commented Jul 8, 2026

Copy link
Copy Markdown
  • This allows to use icons by lua patterns
  • Improve icons for env specific files .env.example, .env.local etc.

Useful links:
https://www.lua.org/pil/20.2.html
https://www.lua.org/manual/5.1/manual.html#5.4.1
https://gitspartv.github.io/lua-patterns/

- This allows to use icons by lua patterns
- Improve icons for env specific files .env.example, .env.local etc.

Useful links:
 https://www.lua.org/pil/20.2.html
 https://www.lua.org/manual/5.1/manual.html#5.4.1
 https://gitspartv.github.io/lua-patterns/
@rokbot rokbot force-pushed the feat/icons-by-pattern branch from c8568cf to 42a301a Compare July 14, 2026 00:18

@alex-courtis alex-courtis left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Questions

  1. Why do we need to sort the user pattern icons into user_patterns_sorted? What is the significance of the sort?
  2. Should this work with file names / extensions? I could only make it work with file types.

Feedback

Thank you, this is a great addition to nvim-web-devicons.

I do have some concerns:

  • Performance: pattern matching is expensive and web-devicons is used in a great many places. It must be as fast as possible.
    • Ameliorate: only use patterns for user overrides. The user can choose to incur the cost.
  • Completeness: it seems we can only override filetypes, not names or extensions. Users will want this. My first test was with a file name, however that did not work.
    • Proposal: remove override_by_pattern and allow users to specify patterns for all override_by_

Please reply with your thoughts and we can decide on the final direction.

Work Needed, As Submitted

Please:

Manual Testing

Override Working

require'nvim-web-devicons'.setup {
  override_by_pattern = {
    ["^kconf.*$"] = {
      icon = "K",
      color = "#FF0000",
      name = "kconfsomething"
    }
  }
}

Shows icon and:

Overrides
---------
K  ^kconf.*$  DevIconKsomething  guifg=#ff0000

Sample Working

.env.foo shows icon as expected

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants