nvim-tree.lua
nvim-tree.lua copied to clipboard
Icon Placement Right
Can this functionality be implemented utilising API? No, it's internal behaviour.
Describe the solution you'd like Show icons: git, diagnostic, modified at the far right side of the tree.
Describe alternatives you've considered Right sign column, not possible.
Additional context #2348
Requires #1510
Possible values: "right"
"end"
"rightest"
Silently move placement from renderer.icons
to git
modified
`diagnostics.
I currently know nothing about how this plugin renders nor writing complex lua plugin, so I'm sorry but still not able to make a PR to implement this feature. The only thing I know is that this may be implemented by vim.api.nvim_buf_set_extmark
. If nobody makes PR, will you or when will you implement it by yourself?
This issue is open and is a candidate for implementation, however will likely only be implemented when a kind contributor builds it.
@alex-courtis If you still have not picked that up, I think I can work on it.
That would be fantastic @mr2rm !
I have been wanting this one for a while.
I've just started working on this issue. I came up with the idea to add a new option to renderer.icons
which only applies to all the placements with an after
value. If implemented like this, we would have more flexibility to place some of the icons in the before position or on the sign column. I would suggest renderer.icons.after_alignment
with values left
and right
.
@alex-courtis What do you think about this idea? Does it work for you?
Also, we should decide when there is not enough room for the icons on the right. First, should we place icons on the right relative to the current window width or the max width? In both cases, what should be the behavior when there is no space to show all the icons on the right?
I came up with the idea to add a new option to
renderer.icons
which only applies to all the placements with anafter
value. If implemented like this, we would have more flexibility to place some of the icons in the before position or on the sign column. I would suggestrenderer.icons.after_alignment
with valuesleft
andright
.
That might not be enough; renderer.icons doesn't have visibility or control over placement.
We'd need to create a new value for the ICON_PLACEMENT
enum, say, right
. We'd add that to Decorator
and Builder:format_line
could use it.
First, should we place icons on the right relative to the current window width or the max width?
Current width might be best - some users like various types of dynamic widths and they wouldn't see the icons most of the time.
In both cases, what should be the behavior when there is no space to show all the icons on the right?
Interesting. We could follow the before behaviour and use renderer.icons.padding
. Maybe we could try a single far right pad as well, something like:
filename____Y_X_
I came up with the idea to add a new option to
renderer.icons
which only applies to all the placements with anafter
value. If implemented like this, we would have more flexibility to place some of the icons in the before position or on the sign column. I would suggestrenderer.icons.after_alignment
with valuesleft
andright
.That might not be enough; renderer.icons doesn't have visibility or control over placement.
We'd need to create a new value for the
ICON_PLACEMENT
enum, say,right
. We'd add that toDecorator
andBuilder:format_line
could use it.
Yeah, I've checked the code and of course, we'd need those changes as well. But what do you think about having a setting only for after
placements like the one I suggested?
First, should we place icons on the right relative to the current window width or the max width?
Current width might be best - some users like various types of dynamic widths and they wouldn't see the icons most of the time.
We've already had the issue of displaying the filename and after icons in the right way. If the window/pane is narrow, icons and some parts of the filenames might be hidden.
In both cases, what should be the behavior when there is no space to show all the icons on the right?
Interesting. We could follow the before behaviour and use
renderer.icons.padding
. Maybe we could try a single far right pad as well, something like:filename____Y_X_
But if we follow this way, far-right icons might not be aligned correctly.
Yeah, I've checked the code and of course, we'd need those changes as well. But what do you think about having a setting only for after placements like the one I suggested?
I see, I misread. Yes, that may be needed for extra treatment that right will need.
First, should we place icons on the right relative to the current window width or the max width?
Current width might be best - some users like various types of dynamic widths and they wouldn't see the icons most of the time.
We've already had the issue of displaying the filename and after icons in the right way. If the window/pane is narrow, icons and some parts of the filenames might be hidden.
In both cases, what should be the behavior when there is no space to show all the icons on the right?
Interesting. We could follow the before behaviour and use
renderer.icons.padding
. Maybe we could try a single far right pad as well, something like:filename____Y_X_
But if we follow this way, far-right icons might not be aligned correctly.
That's fair enough. Let's just build it and see how it looks!
I currently know nothing about how this plugin renders nor writing complex lua plugin, so I'm sorry but still not able to make a PR to implement this feature. The only thing I know is that this may be implemented by
vim.api.nvim_buf_set_extmark
. If nobody makes PR, will you or when will you implement it by yourself?
I've implemented this using this extmark
strategy and made a PR https://github.com/nvim-tree/nvim-tree.lua/pull/2839.
I've tested a bunch and the rendering holds up just fine as far as I can tell.