Skip to content

feat: Option for grouping empty directories #247

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

Merged
merged 4 commits into from
Mar 26, 2021

Conversation

sindrets
Copy link
Contributor

@sindrets sindrets commented Mar 25, 2021

Fixes #191.
This adds an option g:nvim_tree_group_empty (disabled by default) that compacts dirs that only contain 1 dir / symlink dir, into one node in the file tree.

2021-03-25-012655_maim

@kyazdani42
Copy link
Member

thanks a lot ! The overall algorithm is perfect and the feature works perfectly.
I must note that toggling this behavior would be useful if you want to add files in between grouped folders :)
Merging this anyway :)

@kyazdani42 kyazdani42 merged commit 709d6b9 into nvim-tree:master Mar 26, 2021
@gegoune
Copy link
Collaborator

gegoune commented Mar 26, 2021

Using lua to configure this, is setting this option to true suppose to work?

vim.g.nvim_tree_group_empty = true

does not work, while

vim.g.nvim_tree_group_empty = 1

does.

Some other options I have set to true do work as expected.

@kyazdani42
Copy link
Member

that's strange, if you find issues refering to the documentation please leave an issue.
I also have to work on that setup flow, but i'd like to finish the buffer thing first. It will make the plugin configuration more lua like.

@Lux3mb0urg
Copy link

Is there a callback function to toggle this feature?
Changing value of vim.g.nvim_tree_group_empty does not work.

@kyazdani42
Copy link
Member

it does work for me though, just assign it to 1 (vim.g.nvim_tree_group_empty must be set in lua not in vimscript)

@sindrets
Copy link
Contributor Author

@cloggier I implemented the option the same way all the other boolean options are currently implemented. The reason why only some options work when you set them to the lua value true is that comparing vim booleans and lua booleans is strange.

1 == true is a false lua statement. However, if 1 then ... end is a true lua statement. Which is why it will work sometimes to set vim variables to the lua value true. And to make things even more confusing true == vim.v["true"] is a true lua statement.

But when using vim variables in lua, you should treat them like vim variables. That means you should use 1 for true and 0 for false until proper lua configuration is implemented.

@Lux3mb0urg no, I did not implement a toggle function.

@gegoune
Copy link
Collaborator

gegoune commented Mar 27, 2021

@sindrets tusen takk for detailed response and amazing PR!

@kyazdani42
Copy link
Member

indeed until i don't make the setup refactoring, this option thing will keep being clunky.

@chardskarth

This comment has been minimized.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Group empty folders
5 participants