nvim-tree.lua icon indicating copy to clipboard operation
nvim-tree.lua copied to clipboard

[Feature request] Possibility to set up padding for icons

Open msva opened this issue 4 years ago • 7 comments

Hi there! I've found that some icons that I set have double-width (and it is recognized by terminal, and some - does not). It leads to the different visual padding between icons and filenames. As workaround, I can set another "custom" icons in nvim-tree (like "default-file", or "empty-folder") to "<icon_character>", but this is not applicable for the icons that nvim-tree takes from devicons.nvim (they always have padding of one space between icon and filename. And the only way I see to handle that - is to manually redefine each icon as "", which I'd like to avoid...

msva avatar Nov 07 '21 13:11 msva

i'm currently rewriting the renderer, i think this might be feasible, but not per icon, globally only.

kyazdani42 avatar Nov 27 '21 12:11 kyazdani42

but not per icon, globally only. Well, "global only" is useful too, but not having possibility to set per-icon padding will not solve the situation in first post: some icons (say, the ones I set for folders) have double width, and some - single-char width. So, they got different padding:

image

msva avatar Nov 29 '21 14:11 msva

here,

  • blue folder icons have long padding by themselves because this icon taken from the font with coloured glyphs (not sure what font exactly, tho), and this icon is double-width there.
  • "green" folder icons are set as "<icon><space>" to get proper indentation with "blue" glyphs (otherwise they have same 1-space padding as files).
  • file icons are not redefined, so they got 1-space padding

msva avatar Nov 29 '21 14:11 msva

by the way, I thought I already posted that in some another issue, but can find it. So, I'll try to repeat here: Since some time (currently I have no way to bisect) NvimTreeFolderIcon highlight group stopped to work. I mean, I can set colors (and other effects) using NvimTree*Name hl-groups, but anything I set for NvimTreeFolderIcon group doesn't apply at all:

image

(as you can see, neither of icons are colorized as per hl-group)

msva avatar Nov 29 '21 15:11 msva

Maybe a better way would be to detect if the icon is going to be rendered as double-width ? I'm not sure if this is feasible because it might depend on the terminal.

kyazdani42 avatar Feb 05 '22 13:02 kyazdani42

Yeah, I'm also not sure if it is possible to know whether icon will be rendered as double-width, or not.

Although...

image

But anyway, I personally see the following idea as easier way to deal with the issue (although a bit kludgy, but should work, IMO):

  1. add option like g.nvim_tree_icons.padding = (number) where user can specify a count of spaces as padding between icons and text.
  2. only apply it to icons that weren't redefined with g.nvim_tree_icons.<type>. So, if users redefine the icon, they can add as much spaces as needed to equalize padding with others.

msva avatar Feb 15 '22 06:02 msva

I really think this could be done manually by the user by overriding the default icon in this case. Or nvim-web-devicon's icons. Otherwise i'll provide a global padding option for icons for sure, when i have some time.

kyazdani42 avatar Feb 15 '22 07:02 kyazdani42

Implemented via #1505

alex-courtis avatar Oct 15 '22 04:10 alex-courtis