aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGiuseppe Gadola <giusgadola@gmail.com>2023-02-15 00:33:36 +0100
committerGiuseppe Gadola <giusgadola@gmail.com>2023-02-15 00:37:50 +0100
commit03830ab867f76fd6d4601daefeaa3a109816cae7 (patch)
tree73872c43cb1b5aae74a3a873c1596229610d1e81
parentdocs(help): auto generate docs (diff)
feat(options): option to not show death animation
-rw-r--r--README.md1
-rw-r--r--lua/pets.lua1
-rw-r--r--lua/pets/pet.lua10
3 files changed, 10 insertions, 2 deletions
diff --git a/README.md b/README.md
index 6d9aa53..e399e52 100644
--- a/README.md
+++ b/README.md
@@ -47,6 +47,7 @@ This is the default configuration:
default_pet = "cat", -- the pet to use for the PetNew command
default_style = "brown", -- the style of the pet to use for the PetNew command
random = false, -- wether to use a random pet for the PetNew command, ovverides default_pet and default_style
+ death_animation = true, -- animate the pet's death, set to false to feel less guilt
}
```
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