diff options
| author | Giuseppe Gadola <giusgadola@gmail.com> | 2023-01-31 11:56:48 +0100 |
|---|---|---|
| committer | Giuseppe Gadola <giusgadola@gmail.com> | 2023-02-10 16:05:59 +0100 |
| commit | 9b791d88c67b9ad0293e0b45783de7219e2bd133 (patch) | |
| tree | 2ea17f721cce9e5607f9ba4fd884d6807d1d6db4 /lua/pets | |
| parent | docs: todo with some things (diff) | |
feat: toggle/multiple instances
Ability to spawn multiple popups simultanuosly and close them.
Diffstat (limited to 'lua/pets')
| -rw-r--r-- | lua/pets/commands.lua | 9 | ||||
| -rw-r--r-- | lua/pets/popup.lua | 28 | ||||
| -rw-r--r-- | lua/pets/setup.lua | 10 | ||||
| -rw-r--r-- | lua/pets/utils.lua | 8 |
4 files changed, 28 insertions, 27 deletions
diff --git a/lua/pets/commands.lua b/lua/pets/commands.lua new file mode 100644 index 0000000..8124cbc --- /dev/null +++ b/lua/pets/commands.lua @@ -0,0 +1,9 @@ +local pets = require("pets") + +vim.api.nvim_create_user_command("Pets", function() + pets.show() +end, {}) -- use nargs = 1 to accept arguments + +vim.api.nvim_create_user_command("PetsCloseAll", function() + pets.closeAll() +end, {}) diff --git a/lua/pets/popup.lua b/lua/pets/popup.lua index f044218..8fe7ebf 100644 --- a/lua/pets/popup.lua +++ b/lua/pets/popup.lua @@ -1,19 +1,19 @@ local M = {} local Popup = require("nui.popup") M.popup = Popup({ - position = { - row = "100%", -- FIX: set row for different sizes / implement offset - col = "100%", - }, - relative = "editor", - size = { - width = 60, - height = 10, - }, - focusable = false, - enter = false, - win_options = { - winblend = 100, -- TODO: set to 100 for transparent background - }, + position = { + row = "100%", -- FIX: set row for different sizes / implement offset + col = "100%", + }, + relative = "editor", + size = { + width = "25%", + height = 10, + }, + focusable = false, + enter = false, + win_options = { + winblend = 10, + }, }) return M diff --git a/lua/pets/setup.lua b/lua/pets/setup.lua deleted file mode 100644 index 94f4d5e..0000000 --- a/lua/pets/setup.lua +++ /dev/null @@ -1,10 +0,0 @@ -local pets = require("pets") - -local ok = pcall(require, "hologram") -if ok then - require("hologram").setup({ auto_display = false }) -end - -vim.api.nvim_create_user_command("PetsShow", function() - pets.show() -end, {}) -- use nargs = 1 to accept arguments diff --git a/lua/pets/utils.lua b/lua/pets/utils.lua index 28c57b8..4325928 100644 --- a/lua/pets/utils.lua +++ b/lua/pets/utils.lua @@ -1,9 +1,11 @@ local M = {} function M.ShowPet(buf) - local source = "/mnt/shared/coding/lua/plugins/pets.nvim/media/test/brown_idle-0.png" - local image = require("hologram.image"):new(source, {}) - image:display(5, 1, buf, {}) -- TODO: set offset to show the pet at the desired height + local source = "/mnt/shared/coding/lua/plugins/pets.nvim/media/test/brown_idle-0.png" + local image = require("hologram.image"):new(source, {}) + + image:display(5, 0, buf, {}) -- TODO: offset option to show the pet at the desired height + return image end return M |