feat: add harpoon

This commit is contained in:
Guz
2024-12-05 19:23:23 -03:00
parent bb39c1dbc7
commit 4973807478
2 changed files with 68 additions and 0 deletions

View File

@@ -4,6 +4,7 @@ return {
cmd = {
"Telescope",
},
dep_of = { "harpoon2" },
keys = {
{ "<leader><space>", ":lua require('telescope.builtin').buffers<cr>", "[Telescope] Find existing buffers" },
{
@@ -33,4 +34,70 @@ return {
-- Telescope dependencies
{ "telescope-fzf-native.nvim", dep_of = { "telescope.nvim" } },
{
"harpoon2",
keys = (function()
local h = nil
local function harpoon()
if h == nil then
h = require("harpoon")
h:setup()
end
return h
end
local function toggle_telescope(harpoon_files)
local telescopeConf = require("telescope.config").values
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 = telescopeConf.file_previewer({}),
sorter = telescopeConf.generic_sorter({}),
})
:find()
end
return {
{
"<leader>w",
function()
harpoon():list():add()
end,
"[Harpoon] Append to list",
},
{
"<C-e>",
function()
toggle_telescope(harpoon():list())
end,
"[Harpoon] Open quick menu",
},
{
"<C-E>",
function()
harpoon().ui:toggle_quick_menu(harpoon():list())
end,
"[Harpoon] Open quick edit menu",
},
{
"<C-p>",
function()
harpoon():list():prev()
end,
"[Harpoon] Jump to previous item",
},
{
"<C-n>",
function()
harpoon():list():next()
end,
"[Harpoon] Jump to next item",
},
}
end)(),
},
}