SmiteshP / nvim-navbuddy

A simple popup display that provides breadcrumbs feature using LSP server
Apache License 2.0
770 stars 30 forks source link

Prevent opening when pressing `l` on element #16

Closed LittleTealeaf closed 1 year ago

LittleTealeaf commented 1 year ago

Through my use so far, I've often accidentally opened an element by pressing l on it (that is, if it doesn't have any children elements), example as: image pressing l would close the pane and navigate to that element. A lot of times, I'm pressing keys fast enough that sometimes I do this by mistake.

Would it be possible to either add an option to prevent this ability, or maybe separate into two actions "select child / open" and just "select child"?

SmiteshP commented 1 year ago

You can define a custom action function and use that in the config.

local function children(display)
    if display.focus_node.children == nil then
        -- actions.select(display)
        return
    end

    local child_node
    if display.focus_node.memory then
        child_node = display.focus_node.children[display.focus_node.memory]
    else
        child_node = display.focus_node.children[1]
    end
    display.focus_node = child_node

    display:redraw()
end
LittleTealeaf commented 1 year ago

That works perfectly, thanks!