From 2122a01f99c6da466b8f0f55c965c11a9043d117 Mon Sep 17 00:00:00 2001 From: Benedikt Peetz Date: Sat, 9 Nov 2024 12:35:44 +0100 Subject: refactor(modules/legacy/conf/nvim): Move to `by-name` --- modules/by-name/nv/nvim/plgs/harpoon/default.nix | 100 +++++++++++++++++++++++ 1 file changed, 100 insertions(+) create mode 100644 modules/by-name/nv/nvim/plgs/harpoon/default.nix (limited to 'modules/by-name/nv/nvim/plgs/harpoon/default.nix') diff --git a/modules/by-name/nv/nvim/plgs/harpoon/default.nix b/modules/by-name/nv/nvim/plgs/harpoon/default.nix new file mode 100644 index 00000000..05a40d9f --- /dev/null +++ b/modules/by-name/nv/nvim/plgs/harpoon/default.nix @@ -0,0 +1,100 @@ +{ + pkgs, + config, + lib, + ... +}: 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; + # menu.width = "vim.api.nvim_win_get_width(0) - 4"; # TODO: integrate that + keymaps = { + tmuxGotoTerminal = null; # TODO: + }; + }; + keymaps = + [ + { + key = "-"; + action.__raw = '' + 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 = ""; + action.__raw = '' + function() + require("harpoon.mark").add_file() + 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 = "q"; + action.__raw = '' + function() + require("harpoon.ui").toggle_quick_menu() + end + ''; + options.desc = "toggle the harpoon normal quick menu to see all marks."; + } + ] + ++ gotoFileMappings + ++ gotoTerminalMappings; + }; +} -- cgit 1.4.1