refactor
This commit is contained in:
94
modules/home/devtools/nixvim/keymap.nix
Normal file
94
modules/home/devtools/nixvim/keymap.nix
Normal file
@@ -0,0 +1,94 @@
|
||||
{
|
||||
config,
|
||||
lib,
|
||||
...
|
||||
}: {
|
||||
programs.nixvim = {
|
||||
globals = {
|
||||
mapleader = " ";
|
||||
maplocalleader = " ";
|
||||
};
|
||||
|
||||
keymaps = let
|
||||
normal =
|
||||
lib.mapAttrsToList
|
||||
(key: action: {
|
||||
mode = "n";
|
||||
inherit action key;
|
||||
})
|
||||
{
|
||||
# "<C-c>" = "<cmd> %y+ <CR>";
|
||||
"<C-v>" = "p";
|
||||
"<C-a>" = "ggVG";
|
||||
"<Space>" = "<NOP>";
|
||||
|
||||
# Esc to clear search results
|
||||
"<esc>" = ":noh<CR>";
|
||||
|
||||
# fix Y behaviour
|
||||
Y = "y$";
|
||||
|
||||
# back and fourth between the two most recent files
|
||||
"<C-c>" = ":b#<CR>";
|
||||
|
||||
# close by Ctrl+x
|
||||
"<C-x>" = ":close<CR>";
|
||||
|
||||
# save by Space+s or Ctrl+s
|
||||
"<leader>s" = ":w<CR>";
|
||||
"<C-s>" = ":w<CR>";
|
||||
|
||||
# navigate to left/right window
|
||||
"<leader>h" = "<C-w>h";
|
||||
"<leader>l" = "<C-w>l";
|
||||
|
||||
# Press 'H', 'L' to jump to start/end of a line (first/last character)
|
||||
L = "$";
|
||||
H = "^";
|
||||
|
||||
# resize with arrows
|
||||
"<C-Up>" = ":resize -2<CR>";
|
||||
"<C-Down>" = ":resize +2<CR>";
|
||||
"<C-Left>" = ":vertical resize +2<CR>";
|
||||
"<C-Right>" = ":vertical resize -2<CR>";
|
||||
|
||||
# move current line up/down
|
||||
# M = Alt key
|
||||
"<M-k>" = ":move-2<CR>";
|
||||
"<M-j>" = ":move+<CR>";
|
||||
|
||||
"<leader>rp" = ":!remi push<CR>";
|
||||
};
|
||||
visual =
|
||||
lib.mapAttrsToList
|
||||
(key: action: {
|
||||
mode = "v";
|
||||
inherit action key;
|
||||
})
|
||||
{
|
||||
"<C-c>" = "y";
|
||||
# better indenting
|
||||
">" = ">gv";
|
||||
"<" = "<gv";
|
||||
"<TAB>" = ">gv";
|
||||
"<S-TAB>" = "<gv";
|
||||
|
||||
# move selected line / block of text in visual mode
|
||||
"K" = ":m '<-2<CR>gv=gv";
|
||||
"J" = ":m '>+1<CR>gv=gv";
|
||||
};
|
||||
insert =
|
||||
lib.mapAttrsToList
|
||||
(key: action: {
|
||||
mode = "i";
|
||||
inherit action key;
|
||||
})
|
||||
{
|
||||
"<C-v>" = "<esc>p";
|
||||
};
|
||||
in
|
||||
config.lib.nixvim.keymaps.mkKeymaps
|
||||
{options.silent = true;}
|
||||
(normal ++ visual ++ insert);
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user