diff options
Diffstat (limited to 'lua')
| -rw-r--r-- | lua/pets.lua | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/lua/pets.lua b/lua/pets.lua index 363f049..7c7097f 100644 --- a/lua/pets.lua +++ b/lua/pets.lua @@ -21,7 +21,11 @@ function M.setup(options) end -- create a Pet object and add it to the pets table -function M.create_pet(name, type, style) -- TODO: don't allow duplicate names +function M.create_pet(name, type, style) + if M.pets[name] ~= nil then + vim.api.nvim_err_writeln("Name already in use") + return + end local pet = require("pets.pet").Pet.new(name, type, style, M.options.row, M.options.col) pet:animate() M.pets[pet.name] = pet @@ -32,7 +36,7 @@ function M.kill_pet(name) M.pets[name]:kill() M.pets[name] = nil else - print("Pet name incorrect") + vim.api.nvim_err_writeln("Pet name not found") end end |