aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGiuseppe Gadola <giusgadola@gmail.com>2023-01-28 14:41:07 +0100
committerGiuseppe Gadola <giusgadola@gmail.com>2023-02-10 16:05:59 +0100
commitd9fc8c7eca8e6d6d4f2d59782f1bc161f1ea0309 (patch)
treec7e9bc5cebac68849bb68f37b00e261e1d5dbff3
parentInitial commit (diff)
chore: first commit
-rw-r--r--.gitignore1
-rw-r--r--README.md49
-rw-r--r--TODO.md11
-rw-r--r--docs/pets.txt16
-rw-r--r--lua/pets.lua23
-rw-r--r--lua/pets/popup.lua19
-rw-r--r--lua/pets/setup.lua10
-rw-r--r--lua/pets/utils.lua9
-rw-r--r--lua/plugin_name.lua22
-rw-r--r--lua/plugin_name/module.lua8
-rw-r--r--plugin/plugin_name.lua1
-rw-r--r--tests/pets/pets_spec.lua (renamed from tests/plugin_name/plugin_name_spec.lua)0
12 files changed, 93 insertions, 76 deletions
diff --git a/.gitignore b/.gitignore
index 238d11c..1925341 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1 +1,2 @@
vendor/plenary.nvim
+media/
diff --git a/README.md b/README.md
index 99ad8be..faafa38 100644
--- a/README.md
+++ b/README.md
@@ -1,45 +1,4 @@
-# A Neovim Plugin Template
-
-![GitHub Workflow Status](https://img.shields.io/github/actions/workflow/status/ellisonleao/nvim-plugin-template/default.yml?branch=main&style=for-the-badge)
-![Lua](https://img.shields.io/badge/Made%20with%20Lua-blueviolet.svg?style=for-the-badge&logo=lua)
-
-
-A template repository for Neovim plugins.
-
-## Using it
-
-Via `gh`:
-
-```
-$ gh repo create my-plugin -p ellisonleao/nvim-plugin-template
-```
-
-Via github web page:
-
-Click on `Use this template`
-
-![](https://docs.github.com/assets/cb-36544/images/help/repository/use-this-template-button.png)
-
-## Features and structure
-
-- 100% Lua
-- Github actions to run tests and check for formatting errors (Stylua)
-- Tests created with [busted](https://olivinelabs.com/busted/) + [plenary.nvim](https://github.com/nvim-lua/plenary.nvim)
-
-### Plugin structure
-
-```
-.
-├── lua
-│   ├── plugin_name
-│   │   └── module.lua
-│   └── plugin_name.lua
-├── Makefile
-├── plugin
-│   └── plugin_name.lua
-├── README.md
-├── tests
-│   ├── minimal_init.lua
-│   └── plugin_name
-│   └── plugin_name_spec.lua
-```
+# Pets.nvim
+## Temp
+- dependencies: hologram.nvim
+- copyright vscode-pets
diff --git a/TODO.md b/TODO.md
new file mode 100644
index 0000000..9e13390
--- /dev/null
+++ b/TODO.md
@@ -0,0 +1,11 @@
+# To do
+## Technical
+- Might need to create an hidden buffer and then display it in the popup
+
+## Usability
+- [ ] Fix `:h` page formatting
+
+# Info
+- Using `gifsicle` to extract pngs from vscode-pets' gifs
+## Limitations
+- The plugin doesn't work inside tmux!!
diff --git a/docs/pets.txt b/docs/pets.txt
new file mode 100644
index 0000000..0ce527a
--- /dev/null
+++ b/docs/pets.txt
@@ -0,0 +1,16 @@
+================================================================================
+ *pets.nvim*
+
+pets.nvim is a Plugin that recreates the funcionality provided by vscode-pets.
+This plugin is completely useless and has no real purpose but it's fun.
+It uses https://github.com/edluffy/hologram.nvim to display images in the
+terminal, which for now only supports the kitty terminal.
+
+To find out more:
+https://github.com/giusgad/pets.nvim
+
+ :h AlphaHelloWorld
+
+PetsShow *PetsShow*
+ Starts displaying the cute pet
+================================================================================
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
diff --git a/plugin/plugin_name.lua b/plugin/plugin_name.lua
deleted file mode 100644
index 6808ee4..0000000
--- a/plugin/plugin_name.lua
+++ /dev/null
@@ -1 +0,0 @@
-vim.api.nvim_create_user_command("MyFirstFunction", require("plugin_name").hello, {})
diff --git a/tests/plugin_name/plugin_name_spec.lua b/tests/pets/pets_spec.lua
index 42ab112..42ab112 100644
--- a/tests/plugin_name/plugin_name_spec.lua
+++ b/tests/pets/pets_spec.lua