feat: Add icons by pattern and better env support#649
Open
rokbot wants to merge 1 commit into
Open
Conversation
- 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/
c8568cf to
42a301a
Compare
alex-courtis
requested changes
Jul 14, 2026
Member
There was a problem hiding this comment.
Questions
- Why do we need to sort the user pattern icons into
user_patterns_sorted? What is the significance of the sort? - 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_patternand allow users to specify patterns for alloverride_by_
- Proposal: remove
Please reply with your thoughts and we can decide on the final direction.
Work Needed, As Submitted
Please:
- Change from lua patterns to vim regex patterns to be processed by
vim.fn.match. nvim-tree uses vim regex, as do most other plugins, and we should provide a consistent user experience. - Explicitly specify which regexes are used, in the readme
- Resolve the style issue https://github.com/nvim-tree/nvim-web-devicons/actions/runs/29295576657/job/86978468164?pr=649
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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/