modules: add hop-nvim

This commit is contained in:
Dmitriy Pleshevskiy 2024-04-21 11:46:13 +03:00
parent 782c380023
commit 439437402d
Signed by: pleshevskiy
GPG Key ID: 17041163DA10A9A2
4 changed files with 116 additions and 8 deletions

View File

@ -254,6 +254,7 @@
nvim-treesitter = { };
gitsigns-nvim = { };
neoformat = { };
hop-nvim = { };
};
plugins = with prev.nix2lua.lib; {
@ -272,6 +273,9 @@
lualine_z = [ "location" "mode" ];
};
});
nvim-colorizer = pipe1
(require "colorizer")
(call0 "setup");
};
});

View File

@ -2,8 +2,8 @@
with nix2lua.lib;
{ configs ? { }
, keymaps ? [
let
defaultKeymaps = [
{ mode = "n"; bind = "]h"; command = raw "next_hunk"; }
{ mode = "n"; bind = "[h"; command = raw "prev_hunk"; }
{ mode = "n"; bind = "<leader>gs"; command = raw "gs.stage_hunk"; }
@ -15,11 +15,18 @@ with nix2lua.lib;
{ mode = "n"; bind = "<leader>gD"; command = lambda0 (call "gs.diffthis" "~"); }
{ mode = "n"; bind = "<leader>gtb"; command = raw "gs.toggle_current_line_blame"; }
{ mode = "n"; bind = "<leader>gtd"; command = raw "gs.toggle_deleted"; }
]
];
in
{ configs ? { }
, keymaps ? defaultKeymaps
, extraKeymaps ? [ ]
}:
let
bufferedKeymaps = map (args: lib.recursiveUpdate args { opts.buffer = var "bufnr"; }) keymaps;
bufferedKeymaps = map
(args: lib.recursiveUpdate args { opts.buffer = var "bufnr"; })
(keymaps ++ extraKeymaps);
in
{
gitsigns-nvim = [

92
modules/hop-nvim.nix Normal file
View File

@ -0,0 +1,92 @@
{ nix2lua, vim, ... }:
with nix2lua.lib;
let
hintDirAfter = var "hint.HintDirection.AFTER_CURSOR";
hintDirBefore = var "hint.HintDirection.BEFORE_CURSOR";
defaultKeymaps = [
{ mode = ""; bind = "<leader>hc"; command = "<CMD>HopChar1<CR>"; }
{
mode = "";
bind = "<leader>hf";
command = lambda0 (call "hop.hint_char1" {
direction = hintDirAfter;
current_line_only = true;
});
}
{
mode = "";
bind = "<leader>hF";
command = lambda0 (call "hop.hint_char1" {
direction = hintDirBefore;
current_line_only = true;
});
}
{
mode = "";
bind = "<leader>hbc";
command = lambda0 (call "hop.hint_char1" { direction = hintDirAfter; });
}
{
mode = "";
bind = "<leader>htc";
command = lambda0 (call "hop.hint_char1" { direction = hintDirBefore; });
}
{
mode = "";
bind = "<leader>hw";
command = "<Cmd>HopWord<CR>";
}
{
mode = "";
bind = "<leader>hbw";
command = lambda0 (call "hop.hint_words" { direction = hintDirAfter; });
}
{
mode = "";
bind = "<leader>htw";
command = lambda0 (call "hop.hint_words" { direction = hintDirBefore; });
}
{
mode = "";
bind = "<leader>hp";
command = "<CMD>HopPattern<CR>";
}
{
mode = "";
bind = "<leader>hbp";
command = lambda0 (call "hop.hint_patterns" { direction = hintDirAfter; });
}
{
mode = "";
bind = "<leader>htp";
command = lambda0 (call "hop.hint_patterns" { direction = hintDirBefore; });
}
{
mode = "";
bind = "<leader>hbv";
command = lambda0 (call "hop.hint_vertical" { direction = hintDirAfter; });
}
{
mode = "";
bind = "<leader>htv";
command = lambda0 (call "hop.hint_vertical" { direction = hintDirBefore; });
}
];
in
{ configs ? { }
, keymaps ? defaultKeymaps
, extraKeymaps ? [ ]
}:
{
hop-nvim = [
(local (set "hop" (require "hop")))
(pipe1 (var "hop") (call "setup" configs))
(local (set "hint" (require "hop.hint")))
] ++ map vim.keymap.set (keymaps ++ extraKeymaps);
}

View File

@ -1,10 +1,15 @@
{ nix2lua, vim, ... }:
{ configs ? { }
, keymaps ? [
let
defaultKeymaps = [
{ mode = "n"; bind = "<leader>nt"; command = "<CMD>NvimTreeToggle<CR>"; }
{ mode = "n"; bind = "<leader>nf"; command = "<CMD>NvimTreeFindFile<CR>"; }
]
];
in
{ configs ? { }
, keymaps ? defaultKeymaps
, extraKeymaps ? [ ]
}:
with nix2lua.lib;
@ -45,6 +50,6 @@ let isEmptyVar = name: eq "" (var name); in
(vim.api.nvim_create_autocmd [ "VimEnter" ] { callback = var "open_nvim_tree"; })
]
++ (map vim.keymap.set keymaps)
++ map vim.keymap.set (keymaps ++ extraKeymaps)
);
}