diff options
| author | Giuseppe Gadola <giusgadola@gmail.com> | 2023-01-28 14:41:07 +0100 |
|---|---|---|
| committer | Giuseppe Gadola <giusgadola@gmail.com> | 2023-02-10 16:05:59 +0100 |
| commit | d9fc8c7eca8e6d6d4f2d59782f1bc161f1ea0309 (patch) | |
| tree | c7e9bc5cebac68849bb68f37b00e261e1d5dbff3 /lua | |
| parent | Initial commit (diff) | |
chore: first commit
Diffstat (limited to 'lua')
| -rw-r--r-- | lua/pets.lua | 23 | ||||
| -rw-r--r-- | lua/pets/popup.lua | 19 | ||||
| -rw-r--r-- | lua/pets/setup.lua | 10 | ||||
| -rw-r--r-- | lua/pets/utils.lua | 9 | ||||
| -rw-r--r-- | lua/plugin_name.lua | 22 | ||||
| -rw-r--r-- | lua/plugin_name/module.lua | 8 |
6 files changed, 61 insertions, 30 deletions
diff --git a/lua/pets.lua b/lua/pets.lua new file mode 100644 index 0000000..3038b83 --- /dev/null +++ b/lua/pets.lua @@ -0,0 +1,23 @@ +local M = {} + +function M.setup(options) + options = options or {} + require("pets.setup") +end + +function M.show() + local popup = require("pets.popup").popup + local utils = require("pets.utils") + popup:mount() + + -- insert lines to avoid the image being stretched + vim.api.nvim_buf_set_lines(popup.bufnr, 1, -1, false, { "", "", "", "", "", "", "", "", "", "", "" }) + popup.buf_options = { -- then set the buffer to be readonly + modifiable = false, + readonly = true, + } + + utils.ShowPet(popup.bufnr) +end + +return M diff --git a/lua/pets/popup.lua b/lua/pets/popup.lua new file mode 100644 index 0000000..f044218 --- /dev/null +++ b/lua/pets/popup.lua @@ -0,0 +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 + }, +}) +return M diff --git a/lua/pets/setup.lua b/lua/pets/setup.lua new file mode 100644 index 0000000..94f4d5e --- /dev/null +++ b/lua/pets/setup.lua @@ -0,0 +1,10 @@ +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 new file mode 100644 index 0000000..28c57b8 --- /dev/null +++ b/lua/pets/utils.lua @@ -0,0 +1,9 @@ +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 +end + +return M diff --git a/lua/plugin_name.lua b/lua/plugin_name.lua deleted file mode 100644 index 5320823..0000000 --- a/lua/plugin_name.lua +++ /dev/null @@ -1,22 +0,0 @@ --- main module file -local module = require("plugin_name.module") - -local M = {} -M.config = { - -- default config - opt = "Hello!", -} - --- setup is the public method to setup your plugin -M.setup = function(args) - -- you can define your setup function here. Usually configurations can be merged, accepting outside params and - -- you can also put some validation here for those. - M.config = vim.tbl_deep_extend("force", M.config, args or {}) -end - --- "hello" is a public method for the plugin -M.hello = function() - module.my_first_function() -end - -return M diff --git a/lua/plugin_name/module.lua b/lua/plugin_name/module.lua deleted file mode 100644 index 441e923..0000000 --- a/lua/plugin_name/module.lua +++ /dev/null @@ -1,8 +0,0 @@ --- module represents a lua module for the plugin -local M = {} - -M.my_first_function = function() - return "hello world!" -end - -return M |