support mini.icons in mini.starter
Opened this issue · 6 comments
Contributing guidelines
- I have read CONTRIBUTING.md
- I have read CODE_OF_CONDUCT.md
Module(s)
mini.starter
Description
Hey, I have been integrating more mini.nvim lately. mini.deps
, mini.sessions
and mini.starter
been the latest.
While (as always) liking the minimal implementation of each plugin, I'm wondering if we could have mini.icons natively support mini.starters for various items:
- filetype: which faciliate eye-balling the files
- action items: less critical but good to have (we can otherwise specify manually)
Thanks for your consideration.
Thanks for the suggestion!
Unfortunately, it is not as easy as it might seem at first glance.
The main obstacle is that 'mini.starter' shows unique prefix for each item to highlight it with different highlight group. That unique prefix is (intentionally) computed from item's name. Both of these facts make adding icons more complicated as it should be:
- Adding icons as part of item's name from
recent_files
section is the easiest and most straightforward way to do it. But it will mess up with prefix computation, as icon will be considered as part of the prefix. The solution here might be to modify prefix computation to start from first character fromconfig.query_updaters
and contain the widest contiguous range of them. This is doable, but requires some refactor (which might be a good thing in on itself) and will lead to not highlighted icons (which might also be a good thing, as some of icons UI are also monotone). - Adding new
gen_hook.adding_icon()
which will add highlighted icon to the left of item with "Recent files" section name. Also doable, but item name can contain full path (ifshow_path
is enabled) which will lead to not correct icon. The solution here might be to store full file path as private item to later use by new hook.
The relatively easy approach to implement this right now is to add icons to the right of the file name, but I think it doesn't look good and doesn't really help improve usability.
I'll think if there is another approach or if any of mentioned above are reasonable.
I've just tried the gen_hook.adding_icon()
approach. Although it is relatively ok, my first reaction is that I don't really like misalignment that adding icons introduces. Plus highlighted icons don't dim with MiniStarterInactive
when item is inactive (as it should because it is not part of an item), which is confusing.
So I think the first approach with modifying how prefix is computed and highlighted might be the best approach here.
I'm learning lua
myself in my spare time but split the icon with the file_name should be straighforward(-ish) (hopefully). Then I did a quick stackoverflow search, the most upvoted answer from this link should do the trick
function mysplit(inputstr, sep)
if sep == nil then
sep = "%s"
end
local t = {}
for str in string.gmatch(inputstr, "([^"..sep.."]+)") do
table.insert(t, str)
end
return t
end
I'm learning
lua
myself in my spare time but split the icon with the file_name should be straighforward(-ish) (hopefully). Then I did a quick stackoverflow search, the most upvoted answer from this link should do the trickfunction mysplit(inputstr, sep) if sep == nil then sep = "%s" end local t = {} for str in string.gmatch(inputstr, "([^"..sep.."]+)") do table.insert(t, str) end return t end
Neovim has vim.split()
for that, but unfortunately that won't work because file name can contain spaces.
I'm learning
lua
myself in my spare time but split the icon with the file_name should be straighforward(-ish) (hopefully). Then I did a quick stackoverflow search, the most upvoted answer from this link should do the trickfunction mysplit(inputstr, sep) if sep == nil then sep = "%s" end local t = {} for str in string.gmatch(inputstr, "([^"..sep.."]+)") do table.insert(t, str) end return t endNeovim has
vim.split()
for that, but unfortunately that won't work because file name can contain spaces.
When icon is enabled, don't we just need to remove anything in front of the first space before calculating prefix?
When icon is enabled, don't we just need to remove anything in front of the first space before calculating prefix?
This might work, but would require some hack-ish way to manipulate data structures. I think computing prefix only from registered query updaters is a good approach in on itself which just happens to unlock adding icons this way.