feat(icons): provide language specific icons in extras
What is this PR for?
Provide language specific file icons. The intent is to lay the foundation of this type of extension / configuration. I've added icons for file types that I interact with but this is definitely not holistic. I also went back and forth on whether the configuration should be within the core UI config or in the extras (I landed on the later). Definitely open to feedback on these changes.
Does this PR fix an existing issue?
Nope.
Checklist
- [x] I've read the CONTRIBUTING guidelines.
Thanks!
I do think it makes most sense to contribute PR's to mini.icons.
@echasnovski what's your take on this? What are your requirements to add new icons to mini.icons vs leaving it up to the user to configure?
See the diff in this PR.
I currently added this one for example:
["NEWS.md"] = { glyph = "", hl = "MiniIconsYellow" },
@echasnovski what's your take on this? What are your requirements to add new icons to
mini.iconsvs leaving it up to the user to configure?
I am leaning on a more cautious side of adding new built-in support for icons, i.e. preferring to suggest user configurations.
Which icon names are intended to be supported in 'mini.icons' is planned to be documented. Here is a rough draft:
- Category "filetype" - any filetype that is reasonably used in the wild. This is intended as a widest net for supporting use cases. Users then are encouraged to have a proper filetype detection set up. Note: this currently has some problems due to handful of manually tracked extensions which have precedence over
vim.filetype.match()for speed reasons. See, for example, echasnovski/mini.nvim#1017. Give me couple of days to try to figure out the best compromise here. - Categories "directory", "file", "extension" categories - popular not language/software specific, with few exceptions (like for Git, Make, etc.).
- Category "lsp" - only values of some
*Kinddefined in LSP specification. - Category "os" - operating systems which have
nf-md-*icon (which is used as proxy for "popular OS").
So from what I am seeing in this PR, I will add '.gitkeep', 'CODEOWNERS', 'NEWS', 'NEWS.md' files plus any filetype which has evidence of actual usage (like presence in built-in Neovim detection or fairly popular filetype plugin).
There are now documented criteria in each category for an icon to be considered for adding to built-ins. TL;DR: basically what is listed in previous comment.
I plan to add new icon data tomorrow.
ok, great!
@m0lson84 would be good to check after tomorrow to see what icons can be removed from the PR
Some of the filetypes from this PR were added to 'mini.icons'. Here is the commit.
Some notes:
- 'tf' filetype doesn't seem to be for terraform, but for something called TinyFugue MUD client.
vim.filetype.match()detects terraform only by contents so I've added special handling of 'tf' extension. - I could not find reasonable usages of 'gotmpl' and 'dotenv' filetypes, so they are not added.
@m0lson84, thanks for suggesting new additions! In the future, if you find some reasonably usable filetype in the wild (with evidence, like filetype plugin containing 'ftdetect' directory), feel free to open a PR in 'mini.nvim'. The rest categories will have harder time getting merged.
Awesome, thanks @echasnovski!
The new NEWS icon however is currently the same as for changelog.
I used one of the newspaper icons. Maybe a better fit?
The new
NEWSicon however is currently the same as for changelog.
This was deliberate as 'NEWS.md' and 'CHANGELOG.md' seem to be used interchangeably. But I am open to changing it to nf-md-newspaper_variant.
Added tests for mini.icons that checks that no icons are added that already exist in mini.icons...
@echasnovski for my plugins (and for a lot of repos using conventional commits), the CHANGELOG.md file is auto generated based on conventional commits.
The NEWS.md file is a manual file, more similar to what you'd find in :h news.
I noticed you didn't include any of the javascript/typescript ecosystem icons, while those are wildly used. Is there a reason for this? Most of those icons are the exact icons used by the related projects.
Also worth mentioning is that with this PR, fzf-lua seems broken...
No idea why though.
I noticed you didn't include any of the javascript/typescript ecosystem icons, while those are wildly used. Is there a reason for this? Most of those icons are the exact icons used by the related projects.
I think drawing the line at supporting languages/siftware only through filetypes is a healthy compromise long term. The last thing I want is to end up with tons of languages 'mini.icons' has to extensively support. There are Neovim distributions and language plugins for that :)
Thinking about it, I might have to export MiniIcons.set(), because setting icons now can be done only by calling MiniIcons.setup() (which would require careful config preservation).
Also worth mentioning is that with this PR, fzf-lua seems broken...
Very strange indeed.
@echasnovski something seems broken with the devicons integration and setting custom icons..
When I do require("nvim-web-devicons").get_icons(), I get the error below:
E5108: Error executing lua ...lke/.local/share/nvim/lazy/mini.icons/lua/mini/icons.lua:506: Invalid highlight name: 'MiniIconsGray'
stack traceback:
[C]: in function 'get_hl_data'
...lke/.local/share/nvim/lazy/mini.icons/lua/mini/icons.lua:506: in function 'get_hex'
...lke/.local/share/nvim/lazy/mini.icons/lua/mini/icons.lua:529: in function 'make_icon_tbl'
...lke/.local/share/nvim/lazy/mini.icons/lua/mini/icons.lua:535: in function 'make_category_tbl'
...lke/.local/share/nvim/lazy/mini.icons/lua/mini/icons.lua:547: in function 'get_icons'
[string ":lua"]:1: in main chunk
That is with this PR, but I don't see anything wrong being set here.
It is MiniIconsGrey, not MiniIconsGray.
Right, should have spotted that :) Fixed!
Merged. ty!
@echasnovski Thanks for looking this over and bringing some of these suggestions into mini.icons. @folke Thanks for cleaning up my changes and fixing the broken areas 😅.
Added tests for
mini.iconsthat checks that no icons are added that already exist inmini.icons...
I am not sure how those tests are run, but 'CODEOWNERS' is present in 'mini.icons' (and is properly present in MiniIcons.list('file')), yet tests did not fail for it also present in LazyVim.
You're right. The tests only check specs from extras. Will remove!
@echasnovski for my plugins (and for a lot of repos using conventional commits), the
CHANGELOG.mdfile is auto generated based on conventional commits. TheNEWS.mdfile is a manual file, more similar to what you'd find in:h news.
@folke, do you want to do the honors and choose color for 'NEWS' icon ("', a.k.a. plain 'nf-md-newspaper')?
Anything works for me :)
Another docs I frequently use btw is TODO.md, but not sure how common that is...
There are now both 'NEWS{.md}' and 'TODO{.md}' on latest main.
Sweet! ty! :)