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

Icon Placement Right

Open alex-courtis opened this issue 1 year ago • 13 comments

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

alex-courtis avatar Aug 01 '23 01:08 alex-courtis

Requires #1510

alex-courtis avatar Aug 01 '23 01:08 alex-courtis

Possible values: "right" "end" "rightest"

Silently move placement from renderer.icons to git modified `diagnostics.

alex-courtis avatar Aug 01 '23 01:08 alex-courtis

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?

vollowx avatar Oct 02 '23 11:10 vollowx

This issue is open and is a candidate for implementation, however will likely only be implemented when a kind contributor builds it.

alex-courtis avatar Oct 07 '23 03:10 alex-courtis

@alex-courtis If you still have not picked that up, I think I can work on it.

mr2rm avatar Apr 21 '24 18:04 mr2rm

That would be fantastic @mr2rm !

I have been wanting this one for a while.

alex-courtis avatar Apr 21 '24 23:04 alex-courtis

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?

mr2rm avatar Apr 25 '24 20:04 mr2rm

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?

mr2rm avatar Apr 27 '24 10:04 mr2rm

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.

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.

alex-courtis avatar Apr 28 '24 04:04 alex-courtis

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_

alex-courtis avatar Apr 28 '24 04:04 alex-courtis

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.

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.

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?

mr2rm avatar Apr 28 '24 13:04 mr2rm

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.

mr2rm avatar Apr 28 '24 14:04 mr2rm

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!

alex-courtis avatar Apr 29 '24 00:04 alex-courtis

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.

evertonse avatar Jul 14 '24 20:07 evertonse