From 03830ab867f76fd6d4601daefeaa3a109816cae7 Mon Sep 17 00:00:00 2001 From: Giuseppe Gadola Date: Wed, 15 Feb 2023 00:33:36 +0100 Subject: feat(options): option to not show death animation --- lua/pets.lua | 1 + lua/pets/pet.lua | 10 ++++++++-- 2 files changed, 9 insertions(+), 2 deletions(-) (limited to 'lua') diff --git a/lua/pets.lua b/lua/pets.lua index 2626f22..ce9c61c 100644 --- a/lua/pets.lua +++ b/lua/pets.lua @@ -8,6 +8,7 @@ M.options = { default_pet = "cat", default_style = "brown", random = true, + death_animation = true, } M.pets = {} diff --git a/lua/pets/pet.lua b/lua/pets/pet.lua index a132a1e..e13d9e0 100644 --- a/lua/pets/pet.lua +++ b/lua/pets/pet.lua @@ -22,13 +22,14 @@ local popup_opts = { -- @param name the actual name for the pet -- @param type the species of the pet e.g. cat -- @param style the color/style of the pet e.g. brown --- @param user_opts the table with user options (to be passed to Animation) +-- @param user_opts the table with user options -- @return a new Pet instance function M.Pet.new(name, type, style, user_opts) local instance = setmetatable({}, M.Pet) instance.name = name instance.type = type instance.style = style + instance.death_animation = user_opts.death_animation local wd = debug.getinfo(1).source:sub(2):match("(.*nvim/)") .. "media/" instance.sourcedir = wd .. type .. "/" .. style .. "/" @@ -47,7 +48,12 @@ end -- delete the pet :( function M.Pet:kill() - self.animation.dying = true + if self.death_animation then + self.animation.dying = true + else + self.animation:stop() + self.popup:unmount() + end end return M -- cgit v1.3-2-g11bf