Nix-Hyprland/nixos/modules/nixvim/keymaps.nix

69 lines
1.6 KiB
Nix
Raw Normal View History

2024-04-18 00:51:55 -04:00
{ config, lib, ... }: {
2024-04-16 20:52:14 -04:00
programs.nixvim = {
globals = {
mapleader = "\\";
maplocalleader = "\\";
};
2024-04-18 00:51:55 -04:00
keymaps = let
normal =
lib.mapAttrsToList
(key: action: {
mode = "n";
inherit action key;
})
{
# Open Neotree
"<leader>n" = ":Neotree<CR>";
# 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 \+s or Ctrl+s
"<leader>s" = ":w<CR>";
"<C-s>" = ":w<CR>";
# navigate windows
"<leader>h" = "<C-w>h";
"<leader>j" = "<C-w>j";
"<leader>k" = "<C-w>k";
"<leader>l" = "<C-w>l";
# 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>";
};
visual =
lib.mapAttrsToList
(key: action: {
mode = "v";
inherit action key;
})
{
# move selected line / block of text in visual mode
"K" = ":m '<-2<CR>gv=gv";
"J" = ":m '>+1<CR>gv=gv";
};
in
config.nixvim.helpers.keymaps.mkKeymaps
{options.silent = true;}
(normal ++ visual);
2024-04-16 20:52:14 -04:00
};
}