Files
nvim-config/lua/plugins/harpoon.lua
2024-05-21 09:41:18 +02:00

45 lines
1.0 KiB
Lua

return {
"ThePrimeagen/harpoon",
branch = "harpoon2",
dependencies = { "nvim-lua/plenary.nvim" },
config = function()
local harpoon = require("harpoon")
-- Setup Harpoon with Telescope
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
-- Setup Harpoon keybinds
harpoon:setup()
vim.keymap.set("n", "<leader>a", function()
harpoon:list():add()
end)
vim.keymap.set("n", "<C-e>", function()
toggle_telescope(harpoon:list())
end)
vim.keymap.set("n", "<A-p>", function()
harpoon:list():prev()
end)
vim.keymap.set("n", "<A-n>", function()
harpoon:list():next()
end)
end,
}