|
| 1 | +return { |
| 2 | + "ThePrimeagen/harpoon", |
| 3 | + branch = "harpoon2", |
| 4 | + dependencies = { "nvim-lua/plenary.nvim" }, |
| 5 | + config = function() |
| 6 | + local harpoon = require("harpoon") |
| 7 | + harpoon:setup({}) |
| 8 | + |
| 9 | + -- basic telescope configuration |
| 10 | + local conf = require("telescope.config").values |
| 11 | + local function toggle_telescope(harpoon_files) |
| 12 | + local file_paths = {} |
| 13 | + for _, item in ipairs(harpoon_files.items) do |
| 14 | + table.insert(file_paths, item.value) |
| 15 | + end |
| 16 | + |
| 17 | + require("telescope.pickers") |
| 18 | + .new({}, { |
| 19 | + prompt_title = "Harpoon", |
| 20 | + finder = require("telescope.finders").new_table({ |
| 21 | + results = file_paths, |
| 22 | + }), |
| 23 | + previewer = conf.file_previewer({}), |
| 24 | + sorter = conf.generic_sorter({}), |
| 25 | + }) |
| 26 | + :find() |
| 27 | + end |
| 28 | + |
| 29 | + vim.keymap.set("n", "<leader>fh", function() |
| 30 | + toggle_telescope(harpoon:list()) |
| 31 | + end, { desc = "Open harpoon window" }) |
| 32 | + |
| 33 | + vim.keymap.set("n", "<leader>a", function() |
| 34 | + harpoon:list():add() |
| 35 | + end) |
| 36 | + vim.keymap.set("n", "<C-e>", function() |
| 37 | + harpoon.ui:toggle_quick_menu(harpoon:list()) |
| 38 | + end) |
| 39 | + |
| 40 | + vim.keymap.set("n", "<C-j>", function() |
| 41 | + harpoon:list():select(1) |
| 42 | + end) |
| 43 | + vim.keymap.set("n", "<C-k>", function() |
| 44 | + harpoon:list():select(2) |
| 45 | + end) |
| 46 | + vim.keymap.set("n", "<C-l>", function() |
| 47 | + harpoon:list():select(3) |
| 48 | + end) |
| 49 | + vim.keymap.set("n", "<C-;>", function() |
| 50 | + harpoon:list():select(4) |
| 51 | + end) |
| 52 | + |
| 53 | + -- Toggle previous & next buffers stored within Harpoon list |
| 54 | + vim.keymap.set("n", "<C-n>", function() |
| 55 | + harpoon:list():prev() |
| 56 | + end) |
| 57 | + vim.keymap.set("n", "<C-p>", function() |
| 58 | + harpoon:list():next() |
| 59 | + end) |
| 60 | + end, |
| 61 | +} |
0 commit comments