{ config, lib, ... }: { programs.nixvim = { globals = { mapleader = " "; maplocalleader = " "; }; keymaps = let normal = lib.mapAttrsToList (key: action: { mode = "n"; inherit action key; }) { # "" = " %y+ "; "" = "p"; "" = "%y"; "" = ""; # Esc to clear search results "" = ":noh"; # fix Y behaviour Y = "y$"; # back and fourth between the two most recent files "" = ":b#"; # close by Ctrl+x "" = ":close"; # save by Space+s or Ctrl+s "s" = ":w"; "" = ":w"; # navigate to left/right window "h" = "h"; "l" = "l"; # Press 'H', 'L' to jump to start/end of a line (first/last character) L = "$"; H = "^"; # resize with arrows "" = ":resize -2"; "" = ":resize +2"; "" = ":vertical resize +2"; "" = ":vertical resize -2"; # move current line up/down # M = Alt key "" = ":move-2"; "" = ":move+"; "rp" = ":!remi push"; }; visual = lib.mapAttrsToList (key: action: { mode = "v"; inherit action key; }) { "" = "y"; # better indenting ">" = ">gv"; "<" = "" = ">gv"; "" = "" = "p"; }; in config.nixvim.helpers.keymaps.mkKeymaps {options.silent = true;} (normal ++ visual ++ insert); }; }