aboutsummaryrefslogtreecommitdiff
path: root/lua
diff options
context:
space:
mode:
Diffstat (limited to 'lua')
-rw-r--r--lua/pets/commands.lua15
1 files changed, 12 insertions, 3 deletions
diff --git a/lua/pets/commands.lua b/lua/pets/commands.lua
index 87b7318..d9c6745 100644
--- a/lua/pets/commands.lua
+++ b/lua/pets/commands.lua
@@ -16,7 +16,7 @@ vim.api.nvim_create_user_command("PetsNew", function(input)
pets.create_pet(input.args, pet, style)
end, { nargs = 1 })
-local function autocomplete(_, cmdline)
+local function autocomplete_petsnew(_, cmdline)
local matches = {}
local words = vim.split(cmdline, " ", { trimempty = true })
@@ -46,7 +46,7 @@ vim.api.nvim_create_user_command("PetsNewCustom", function(input)
end
local type, style, name = args[1], args[2], args[3]
pets.create_pet(name, type, style)
-end, { nargs = 1, complete = autocomplete })
+end, { nargs = 1, complete = autocomplete_petsnew })
vim.api.nvim_create_user_command("PetsKillAll", function()
pets.kill_all()
@@ -54,7 +54,16 @@ end, {})
vim.api.nvim_create_user_command("PetsKill", function(input)
pets.kill_pet(input.args)
-end, { nargs = 1 })
+end, {
+ nargs = 1,
+ complete = function()
+ local matches = {}
+ for k, _ in pairs(pets.pets) do
+ table.insert(matches, k)
+ end
+ return matches
+ end,
+})
vim.api.nvim_create_user_command("PetsList", function()
pets.list()