Directory Node Expanded State #3090
-
Hey, I am trying to figure out if a directory node is open, is there a simple way to find this out. This is what I have so far, I want to only trigger the edit if the node is expanded. function nvimtree.collapse_dir()
local node = api.tree.get_node_under_cursor()
local is_folder = node.fs_stat and node.fs_stat.type == "directory" or false
if is_folder == false then
return
end
api.node.open.edit()
end |
Beta Was this translation helpful? Give feedback.
Answered by
alex-courtis
Mar 27, 2025
Replies: 1 comment 2 replies
-
Take a look at the node classes: https://github.com/nvim-tree/nvim-tree.lua/blob/master/lua/nvim-tree/_meta/api.lua I think directory open should cover you.
|
Beta Was this translation helpful? Give feedback.
2 replies
Answer selected by
jacob7395
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Take a look at the node classes: https://github.com/nvim-tree/nvim-tree.lua/blob/master/lua/nvim-tree/_meta/api.lua
I think directory open should cover you.
node:is(DirectoryNode)
might be useful as well.