utility/harpoon: init

This commit is contained in:
Theodor Björkman 2025-03-06 15:40:57 +01:00 committed by GitHub
commit 4648c3b28f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 126 additions and 8 deletions

View file

@ -6,6 +6,7 @@
./direnv
./fzf-lua
./gestures
./harpoon
./icon-picker
./images
./leetcode-nvim

View file

@ -0,0 +1,41 @@
{
options,
config,
lib,
...
}: let
inherit (lib.modules) mkIf;
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;
cmd = ["Harpoon"];
keys = [
(mkKeymap "n" keys.markFile "<Cmd>lua require('harpoon'):list():add()<CR>" {desc = mappings.markFile.description;})
(mkKeymap "n" keys.listMarks "<Cmd>lua require('harpoon').ui:toggle_quick_menu(require('harpoon'):list())<CR>" {desc = mappings.listMarks.description;})
(mkKeymap "n" keys.file1 "<Cmd>lua require('harpoon'):list():select(1)<CR>" {desc = mappings.file1.description;})
(mkKeymap "n" keys.file2 "<Cmd>lua require('harpoon'):list():select(2)<CR>" {desc = mappings.file2.description;})
(mkKeymap "n" keys.file3 "<Cmd>lua require('harpoon'):list():select(3)<CR>" {desc = mappings.file3.description;})
(mkKeymap "n" keys.file4 "<Cmd>lua require('harpoon'):list():select(4)<CR>" {desc = mappings.file4.description;})
];
};
binds.whichKey.register = pushDownDefault {
"<leader>a" = "Harpoon Mark";
};
};
};
}

View file

@ -0,0 +1,6 @@
{
imports = [
./harpoon.nix
./config.nix
];
}

View file

@ -0,0 +1,53 @@
{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;
in {
options.vim.navigation.harpoon = {
mappings = {
markFile = mkMappingOption "Mark file [Harpoon]" "<leader>a";
listMarks = mkMappingOption "List marked files [Harpoon]" "<C-e>";
file1 = mkMappingOption "Go to marked file 1 [Harpoon]" "<C-j>";
file2 = mkMappingOption "Go to marked file 2 [Harpoon]" "<C-k>";
file3 = mkMappingOption "Go to marked file 3 [Harpoon]" "<C-l>";
file4 = mkMappingOption "Go to marked file 4 [Harpoon]" "<C-;>";
};
enable = mkEnableOption "Quick bookmarks on keybinds [Harpoon]";
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
'';
};
};
};
};
}