From 679708c6a3dd91f639b145398286720f6b3ff1bf Mon Sep 17 00:00:00 2001
From: Squibid <me@zacharyscheiman.com>
Date: Sat, 23 Mar 2024 17:11:00 -0400
Subject: remove items from harpoon using dropdown menu

---
 lua/core/harpoon.lua | 20 ++++++++++++--------
 1 file changed, 12 insertions(+), 8 deletions(-)

(limited to 'lua/core')

diff --git a/lua/core/harpoon.lua b/lua/core/harpoon.lua
index 4d20828..ce68bdd 100644
--- a/lua/core/harpoon.lua
+++ b/lua/core/harpoon.lua
@@ -28,21 +28,25 @@ function M.switcher()
       end)
 
       -- remove harpoon item
-      -- TODO:
-
-      -- select items, and open buffer
-      vim.keymap.set("n", "<C-v>", function()
+      vim.keymap.set("i", "<C-a>", function()
         if action_state.get_selected_entry() then
-          actions.close(prompt_bufnr)
-          vim.cmd("vsplit "..action_state.get_selected_entry()[1])
+          for i, v in ipairs(filepaths) do
+            if v == action_state.get_selected_entry()[1] then
+              harpoon:list():removeAt(i)
+              actions.close(prompt_bufnr)
+              M.switcher()
+            end
+          end
         end
       end)
-      vim.keymap.set({ "n", "i" }, "<C-s>", function()
+
+      -- select items, and open buffer
+      vim.keymap.set("i", "<C-s>", function()
         if action_state.get_selected_entry() then
           actions.close(prompt_bufnr)
           vim.cmd("split "..action_state.get_selected_entry()[1])
         end
-      end)
+      end, { buffer = true, remap = true })
       actions.select_default:replace(function()
         if action_state.get_selected_entry() then
           actions.close(prompt_bufnr)
-- 
cgit v1.2.1