return { "ThePrimeagen/harpoon", branch = "harpoon2", opts = { menu = { width = vim.api.nvim_win_get_width(0) - 4, }, settings = { save_on_toggle = true, }, }, init = function() local wk = require("which-key") wk.add({ mode = { "n" }, { "h", group = "Harpoon" }, { "hr", group = "Replace harpoon slot" }, { "", group = "Harpoon list delete" }, }) end, config = function(_, opts) local harpoon = require("harpoon") -- Apply the base configuration harpoon.setup(opts) -- Extend functionality harpoon:extend({ UI_CREATE = function(cx) vim.keymap.set("n", "", function() harpoon.ui:select_menu_item({ vsplit = true }) end, { buffer = cx.bufnr }) vim.keymap.set("n", "", function() harpoon.ui:select_menu_item({ split = true }) end, { buffer = cx.bufnr }) vim.keymap.set("n", "", function() harpoon.ui:select_menu_item({ tabedit = true }) end, { buffer = cx.bufnr }) end, }) end, keys = function() local keys = { { "ha", function() require("harpoon"):list():add() end, desc = "Add buffer to harpoon list", }, { "hi", function() require("harpoon"):list():prepend() end, desc = "Prepend buffer to harpoon list", }, { "", function() local harpoon = require("harpoon") harpoon.ui:toggle_quick_menu(harpoon:list()) end, desc = "Open harpoon list menu", }, { "", function() require("harpoon"):list():prev({ ui_nav_wrap = false }) end, desc = "Previous harpoon list", }, { "", function() require("harpoon"):list():next({ ui_nav_wrap = false }) end, desc = "Next harpoon list", }, } for i = 0, 9 do table.insert(keys, { "", function() require("harpoon"):list():select(i) end, desc = "Harpoon list " .. i, }) table.insert(keys, { "h" .. i, function() require("harpoon"):list():select(i) end, desc = "Harpoon list " .. i, }) table.insert(keys, { "hr" .. i, function() require("harpoon"):list():replace_at(i) end, desc = "Replace buffer at harpoon slot " .. i, }) end return keys end, }