API: how to query node whether it's a directory (in a consistent way)? #2443
Answered
by
Akmadan23
przepompownia
asked this question in
Q&A
-
vim/vim#12087 (comment) is still not fixed so I need to use some custom replacement for Currently in vim.keymap.set(
'n',
'<CR>',
injectNode(function(node)
if node.name == '..' or node.type == 'directory' then
treeapi.node.open.edit()
return
end
treeapi.tree.close()
base.tab_drop_path(node.absolute_path)
end),
{buffer = bufnr, noremap = true}
) It would be good to have |
Beta Was this translation helpful? Give feedback.
Answered by
Akmadan23
Oct 4, 2023
Replies: 1 comment 2 replies
-
I'm not sure what you're looking for, nodes are just tables, so to check whether a node is a directory you have two options:
Then there is the root node, which actually is not a node, since it's a table with only the |
Beta Was this translation helpful? Give feedback.
2 replies
Answer selected by
Akmadan23
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I'm not sure what you're looking for, nodes are just tables, so to check whether a node is a directory you have two options:
node.type
is'directory'
(like you did)node.nodes
is a tableThen there is the root node, which actually is not a node, since it's a table with only the
name
field.