Replies: 3 comments 4 replies
-
I like the first idea, also I suggest something like {
"indent",
zindex = 10,
indent_size = 2,
padding = 1, -- extra padding on left hand side,
extensions = {
{ "indent_guide", enabled = true, zindex = 10, align = "right", ... }, -- `...` = the config itself
{ "collapser_icon", enabled = true, zindex = 20, align = "right", ... }, -- `...` = the config itself
},
},
{
"name",
trailing_slash = false,
extensions = {
{ "git_status", enabled = true, zindex = 10, align = "right", use_colors, symbols = { ... } },
},
}, |
Beta Was this translation helpful? Give feedback.
-
After looking through the options, I feel like having an explicit "container" component is the most obvious way of configuring this functionality. Here's what I'm thinking: local config = {
renderers = {
{
"container",
width = "fit_content", --<-- default value for width
content = {
{
"indent",
zindex = 10,
indent_size = 2,
padding = 1, -- extra padding on left hand side,
},
{ "indent_guide", enabled = true, zindex = 10, align = "right", ... }, -- `...` = the config itself
{ "collapser_icon", enabled = true, zindex = 20, align = "right", ... }, -- `...` = the config itself
}
}
},
{
"container",
width = 2,
content = {
{ "icon", zindex = 10 },
{ "diagnostics", zindex = 20, show_errors_only = true },
}
},
{
"container",
width = "100%", -- <-- means 100% of what's left from the current column to the window width
content = {
{ "name", trailing_slash = false, zindex = 5 },
{ "git_status", enabled = true, zindex = 10, align = "right", symbols = { ... } },
}
}
} Of course, at this point this is a bigger issue than can be handled within the file nesting PR and shouldn't hold that up or even be done there. I was originally hoping that the design of this could somehow fit into that but that was a bad idea... |
Beta Was this translation helpful? Give feedback.
-
can we get some config to show nested files even if they're hidden and hidden files aren't shown? e.g. yes hide |
Beta Was this translation helpful? Give feedback.
-
Background
So @lopi-py is adding the file nesting feature and that lead to a discussion on how to add a new component that needs to overlap with the indent component to look correct, especially with the indent guides turned on. (Issue: #118 PR: #164)
Here's an example:
![image](https://user-images.githubusercontent.com/5160605/159479255-52b99b61-8df6-485f-a9a0-a9476d10cbcd.png)
In the screenshot above, the arrow/triangle icon to the left of the folders is replacing indent guides that would normally be there, instead of just pushing them to the left. The actually nesting part is at the bottom with the "test" files.
That got us thinking about finding a clean way to do this that does not involve just making the indent component responsible for this. The reasons against it is that it's obviously more correct to have each component do only one thing, and it doesn't seem intuitive to go to the indent component to configure the expanders used for the file nesting feature.
Solution
My solution to this problem is to create system where you can define overlapping components, where each subsequent component will just overwrite the one below it. This can be used in other situations as well, but for the indent/expander example, if we say that an array of components are overlapping components:
When rendered, that first array of components will produce this for something three levels deep:
The same strategy could be used to have multiple components for an icon where it can be overwritten in special situations.
Maybe some people want to replace a file icon with a diagnostic icon if there is an error.
It can also be used to right align something to the right edge of the window if we add a component that is a "flex" component that just fills with spaces up until the width of the window. That way we can take any component and put it in the right hand column, such as the git status like vs code does. We can also include the name component itself in an overlapping component, so that the git status and/or diagnostic signs are guaranteed to be shown on the right hand side even if a file name is too long to fit.
The technical solution on how to apply overlapping components is not too hard. The really hard part is how to present it in a way that it is intuitive for everyone to work with in a config table. The two obvious ideas to me are to either:
width = 4
width = "100%"
width = "size_to_content"
width = function(node) return node.indent * 2 end
.Beta Was this translation helpful? Give feedback.
All reactions