-
-
Notifications
You must be signed in to change notification settings - Fork 57
nui.popup
Munif Tanjim edited this page Jun 22, 2023
·
3 revisions
The window id for a popup
is stored in .winid
property once the popup is mounted. You can focus the popup window using that:
vim.api.nvim_set_current_win(popup.winid)
Depending on what your use case is, you probably want to setup some way for the popup window to close itself. Below are some common strategies. All of the examples below assume you have created a Popup window already, such as in the example at lua/nui/popup.
NOTE: If the popup is not cleaned up properly with popup:unmount()
when the window is closed, you may get undesired behavior such as an orphaned window border.
This example will close the popup when it loses focus for any reason, including an explicit close or the user switching to another window:
popup:mount()
popup:on("BufLeave", function()
popup:unmount()
end, { once = true })