[Question] Is there any API for navigating layouts? #289
Replies: 3 comments 6 replies
-
local Layout = require("nui.layout")
local Popup = require("nui.popup")
local popup = {
a = Popup({ border = "single" }),
b = Popup({ border = "single" }),
c = Popup({ border = "single" }),
}
local layout = Layout(
{
relative = "editor",
position = "50%",
size = { height = 10, width = 60 },
},
Layout.Box({
Layout.Box(popup.a, { grow = 1 }),
Layout.Box(popup.b, { grow = 1 }),
Layout.Box(popup.c, { grow = 1 }),
}, { dir = "row" })
)
for _, p in pairs(popup) do
p:on("BufLeave", function()
vim.schedule(function()
local bufnr = vim.api.nvim_get_current_buf()
for _, lp in pairs(popup) do
if lp.bufnr == bufnr then
return
end
end
layout:unmount()
end)
end)
end
layout:mount() |
Beta Was this translation helpful? Give feedback.
-
I don't think I understand the problem. What exactly are you trying to do? 🤔 If you just want to focus a specific popup, you can use The window id for a popup is stored in `.winid property. So it'll be something like: vim.api.nvim_set_current_win(popup.a.winid) |
Beta Was this translation helpful? Give feedback.
-
Not sure what you mean.
I think that would be solved by the suggestion in #289 (comment) ?
If you're talking about It might also be an expected behavior, because the doc says:
It might also be true for It's not something |
Beta Was this translation helpful? Give feedback.
-
Hi,
Thank you for your plugin! I'm making a tool which initially launches three pop-up windows below the cursor. I'd like the user to start in the first one and navigate between the three with
<Tab>
.For a number of reasons, this seems to require a surprising amount of work.
<Ctrl-W>
type command to navigate them for three reasons: firstly, none of them work in the general case of multiple windows, secondly, they conflict with theBufLeave
event, and thirdly, despite setting the third window to be unfocusable, by using<Ctrl-W>#w
commands for an appropriate number#
, I am able to focus it using keystrokes.It seems like this would be a common task, so I'm wondering if I'm missing something with my strategy (e.g. maybe I should be using a Table, or some collection of methods for this task), or if this is a feature gap.
Beta Was this translation helpful? Give feedback.
All reactions