about summary refs log tree commit diff stats
path: root/modules/by-name
diff options
context:
space:
mode:
authorBenedikt Peetz <benedikt.peetz@b-peetz.de>2025-04-09 21:16:27 +0200
committerBenedikt Peetz <benedikt.peetz@b-peetz.de>2025-04-09 21:16:27 +0200
commit0a88e9ea14c91386dec6f599e83bcd4804b3d9c4 (patch)
tree46ab1900201afcf96ee59c9338bc9262508f84c7 /modules/by-name
parentmodules/nvim/plgs/lf-nvim: Switch to the upstream lf.nvim package (diff)
downloadnixos-config-prime.zip
modules/nvim/plgs/harpoon: Update commands in keymaps to harpoon2 prime
Diffstat (limited to '')
-rw-r--r--modules/by-name/nv/nvim/plgs/harpoon/default.nix112
1 files changed, 30 insertions, 82 deletions
diff --git a/modules/by-name/nv/nvim/plgs/harpoon/default.nix b/modules/by-name/nv/nvim/plgs/harpoon/default.nix
index 15e25468..3760ce15 100644
--- a/modules/by-name/nv/nvim/plgs/harpoon/default.nix
+++ b/modules/by-name/nv/nvim/plgs/harpoon/default.nix
@@ -1,96 +1,44 @@
 {
-  pkgs,
-  config,
   lib,
+  config,
   ...
 }: let
-  numbers = ["0" "1" "2" "3" "4" "5" "6" "7" "8" "9"];
-  mkNumberedCommand = {
-    command_template,
-    prefix,
-    number,
-    desc_template,
-  }: {
-    key = "${prefix}${number}";
-    action.__raw = ''
-      function()
-        ${command_template number}
-      end
-    '';
-    options.desc = "${desc_template number}";
-  };
-  mkGotoTerminalCommand = number: let
-    desc_template = number: "Goto terminal number ${number}";
-    command_template = number: ''require("harpoon.term").gotoTerminal(${number})'';
-    prefix = "gt";
-  in
-    mkNumberedCommand {inherit desc_template command_template prefix number;};
-  mkGotoFileCommand = number: let
-    desc_template = number: "Goto Buffer number ${number}";
-    command_template = number: ''require("harpoon.ui").nav_file(${number})'';
-    prefix = "gf";
-  in
-    mkNumberedCommand {inherit desc_template command_template prefix number;};
-
-  gotoTerminalMappings = builtins.map mkGotoTerminalCommand numbers;
-  gotoFileMappings = builtins.map mkGotoFileCommand numbers;
   cfg = config.soispha.programs.nvim;
 in {
   home-manager.users.soispha.programs.nixvim = lib.mkIf cfg.enable {
-    plugins.harpoon = {
-      enable = true;
-      package = pkgs.vimPlugins.harpoon;
-      enableTelescope = true;
-    };
+    plugins.harpoon.enable = true;
+
     keymaps =
-      [
-        {
-          key = "-";
-          action.__raw = ''
+      lib.mapAttrsToList
+      (key: action: {
+        mode = "n";
+        inherit key;
+        action.__raw = builtins.elemAt action 0;
+        options.silent = true;
+        options.desc = builtins.elemAt action 1;
+      })
+      {
+        # add current file
+        "<leader><leader>" = [
+          # lua
+          ''
             function()
-              require("harpoon.ui").nav_next()
-             end
-          '';
-          options.desc = "go to the next marked file";
-        }
-        {
-          key = "_";
-          action.__raw = ''
-            function()
-              require("harpoon.ui").nav_prev()
-             end
-          '';
-          options.desc = "go to the previous marked file";
-        }
-        {
-          key = "<leader><leader>";
-          action.__raw = ''
-            function()
-              require("harpoon.mark").add_file()
+              require("harpoon"):list():add()
             end
-          '';
-          options.desc = "add a mark to the open file in harpoon.";
-        }
-        {
-          key = "gqc";
-          action.__raw = ''
-            function()
-              require("harpoon.cmd-ui").toggle_quick_menu()
-            end
-          '';
-          options.desc = "toggle the harpoon command quick menu to see all commands.";
-        }
-        {
-          key = "<leader>q";
-          action.__raw = ''
+          ''
+          "Add a mark to the open file in harpoon."
+        ];
+
+        # open menu
+        "<leader>q" = [
+          # lua
+          ''
             function()
-              require("harpoon.ui").toggle_quick_menu()
+                require("harpoon").ui:toggle_quick_menu(require("harpoon"):list())
             end
-          '';
-          options.desc = "toggle the harpoon normal quick menu to see all marks.";
-        }
-      ]
-      ++ gotoFileMappings
-      ++ gotoTerminalMappings;
+          ''
+          "Toggle the harpoon normal quick menu to see all marks."
+        ];
+      };
   };
 }