-
Notifications
You must be signed in to change notification settings - Fork 0
/
config.h
215 lines (156 loc) · 9.73 KB
/
config.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
#ifndef CONFIG_H
#define CONFIG_H
#define KEY_ARG_NONE { 0 }
#define MOTION_ARG_NONE { 0 }
const motionkey_t motion_keys[] = {
{ "w", { m_word, { .word_type = WORD_NONE }, M_EXCLUSIVE } },
{ "b", { m_word, { .word_type = WORD_BACKWARD }, M_EXCLUSIVE } },
{ "e", { m_word, { .word_type = WORD_END }, M_EXCLUSIVE } },
{ "ge", { m_word, { .word_type = WORD_END | WORD_BACKWARD }, M_EXCLUSIVE } },
{ "W", { m_word, { .word_type = WORD_SPACE }, M_EXCLUSIVE } },
{ "B", { m_word, { .word_type = WORD_BACKWARD | WORD_SPACE }, M_EXCLUSIVE } },
{ "E", { m_word, { .word_type = WORD_END | WORD_SPACE }, M_EXCLUSIVE } },
{ "gE", { m_word, { .word_type = WORD_END | WORD_BACKWARD | WORD_SPACE }, M_EXCLUSIVE } },
{ "j", { m_move, { .pos = { 0, 1 } }, M_LINEWISE } },
{ "k", { m_move, { .pos = { 0, -1 } }, M_LINEWISE } },
{ "h", { m_move, { .pos = { -1, 0 } }, M_EXCLUSIVE } },
{ "l", { m_move, { .pos = { 1, 0 } }, M_EXCLUSIVE } },
{ "{", { m_para, { .dir = -1 }, M_LINEWISE } },
{ "}", { m_para, { .dir = +1 }, M_LINEWISE } },
{ "%", { m_paren, { '%' }, M_NONE } },
{ "[[", { m_func, { .dir = -1, .scan_ch = '{' }, M_LINEWISE } },
{ "]]", { m_func, { .dir = +1, .scan_ch = '{' }, M_LINEWISE } },
{ "[#", { m_func, { .dir = -1, .scan_ch = '#' }, M_LINEWISE } },
{ "]#", { m_func, { .dir = +1, .scan_ch = '#' }, M_LINEWISE } },
{ "[{", { m_paren, { '{' }, M_LINEWISE } },
{ "[(", { m_paren, { '(' }, M_LINEWISE } },
{ "]}", { m_paren, { '}' }, M_LINEWISE } },
{ "])", { m_paren, { ')' }, M_LINEWISE } },
{ "f", { m_find, { .find_type = 0 }, M_NONE } },
{ "F", { m_find, { .find_type = F_REV }, M_NONE } },
{ "t", { m_find, { .find_type = F_TIL }, M_NONE } },
{ "T", { m_find, { .find_type = F_REV | F_TIL }, M_NONE } },
{ ";", { m_findnext, { .find_type = 0 }, M_NONE } },
{ ",", { m_findnext, { .find_type = F_REV }, M_NONE } },
{ "0", { m_goto, { .pos = { 0, -1 } }, M_EXCLUSIVE } },
{ "^", { m_sol, MOTION_ARG_NONE, M_EXCLUSIVE } },
{ "|", { m_col, MOTION_ARG_NONE, M_NONE } },
{ "$", { m_eol, { 0 }, M_NONE } },
{ "g_", { m_eol, { 1 }, M_NONE } },
{ "gg", { m_sof, MOTION_ARG_NONE, M_LINEWISE } },
{ "G", { m_eof, MOTION_ARG_NONE, M_LINEWISE } },
{ "H", { m_sos, MOTION_ARG_NONE, M_LINEWISE } },
{ "M", { m_mos, MOTION_ARG_NONE, M_LINEWISE } },
{ "L", { m_eos, MOTION_ARG_NONE, M_LINEWISE } },
{ "/", { m_search, { +1 }, M_EXCLUSIVE } },
{ "?", { m_search, { -1 }, M_EXCLUSIVE } },
{ "n", { m_searchnext, { +1 }, M_EXCLUSIVE } },
{ "N", { m_searchnext, { -1 }, M_EXCLUSIVE } },
};
const size_t motion_keys_cnt = sizeof motion_keys / sizeof *motion_keys;
#define K_STR(k) (char[]){ k, 0 }
const nkey_t nkeys[] = {
/* order is important */
/* char, func, arg, mode */
{ K_STR(K_ESC), k_escape, KEY_ARG_NONE, UI_INSERT_ANY | UI_VISUAL_ANY },
{ "i", k_set_mode, { UI_INSERT }, UI_NORMAL },
{ "V", k_set_mode, { UI_VISUAL_LN }, UI_NORMAL | UI_VISUAL_ANY },
{ "v", k_set_mode, { UI_VISUAL_CHAR }, UI_NORMAL | UI_VISUAL_ANY },
{ K_STR(CTRL_AND('v')), k_set_mode, { UI_VISUAL_COL }, UI_NORMAL | UI_VISUAL_ANY },
{ "o", k_open, { 1 }, UI_NORMAL },
{ "O", k_open, { -1 }, UI_NORMAL },
{ "o", k_vtoggle, { 0 }, UI_VISUAL_ANY },
{ "O", k_vtoggle, { 1 }, UI_VISUAL_ANY },
{ "d", k_del, KEY_ARG_NONE, UI_NORMAL | UI_VISUAL_ANY },
{ "c", k_change, KEY_ARG_NONE, UI_NORMAL | UI_VISUAL_ANY },
{ "y", k_yank, KEY_ARG_NONE, UI_NORMAL | UI_VISUAL_ANY },
{ "p", k_put, { false }, UI_NORMAL | UI_VISUAL_ANY },
{ "P", k_put, { true }, UI_NORMAL | UI_VISUAL_ANY },
{ "J", k_join, { .b = true }, UI_NORMAL | UI_VISUAL_ANY },
{ "gJ", k_join, { .b = false }, UI_NORMAL | UI_VISUAL_ANY },
{ ">", k_indent, { +1 }, UI_NORMAL | UI_VISUAL_ANY },
{ "<", k_indent, { -1 }, UI_NORMAL | UI_VISUAL_ANY },
/* TODO: visual replace */
{ "r", k_replace, { 0 }, UI_NORMAL | UI_VISUAL_ANY },
{ "R", /* TODO */ k_replace, { 1 }, UI_NORMAL },
{ ":", k_prompt_cmd, KEY_ARG_NONE, UI_NORMAL | UI_VISUAL_ANY }, /* k_set_mode instead? */
{ "!", k_filter, { .filter = { FILTER_CMD, NULL }}, UI_NORMAL | UI_VISUAL_ANY },
{ "g!", k_filter, { .filter.type = FILTER_SELF }, UI_NORMAL | UI_VISUAL_ANY },
{ "gq", k_filter, { .filter = { FILTER_CMD, "fmt" }}, UI_NORMAL | UI_VISUAL_ANY },
{ "gi", k_go_insert, KEY_ARG_NONE, UI_NORMAL },
{ "~", k_case, { CASE_TOGGLE }, UI_NORMAL | UI_VISUAL_ANY },
{ "gU", k_case, { CASE_UPPER }, UI_NORMAL | UI_VISUAL_ANY },
{ "gu", k_case, { CASE_LOWER }, UI_NORMAL | UI_VISUAL_ANY },
{ "gv", k_go_visual, KEY_ARG_NONE, UI_NORMAL },
{ "*", k_on_word, { .word_action = { word_search, false } }, UI_NORMAL | UI_VISUAL_ANY },
{ "#", k_on_word, { .word_action = { word_search, true } }, UI_NORMAL | UI_VISUAL_ANY },
{ "[i", k_on_word, { .word_action = { word_list, false } }, UI_NORMAL | UI_VISUAL_ANY },
{ "[I", k_on_word, { .word_action = { word_list, true } }, UI_NORMAL | UI_VISUAL_ANY },
{ K_STR(CTRL_AND(']')), k_on_word, { .word_action = { word_tag } }, UI_NORMAL },
{ "K", k_on_word, { .word_action = { word_man } }, UI_NORMAL | UI_VISUAL_ANY },
{ "gf", k_on_fname, { .word_action = { word_gofile, false } }, UI_NORMAL | UI_VISUAL_ANY },
{ (char []){ CTRL_AND('w'), 'f', 0 }, k_on_fname, { .word_action = { word_gofile, true } }, UI_NORMAL | UI_VISUAL_ANY },
{ "gt", k_go_tab, { .pos.x = +1 }, UI_NORMAL | UI_VISUAL_ANY },
{ "gT", k_go_tab, { .pos.x = -1 }, UI_NORMAL | UI_VISUAL_ANY },
{ K_STR(CTRL_AND('l')), k_redraw, KEY_ARG_NONE, UI_NORMAL | UI_VISUAL_ANY },
{ K_STR(CTRL_AND('e')), k_scroll, { .pos = { 0, 2 } }, UI_NORMAL | UI_VISUAL_ANY },
{ K_STR(CTRL_AND('y')), k_scroll, { .pos = { 0, -2 } }, UI_NORMAL | UI_VISUAL_ANY },
{ K_STR(CTRL_AND('f')), k_jumpscroll, { +2 }, UI_NORMAL | UI_VISUAL_ANY },
{ K_STR(CTRL_AND('b')), k_jumpscroll, { -2 }, UI_NORMAL | UI_VISUAL_ANY },
{ K_STR(CTRL_AND('d')), k_jumpscroll, { +1 }, UI_NORMAL | UI_VISUAL_ANY },
{ K_STR(CTRL_AND('u')), k_jumpscroll, { -1 }, UI_NORMAL | UI_VISUAL_ANY },
{ "zz", k_scroll, { .pos = { 1, 0 } }, UI_NORMAL | UI_VISUAL_ANY },
{ "zt", k_scroll, { .pos = { 1, -1 } }, UI_NORMAL | UI_VISUAL_ANY },
{ "zb", k_scroll, { .pos = { 1, +1 } }, UI_NORMAL | UI_VISUAL_ANY },
{ (char[]){ CTRL_AND('w'), 'h', 0 }, k_winsel, { .pos.x = -1 }, UI_NORMAL | UI_VISUAL_ANY },
{ (char[]){ CTRL_AND('w'), 'l', 0 }, k_winsel, { .pos.x = +1 }, UI_NORMAL | UI_VISUAL_ANY },
{ (char[]){ CTRL_AND('w'), 'j', 0 }, k_winsel, { .pos.y = +1 }, UI_NORMAL | UI_VISUAL_ANY },
{ (char[]){ CTRL_AND('w'), 'k', 0 }, k_winsel, { .pos.y = -1 }, UI_NORMAL | UI_VISUAL_ANY },
{ (char[]){ CTRL_AND('w'), 'H', 0 }, k_winmove, { .pos.x = -1 }, UI_NORMAL | UI_VISUAL_ANY },
{ (char[]){ CTRL_AND('w'), 'L', 0 }, k_winmove, { .pos.x = +1 }, UI_NORMAL | UI_VISUAL_ANY },
{ (char[]){ CTRL_AND('w'), 'J', 0 }, k_winmove, { .pos.y = +1 }, UI_NORMAL | UI_VISUAL_ANY },
{ (char[]){ CTRL_AND('w'), 'K', 0 }, k_winmove, { .pos.y = -1 }, UI_NORMAL | UI_VISUAL_ANY },
{ (char[]){ CTRL_AND('w'), 't', 0 }, k_winabsolute, { .pos.x = -1 }, UI_NORMAL | UI_VISUAL_ANY },
{ (char[]){ CTRL_AND('w'), 'b', 0 }, k_winabsolute, { .pos.x = +1 }, UI_NORMAL | UI_VISUAL_ANY },
{ K_STR(CTRL_AND('g')), k_show, KEY_ARG_NONE, UI_NORMAL | UI_VISUAL_ANY },
{ K_STR(CTRL_AND('y')), k_ins_colcopy, { -1 }, UI_INSERT_ANY },
{ K_STR(CTRL_AND('e')), k_ins_colcopy, { +1 }, UI_INSERT_ANY },
{ "I", k_set_mode, { UI_INSERT_COL }, UI_VISUAL_COL },
{ K_STR(CTRL_AND('o')), k_normal1, KEY_ARG_NONE, UI_INSERT /* !INSERT_ANY */ },
{ "ZZ", k_docmd, { .cmd = { .argv = (const char *[]){ "ZZ", NULL }, .fn = { .arg0 = "ZZ", .f_argv = c_x, } } }, UI_NORMAL | UI_VISUAL_ANY },
{ "ZQ", k_docmd, { .cmd = { .argv = (const char *[]){ "ZQ", NULL }, .fn = { .arg0 = "ZQ", .f_argv = c_q, .inverse = true } } }, UI_NORMAL | UI_VISUAL_ANY },
{ K_STR(CTRL_AND('a')), k_inc_dec, { +1 }, UI_NORMAL },
{ K_STR(CTRL_AND('x')), k_inc_dec, { -1 }, UI_NORMAL },
{ "ga", k_showch, KEY_ARG_NONE, UI_NORMAL | UI_VISUAL_ANY },
/* leaders: */
{ "\\x", k_docmd, { .cmd = { .argv = (const char *[]){ "r", "xselo", NULL }, .fn = { .f_arg1 = c_r, .single_arg = true, .inverse = true } } }, UI_NORMAL },
};
const size_t nkeys_cnt = sizeof nkeys / sizeof *nkeys;
const keymap_t maps[] = {
{ IO_MAP, 'I', "^i" },
{ IO_MAP, 'a', "li" },
{ IO_MAP, 'A', "$li" }, /* remap not allowed, hence "$a" wouldn't work */
{ IO_MAP, '\r', "j^" },
{ IO_MAP, 'C', "c$" },
{ IO_MAP, 'D', "d$" },
{ IO_MAPV, 'C', "c" },
{ IO_MAPV, 'D', "d" },
/* TODO: delete command needs to handle count */
{ IO_MAP, 'x', "dl" },
{ IO_MAP, 'X', "dh" },
{ IO_MAPV, 'x', "d" },
{ IO_MAPV, 'X', "d" },
/* TODO: change command needs to handle count */
{ IO_MAP, 's', "cl" },
{ IO_MAP, 'S', "0c$" },
{ IO_MAPV, 's', "c" },
/* insert mode keys - ^U, ^K and ^W */
{ IO_MAPI, CTRL_AND('U'), (char[]){ CTRL_AND('o'), 'd', '0', 0 } },
{ IO_MAPI, CTRL_AND('K'), (char[]){ CTRL_AND('o'), 'd', '$', 0 } },
{ IO_MAPI, CTRL_AND('W'), (char[]){ CTRL_AND('o'), 'd', 'b', 0 } },
{ IO_MAP, 'Y', "y$" },
{ IO_MAPV, 'Y', "y" },
{ IO_MAPV, 'R', "c" },
{ 0 }
};
#endif