From 94b4724e031fc3c9b6da19bdef574f44fabcca16 Mon Sep 17 00:00:00 2001 From: giuseppegadola Date: Wed, 24 May 2023 14:07:17 +0200 Subject: feat: handle window resizes Resize the popup when the window is resized. Related: #32 #11 Fixes #24 --- lua/pets/pet.lua | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'lua/pets/pet.lua') diff --git a/lua/pets/pet.lua b/lua/pets/pet.lua index 6540b1d..47bb2b0 100644 --- a/lua/pets/pet.lua +++ b/lua/pets/pet.lua @@ -15,6 +15,7 @@ function M.Pet.new(name, type, style, user_opts, state) instance.style = style instance.death_animation = user_opts.death_animation instance.state = state + instance.popup_opts = user_opts.popup local wd = debug.getinfo(1).source:sub(2):match("(.*nvim/)") .. "media/" instance.sourcedir = wd .. type .. "/" .. style .. "/" @@ -77,4 +78,11 @@ function M.Pet:set_idle(idle) self.animation:set_state({ idle = idle }) end +function M.Pet:refresh_popup() + self.popup:unmount() + self.popup = require("nui.popup")(self.popup_opts) + self.popup:mount() + self.animation.popup = self.popup +end + return M -- cgit v1.3-2-g11bf