diff --git a/chezmoi/dot_config/nvim/lua/aleidk/plugins/bookmarks.lua b/chezmoi/dot_config/nvim/lua/aleidk/plugins/bookmarks.lua index fcfd24f..fe3a1a2 100644 --- a/chezmoi/dot_config/nvim/lua/aleidk/plugins/bookmarks.lua +++ b/chezmoi/dot_config/nvim/lua/aleidk/plugins/bookmarks.lua @@ -1,3 +1,13 @@ +local function select_or_create(search) + local grapple = require("grapple") + + if grapple.exists(search) then + grapple.select(search) + else + grapple.tag() + end +end + return { "cbochs/grapple.nvim", dependencies = { @@ -6,14 +16,19 @@ return { lazy = false, cmd = "Grapple", keys = { - { "a", "Grapple toggle", desc = "Toggle bookmark for current file" }, - { "t", "Grapple toggle_tags", desc = "Toggle bookmarks window" }, - { "T", "Grapple toggle_scopes", desc = "Toggle scopes window" }, - { "n", "Grapple cycle forward", desc = "Next bookmark" }, - { "N", "Grapple cycle backward", desc = "Prev bookmark" }, - { "j", "Grapple select index=1", desc = "bookmark 1" }, - { "k", "Grapple select index=2", desc = "bookmark 2" }, - { "l", "Grapple select index=3", desc = "bookmark 3" }, - { "ñ", "Grapple select index=4", desc = "bookmark 4" }, + { "a", "Grapple toggle", desc = "Toggle bookmark for current file" }, + { "D", "Grapple reset", desc = "Delete all bookmarks" }, + { "t", "Grapple toggle_tags", desc = "Toggle bookmarks window" }, + { "T", "Grapple toggle_scopes", desc = "Toggle scopes window" }, + { "n", "Grapple cycle forward", desc = "Next bookmark" }, + { "N", "Grapple cycle backward", desc = "Prev bookmark" }, + { "j", function() select_or_create({ index = 1 }) end, desc = "Go or create bookmark 1" }, + { "k", function() select_or_create({ index = 2 }) end, desc = "Go or create bookmark 2" }, + { "l", function() select_or_create({ index = 3 }) end, desc = "Go or create bookmark 3" }, + { "ñ", function() select_or_create({ index = 4 }) end, desc = "Go or create bookmark 4" }, + { "J", "Grapple tag index=1", desc = "Override bookmark 1" }, + { "K", "Grapple tag index=2", desc = "Override bookmark 2" }, + { "L", "Grapple tag index=3", desc = "Override bookmark 3" }, + { "Ñ", "Grapple tag index=4", desc = "Override bookmark 4" }, }, }