aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--README.md1
-rw-r--r--lua/pets.lua16
-rw-r--r--lua/pets/commands.lua9
-rw-r--r--lua/pets/pet.lua5
4 files changed, 31 insertions, 0 deletions
diff --git a/README.md b/README.md
index 7feddf4..5bdb4db 100644
--- a/README.md
+++ b/README.md
@@ -89,6 +89,7 @@ These are all the available commands:
- `PetsList`: prints the names of all the pets that are currently alive
- `PetsKill {name}`: kills the pet with given name, which will immediately blink out of existence. Forever.
- `PetsKillAll`: kills all the pets, poor creatures. Works just as PetsKill but for every pet.
+- `PetsRemove`/`PetsRemoveAll` as `PetsKill` and `PetsKillAll` but without animation.
- `PetsPauseToggle`: pause/resume animations for all pets, leaving them on screen as cute little statues
- `PetsHideToggle`: pause the animation for all pets and hide them / show all the pets again and resume animations
- `PetsIdleToggle`/`PetsSleepToggle`: basically a do-not-disturb mode, pets are still animated but do not move around
diff --git a/lua/pets.lua b/lua/pets.lua
index 6f04798..9ebc71a 100644
--- a/lua/pets.lua
+++ b/lua/pets.lua
@@ -80,6 +80,15 @@ function M.kill_pet(name)
end
end
+function M.remove_pet(name)
+ if M.pets[name] ~= nil then
+ M.pets[name]:remove()
+ M.pets[name] = nil
+ else
+ utils.warning("Couldn't find a pet named \"" .. name .. '"')
+ end
+end
+
function M.kill_all()
for _, pet in pairs(M.pets) do
pet:kill()
@@ -87,6 +96,13 @@ function M.kill_all()
M.pets = {}
end
+function M.remove_all()
+ for _, pet in pairs(M.pets) do
+ pet:remove()
+ end
+ M.pets = {}
+end
+
function M.list()
local empty = true
for pet in pairs(M.pets) do
diff --git a/lua/pets/commands.lua b/lua/pets/commands.lua
index a240fc0..f521710 100644
--- a/lua/pets/commands.lua
+++ b/lua/pets/commands.lua
@@ -38,6 +38,9 @@ end, { nargs = 1, complete = utils.complete_typestyle })
vim.api.nvim_create_user_command("PetsKillAll", function()
pets.kill_all()
end, {})
+vim.api.nvim_create_user_command("PetsRemoveAll", function()
+ pets.remove_all()
+end, {})
vim.api.nvim_create_user_command("PetsKill", function(input)
pets.kill_pet(input.args)
@@ -45,6 +48,12 @@ end, {
nargs = 1,
complete = utils.complete_name,
})
+vim.api.nvim_create_user_command("PetsRemove", function(input)
+ pets.remove_pet(input.args)
+end, {
+ nargs = 1,
+ complete = utils.complete_name,
+})
vim.api.nvim_create_user_command("PetsList", function()
pets.list()
diff --git a/lua/pets/pet.lua b/lua/pets/pet.lua
index 2cc6cfc..6540b1d 100644
--- a/lua/pets/pet.lua
+++ b/lua/pets/pet.lua
@@ -55,6 +55,11 @@ function M.Pet:kill()
end
end
+function M.Pet:remove()
+ self.animation:stop()
+ self.popup:unmount()
+end
+
function M.Pet:set_paused(paused)
self.animation:set_state({
paused = paused,