MunifTanjim / nui.nvim

UI Component Library for Neovim.
MIT License
1.62k stars 57 forks source link

Popup does not maintain the desired position on resize. #235

Closed jackMort closed 1 year ago

jackMort commented 1 year ago

screencast-bpconcjcammlapcogcnnelfmaeghhagj-2023.01.20-10_47_37.webm

as on preview video. here's the popup definition:

popup = Popup({
      position = { row = 0, col = "100%" },
      size = {
        width = 1,
        height = HEIGHT,
      },
      focusable = false,
      relative = "win",
      border = {
        style = "none",
      },
      buf_options = {
        modifiable = true,
        readonly = false,
      },
      win_options = {
        winblend = 30,
        winhighlight = "Normal:,FloatBorder:",
      },
    })
MunifTanjim commented 1 year ago

This is expected. Nui components do not react to resize events automatically.

You can try something like this:

vim.api.nvim_create_autocmd("WinResized", {
  group = vim.api.nvim_create_augroup("refresh_popup_layout", { clear = true }),
  callback = function()
    popup:update_layout()
  end,
})

popup:update_layout() resizes and repositions the popup (using current config). You can even pass a config table if you want to change the current config.

Note: WinResized event is not available in older Neovim.

jackMort commented 1 year ago

Great, thank you!