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