nvim-tree / nvim-tree/nvim-tree.lua
`group_empty` with line wrapping
Nobody has claimed this yet.
- Dominant language
- Lua
- Stars
- 8.6k
- Forks
- 639
- Avg merge
- 1d 14h
- Merged PRs (30d)
- 2
Description
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:
- They are the first in the current "chain" OR
- 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_emptydepth (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!
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
No file or test is named in the issue. Start by locating the existing group_empty option, its renaming logic, and the tree display width handling; then trace how grouped folders are rendered. Done means grouped empty folders wrap without exceeding the configured width while preserving the requested display names.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- lua
- Domain
- cli
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100