74 lines
1.8 KiB
Lua

local utils = require("utils")
return {
"ThePrimeagen/harpoon",
branch = "harpoon2",
dependencies = { "nvim-lua/plenary.nvim" },
config = function()
local harpoon = require("harpoon")
harpoon:setup()
local list = harpoon:list()
utils.nmapkey("<leader>a", function()
list:add()
end, "Add to harpoon buffers")
utils.nmapkey("<C-h>", function()
list:select(1)
end, "Navigate to harpoon buffer 1")
utils.nmapkey("<C-t>", function()
list:select(2)
end, "Navigate to harpoon buffer 2")
utils.nmapkey("<C-n>", function()
list:select(3)
end, "Navigate to harpoon buffer 3")
utils.nmapkey("<C-s>", function()
list:select(4)
end, "Navigate to harpoon buffer 1")
-- Toggle previous & next buffers stored within Harpoon list
utils.nmapkey("<C-A-p>", function()
list:prev()
end, "Go to previous harpoon buffer")
utils.nmapkey("<C-A-n>", function()
list:next()
end, "Go to next harpoon buffer")
-- Remove current buffer from list
utils.nmapkey("<C-A-e>", function()
list:remove()
end, "Remove current buffer from harpoon list")
-- Reset buffer
utils.nmapkey("<C-A-r>", function()
for _, item in ipairs(list.items) do
list:remove(item)
end
end, "Reset harpoon list")
-- 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
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
utils.nmapkey("<C-e>", function()
toggle_telescope(list)
end, "Open harpoon window")
end,
}