@@ -0,0 +1,116 @@
1+use crossterm::event::{KeyEvent as Key, KeyModifiers as Modifiers};
2+use helix_core::commands::{self, Command};
3+use std::collections::HashMap;
4+
5+// Kakoune-inspired:
6+// mode = {
7+// normal = {
8+// q = record_macro
9+// w = (next) word
10+// e = end of word
11+// r =
12+// t = 'till char
13+// y = yank
14+// u = undo
15+// U = redo
16+// i = insert
17+// I = INSERT (start of line)
18+// o = open below (insert on new line below)
19+// O = open above (insert on new line above)
20+// p = paste (before cursor)
21+// P = PASTE (after cursor)
22+// ` =
23+// [ = select to text object start (alt = select whole object)
24+// ] = select to text object end
25+// { = extend to inner object start
26+// } = extend to inner object end
27+// a = append
28+// A = APPEND (end of line)
29+// s = split
30+// S = select
31+// d = delete()
32+// f = find_char()
33+// g = goto (gg, G, gc, gd, etc)
34+//
35+// h = move_char_left(n)
36+// j = move_line_down(n)
37+// k = move_line_up(n)
38+// l = move_char_right(n)
39+// : = command line
40+// ; = collapse selection to cursor
41+// " = use register
42+// ` = convert case? (to lower) (alt = swap case)
43+// ~ = convert to upper case
44+// . = repeat last command
45+// \ = disable hook?
46+// / = search
47+// > = indent
48+// < = deindent
49+// % = select whole buffer (in vim = jump to matching bracket)
50+// * = search pattern in selection
51+// ( = rotate main selection backward
52+// ) = rotate main selection forward
53+// - = trim selections? (alt = merge contiguous sel together)
54+// @ = convert tabs to spaces
55+// & = align cursor
56+// ? = extend to next given regex match (alt = to prev)
57+//
58+// z = save selections
59+// Z = restore selections
60+// x = select line
61+// X = extend line
62+// c = change selected text
63+// C = copy selection?
64+// v = view menu (viewport manipulation)
65+// b = select to previous word start
66+// B = select to previous WORD start
67+//
68+//
69+//
70+//
71+//
72+//
73+// = = align?
74+// + =
75+// }
76+// }
77+
78+macro_rules! hashmap {
79+ (@single $($x:tt)*) => (());
80+ (@count $($rest:expr),*) => (<[()]>::len(&[$(hashmap!(@single $rest)),*]));
81+
82+ ($($key:expr => $value:expr,)+) => { hashmap!($($key => $value),+) };
83+ ($($key:expr => $value:expr),*) => {
84+ {
85+ let _cap = hashmap!(@count $($key),*);
86+ let mut _map = ::std::collections::HashMap::with_capacity(_cap);
87+ $(
88+ let _ = _map.insert($key, $value);
89+ )*
90+ _map
91+ }
92+ };
93+}
94+
95+type Keymap = HashMap<Key, Command>;
96+
97+fn default() -> Keymap {
98+ hashmap!(
99+ Key {
100+ code: "h",
101+ modifiers: Modifiers::NONE
102+ } => commands::move_char_left,
103+ Key {
104+ code: "j",
105+ modifiers: Modifiers::NONE
106+ } => commands::move_line_down,
107+ Key {
108+ code: "k",
109+ modifiers: Modifiers::NONE
110+ } => commands::move_line_up,
111+ Key {
112+ code: "l",
113+ modifiers: Modifiers::NONE
114+ } => commands::move_char_right,
115+ );
116+}