Skip to content

Request for API to get the collapsed or opened status of a directory node. #3014

@Kaiser-Yang

Description

@Kaiser-Yang

Why this feature request?

I've used vscode's vim extension for a while. When I used explorer in vscode, I found a nice functionality, I can use h to collapse a folder if opened or go to the parent node if collapsed. So I try to implement this in my nvim like this:

        local node = api.tree.get_node_under_cursor()
        if node == nil then
            return
        end
        if vim.fn.isdirectory(node.absolute_path) == 1 then
            -- there should be an API to get the status of the directory node
            if node is not opened then
                api.node.navigate.parent(node)
            else
                api.node.open.edit(node)
            end
        end

I've checked the exposed APIs and not found any related APIs.

Solution

I've checked the source code directory.lua, may expose a new API returning the value of self:last_group_node().open in the file.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions