From c3aa10fb2e5742c18a418b5000eb417f91773597 Mon Sep 17 00:00:00 2001 From: Baipyrus Date: Sat, 30 Mar 2024 16:56:15 +0100 Subject: [PATCH] harpoon install telescope ui --- lua/custom/plugins/harpoon.lua | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/lua/custom/plugins/harpoon.lua b/lua/custom/plugins/harpoon.lua index 9e8ce64..a2cb64b 100644 --- a/lua/custom/plugins/harpoon.lua +++ b/lua/custom/plugins/harpoon.lua @@ -3,5 +3,35 @@ return { 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', 'ho', function() + toggle_telescope(harpoon:list()) + end, { desc = '[H]arpoon [Open]' }) + end, }