From 0268c6a3460efd13cf91c283b48416d2c5805b99 Mon Sep 17 00:00:00 2001 From: Gabriel Volpe Date: Fri, 5 Apr 2024 14:22:47 +0200 Subject: [PATCH] harpoon: override mappings to delete without prompt --- flake.lock | 6 +++--- modules/harpoon/default.nix | 23 +++++++++++++++++++++-- 2 files changed, 24 insertions(+), 5 deletions(-) diff --git a/flake.lock b/flake.lock index 1083690..51491b8 100644 --- a/flake.lock +++ b/flake.lock @@ -323,11 +323,11 @@ "harpoon": { "flake": false, "locked": { - "lastModified": 1707652817, - "narHash": "sha256-9/7aP12+MIKOU8mDgWmMDel/3VvBRJFQ4RIyOSofSRo=", + "lastModified": 1712299680, + "narHash": "sha256-iqeg/E44RLMeZcJ9pj4n2Z3wtvGMC6QvCyDNWeqLdXE=", "owner": "kimabrandt-flx", "repo": "harpoon", - "rev": "e0bdf91cafce78136547e982db59a262492fa8eb", + "rev": "933fc6005edc6b1f3568d8b23cb38b76cb54e49e", "type": "github" }, "original": { diff --git a/modules/harpoon/default.nix b/modules/harpoon/default.nix index 8d40625..0d2b585 100644 --- a/modules/harpoon/default.nix +++ b/modules/harpoon/default.nix @@ -22,14 +22,33 @@ in require('harpoon'):setup() ${writeIf tele.enable '' - vim.keymap.set("n", "hl", function() require("telescope").extensions.harpoon.marks() end, { desc = "List" }) + local themes = require("telescope.themes") + local hm_actions = require("telescope._extensions.harpoon_marks.actions") + + vim.keymap.set( + "n", + "hl", + function() + require("telescope").extensions.harpoon.marks(themes.get_dropdown({ + previewer = false, + layout_config = { width = 0.6 }, + path_display = { truncate = 10 }, + attach_mappings = function(_, map) + map("i", "", hm_actions.delete_mark_selections) + map("n", "", hm_actions.delete_mark_selections) + return true + end, + })) + end, + { desc = "List" } + ) ''} ${writeIf keys.enable '' wk.register({ ["h"] = { name = "Harpoon", - a = { "lua require('harpoon'):list():append()", "Add" }, + a = { "lua require('harpoon'):list():add()", "Add" }, d = { "lua require('harpoon'):list():remove()", "Del" }, }, })