mirror of
https://github.com/nix-community/nixvim.git
synced 2025-06-22 17:03:31 +02:00
plugins/harpoon: fix keymaps + test
This commit is contained in:
parent
418bf5da17
commit
73f21c063d
2 changed files with 102 additions and 23 deletions
|
@ -10,11 +10,11 @@ with lib; let
|
|||
|
||||
projectConfigModule = types.submodule {
|
||||
options = {
|
||||
termCommands = helpers.mkNullOrOption (types.listOf types.str) ''
|
||||
termCommands = helpers.mkNullOrOption (with types; listOf str) ''
|
||||
List of predefined terminal commands for this project.
|
||||
'';
|
||||
|
||||
marks = helpers.mkNullOrOption (types.listOf types.str) ''
|
||||
marks = helpers.mkNullOrOption (with types; listOf str) ''
|
||||
List of predefined marks (filenames) for this project.
|
||||
'';
|
||||
};
|
||||
|
@ -42,7 +42,7 @@ in {
|
|||
Keymap for toggling the quick menu.";
|
||||
'';
|
||||
|
||||
navFile = helpers.mkNullOrOption (types.attrsOf types.str) ''
|
||||
navFile = helpers.mkNullOrOption (with types; attrsOf str) ''
|
||||
Keymaps for navigating to marks.
|
||||
|
||||
Examples:
|
||||
|
@ -62,7 +62,7 @@ in {
|
|||
Keymap for navigating to previous mark.";
|
||||
'';
|
||||
|
||||
gotoTerminal = helpers.mkNullOrOption (types.attrsOf types.str) ''
|
||||
gotoTerminal = helpers.mkNullOrOption (with types; attrsOf str) ''
|
||||
Keymaps for navigating to terminals.
|
||||
|
||||
Examples:
|
||||
|
@ -78,7 +78,7 @@ in {
|
|||
Keymap for toggling the cmd quick menu.
|
||||
'';
|
||||
|
||||
tmuxGotoTerminal = helpers.mkNullOrOption (types.attrsOf types.str) ''
|
||||
tmuxGotoTerminal = helpers.mkNullOrOption (with types; attrsOf str) ''
|
||||
Keymaps for navigating to tmux windows/panes.
|
||||
Attributes can either be tmux window ids or pane identifiers.
|
||||
|
||||
|
@ -107,9 +107,11 @@ in {
|
|||
Closes any tmux windows harpoon that harpoon creates when you close Neovim.
|
||||
'';
|
||||
|
||||
excludedFiletypes = helpers.defaultNullOpts.mkNullable (types.listOf types.str) "['harpoon']" ''
|
||||
Filetypes that you want to prevent from adding to the harpoon list menu.
|
||||
'';
|
||||
excludedFiletypes =
|
||||
helpers.defaultNullOpts.mkNullable
|
||||
(with types; listOf str)
|
||||
''["harpoon"]''
|
||||
"Filetypes that you want to prevent from adding to the harpoon list menu.";
|
||||
|
||||
markBranch = helpers.defaultNullOpts.mkBool false ''
|
||||
Set marks specific to each git branch inside git repository.
|
||||
|
@ -124,7 +126,7 @@ in {
|
|||
example = ''
|
||||
projects = {
|
||||
"$HOME/personal/vim-with-me/server" = {
|
||||
term.cmds = [
|
||||
termCommands = [
|
||||
"./env && npx ts-node src/index.ts"
|
||||
];
|
||||
};
|
||||
|
@ -143,8 +145,9 @@ in {
|
|||
'';
|
||||
|
||||
borderChars =
|
||||
helpers.defaultNullOpts.mkNullable (types.listOf types.str)
|
||||
"[ \"─\" \"│\" \"─\" \"│\" \"╭\" \"╮\" \"╯\" \"╰\" ]"
|
||||
helpers.defaultNullOpts.mkNullable
|
||||
(with types; listOf str)
|
||||
''["─" "│" "─" "│" "╭" "╮" "╯" "╰"]''
|
||||
"Border characters";
|
||||
};
|
||||
};
|
||||
|
@ -155,27 +158,41 @@ in {
|
|||
(
|
||||
name: value: {
|
||||
term.cmds = value.termCommands;
|
||||
mark.marks = map (mark: {filename = mark;}) value.marks;
|
||||
mark.marks =
|
||||
helpers.ifNonNull' value.marks
|
||||
(
|
||||
map
|
||||
(
|
||||
mark: {
|
||||
filename = mark;
|
||||
}
|
||||
)
|
||||
value.marks
|
||||
);
|
||||
}
|
||||
)
|
||||
cfg.projects;
|
||||
|
||||
options =
|
||||
setupOptions = with cfg;
|
||||
{
|
||||
global_settings = {
|
||||
save_on_toggle = cfg.saveOnToggle;
|
||||
save_on_change = cfg.saveOnChange;
|
||||
enter_on_sendcmd = cfg.enterOnSendcmd;
|
||||
tmux_autoclose_windows = cfg.tmuxAutocloseWindows;
|
||||
excluded_filetypes = cfg.excludedFiletypes;
|
||||
mark_branch = cfg.markBranch;
|
||||
save_on_toggle = saveOnToggle;
|
||||
save_on_change = saveOnChange;
|
||||
enter_on_sendcmd = enterOnSendcmd;
|
||||
tmux_autoclose_windows = tmuxAutocloseWindows;
|
||||
excluded_filetypes = excludedFiletypes;
|
||||
mark_branch = markBranch;
|
||||
};
|
||||
|
||||
inherit projects;
|
||||
|
||||
menu = {
|
||||
inherit (cfg.menu) width height;
|
||||
borderchars = cfg.menu.borderChars;
|
||||
inherit
|
||||
(menu)
|
||||
width
|
||||
height
|
||||
;
|
||||
borderchars = menu.borderChars;
|
||||
};
|
||||
}
|
||||
// cfg.extraOptions;
|
||||
|
@ -184,7 +201,7 @@ in {
|
|||
extraPlugins = [cfg.package];
|
||||
|
||||
extraConfigLua = ''
|
||||
require('harpoon').setup(${helpers.toLuaObject options})
|
||||
require('harpoon').setup(${helpers.toLuaObject setupOptions})
|
||||
'';
|
||||
|
||||
keymaps = let
|
||||
|
@ -247,7 +264,7 @@ in {
|
|||
(id: "function() require('harpoon.tmux').gotoTerminal(${id}) end")
|
||||
);
|
||||
in
|
||||
helpers.mkKeymaps
|
||||
helpers.keymaps.mkKeymaps
|
||||
{
|
||||
mode = "n";
|
||||
lua = true;
|
||||
|
|
62
tests/test-sources/plugins/utils/harpoon.nix
Normal file
62
tests/test-sources/plugins/utils/harpoon.nix
Normal file
|
@ -0,0 +1,62 @@
|
|||
{
|
||||
empty = {
|
||||
# Harpoon expects to access `~/.local/share/nvim/harpoon.json` which is not available in the
|
||||
# test environment
|
||||
tests.dontRun = true;
|
||||
|
||||
plugins.harpoon.enable = true;
|
||||
};
|
||||
|
||||
example = {
|
||||
# Harpoon expects to access `~/.local/share/nvim/harpoon.json` which is not available in the
|
||||
# test environment
|
||||
tests.dontRun = true;
|
||||
|
||||
plugins.harpoon = {
|
||||
enable = true;
|
||||
|
||||
keymapsSilent = true;
|
||||
keymaps = {
|
||||
addFile = "<leader>a";
|
||||
navFile = {
|
||||
"1" = "<C-j>";
|
||||
"2" = "<C-k>";
|
||||
"3" = "<C-l>";
|
||||
"4" = "<C-m>";
|
||||
};
|
||||
navNext = "<leader>b";
|
||||
navPrev = "<leader>c";
|
||||
gotoTerminal = {
|
||||
"1" = "J";
|
||||
"2" = "K";
|
||||
"3" = "L";
|
||||
"4" = "M";
|
||||
};
|
||||
cmdToggleQuickMenu = "<leader>d";
|
||||
tmuxGotoTerminal = {
|
||||
"1" = "<C-1>";
|
||||
"2" = "<C-2>";
|
||||
"{down-of}" = "<leader>g";
|
||||
};
|
||||
};
|
||||
saveOnToggle = false;
|
||||
saveOnChange = true;
|
||||
enterOnSendcmd = false;
|
||||
tmuxAutocloseWindows = false;
|
||||
excludedFiletypes = ["harpoon"];
|
||||
markBranch = false;
|
||||
projects = {
|
||||
"$HOME/personal/vim-with-me/server" = {
|
||||
termCommands = [
|
||||
"./env && npx ts-node src/index.ts"
|
||||
];
|
||||
};
|
||||
};
|
||||
menu = {
|
||||
width = 60;
|
||||
height = 10;
|
||||
borderChars = ["─" "│" "─" "│" "╭" "╮" "╯" "╰"];
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue