nixeovim/modules/profiles/recommended.nix

155 lines
5.4 KiB
Nix
Raw Normal View History

2024-05-08 01:11:48 +03:00
{ config, lib, ... }:
with lib.nix2lua;
let
inherit (lib.mod) Space cmd leader localLeader ctrl;
2024-05-08 01:11:48 +03:00
gs = config.plugin.gitsigns-nvim.varName;
hop = config.plugin.hop-nvim.varName;
in
{
imports = [
./base.nix
./recommended-plugins.nix
];
input = {
leader = lib.mkDefault ",";
localLeader = lib.mkDefault "'";
};
plugins.gitsigns.keymap.set = [
rec {
mode = "n";
lhs = "]h";
rhs = lambda0 (ifelse (var "vim.wo.diff")
(call1 "vim.cmd.normal" [ lhs (nf "bang" true) ])
(call1 "${gs}.nav_hunk" "next")
);
}
rec {
mode = "n";
lhs = "[h";
rhs = lambda0 (ifelse (var "vim.wo.diff")
(call1 "vim.cmd.normal" [ lhs (nf "bang" true) ])
(call1 "${gs}.nav_hunk" "prev")
);
}
2024-05-08 01:30:47 +03:00
{ mode = "n"; lhs = localLeader "gs"; rhs = raw "${gs}.stage_hunk"; }
{ mode = "n"; lhs = localLeader "gS"; rhs = raw "${gs}.stage_buffer"; }
2024-05-08 01:30:47 +03:00
{ mode = "n"; lhs = localLeader "gr"; rhs = raw "${gs}.reset_hunk"; }
{ mode = "n"; lhs = localLeader "gR"; rhs = raw "${gs}.reset_buffer"; }
2024-05-08 01:30:47 +03:00
{ mode = "n"; lhs = localLeader "gu"; rhs = raw "${gs}.undo_stage_hunk"; }
{ mode = "n"; lhs = localLeader "gp"; rhs = raw "${gs}.preview_hunk"; }
{ mode = "n"; lhs = localLeader "gb"; rhs = lambda0 (call "${gs}.blame_line" { full = true; }); }
{ mode = "n"; lhs = localLeader "gd"; rhs = raw "${gs}.diffthis"; }
{ mode = "n"; lhs = localLeader "gD"; rhs = lambda0 (call "${gs}.diffthis" "~"); }
{ mode = "n"; lhs = localLeader "gtb"; rhs = raw "${gs}.toggle_current_line_blame"; }
{ mode = "n"; lhs = localLeader "gtd"; rhs = raw "${gs}.toggle_deleted"; }
2024-05-08 01:11:48 +03:00
];
plugins.navigation.hop-nvim.keymap.set = { after, before }: [
2024-05-08 01:30:47 +03:00
{ lhs = leader "hc"; rhs = cmd "HopChar1"; }
2024-05-08 01:11:48 +03:00
{
2024-05-08 01:30:47 +03:00
lhs = leader "hf";
2024-05-08 01:11:48 +03:00
rhs = lambda0 (call "${hop}.hint_char1" {
direction = after;
current_line_only = true;
});
}
{
2024-05-08 01:30:47 +03:00
lhs = leader "hF";
2024-05-08 01:11:48 +03:00
rhs = lambda0 (call "${hop}.hint_char1" {
direction = before;
current_line_only = true;
});
}
{
2024-05-08 01:30:47 +03:00
lhs = leader "hbc";
2024-05-08 01:11:48 +03:00
rhs = lambda0 (call "${hop}.hint_char1" { direction = after; });
}
{
2024-05-08 01:30:47 +03:00
lhs = leader "htc";
2024-05-08 01:11:48 +03:00
rhs = lambda0 (call "${hop}.hint_char1" { direction = before; });
}
2024-05-08 01:30:47 +03:00
{ lhs = leader "hw"; rhs = cmd "HopWord"; }
2024-05-08 01:11:48 +03:00
{
2024-05-08 01:30:47 +03:00
lhs = leader "hbw";
2024-05-08 01:11:48 +03:00
rhs = lambda0 (call "${hop}.hint_words" { direction = after; });
}
{
2024-05-08 01:30:47 +03:00
lhs = leader "htw";
2024-05-08 01:11:48 +03:00
rhs = lambda0 (call "${hop}.hint_words" { direction = before; });
}
2024-05-08 01:30:47 +03:00
{ lhs = leader "hp"; rhs = cmd "HopPattern"; }
2024-05-08 01:11:48 +03:00
{
2024-05-08 01:30:47 +03:00
lhs = leader "hbp";
2024-05-08 01:11:48 +03:00
rhs = lambda0 (call "${hop}.hint_patterns" { direction = after; });
}
{
2024-05-08 01:30:47 +03:00
lhs = leader "htp";
2024-05-08 01:11:48 +03:00
rhs = lambda0 (call "${hop}.hint_patterns" { direction = before; });
}
{
2024-05-08 01:30:47 +03:00
lhs = leader "hbv";
2024-05-08 01:11:48 +03:00
rhs = lambda0 (call "${hop}.hint_vertical" { direction = after; });
}
{
2024-05-08 01:30:47 +03:00
lhs = leader "htv";
2024-05-08 01:11:48 +03:00
rhs = lambda0 (call "${hop}.hint_vertical" { direction = before; });
}
];
plugins.language-server.lspconfig.keymap.set = [
{ mode = "n"; lhs = "gD"; rhs = raw "vim.lsp.buf.declaration"; }
{ mode = "n"; lhs = "gd"; rhs = raw "vim.lsp.buf.definition"; }
{ mode = "n"; lhs = "K"; rhs = raw "vim.lsp.buf.hover"; }
{ mode = "n"; lhs = "gi"; rhs = raw "vim.lsp.buf.implementation"; }
{ mode = "n"; lhs = "gr"; rhs = raw "vim.lsp.buf.references"; }
{ mode = "n"; lhs = "gy"; rhs = raw "vim.lsp.buf.type_definition"; }
{ mode = "n"; lhs = localLeader "sh"; rhs = raw "vim.lsp.buf.signature_help"; }
2024-05-08 01:30:47 +03:00
{ mode = "n"; lhs = localLeader "n"; rhs = raw "vim.lsp.buf.rename"; }
{ mode = [ "n" "v" ]; lhs = localLeader "a"; rhs = raw "vim.lsp.buf.code_action"; }
2024-05-08 01:11:48 +03:00
];
vim.keymap.set = lib.optionals config.plugins.language-server.lspconfig.enable [
{ mode = "n"; lhs = localLeader "df"; rhs = raw "vim.diagnostic.open_float"; }
2024-05-08 01:11:48 +03:00
{ mode = "n"; lhs = "[d"; rhs = raw "vim.diagnostic.goto_prev"; }
{ mode = "n"; lhs = "]d"; rhs = raw "vim.diagnostic.goto_next"; }
{ mode = "n"; lhs = localLeader "dl"; rhs = raw "vim.diagnostic.setloclist"; }
2024-05-08 01:11:48 +03:00
] ++ lib.optionals config.plugins.navigation.telescope.enable (
[
2024-05-08 01:30:47 +03:00
{ mode = "n"; lhs = leader "ff"; rhs = cmd "Telescope find_files"; }
{ mode = "n"; lhs = leader "fb"; rhs = cmd "Telescope buffers"; }
{ mode = "n"; lhs = leader "fh"; rhs = cmd "Telescope help_tags"; }
2024-05-08 01:11:48 +03:00
] ++ lib.optionals (config.plugins.navigation.telescope.extensions ? telescope-live-grep-args-nvim) [
{
mode = "n";
2024-05-08 01:30:47 +03:00
lhs = leader "fg";
rhs = lambda0 (pipe [
config.plugin.telescope-nvim.var
"extensions"
"live_grep_args"
(call0 "live_grep_args")
]);
}
]
) ++ lib.optionals config.plugins.snippet.luasnip.enable (
2024-05-21 01:45:23 +03:00
let
ls = pipe1 config.plugin.luasnip.var;
jump = dir: (if' (ls (call "locally_jumpable" dir)) (ls (call "jump" dir)));
in
[
{ mode = "i"; lhs = ctrl "K"; rhs = lambda0 (ls (call0 "expand")); silent = true; }
2024-05-21 01:45:23 +03:00
{ mode = [ "i" "s" ]; lhs = ctrl "L"; rhs = lambda0 (jump 1); silent = true; }
{ mode = [ "i" "s" ]; lhs = ctrl "H"; rhs = lambda0 (jump (-1)); silent = true; }
{
mode = [ "i" "s" ];
lhs = ctrl "E";
rhs = lambda0 (if' (ls (call0 "choice_active")) (ls (call "change_choice" 1)));
silent = true;
2024-05-08 01:11:48 +03:00
}
]
);
}