about summary refs log tree commit diff stats
path: root/hm/soispha/conf/nvim/plugins/harpoon/default.nix
diff options
context:
space:
mode:
authorSoispha <soispha@vhack.eu>2023-08-26 23:42:21 +0200
committerSoispha <soispha@vhack.eu>2023-08-26 23:42:21 +0200
commit3f600ab07dbad3b6dd7655587ddea158b19aea71 (patch)
tree7164ccd965e1d14ade970aeb8eb188b1442a6c91 /hm/soispha/conf/nvim/plugins/harpoon/default.nix
parentStyle(treewide): Format all lua-files makes lua ➛ nix easier (diff)
downloadnixos-config-3f600ab07dbad3b6dd7655587ddea158b19aea71.zip
Refactor(treewide): Abbreviate path names
Diffstat (limited to 'hm/soispha/conf/nvim/plugins/harpoon/default.nix')
-rw-r--r--hm/soispha/conf/nvim/plugins/harpoon/default.nix95
1 files changed, 95 insertions, 0 deletions
diff --git a/hm/soispha/conf/nvim/plugins/harpoon/default.nix b/hm/soispha/conf/nvim/plugins/harpoon/default.nix
new file mode 100644
index 00000000..ecd1d6cb
--- /dev/null
+++ b/hm/soispha/conf/nvim/plugins/harpoon/default.nix
@@ -0,0 +1,95 @@
+{...}: let
+  numbers = ["0" "1" "2" "3" "4" "5" "6" "7" "8" "9"];
+  mkNumberedCommand = {
+    command_template,
+    prefix,
+    number,
+    desc_template,
+  }: {
+    name = "${prefix}${number}";
+    value = {
+      action = ''
+        function()
+          ${command_template number}
+        end
+      '';
+      lua = true;
+      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.listToAttrs (builtins.map mkGotoTerminalCommand numbers);
+  gotoFileMappings = builtins.listToAttrs (builtins.map mkGotoFileCommand numbers);
+in {
+  programs.nixvim = {
+    plugins.harpoon = {
+      enable = true;
+      # menu.width = "vim.api.nvim_win_get_width(0) - 4"; # TODO: integrate that
+      keymaps = {
+        tmuxGotoTerminal = null; # TODO:
+      };
+    };
+    maps.normalVisualOp =
+      {
+        "-" = {
+          action = ''
+            function()
+              require("harpoon.ui").nav_next()
+             end
+          '';
+          lua = true;
+          desc = "go to the next marked file";
+        };
+        "_" = {
+          action = ''
+            function()
+              require("harpoon.ui").nav_prev()
+             end
+          '';
+          lua = true;
+          desc = "go to the previous marked file";
+        };
+        "<leader><leader>" = {
+          action = ''
+            function()
+              require("harpoon.mark").add_file()
+            end
+          '';
+          lua = true;
+          desc = "add a mark to the open file in harpoon.";
+        };
+        "gqc" = {
+          action = ''
+            function()
+              require("harpoon.cmd-ui").toggle_quick_menu()
+            end
+          '';
+          lua = true;
+          desc = "toggle the harpoon command quick menu to see all commands.";
+        };
+        "<leader>q" = {
+          action = ''
+            function()
+              require("harpoon.ui").toggle_quick_menu()
+            end
+          '';
+          lua = true;
+          desc = "toggle the harpoon normal quick menu to see all marks.";
+        };
+      }
+      // gotoFileMappings
+      // gotoTerminalMappings;
+  };
+}