nixeovim/lib/mod.nix

77 lines
1.4 KiB
Nix

{ lib }:
let
inherit (builtins) listToAttrs;
inherit (lib) nameValuePair toLower;
wrap = val: "<${val}>";
char = num: wrap "Char-${num}"; # map a character by its decimal, octal or hexadecimal number
shift = key: wrap "S-${key}"; # shift-key *shift* *<S-*
ctrl = key: wrap "C-${key}"; # control-key *control* *ctrl* *<C-*
meta = key: wrap "M-${key}"; # alt-key or meta-key *META* *ALT* *<M-*
super = key: wrap "D-${key}"; # command-key or "super" key *<D-*
keys = listToAttrs (map (v: nameValuePair v (wrap (toLower v))) (
[
"leader"
"localLeader"
"cmd"
"plug"
"mouseMove"
"nul"
"bs"
"tab"
"nl"
"cr"
"esc"
"space"
"lt"
"bslash"
"bar"
"del"
"csi"
"eol"
"ignore"
"nop"
"up"
"down"
"left"
"right"
"help"
"undo"
"insert"
"home"
"end"
"pageUp"
"pageDown"
"kUp"
"kDown"
"kLeft"
"kRight"
"kHome"
"kEnd"
"kOrigin"
"kPageUp"
"kPageDown"
"kDel"
"kPlus"
"kMinus"
"kMultiply"
"kDivide"
"kPoint"
"kComma"
"kEqual"
"kEnter"
]
++ map (n: "F${toString n}") (lib.range 1 12)
++ map (n: "k${toString n}") (lib.range 0 9)
)
);
in
{ inherit char shift ctrl meta super; } // keys // {
return = keys.cr;
enter = keys.cr;
backslash = keys.bslash;
}