NvChad / menu

Menu plugin for neovim ( supports nested menus ) made using volt
GNU General Public License v3.0
335 stars 5 forks source link

Feature request: some APIs #6

Closed epheien closed 6 days ago

epheien commented 1 week ago
  1. check menu is open
  2. close menu
siduck commented 1 week ago

you're supposed to press enter or press q/esc to close the window.

As for mouse=true, you can just click outside the menu and it'll close

epheien commented 1 week ago

you're supposed to press enter or press q/esc to close the window.

As for mouse=true, you can just click outside the menu and it'll close

The problem is that if I press the mouse twice, the menu will pop up twice.

      local callback = function(mouse)
        return function()
          local options = vim.bo.ft == "NvimTree" and "nvimtree" or "mydef"
          require("menu").open(options, { mouse = mouse, border = false })
        end
      end
      vim.keymap.set("n", "<RightRelease>", callback(true), {})
      vim.keymap.set("n", "Z", callback(false), { nowait = true })
Xnip2024-10-09_12-00-14
siduck commented 1 week ago

right click twice you mean?

epheien commented 1 week ago

right click twice you mean?

Yes. The expectation is to close the menu and then reopen it.

So I need to know if menu is open then close it, finally open it.

siduck commented 1 week ago
local menu_opened =  #require("menu.state").bufids > 0
epheien commented 1 week ago
local menu_opened =  #require("menu.state").bufids > 0

It works.

And is there still an interface to manualy close the menu?

siduck commented 1 week ago

you need to focus on the menu and press q

to do this programmatically, use nvim_buf_call and get any bufid from the bufids and callback should be this : vim.api.nvim_feedkeys("q", "x", false)

siduck commented 6 days ago

@epheien the issue should be fixed now, it wont allow more than 1 menu instance