echasnovski / mini.nvim

Library of 40+ independent Lua modules improving overall Neovim (version 0.8 and higher) experience with minimal effort
MIT License
4.45k stars 171 forks source link

get icons based on file paths rather than display text #955

Open jason0x43 opened 3 weeks ago

jason0x43 commented 3 weeks ago

Contributing guidelines

Module(s)

mini.pick

Description

I made a custom source to show git files with multiple scopes, along with the status, based on this comment. The items look like

{
  text = "H path/to/file.js",
  path = "path/to/file.js"
},
{
  text = "? path/to/untracked.js",
  path = "path/to/untracked.js"
},

That works great, except that file icons don't show up. The request is for default_show to show icons for file items based on the file path rather than the display text.

The root issue is that get_icon in default_show is passed the text of each item rather than the entire item (or the path for file items).

jason0x43 commented 3 weeks ago

A way to specify a custom prefix in the item would also work, assuming the icon would be added onto that. Maybe. Something like

{
  text = "path/to/file.js",
  prefix = "H",
  path = "path/to/file.js"
}
echasnovski commented 3 weeks ago

Thanks for the suggestion!

This looks like a reasonable use case. There is some work planned regarding icons in 'mini.nvim', so I think I'll revisit this feature during it.