From 6f3e935980ed0aefa34e70a0ce8550c63ec7fe05 Mon Sep 17 00:00:00 2001 From: Oscar Wallberg Date: Mon, 8 Jan 2024 18:25:10 +0100 Subject: [PATCH] feat: add grapple toggle keybind --- lua/plugins/grapple.lua | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/lua/plugins/grapple.lua b/lua/plugins/grapple.lua index 9bb7ec0..1b950e0 100644 --- a/lua/plugins/grapple.lua +++ b/lua/plugins/grapple.lua @@ -4,12 +4,32 @@ local function setup() local grapple = require("grapple") grapple.setup() vim.keymap.set("n", "'", grapple.popup_tags) + vim.keymap.set("n", "mm", function () + if grapple.exists() then + grapple.untag() + return + end + + for i = 1, 9 do + local opts = { key = "m" .. i, } + if not grapple.exists(opts) then + grapple.tag(opts) + return + end + end + + grapple.tag({ key = "m?", }) + end) + for i = 1, 9 do + local opts = { key = "m" .. i, } + vim.keymap.set("n", "m" .. i, function () - grapple.tag({ key = "m" .. i, }) + grapple.tag(opts) end) + vim.keymap.set("n", "" .. i, function () - grapple.select({ key = "m" .. i, }) + grapple.select(opts) end) end end