From 0e970d95b71a279dd50f5b26d5fee9012ff3316f Mon Sep 17 00:00:00 2001 From: ecosse3 Date: Sun, 25 Feb 2024 11:20:25 +0100 Subject: [PATCH] feat(plugins): add nvim-scissors plugin for snippet management --- .gitignore | 1 + lua/config/plugins.lua | 48 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 49 insertions(+) diff --git a/.gitignore b/.gitignore index e4bd0ce9..1e347d60 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ spell .DS_Store +snippets diff --git a/lua/config/plugins.lua b/lua/config/plugins.lua index beef6b23..ee4a4a07 100644 --- a/lua/config/plugins.lua +++ b/lua/config/plugins.lua @@ -584,6 +584,54 @@ return { }, -- Snippets & Language & Syntax + { + "chrisgrieser/nvim-scissors", + dependencies = "nvim-telescope/telescope.nvim", -- optional + opts = { + snippetDir = vim.fn.stdpath("config") .. "/snippets", + }, + keys = { + "asa", + "ase", + }, + config = function() + local present, wk = pcall(require, "which-key") + if not present then + return + end + + wk.register({ + a = { + s = { + name = "Snippets", + a = { 'lua require("scissors").addNewSnippet()', 'Add new snippet' }, + e = { 'lua require("scissors").editSnippet()', 'Edit snippet' }, + } + } + }, { + mode = "n", -- NORMAL mode + prefix = "", + silent = true, -- use `silent` when creating keymaps + noremap = true, -- use `noremap` when creating keymaps + nowait = false, -- use `nowait` when creating keymaps + }) + + wk.register({ + a = { + s = { + name = "Snippets", + a = { 'lua require("scissors").addNewSnippet()', 'Add new snippet from selection' }, + } + } + }, { + mode = "x", -- VISUAL mode + prefix = "", + silent = true, -- use `silent` when creating keymaps + noremap = true, -- use `noremap` when creating keymaps + nowait = false, -- use `nowait` when creating keymaps + }) + end + }, { "windwp/nvim-autopairs", event = "InsertEnter",