mirror of
https://github.com/Baipyrus/nvim-config.git
synced 2024-09-11 12:39:44 +00:00
53 lines
1.5 KiB
Lua
53 lines
1.5 KiB
Lua
return {
|
|
'ThePrimeagen/harpoon',
|
|
branch = 'harpoon2',
|
|
dependencies = {
|
|
'nvim-lua/plenary.nvim',
|
|
'nvim-telescope/telescope.nvim',
|
|
},
|
|
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())
|
|
end, { desc = '[H]arpoon [O]pen' })
|
|
-- Append to harpoon list
|
|
vim.keymap.set('n', '<leader>ha', function()
|
|
harpoon:list():append()
|
|
end, { desc = '[H]arpoon [A]ppend' })
|
|
-- Append to harpoon list
|
|
vim.keymap.set('n', '<leader>hr', function()
|
|
harpoon:list():remove()
|
|
end, { desc = '[H]arpoon [R]emove' })
|
|
-- 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)
|
|
end,
|
|
}
|