From d126bbdc2474435b0a7ed242351ef3e145cdcc4f Mon Sep 17 00:00:00 2001 From: Theodor Bjorkman Date: Fri, 28 Feb 2025 09:06:21 +0100 Subject: [PATCH 1/5] plugins/utility/harpoon: added harpoon Harpoon (branch harpoon2) has been added as a plugin. Set under navigation to allow for more naviation plugins to be added in the future (set telescope under navigation?). Basic options and keybinds are included. --- modules/plugins/utility/default.nix | 1 + modules/plugins/utility/harpoon/config.nix | 51 +++++++++++++++++++++ modules/plugins/utility/harpoon/default.nix | 6 +++ modules/plugins/utility/harpoon/harpoon.nix | 45 ++++++++++++++++++ npins/sources.json | 12 +++++ 5 files changed, 115 insertions(+) create mode 100644 modules/plugins/utility/harpoon/config.nix create mode 100644 modules/plugins/utility/harpoon/default.nix create mode 100644 modules/plugins/utility/harpoon/harpoon.nix diff --git a/modules/plugins/utility/default.nix b/modules/plugins/utility/default.nix index 475790707..6dbd9bd84 100644 --- a/modules/plugins/utility/default.nix +++ b/modules/plugins/utility/default.nix @@ -5,6 +5,7 @@ ./diffview ./fzf-lua ./gestures + ./harpoon ./icon-picker ./images ./leetcode-nvim diff --git a/modules/plugins/utility/harpoon/config.nix b/modules/plugins/utility/harpoon/config.nix new file mode 100644 index 000000000..871a338a2 --- /dev/null +++ b/modules/plugins/utility/harpoon/config.nix @@ -0,0 +1,51 @@ +{ + options, + config, + lib, + ... +}: let + inherit (lib.modules) mkIf; + inherit (lib.lists) optionals; + inherit (lib.strings) concatStrings; + inherit (lib.nvim.binds) pushDownDefault mkKeymap; + + cfg = config.vim.navigation.harpoon; + + keys = cfg.mappings; + inherit (options.vim.navigation.harpoon) mappings; +in { + config = mkIf cfg.enable { + vim = { + startPlugins = ["plenary-nvim"]; + + lazy.plugins.harpoon = { + package = "harpoon"; + setupModule = "harpoon"; + inherit (cfg) setupOpts; + + before = '' + ''; + + after = '' + local harpoon = require("harpoon") + harpoon.setup({}) + ''; + + cmd = ["Harpoon"]; + + keys = [ + (mkKeymap "n" keys.markFile "lua require('harpoon'):list():add()" {desc = mappings.markFile.description;}) + (mkKeymap "n" keys.listMarks "lua require('harpoon').ui:toggle_quick_menu(require('harpoon'):list())" {desc = mappings.listMarks.description;}) + (mkKeymap "n" keys.file1 "lua require('harpoon'):list():select(1)" {desc = mappings.file1.description;}) + (mkKeymap "n" keys.file2 "lua require('harpoon'):list():select(2)" {desc = mappings.file2.description;}) + (mkKeymap "n" keys.file3 "lua require('harpoon'):list():select(3)" {desc = mappings.file3.description;}) + (mkKeymap "n" keys.file4 "lua require('harpoon'):list():select(4)" {desc = mappings.file4.description;}) + ]; + }; + + binds.whichKey.register = pushDownDefault { + "a" = "Harpoon Mark"; + }; + }; + }; +} diff --git a/modules/plugins/utility/harpoon/default.nix b/modules/plugins/utility/harpoon/default.nix new file mode 100644 index 000000000..1299f6a5c --- /dev/null +++ b/modules/plugins/utility/harpoon/default.nix @@ -0,0 +1,6 @@ +_: { + imports = [ + ./harpoon.nix + ./config.nix + ]; +} diff --git a/modules/plugins/utility/harpoon/harpoon.nix b/modules/plugins/utility/harpoon/harpoon.nix new file mode 100644 index 000000000..5f1e93e04 --- /dev/null +++ b/modules/plugins/utility/harpoon/harpoon.nix @@ -0,0 +1,45 @@ +{lib, ...}: let + inherit (lib.options) mkEnableOption mkOption; + inherit (lib.types) bool; + inherit (lib.nvim.binds) mkMappingOption; + inherit (lib.nvim.types) mkPluginSetupOption luaInline; + inherit (lib.generators) mkLuaInline; + setupOptions = { + defaults = { + save_on_toggle = mkOption { + description = "any time the ui menu is closed then we will save the state back to the backing list, not to the fs"; + type = bool; + default = false; + }; + sync_on_ui_close = mkOption { + description = "any time the ui menu is closed then the state of the list will be sync'd back to the fs"; + type = bool; + default = false; + }; + key = mkOption { + description = "how the out list key is looked up. This can be useful when using worktrees and using git remote instead of file path"; + type = luaInline; + default = mkLuaInline '' + function() + return vim.loop.cwd() + end + ''; + }; + }; + }; +in { + options.vim.navigation.harpoon = { + mappings = { + markFile = mkMappingOption "Mark file [Harpoon]" "a"; + listMarks = mkMappingOption "List marked files [Harpoon]" ""; + file1 = mkMappingOption "Go to marked file 1 [Harpoon]" ""; + file2 = mkMappingOption "Go to marked file 2 [Harpoon]" ""; + file3 = mkMappingOption "Go to marked file 3 [Harpoon]" ""; + file4 = mkMappingOption "Go to marked file 4 [Harpoon]" ""; + }; + + enable = mkEnableOption "Harpoon: quick bookmarks on keybinds"; + + setupOpts = mkPluginSetupOption "Harpoon" setupOptions; + }; +} diff --git a/npins/sources.json b/npins/sources.json index 0dc9e21bf..b04ccff39 100644 --- a/npins/sources.json +++ b/npins/sources.json @@ -471,6 +471,18 @@ "url": "https://github.com/ellisonleao/gruvbox.nvim/archive/089b60e92aa0a1c6fa76ff527837cd35b6f5ac81.tar.gz", "hash": "0mr8q2xi4s2anibll8lhxax7q1akyg687bp5r58gckkhi04064q4" }, + "harpoon": { + "type": "Git", + "repository": { + "type": "GitHub", + "owner": "ThePrimeagen", + "repo": "harpoon" + }, + "branch": "harpoon2", + "revision": "ed1f853847ffd04b2b61c314865665e1dadf22c7", + "url": "https://github.com/ThePrimeagen/harpoon/archive/ed1f853847ffd04b2b61c314865665e1dadf22c7.tar.gz", + "hash": "1dcpdlna2lff9dlsh6i4v16qmn5r9279wdvn0ry3xg4abqwnzc9g" + }, "haskell-tools-nvim": { "type": "Git", "repository": { From 7f63328de1436139ed5aae2f297b59e528c8e1fd Mon Sep 17 00:00:00 2001 From: Theodor Bjorkman Date: Fri, 28 Feb 2025 19:10:53 +0100 Subject: [PATCH 2/5] Fixed PR comments Formatting and changelog --- docs/release-notes/rl-0.8.md | 4 ++ modules/plugins/utility/harpoon/config.nix | 10 ---- modules/plugins/utility/harpoon/default.nix | 2 +- modules/plugins/utility/harpoon/harpoon.nix | 52 +++++++++++---------- 4 files changed, 32 insertions(+), 36 deletions(-) diff --git a/docs/release-notes/rl-0.8.md b/docs/release-notes/rl-0.8.md index 0440f38f4..1703d86d7 100644 --- a/docs/release-notes/rl-0.8.md +++ b/docs/release-notes/rl-0.8.md @@ -192,3 +192,7 @@ - Add formatters for go: [gofmt](https://go.dev/blog/gofmt), [golines](https://github.com/segmentio/golines) and [gofumpt](https://github.com/mvdan/gofumpt) + +[UltraGhostie](https://github.com/UltraGhostie) + +- Add [harpoon](https://github.com/ThePrimeagen/harpoon) plugin for navigation diff --git a/modules/plugins/utility/harpoon/config.nix b/modules/plugins/utility/harpoon/config.nix index 871a338a2..487e67e43 100644 --- a/modules/plugins/utility/harpoon/config.nix +++ b/modules/plugins/utility/harpoon/config.nix @@ -5,8 +5,6 @@ ... }: let inherit (lib.modules) mkIf; - inherit (lib.lists) optionals; - inherit (lib.strings) concatStrings; inherit (lib.nvim.binds) pushDownDefault mkKeymap; cfg = config.vim.navigation.harpoon; @@ -23,14 +21,6 @@ in { setupModule = "harpoon"; inherit (cfg) setupOpts; - before = '' - ''; - - after = '' - local harpoon = require("harpoon") - harpoon.setup({}) - ''; - cmd = ["Harpoon"]; keys = [ diff --git a/modules/plugins/utility/harpoon/default.nix b/modules/plugins/utility/harpoon/default.nix index 1299f6a5c..21637c5be 100644 --- a/modules/plugins/utility/harpoon/default.nix +++ b/modules/plugins/utility/harpoon/default.nix @@ -1,4 +1,4 @@ -_: { +{ imports = [ ./harpoon.nix ./config.nix diff --git a/modules/plugins/utility/harpoon/harpoon.nix b/modules/plugins/utility/harpoon/harpoon.nix index 5f1e93e04..9e313611e 100644 --- a/modules/plugins/utility/harpoon/harpoon.nix +++ b/modules/plugins/utility/harpoon/harpoon.nix @@ -4,29 +4,6 @@ inherit (lib.nvim.binds) mkMappingOption; inherit (lib.nvim.types) mkPluginSetupOption luaInline; inherit (lib.generators) mkLuaInline; - setupOptions = { - defaults = { - save_on_toggle = mkOption { - description = "any time the ui menu is closed then we will save the state back to the backing list, not to the fs"; - type = bool; - default = false; - }; - sync_on_ui_close = mkOption { - description = "any time the ui menu is closed then the state of the list will be sync'd back to the fs"; - type = bool; - default = false; - }; - key = mkOption { - description = "how the out list key is looked up. This can be useful when using worktrees and using git remote instead of file path"; - type = luaInline; - default = mkLuaInline '' - function() - return vim.loop.cwd() - end - ''; - }; - }; - }; in { options.vim.navigation.harpoon = { mappings = { @@ -38,8 +15,33 @@ in { file4 = mkMappingOption "Go to marked file 4 [Harpoon]" ""; }; - enable = mkEnableOption "Harpoon: quick bookmarks on keybinds"; + enable = mkEnableOption "Quick bookmarks on keybinds [Harpoon]"; - setupOpts = mkPluginSetupOption "Harpoon" setupOptions; + setupOpts = mkPluginSetupOption "Harpoon" { + defaults = { + save_on_toggle = mkOption { + type = bool; + default = false; + description = '' any time the ui menu is closed then we will save the + state back to the backing list, not to the fs''; + }; + sync_on_ui_close = mkOption { + type = bool; + default = false; + description = '' any time the ui menu is closed then the state of the + list will be sync'd back to the fs''; + }; + key = mkOption { + type = luaInline; + default = mkLuaInline '' + function() + return vim.loop.cwd() + end + ''; + description = '' how the out list key is looked up. This can be useful + when using worktrees and using git remote instead of file path''; + }; + }; + }; }; } From 17a503ec4d7820456bf7824c3519c70ee79b06ec Mon Sep 17 00:00:00 2001 From: Theodor Bjorkman Date: Fri, 28 Feb 2025 19:13:20 +0100 Subject: [PATCH 3/5] Fixed description typo --- modules/plugins/utility/harpoon/harpoon.nix | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/modules/plugins/utility/harpoon/harpoon.nix b/modules/plugins/utility/harpoon/harpoon.nix index 9e313611e..835a343bc 100644 --- a/modules/plugins/utility/harpoon/harpoon.nix +++ b/modules/plugins/utility/harpoon/harpoon.nix @@ -22,13 +22,13 @@ in { save_on_toggle = mkOption { type = bool; default = false; - description = '' any time the ui menu is closed then we will save the + description = '' Any time the ui menu is closed then we will save the state back to the backing list, not to the fs''; }; sync_on_ui_close = mkOption { type = bool; default = false; - description = '' any time the ui menu is closed then the state of the + description = '' Any time the ui menu is closed then the state of the list will be sync'd back to the fs''; }; key = mkOption { @@ -38,7 +38,7 @@ in { return vim.loop.cwd() end ''; - description = '' how the out list key is looked up. This can be useful + description = '' How the out list key is looked up. This can be useful when using worktrees and using git remote instead of file path''; }; }; From 364a59b3be874d7e5b0406af619a7405df3a7a77 Mon Sep 17 00:00:00 2001 From: Theodor Bjorkman Date: Tue, 4 Mar 2025 08:55:36 +0100 Subject: [PATCH 4/5] Fixed description formatting --- modules/plugins/utility/harpoon/harpoon.nix | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/modules/plugins/utility/harpoon/harpoon.nix b/modules/plugins/utility/harpoon/harpoon.nix index 835a343bc..9961aa07a 100644 --- a/modules/plugins/utility/harpoon/harpoon.nix +++ b/modules/plugins/utility/harpoon/harpoon.nix @@ -22,14 +22,18 @@ in { save_on_toggle = mkOption { type = bool; default = false; - description = '' Any time the ui menu is closed then we will save the - state back to the backing list, not to the fs''; + description = '' + Any time the ui menu is closed then we will save the + state back to the backing list, not to the fs + ''; }; sync_on_ui_close = mkOption { type = bool; default = false; - description = '' Any time the ui menu is closed then the state of the - list will be sync'd back to the fs''; + description = '' + Any time the ui menu is closed then the state of the + list will be sync'd back to the fs + ''; }; key = mkOption { type = luaInline; @@ -38,8 +42,10 @@ in { return vim.loop.cwd() end ''; - description = '' How the out list key is looked up. This can be useful - when using worktrees and using git remote instead of file path''; + description = '' + How the out list key is looked up. This can be useful + when using worktrees and using git remote instead of file path + ''; }; }; }; From 77e4f28522e64443da0e152c2266a386e64ee858 Mon Sep 17 00:00:00 2001 From: Theodor Bjorkman Date: Wed, 5 Mar 2025 10:12:30 +0100 Subject: [PATCH 5/5] Fixed description indentation --- modules/plugins/utility/harpoon/harpoon.nix | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/modules/plugins/utility/harpoon/harpoon.nix b/modules/plugins/utility/harpoon/harpoon.nix index 9961aa07a..4478c938b 100644 --- a/modules/plugins/utility/harpoon/harpoon.nix +++ b/modules/plugins/utility/harpoon/harpoon.nix @@ -24,7 +24,7 @@ in { default = false; description = '' Any time the ui menu is closed then we will save the - state back to the backing list, not to the fs + state back to the backing list, not to the fs ''; }; sync_on_ui_close = mkOption { @@ -32,7 +32,7 @@ in { default = false; description = '' Any time the ui menu is closed then the state of the - list will be sync'd back to the fs + list will be sync'd back to the fs ''; }; key = mkOption { @@ -44,7 +44,7 @@ in { ''; description = '' How the out list key is looked up. This can be useful - when using worktrees and using git remote instead of file path + when using worktrees and using git remote instead of file path ''; }; };