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

Unwanted space around trailing slash (custom renderers)

Open wookayin opened this issue 3 years ago • 1 comments

Following the suggestion from #112, I was using a custom trailing_slash renderer component to make it highlighted with a different color:

-- Append trailing slashes on directories (#112)
components = {
  trailing_slash = function ()
    return {
      text = "/",
      highlight = "NeoTreeDirectoryIcon",
    }
  end,
},
renderers = {
  directory = {
    {"icon"},
    {"name", use_git_status_colors = false, trailing_slash = true},
    {"trailing_slash"},
    {"diagnostics"},
    {"git_status"},
  }
},

Since some version (I haven't bisected yet), a space between name and trailing_slash components have appeared:

image

It was working fine without the unwanted space around when we are at #112. Is this an artifact/side effect of some change? I think there should be no space appearing.

wookayin avatar Aug 14 '22 00:08 wookayin

Sorry about that. I had to switch the padding from the left of the symbols that come after names to the right hand side of the name component to simplify some other layout issues I had. https://github.com/nvim-neo-tree/neo-tree.nvim/commit/365df55373f07cd293752776e430dfacec947c98

I just added in a new option that will fix this for you in main. You'll need to set right_padding = 0 on the name component and add the trailing space onto your custom trailing_slash component:

          components = {
            trailing_slash = function ()
              return {
                text = "/ ",
                highlight = "NeoTreeDirectoryIcon",
              }
            end,
          },
          renderers = {
            directory = {
              {"icon"},
              {"name", use_git_status_colors = false, trailing_slash = false, right_padding = 0},
              {"trailing_slash"},
              {"diagnostics"},
              {"git_status"},
            }
          },

cseickel avatar Aug 14 '22 01:08 cseickel

Thanks for adding the option, works as expected!

wookayin avatar Aug 18 '22 04:08 wookayin

@cseickel But the git_status icon (?) should be placed in the rightmost (see the screenshot). Please let me know if I should open a new issue for this.

wookayin avatar Aug 18 '22 23:08 wookayin

I'm not sure what you mean. The screenshot seems to match the renderers you have defined, except for the space after the name being in the wrong place.

If you want to have right aligned symbols like the current default, you should copy the renderers deifned in the defaults.lua file and insert your custom trailing slash component:

https://github.com/nvim-neo-tree/neo-tree.nvim/blob/684894e7e6038c2e8d8595139ac24d14b267c75d/lua/neo-tree/defaults.lua#L216-L257

cseickel avatar Aug 18 '22 23:08 cseickel