From 5cdf7648aa5cfb75bfdc87aead06845810b78cb0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?B=C3=A9la=20Richartz?= Date: Fri, 12 Apr 2024 11:00:01 +0200 Subject: [PATCH] Refining harpoon2 keybindings and add telescope binding --- after/plugin/harpoon.lua | 40 +++++++++++++++++++++++++++++++++++++--- 1 file changed, 37 insertions(+), 3 deletions(-) diff --git a/after/plugin/harpoon.lua b/after/plugin/harpoon.lua index 860079b..7649def 100644 --- a/after/plugin/harpoon.lua +++ b/after/plugin/harpoon.lua @@ -1,13 +1,47 @@ local harpoon = require("harpoon") -- REQUIRED -harpoon:setup() +harpoon:setup({}) -- REQUIRED +-- +-- basic telescope configuration +local conf = require("telescope.config").values +local function toggle_telescope(harpoon_files) + local file_paths = {} + for _, item in ipairs(harpoon_files.items) do + table.insert(file_paths, item.value) + end -vim.keymap.set("n", "a", function() harpoon:list():append() end) -vim.keymap.set("n", "h", function() harpoon.ui:toggle_quick_menu(harpoon:list()) end) + require("telescope.pickers").new({}, { + prompt_title = "Harpoon", + finder = require("telescope.finders").new_table({ + results = file_paths, + }), + previewer = conf.file_previewer({}), + sorter = conf.generic_sorter({}), + }):find() +end + +vim.keymap.set("n", "H", function() toggle_telescope(harpoon:list()) end, + { desc = "Open harpoon in telescope" }) + + +vim.keymap.set("n", "a", function() harpoon:list():add() end, + { desc = "Harpoon: Add current buffer" }) +vim.keymap.set("n", "h", function() harpoon.ui:toggle_quick_menu(harpoon:list()) end, + { desc = "Harpoon: Toggle quick menu" }) vim.keymap.set("n", "", function() harpoon:list():select(1) end) vim.keymap.set("n", "", function() harpoon:list():select(2) end) vim.keymap.set("n", "", function() harpoon:list():select(3) end) vim.keymap.set("n", "", function() harpoon:list():select(4) end) +vim.keymap.set("n", "", function() harpoon:list():select(5) end) +vim.keymap.set("n", "", function() harpoon:list():select(6) end) +vim.keymap.set("n", "", function() harpoon:list():select(7) end) +vim.keymap.set("n", "", function() harpoon:list():select(8) end) + +-- Toggle previous & next buffers stored within Harpoon list +vim.keymap.set("n", "", function() harpoon:list():prev() end, + { desc = "Harpoon: Previous buffer" }) +vim.keymap.set("n", "", function() harpoon:list():next() end, + { desc = "Harpoon: Next buffer" })