Closed jackMort closed 1 year ago
I also tried another option to mount settings_panel and call :hide()
/:show()
methods, it works but in my use case I'm want to start with hidden panel, can you help me with that?
nvm it works, I had to run settings_panel:mount()
:
local settings_open = false
for _, popup in ipairs({ settings_panel, chat_input }) do
for _, mode in ipairs({ "n", "i" }) do
popup:map(mode, "<C-o>", function()
if settings_open then
layout:update(Layout.Box({
Layout.Box(chat_window, { grow = 1 }),
Layout.Box(chat_input, { size = 3 }),
}, { dir = "col" }))
settings_panel:hide()
vim.api.nvim_set_current_win(chat_input.winid)
else
layout:update(Layout.Box({
Layout.Box({
Layout.Box(chat_window, { grow = 1 }),
Layout.Box(chat_input, { size = 3 }),
}, { dir = "col", grow = 1 }),
Layout.Box(settings_panel, { size = 40 }),
}, { dir = "row" }))
settings_panel:show()
settings_panel:mount()
vim.api.nvim_set_current_win(settings_panel.winid)
vim.api.nvim_buf_set_option(settings_panel.bufnr, "modifiable", false)
vim.api.nvim_win_set_option(settings_panel.winid, "cursorline", true)
end
settings_open = not settings_open
end, {})
end
end
Re-opening.
This should be handled automatically. When you're using Layout
you shouldn't need to deal with :mount
, :unmount
etc. for each individual components.
@jackMort can you check if https://github.com/MunifTanjim/nui.nvim/pull/222 fixes your issue? In your example, you shouldn't need to mount / show / hide / unmount settings_panel
manually. Layout
should do it for you automatically.
Yes, it solves the issue, thank you!
I want dynamically show/hide settings panel (Popup window which appears as part of layout) but it only shows the empty space, looks like it's not mounted or so? Is this possible?