tree-view... Ignore folders
I couldn't find an option to ignore folders such as .git & node_modules when using the :tree!
I can use za to hide dotfiles but the node_modules folder is not one, but I also don't want to hide it, (If I can hide node_modules would be another option tho)
So I would like to use :tree and keep the node_modules and .git folders folded... instead of using zx to toggle them. Thanks, I really like vifm, and I really appreciate all the effort put into it
Which files/directories to ignore can be set via :filter command, but it's not specific to tree-view.
You're speaking of ignoring them but then of having some directories folded by default, so which is it?
Using :tree - Would be great to keep certain files folded... So if the dir has node_modules and .git folders is gonna show them folded. This is what I would like to get, if not possible then:
Using :filter + :tree - This is a workaround that I think we can get?... Using something like this:
command! FilterTree :execute 'filter /^node_modules\/$|^\.git\/$/' | tree
nnoremap t :FilterTree<cr>
But now I need to find a way to toggle it, so it sends :filter after the first one... That's pretty much what I'm looking for
Using
:tree- Would be great to keep certain files folded... So if the dir has node_modules and .git folders is gonna show them folded. This is what I would like to get, if not possible then:
Not possible at the moment.
But now I need to find a way to toggle it
The filter can be toggled with :filter!, but then tree-view and filtering might get out of sync. It might be better to have a second key to exit tree and reset filter with :filter (no parameters).
\| let $toggle = 0
command! FilterTree :
\| if $toggle != 1
\| execute 'filter /^node_modules\/$|^\.git\/$/' | tree
\| let $toggle = 1
\| elseif $toggle == 1
\| execute 'filter' | tree!
\| let $toggle = 0
\| endif
\| let $toggle2 = 0
command! FilterTreeTwo :
\| if $toggle2 != 1
\| execute 'filter /^node_modules\/$|^\.git\/$/' | tree depth=2
\| let $toggle2 = 1
\| elseif $toggle2 == 1
\| execute 'tree'
\| let $toggle2 = 0
\| endif
nnoremap tt :FilterTree<cr>
nnoremap tT :FilterTreeTwo<cr>
Both seems to work, I did it this way since I got a few cmds for fzf with this logic... I haven't noticed any issues, what do u think?
PREVIEW: https://github.com/user-attachments/assets/346dfe8b-05d9-4566-96f2-b2f5abd2d942
execute 'filter /^node_modules\/$|^\.git\/$/' | tree
can be simplified:
filter {node_modules/,.git/} | tree
execute 'tree' can also be replaced with tree.
elseif $toggle2 == 1 (same for $toggle) can be replaced with else.
2 :let commands can be replaced with let $toggle2 = !$toggle2.
:if check can be simplified.
Else-branch of FilterTreeTwo differs from FilterTree, but maybe that's intentional.
So, something like this:
let $toggle = 0
command! FilterTree :
\| if $toggle
\| filter {node_modules/,.git/} | tree
\| else
\| filter | tree!
\| endif
\| let $toggle = !$toggle
let $toggle2 = 0
command! FilterTreeTwo :
\| if $toggle2
\| filter {node_modules/,.git/} | tree depth=2
\| else
\| tree
\| end
\| let $toggle2 = !$toggle2
Thank you so much... Now, looks way better:
Just 1 thing, was needed to add the != 1, it doesn't toggle without it. The rest is perfect!
\| let $toggle = 0
command! FilterTree :
\| if $toggle != 1
\| filter {node_modules/,.git/} | tree
\| else
\| execute 'filter' | tree!
\| endif
\| let $toggle = !$toggle
\| let $toggle2 = 0
command! FilterTreeTwo :
\| if $toggle2 != 1
\| filter {node_modules/,.git/} | tree depth=2
\| else
\| filter {node_modules/,.git/} | tree
\| endif
\| let $toggle2 = !$toggle2
filter {node_modules/,.git/} | tree
With this we avoid getting a tree view without the filter... regardless of the times u press it, just toggle it.
Else-branch of FilterTreeTwo differs from FilterTree, but maybe that's intentional.
Yes, it is. Once I have the tree view open, I just want to toggle it. And also get an option to get depth 2 directly, and toggle it once in it.
Just 1 thing, was needed to add the
!= 1, it doesn't toggle without it.
Right, it should have been if !$toggle and if !$toggle2.