83 lines
1.7 KiB
Nix
83 lines
1.7 KiB
Nix
{ lib }:
|
|
|
|
let
|
|
inherit (builtins) listToAttrs;
|
|
inherit (lib) nameValuePair removePrefix removeSuffix;
|
|
|
|
wrap = val: "<${val}>";
|
|
unwrap = val: removePrefix "<" (removeSuffix ">" val);
|
|
|
|
char = num: wrap "Char-${num}"; # map a character by its decimal, octal or hexadecimal number
|
|
shift = key: wrap "S-${unwrap key}"; # shift-key *shift* *<S-*
|
|
ctrl = key: wrap "C-${unwrap key}"; # control-key *control* *ctrl* *<C-*
|
|
meta = key: wrap "M-${unwrap key}"; # alt-key or meta-key *META* *ALT* *<M-*
|
|
super = key: wrap "D-${unwrap key}"; # command-key or "super" key *<D-*
|
|
|
|
keys = listToAttrs (map (v: nameValuePair v (wrap 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;
|
|
|
|
cmd = expr: keys.Cmd + expr + keys.CR;
|
|
leader = expr: keys.Leader + expr;
|
|
localLeader = expr: keys.LocalLeader + expr;
|
|
space = expr: keys.Space + expr;
|
|
}
|