LazyVim icon indicating copy to clipboard operation
LazyVim copied to clipboard

feat(icons): provide language specific icons in extras

Open m0lson84 opened this issue 1 year ago • 1 comments

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

m0lson84 avatar Jul 05 '24 19:07 m0lson84

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" },

folke avatar Jul 05 '24 21:07 folke

@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?

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 *Kind defined 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).

echasnovski avatar Jul 06 '24 07:07 echasnovski

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.

echasnovski avatar Jul 06 '24 17:07 echasnovski

ok, great!

@m0lson84 would be good to check after tomorrow to see what icons can be removed from the PR

folke avatar Jul 06 '24 18:07 folke

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.

echasnovski avatar Jul 07 '24 13:07 echasnovski

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?

folke avatar Jul 07 '24 15:07 folke

The new NEWS icon 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.

echasnovski avatar Jul 07 '24 15:07 echasnovski

Added tests for mini.icons that checks that no icons are added that already exist in mini.icons...

folke avatar Jul 07 '24 15:07 folke

@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.

folke avatar Jul 07 '24 16:07 folke

Also worth mentioning is that with this PR, fzf-lua seems broken...

No idea why though.

folke avatar Jul 07 '24 16:07 folke

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 avatar Jul 07 '24 16:07 echasnovski

@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.

folke avatar Jul 07 '24 16:07 folke

It is MiniIconsGrey, not MiniIconsGray.

echasnovski avatar Jul 07 '24 16:07 echasnovski

Right, should have spotted that :) Fixed!

folke avatar Jul 07 '24 16:07 folke

Merged. ty!

folke avatar Jul 07 '24 17:07 folke

@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 😅.

m0lson84 avatar Jul 07 '24 17:07 m0lson84

Added tests for mini.icons that checks that no icons are added that already exist in mini.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.

echasnovski avatar Jul 07 '24 18:07 echasnovski

You're right. The tests only check specs from extras. Will remove!

folke avatar Jul 07 '24 18:07 folke

@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.

@folke, do you want to do the honors and choose color for 'NEWS' icon ("󰎕', a.k.a. plain 'nf-md-newspaper')?

echasnovski avatar Jul 09 '24 06:07 echasnovski

Anything works for me :)

Another docs I frequently use btw is TODO.md, but not sure how common that is...

folke avatar Jul 09 '24 08:07 folke

There are now both 'NEWS{.md}' and 'TODO{.md}' on latest main.

echasnovski avatar Jul 09 '24 11:07 echasnovski

Sweet! ty! :)

folke avatar Jul 09 '24 13:07 folke