mini.nvim icon indicating copy to clipboard operation
mini.nvim copied to clipboard

support mini.icons in mini.starter

Open echaya opened this issue 1 year ago • 8 comments

Contributing guidelines

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.

echaya avatar Dec 16 '24 01:12 echaya

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 from config.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 (if show_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.

echasnovski avatar Dec 16 '24 09:12 echasnovski

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.

echasnovski avatar Dec 16 '24 10:12 echasnovski

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

echaya avatar Dec 16 '24 10:12 echaya

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

Neovim has vim.split() for that, but unfortunately that won't work because file name can contain spaces.

echasnovski avatar Dec 16 '24 10:12 echasnovski

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

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

echaya avatar Dec 16 '24 10:12 echaya

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.

echasnovski avatar Dec 16 '24 11:12 echasnovski

Any updates on this? I noticed the issue has been open since 2024. It would be great to have the icons.

krovuxdev avatar Apr 09 '25 17:04 krovuxdev

Any updates on this?

It will probably be implemented someday. Probably, not in 0.16.0 (i.e. next) release.

I noticed the issue has been open since 2024.

"Dec 16, 2024" 👀 There are older feature requests that get implemented, it is not that old yet.

echasnovski avatar Apr 09 '25 18:04 echasnovski