From 49738074784d86687b2414bd80a0ab85ed144a9a Mon Sep 17 00:00:00 2001 From: "Gustavo L de Mello (Guz)" Date: Thu, 5 Dec 2024 19:23:23 -0300 Subject: [PATCH] feat: add harpoon --- lua/dot013/plugins/navigation.lua | 67 +++++++++++++++++++++++++++++++ neovim.nix | 1 + 2 files changed, 68 insertions(+) diff --git a/lua/dot013/plugins/navigation.lua b/lua/dot013/plugins/navigation.lua index 47b9552..5b641e5 100644 --- a/lua/dot013/plugins/navigation.lua +++ b/lua/dot013/plugins/navigation.lua @@ -4,6 +4,7 @@ return { cmd = { "Telescope", }, + dep_of = { "harpoon2" }, keys = { { "", ":lua require('telescope.builtin').buffers", "[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 { + { + "w", + function() + harpoon():list():add() + end, + "[Harpoon] Append to list", + }, + { + "", + function() + toggle_telescope(harpoon():list()) + end, + "[Harpoon] Open quick menu", + }, + { + "", + function() + harpoon().ui:toggle_quick_menu(harpoon():list()) + end, + "[Harpoon] Open quick edit menu", + }, + { + "", + function() + harpoon():list():prev() + end, + "[Harpoon] Jump to previous item", + }, + { + "", + function() + harpoon():list():next() + end, + "[Harpoon] Jump to next item", + }, + } + end)(), + }, } diff --git a/neovim.nix b/neovim.nix index 1f4e180..07d4637 100644 --- a/neovim.nix +++ b/neovim.nix @@ -18,6 +18,7 @@ optPlugins = with pkgs; with pkgs.vimPlugins; [ + harpoon2 telescope-nvim telescope-fzf-native-nvim nvim-treesitter.withAllGrammars