Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Option to not display root folder in filesystem #404

Closed
SergioBenitez opened this issue Jul 4, 2022 · 7 comments
Closed

Option to not display root folder in filesystem #404

SergioBenitez opened this issue Jul 4, 2022 · 7 comments
Labels
enhancement New feature or request

Comments

@SergioBenitez
Copy link

Hi there!

I'm rendering the root of the file system tree outside of neo-tree. I'd like to not display the root twice, but I've been unable to find a way to tell neo-tree not to render the root without modifying neo-tree itself. Unfortunately the docs don't elucidate anything here, at least not after a few readings. It also doesn't seem that custom renderers are able to skip rendering a node entirely. Is there something I'm missing?

Thanks!

@Shougo
Copy link

Shougo commented Jul 4, 2022

I think the root node is needed.
Because the directory is empty, the buffer become empty.

@SergioBenitez
Copy link
Author

Ah, apologies, allow me to clarify.

neo-tree currently renders the tree as:

ROOT
├── dir
├── dir
│   ├── dir
│   │   ├── file.lua
│   │   └── file.lua
│   └── dir
└── dir

I'm adding my own rendering of ROOT (on the bufferline), which makes my tree look like:

ROOT
ROOT
├── dir
├── dir
│   ├── dir
│   │   ├── file.lua
│   │   └── file.lua
│   └── dir
└── dir

To avoid the duplication, I'd need neo-tree to not render the root node, like this:

├── dir
├── dir
│   ├── dir
│   │   ├── file.lua
│   │   └── file.lua
│   └── dir
└── dir

@cseickel
Copy link
Contributor

cseickel commented Jul 5, 2022

There is no way to configure this yet, but it won't be that hard to add. I almost wanted the same thing when I added winbar, but I ended up going for a blank winbar instead which I think looks better.

I'll add the option.

@cseickel cseickel added the enhancement New feature or request label Jul 5, 2022
@cseickel
Copy link
Contributor

cseickel commented Jul 7, 2022

This has been added in the main branch. Can you try it out and let me know if it works as expected?

You just need to add this option:

    require("neo-tree").setup({
        hide_root_node = true
    })

BTW - It's kind of funny that this issue ended up being number 404, isn't it? 😄

@SergioBenitez
Copy link
Author

@cseickel Thank you for the incredibly quick turn around! While the option certainly works, I was hoping that nodes would continue to render as if they were at their original level.

In other words, with the option enabled, the tree now renders like:

- dir
- dir
- ├── dir
- │   ├── file.lua
- │   └── file.lua
- └── dir
- dir

whereas I expected the tree to continue to render as before, just without the root node:

+ ├── dir
+ ├── dir
+ │   ├── dir
+ │   │   ├── file.lua
+ │   │   └── file.lua
+ │   └── dir
+ └── dir

@cseickel
Copy link
Contributor

cseickel commented Jul 7, 2022

Well, you can get to the desired indent by playing with the padding of the indent component:

    require("neo-tree").setup({
      hide_root_node = true,
      default_component_configs = {
        indent = {
          indent_size = 2,
          padding = 3,
        }
      }
    })

Adding the phantom indent guides is not going to happen though.

@cseickel
Copy link
Contributor

cseickel commented Jul 7, 2022

As an alternative, you could also just render the statusline space above Neo-tree as blank space. That's what I do and here is how it looks with the standard tree setup:

image

Technically I hide the tabline completely and use winbar, but the effect would be similar.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants