nixeovim/lib/mod.nix

82 lines
1.5 KiB
Nix
Raw Normal View History

2024-05-08 01:06:31 +03:00
{ lib }:
let
inherit (builtins) listToAttrs;
2024-05-08 01:30:47 +03:00
inherit (lib) nameValuePair;
2024-05-08 01:06:31 +03:00
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-*
2024-05-08 01:30:47 +03:00
keys = listToAttrs (map (v: nameValuePair v (wrap v)) (
2024-05-08 01:06:31 +03:00
[
2024-05-08 01:30:47 +03:00
"Leader"
"LocalLeader"
"Cmd"
"Plug"
"MouseMove"
2024-05-08 01:06:31 +03:00
2024-05-08 01:30:47 +03:00
"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"
2024-05-08 01:06:31 +03:00
"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;
2024-05-08 01:30:47 +03:00
cmd = expr: keys.Cmd + expr + keys.Cr;
leader = expr: keys.Leader + expr;
localLeader = expr: keys.LocalLeader + expr;
2024-05-08 01:06:31 +03:00
}