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

`group_empty` with line wrapping

Open elliotcubit opened this issue 2 years ago • 1 comments

Is your feature request related to a problem? Please describe.

https://github.com/nvim-tree/nvim-tree.lua/issues/2515 asked for custom labels for folders grouped by group_empty, which was implemented in https://github.com/nvim-tree/nvim-tree.lua/pull/2521. It would be nice if it were possible to enable line-wrapping of grouped empty folders so that they can retain legibility.

I squished these tree display examples into <details> blocks, because they're moderately tall.

Right now, this tree
my-project/
  src/
    main/
      scala/
        io/
	  mycoolcompany/
	    myintermediatepackage/
	      mypackage/
	        Package.scala
In this window, is clipped
nvim-tree max width | a main buffer the full editor width
my-project/         |
  src/main/scala/io/|
    Package.scala   |
We can make it a little better, with the new `group_empty` option,
nvim-tree max width | a main buffer the full editor width
my-project/         |
  s/m/s/i/m/m/mypack|
    Package.scala   |

But this doesn't seem ideal to me. It isn't legible, and you can't see the final folder name.

I'd like to be able to get something similar to this
nvim-tree max width | a main buffer the full editor width
my-project/         |
 src/main/scala/io/ |
   mycoolcompany/   |
     myintermedia/  |
       mypackage/   |
         Package.sc |

Describe the solution you'd like

I think that this would be well-solved by a new option called something like group_empty_line_wrap.

When specified, empty folders would only be grouped if:

  1. They are the first in the current "chain" OR
  2. Adding them to the current chain would not cause the folder name to clip past width.max.

(1) guarantees that very long folder display names will always be displayed on their own line - if it clips, it clips.

(2) causes the line wrapping behavior. Note that the check would be performed after the group_empty renaming function is applied, so that it would still be possible to rename folders for display.

Describe alternatives you've considered

These are some other options, which occured to me but weren't thought out in-depth:

  • Add a hard integer config limit to group_empty depth (i.e. group at most 3 things)

    • This seems unideal, since it just makes the problem more rare
  • Add a config function which determines when to "split" grouped folders

    • This seems difficult to implement and also to use
  • Group empty folders except the last child

    • This helps with deeply-nested folders, but makes shallow-nesting more annoying.

Additional context

Nothing :) thank you for building a wonderful project!

elliotcubit avatar Nov 21 '23 16:11 elliotcubit

At risk of sounding trite, could you simply set :set wrap ?

This sort of functionality would be great, however it will be quite difficult, mostly from a UX perspective. It will also be challenging to build as there is an assumption of one node per line.

alex-courtis avatar Nov 25 '23 02:11 alex-courtis