diff options
Diffstat (limited to 'lua/pets')
| -rw-r--r-- | lua/pets/commands.lua | 4 | ||||
| -rw-r--r-- | lua/pets/pet.lua | 19 |
2 files changed, 23 insertions, 0 deletions
diff --git a/lua/pets/commands.lua b/lua/pets/commands.lua index a211d2d..80709fd 100644 --- a/lua/pets/commands.lua +++ b/lua/pets/commands.lua @@ -4,6 +4,10 @@ vim.api.nvim_create_user_command("Pets", function() pets.show() end, {}) -- use nargs = 1 to accept arguments +vim.api.nvim_create_user_command("PetsNew", function(input) + pets.create_pet("Giulio", "cat", "brown") -- TODO: use input.args as name +end, { nargs = 1 }) -- use nargs = 1 to accept arguments + vim.api.nvim_create_user_command("PetsCloseAll", function() pets.closeAll() end, {}) diff --git a/lua/pets/pet.lua b/lua/pets/pet.lua new file mode 100644 index 0000000..4179b38 --- /dev/null +++ b/lua/pets/pet.lua @@ -0,0 +1,19 @@ +local M = {} +M.Pet = {} +M.Pet.__index = M.Pet + +function M.Pet.new(name, type, style) + local instance = setmetatable({}, M.Pet) + instance.name = name + instance.type = type + instance.style = style + local wd = "/mnt/shared/coding/lua/plugins/pets.nvim/media/" -- TODO: adapt to use the correct path when plugin is installed + instance.sourcedir = wd .. type .. "/" .. style .. "/" + return instance +end + +function M.Pet:animate(bufnr) + require("pets.animations").animate(bufnr, self.sourcedir) +end + +return M |