From e785919c04afbfaaa0d11456cd54efa37424bfcb Mon Sep 17 00:00:00 2001 From: Dor Munis <5811812+dormunis@users.noreply.github.com> Date: Sat, 23 Dec 2023 14:41:13 +0200 Subject: [PATCH] Added telescope support --- README.md | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/README.md b/README.md index e6f0bf5..722b402 100644 --- a/README.md +++ b/README.md @@ -79,6 +79,37 @@ vim.keymap.set("n", "", function() harpoon:list():prev() end) vim.keymap.set("n", "", function() harpoon:list():next() end) ``` +### Telescope + +In order to use [Telescope](https://github.com/nvim-telescope/telescope.nvim) as a UI, +make sure to add `telescope` to your dependencies and paste this following snippet into your configuration. + +```lua +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 + +vim.keymap.set("n", "", function() toggle_telescope(harpoon:list()) end, + { desc = "Open harpoon window" }) +``` + ## ⇁ API You can define custom behavior of a harpoon list by providing your own calls.