nvim-config/lua/custom/plugins/harpoon.lua

53 lines
1.5 KiB
Lua
Raw Normal View History

2024-03-30 15:51:35 +00:00
return {
'ThePrimeagen/harpoon',
branch = 'harpoon2',
dependencies = {
'nvim-lua/plenary.nvim',
2024-03-30 15:56:15 +00:00
'nvim-telescope/telescope.nvim',
2024-03-30 15:51:35 +00:00
},
2024-03-30 15:56:15 +00:00
config = function()
local harpoon = require 'harpoon'
harpoon:setup {}
-- 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
-- Open harpoon list window
vim.keymap.set('n', '<leader>ho', function()
toggle_telescope(harpoon:list())
2024-04-05 07:08:27 +00:00
end, { desc = '[H]arpoon [O]pen' })
2024-03-30 16:00:07 +00:00
-- Append to harpoon list
vim.keymap.set('n', '<leader>ha', function()
harpoon:list():append()
end, { desc = '[H]arpoon [A]ppend' })
2024-04-05 07:11:42 +00:00
-- Append to harpoon list
vim.keymap.set('n', '<leader>hr', function()
harpoon:list():remove()
end, { desc = '[H]arpoon [R]emove' })
2024-03-30 16:00:07 +00:00
-- Toggle previous & next buffers stored within Harpoon list
vim.keymap.set('n', '<C-S-P>', function()
harpoon:list():prev()
end)
vim.keymap.set('n', '<C-S-N>', function()
harpoon:list():next()
end)
2024-03-30 15:56:15 +00:00
end,
2024-03-30 15:51:35 +00:00
}