vis: prefix enum VisMotion values with VIS_
[vis.git] / config.def.h
blobf47034bf168a329eba8233d821cbea96ccae3f4a
1 /** configure your desired default key bindings */
2 #define ALIAS(name) .alias = name,
3 #define ACTION(id) .action = &vis_action[VIS_ACTION_##id],
5 static KeyBinding basic_movement[] = {
6 { "<C-z>", ACTION(EDITOR_SUSPEND) },
7 { "<Left>", ACTION(CURSOR_CHAR_PREV) },
8 { "<S-Left>", ACTION(CURSOR_LONGWORD_START_PREV) },
9 { "<Right>", ACTION(CURSOR_CHAR_NEXT) },
10 { "<S-Right>", ACTION(CURSOR_LONGWORD_START_NEXT) },
11 { "<Up>", ACTION(CURSOR_LINE_UP) },
12 { "<Down>", ACTION(CURSOR_LINE_DOWN) },
13 { "<PageUp>", ACTION(WINDOW_PAGE_UP) },
14 { "<PageDown>", ACTION(WINDOW_PAGE_DOWN) },
15 { "<S-PageUp>", ACTION(WINDOW_HALFPAGE_UP) },
16 { "<S-PageDown>", ACTION(WINDOW_HALFPAGE_DOWN) },
17 { "<Home>", ACTION(CURSOR_LINE_BEGIN) },
18 { "<End>", ACTION(CURSOR_LINE_END) },
19 { /* empty last element, array terminator */ },
22 static KeyBinding vis_movements[] = {
23 { "h", ACTION(CURSOR_CHAR_PREV) },
24 { "<Backspace>", ALIAS("h") },
25 { "<C-h>", ALIAS("<Backspace>") },
26 { "l", ACTION(CURSOR_CHAR_NEXT) },
27 { " ", ALIAS("l") },
28 { "k", ACTION(CURSOR_LINE_UP) },
29 { "C-p", ALIAS("k") },
30 { "j", ACTION(CURSOR_LINE_DOWN) },
31 { "<C-j>", ALIAS("j") },
32 { "<C-n>", ALIAS("j") },
33 { "<Enter>", ALIAS("j") },
34 { "gk", ACTION(CURSOR_SCREEN_LINE_UP) },
35 { "g<Up>", ALIAS("gk") },
36 { "gj", ACTION(CURSOR_SCREEN_LINE_DOWN) },
37 { "g<Down>", ALIAS("gj") },
38 { "^", ACTION(CURSOR_LINE_START) },
39 { "g_", ACTION(CURSOR_LINE_FINISH) },
40 { "$", ACTION(CURSOR_LINE_END) },
41 { "%", ACTION(CURSOR_BRACKET_MATCH) },
42 { "b", ACTION(CURSOR_WORD_START_PREV) },
43 { "B", ACTION(CURSOR_LONGWORD_START_PREV) },
44 { "w", ACTION(CURSOR_WORD_START_NEXT) },
45 { "W", ACTION(CURSOR_LONGWORD_START_NEXT) },
46 { "ge", ACTION(CURSOR_WORD_END_PREV) },
47 { "gE", ACTION(CURSOR_LONGWORD_END_PREV) },
48 { "e", ACTION(CURSOR_WORD_END_NEXT) },
49 { "E", ACTION(CURSOR_LONGWORD_END_NEXT) },
50 { "{", ACTION(CURSOR_PARAGRAPH_PREV) },
51 { "}", ACTION(CURSOR_PARAGRAPH_NEXT) },
52 { "(", ACTION(CURSOR_SENTENCE_PREV) },
53 { ")", ACTION(CURSOR_SENTENCE_NEXT) },
54 { "[[", ACTION(CURSOR_FUNCTION_START_PREV) },
55 { "[]", ACTION(CURSOR_FUNCTION_END_PREV) },
56 { "][", ACTION(CURSOR_FUNCTION_START_NEXT) },
57 { "]]", ACTION(CURSOR_FUNCTION_END_NEXT) },
58 { "gg", ACTION(CURSOR_LINE_FIRST) },
59 { "g0", ACTION(CURSOR_SCREEN_LINE_BEGIN) },
60 { "gm", ACTION(CURSOR_SCREEN_LINE_MIDDLE) },
61 { "g$", ACTION(CURSOR_SCREEN_LINE_END) },
62 { "G", ACTION(CURSOR_LINE_LAST) },
63 { "|", ACTION(CURSOR_COLUMN) },
64 { "n", ACTION(CURSOR_SEARCH_NEXT) },
65 { "N", ACTION(CURSOR_SEARCH_PREV) },
66 { "H", ACTION(CURSOR_WINDOW_LINE_TOP) },
67 { "M", ACTION(CURSOR_WINDOW_LINE_MIDDLE) },
68 { "L", ACTION(CURSOR_WINDOW_LINE_BOTTOM) },
69 { "*", ACTION(CURSOR_SEARCH_WORD_FORWARD) },
70 { "#", ACTION(CURSOR_SEARCH_WORD_BACKWARD) },
71 { "f", ACTION(TO_RIGHT) },
72 { "F", ACTION(TO_LEFT) },
73 { "t", ACTION(TILL_RIGHT) },
74 { "T", ACTION(TILL_LEFT) },
75 { ";", ACTION(TOTILL_REPEAT) },
76 { ",", ACTION(TOTILL_REVERSE) },
77 { "/", ACTION(PROMPT_SEARCH_FORWARD) },
78 { "?", ACTION(PROMPT_SEARCH_BACKWARD) },
79 { "`", ACTION(MARK_GOTO) },
80 { "'", ACTION(MARK_GOTO_LINE) },
81 { /* empty last element, array terminator */ },
84 static KeyBinding vis_textobjs[] = {
85 { "aw", ACTION(TEXT_OBJECT_WORD_OUTER) },
86 { "aW", ACTION(TEXT_OBJECT_LONGWORD_OUTER) },
87 { "as", ACTION(TEXT_OBJECT_SENTENCE) },
88 { "ap", ACTION(TEXT_OBJECT_PARAGRAPH) },
89 { "a[", ACTION(TEXT_OBJECT_SQUARE_BRACKET_OUTER) },
90 { "a]", ALIAS("a[") },
91 { "a(", ACTION(TEXT_OBJECT_PARANTHESE_OUTER) },
92 { "a)", ALIAS("a(") },
93 { "ab", ALIAS("a(") },
94 { "a<", ACTION(TEXT_OBJECT_ANGLE_BRACKET_OUTER) },
95 { "a>", ALIAS("a<") },
96 { "a{", ACTION(TEXT_OBJECT_CURLY_BRACKET_OUTER) },
97 { "a}", ALIAS("a{") },
98 { "aB", ALIAS("a{") },
99 { "a\"", ACTION(TEXT_OBJECT_QUOTE_OUTER) },
100 { "a\'", ACTION(TEXT_OBJECT_SINGLE_QUOTE_OUTER) },
101 { "a`", ACTION(TEXT_OBJECT_BACKTICK_OUTER) },
102 { "ae", ACTION(TEXT_OBJECT_ENTIRE_OUTER) },
103 { "af", ACTION(TEXT_OBJECT_FUNCTION_OUTER) },
104 { "al", ACTION(TEXT_OBJECT_LINE_OUTER) },
105 { "iw", ACTION(TEXT_OBJECT_WORD_INNER) },
106 { "iW", ACTION(TEXT_OBJECT_LONGWORD_INNER) },
107 { "is", ACTION(TEXT_OBJECT_SENTENCE) },
108 { "ip", ACTION(TEXT_OBJECT_PARAGRAPH) },
109 { "i[", ACTION(TEXT_OBJECT_SQUARE_BRACKET_INNER) },
110 { "i]", ALIAS("i[") },
111 { "i(", ACTION(TEXT_OBJECT_PARANTHESE_INNER) },
112 { "i)", ALIAS("i(") },
113 { "ib", ALIAS("ib") },
114 { "i<", ACTION(TEXT_OBJECT_ANGLE_BRACKET_INNER) },
115 { "i>", ALIAS("i<") },
116 { "i{", ACTION(TEXT_OBJECT_CURLY_BRACKET_INNER) },
117 { "i}", ALIAS("i{") },
118 { "iB", ALIAS("i{") },
119 { "i\"", ACTION(TEXT_OBJECT_QUOTE_INNER) },
120 { "i\'", ACTION(TEXT_OBJECT_SINGLE_QUOTE_INNER) },
121 { "i`", ACTION(TEXT_OBJECT_BACKTICK_INNER) },
122 { "ie", ACTION(TEXT_OBJECT_ENTIRE_INNER) },
123 { "if", ACTION(TEXT_OBJECT_FUNCTION_INNER) },
124 { "il", ACTION(TEXT_OBJECT_LINE_INNER) },
125 { /* empty last element, array terminator */ },
128 static KeyBinding vis_operators[] = {
129 { "0", ACTION(COUNT) },
130 { "1", ACTION(COUNT) },
131 { "2", ACTION(COUNT) },
132 { "3", ACTION(COUNT) },
133 { "4", ACTION(COUNT) },
134 { "5", ACTION(COUNT) },
135 { "6", ACTION(COUNT) },
136 { "7", ACTION(COUNT) },
137 { "8", ACTION(COUNT) },
138 { "9", ACTION(COUNT) },
139 { "d", ACTION(OPERATOR_DELETE) },
140 { "c", ACTION(OPERATOR_CHANGE) },
141 { "y", ACTION(OPERATOR_YANK) },
142 { "p", ACTION(PUT_AFTER) },
143 { "P", ACTION(PUT_BEFORE) },
144 { "gp", ACTION(PUT_AFTER_END) },
145 { "gP", ACTION(PUT_BEFORE_END) },
146 { ">", ACTION(OPERATOR_SHIFT_RIGHT) },
147 { "<", ACTION(OPERATOR_SHIFT_LEFT) },
148 { "gU", ACTION(OPERATOR_CASE_UPPER) },
149 { "~", ACTION(OPERATOR_CASE_SWAP) },
150 { "g~", ACTION(OPERATOR_CASE_SWAP) },
151 { "gu", ACTION(OPERATOR_CASE_LOWER) },
152 { "\"", ACTION(REGISTER) },
153 { /* empty last element, array terminator */ },
156 static KeyBinding vis_operator_options[] = {
157 { "v", ACTION(MOTION_CHARWISE) },
158 { "V", ACTION(MOTION_LINEWISE) },
159 { /* empty last element, array terminator */ },
162 static KeyBinding vis_mode_normal[] = {
163 { "<Escape>", ACTION(CURSORS_REMOVE_ALL) },
164 { "<Delete>", ALIAS("x") },
165 { "<C-k>", ACTION(CURSORS_NEW_LINE_ABOVE) },
166 { "<C-j>", ACTION(CURSORS_NEW_LINE_BELOW) },
167 { "<C-a>", ACTION(CURSORS_ALIGN) },
168 { "<C-n>", ACTION(CURSOR_SELECT_WORD) },
169 { "<C-p>", ACTION(CURSORS_REMOVE_LAST) },
170 { "<C-w>n", ALIAS(":open<Enter>") },
171 { "<C-w>c", ALIAS(":q<Enter>") },
172 { "<C-w>s", ALIAS(":split<Enter>") },
173 { "<C-w>v", ALIAS(":vsplit<Enter>") },
174 { "<C-w>j", ACTION(WINDOW_NEXT) },
175 { "<C-w>l", ALIAS("<C-w>j") },
176 { "<C-w><C-w>", ALIAS("<C-w>j") },
177 { "<C-w><C-j>", ALIAS("<C-w>j") },
178 { "<C-w><C-l>", ALIAS("<C-w>j") },
179 { "<C-w>k", ACTION(WINDOW_PREV) },
180 { "<C-w>h", ALIAS("<C-w>k") },
181 { "<C-w><C-h>", ALIAS("<C-w>k") },
182 { "<C-w><C-k>", ALIAS("<C-w>k") },
183 { "<C-w><Backspace>", ALIAS("<C-w>k") },
184 { "<C-b>", ALIAS("<PageUp>") },
185 { "<C-f>", ALIAS("<PageDown>") },
186 { "<C-u>", ALIAS("<S-PageUp>") },
187 { "<C-d>", ALIAS("<S-PageDown>") },
188 { "<C-e>", ACTION(WINDOW_SLIDE_UP) },
189 { "<C-y>", ACTION(WINDOW_SLIDE_DOWN) },
190 { "<C-o>", ACTION(JUMPLIST_PREV) },
191 { "<C-i>", ACTION(JUMPLIST_NEXT) },
192 { "g;", ACTION(CHANGELIST_PREV) },
193 { "g,", ACTION(CHANGELIST_NEXT) },
194 { "a", ACTION(APPEND_CHAR_NEXT) },
195 { "A", ACTION(APPEND_LINE_END) },
196 { "C", ALIAS("c$") },
197 { "D", ALIAS("d$") },
198 { "I", ACTION(INSERT_LINE_START) },
199 { ".", ACTION(REPEAT) },
200 { "o", ACTION(OPEN_LINE_BELOW) },
201 { "O", ACTION(OPEN_LINE_ABOVE) },
202 { "J", ACTION(JOIN_LINE_BELOW) },
203 { "x", ACTION(DELETE_CHAR_NEXT) },
204 { "r", ACTION(REPLACE_CHAR) },
205 { "i", ACTION(MODE_INSERT) },
206 { "v", ACTION(MODE_VISUAL) },
207 { "V", ACTION(MODE_VISUAL_LINE) },
208 { "R", ACTION(MODE_REPLACE) },
209 { "S", ALIAS("cc") },
210 { "s", ALIAS("cl") },
211 { "Y", ALIAS("yy") },
212 { "X", ALIAS("dh") },
213 { "u", ACTION(UNDO) },
214 { "<C-r>", ACTION(REDO) },
215 { "g+", ACTION(LATER) },
216 { "g-", ACTION(EARLIER) },
217 { "<C-l>", ACTION(REDRAW) },
218 { ":", ACTION(PROMPT_SHOW) },
219 { "ZZ", ALIAS(":wq<Enter>") },
220 { "ZQ", ALIAS(":q!<Enter>") },
221 { "zt", ACTION(WINDOW_REDRAW_TOP) },
222 { "zz", ACTION(WINDOW_REDRAW_CENTER) },
223 { "zb", ACTION(WINDOW_REDRAW_BOTTOM) },
224 { "q", ACTION(MACRO_RECORD) },
225 { "@", ACTION(MACRO_REPLAY) },
226 { "gv", ACTION(SELECTION_RESTORE) },
227 { "m", ACTION(MARK_SET) },
228 { /* empty last element, array terminator */ },
231 static KeyBinding vis_mode_visual[] = {
232 { "<C-n>", ACTION(CURSORS_NEW_MATCH_NEXT) },
233 { "<C-x>", ACTION(CURSORS_NEW_MATCH_SKIP) },
234 { "<C-p>", ACTION(CURSORS_REMOVE_LAST) },
235 { "I", ACTION(CURSORS_NEW_LINES_BEGIN) },
236 { "A", ACTION(CURSORS_NEW_LINES_END) },
237 { "<Backspace>", ALIAS("d") },
238 { "<C-h>", ALIAS("<Backspace>") },
239 { "<Delete>", ALIAS("<Backspace>") },
240 { "<Escape>", ACTION(MODE_NORMAL) },
241 { "<C-c>", ALIAS("<Escape>") },
242 { "v", ALIAS("<Escape>") },
243 { "V", ACTION(MODE_VISUAL_LINE) },
244 { ":", ACTION(PROMPT_SHOW_VISUAL) },
245 { "x", ALIAS("d") },
246 { "r", ALIAS("c") },
247 { "s", ALIAS("c") },
248 { "J", ACTION(JOIN_LINES) },
249 { "o", ACTION(SELECTION_FLIP) },
250 { /* empty last element, array terminator */ },
253 static KeyBinding vis_mode_visual_line[] = {
254 { "v", ACTION(MODE_VISUAL) },
255 { "V", ACTION(MODE_NORMAL) },
256 { /* empty last element, array terminator */ },
259 static KeyBinding vis_mode_readline[] = {
260 { "<Backspace>", ACTION(DELETE_CHAR_PREV) },
261 { "<C-h>", ALIAS("<Backspace>") },
262 { "<Delete>", ACTION(DELETE_CHAR_NEXT) },
263 { "<Escape>", ACTION(MODE_NORMAL) },
264 { "<C-c>", ALIAS("<Enter>") },
265 { "<C-d>", ACTION(DELETE_CHAR_NEXT) },
266 { "<C-w>", ACTION(DELETE_WORD_PREV) },
267 { "<C-u>", ACTION(DELETE_LINE_BEGIN) },
268 { /* empty last element, array terminator */ },
271 static KeyBinding vis_mode_prompt[] = {
272 { "<Backspace>", ACTION(PROMPT_BACKSPACE) },
273 { "<C-h>", ALIAS("<Backspace>") },
274 { "<Enter>", ACTION(PROMPT_ENTER) },
275 { "<C-j>", ALIAS("<Enter>") },
276 { "<Tab>", ACTION(NOP) },
277 { /* empty last element, array terminator */ },
280 static KeyBinding vis_mode_insert[] = {
281 { "<Escape>", ACTION(MODE_NORMAL) },
282 { "<C-c>", ALIAS("<Escape>") },
283 { "<C-i>", ALIAS("<Tab>") },
284 { "<Enter>", ACTION(INSERT_NEWLINE) },
285 { "<C-j>", ALIAS("<Enter>") },
286 { "<C-m>", ALIAS("<Enter>") },
287 { "<C-o>", ACTION(MODE_OPERATOR_PENDING) },
288 { "<C-v>", ACTION(INSERT_VERBATIM) },
289 { "<C-d>", ALIAS("<Escape><<i") },
290 { "<C-t>", ALIAS("<Escape>>>i") },
291 { "<C-x><C-e>", ACTION(WINDOW_SLIDE_UP) },
292 { "<C-x><C-y>", ACTION(WINDOW_SLIDE_DOWN) },
293 { "<Tab>", ACTION(INSERT_TAB) },
294 { "<C-r>", ACTION(INSERT_REGISTER) },
295 { /* empty last element, array terminator */ },
298 static KeyBinding vis_mode_replace[] = {
299 { /* empty last element, array terminator */ },
302 /* Color definitions for use in the sytax highlighting rules below. A fore
303 * or background color of -1 specifies the default terminal color. */
304 enum {
305 COLOR_NOHILIT,
306 COLOR_SYNTAX0,
307 COLOR_SYNTAX1,
308 COLOR_SYNTAX2,
309 COLOR_SYNTAX3,
310 COLOR_SYNTAX4,
311 COLOR_SYNTAX5,
312 COLOR_SYNTAX6,
313 COLOR_SYNTAX7,
314 COLOR_SYNTAX8,
315 COLOR_SYNTAX9,
316 COLOR_SYNTAX_LAST, /* below are only aliases */
317 COLOR_KEYWORD = COLOR_SYNTAX1,
318 COLOR_CONSTANT = COLOR_SYNTAX4,
319 COLOR_DATATYPE = COLOR_SYNTAX2,
320 COLOR_OPERATOR = COLOR_SYNTAX2,
321 COLOR_CONTROL = COLOR_SYNTAX3,
322 COLOR_PREPROCESSOR = COLOR_SYNTAX4,
323 COLOR_PRAGMA = COLOR_SYNTAX4,
324 COLOR_KEYWORD2 = COLOR_SYNTAX4,
325 COLOR_BRACKETS = COLOR_SYNTAX5,
326 COLOR_STRING = COLOR_SYNTAX6,
327 COLOR_LITERAL = COLOR_SYNTAX6,
328 COLOR_VARIABLE = COLOR_SYNTAX6,
329 COLOR_TARGET = COLOR_SYNTAX5,
330 COLOR_COMMENT = COLOR_SYNTAX7,
331 COLOR_IDENTIFIER = COLOR_SYNTAX8,
332 COLOR_TYPE = COLOR_SYNTAX9,
333 COLOR_WHITESPACE = COLOR_COMMENT,
334 COLOR_SPACES = COLOR_WHITESPACE,
335 COLOR_TABS = COLOR_WHITESPACE,
336 COLOR_EOL = COLOR_WHITESPACE,
337 COLOR_EOF = COLOR_WHITESPACE,
340 static const char *styles[] = {
341 [COLOR_NOHILIT] = "",
342 [COLOR_SYNTAX0] = "fore:red,bold",
343 [COLOR_SYNTAX1] = "fore:green,bold",
344 [COLOR_SYNTAX2] = "fore:green",
345 [COLOR_SYNTAX3] = "fore:magenta,bold",
346 [COLOR_SYNTAX4] = "fore:magenta",
347 [COLOR_SYNTAX5] = "fore:blue,bold",
348 [COLOR_SYNTAX6] = "fore:red",
349 [COLOR_SYNTAX7] = "fore:blue",
350 [COLOR_SYNTAX8] = "fore:cyan",
351 [COLOR_SYNTAX9] = "fore:yellow",
352 [COLOR_SYNTAX_LAST] = NULL,
355 /* Syntax color definitions per file type. Each rule consists of a regular
356 * expression, a color to apply in case of a match and boolean flag inidcating
357 * whether it is a multiline rule.
359 * The syntax rules where initially imported from the sandy editor, written by
360 * Rafael Garcia <rafael.garcia.gallego@gmail.com>
362 #define B "\\b"
363 /* Use this if \b is not in your libc's regex implementation */
364 // #define B "^| |\t|\\(|\\)|\\[|\\]|\\{|\\}|\\||$"
366 /* common rules, used by multiple languages */
368 #define SYNTAX_MULTILINE_COMMENT { \
369 "(/\\*([^*]|\\*+[^*/])*\\*+/|/\\*([^*]|\\*+[^*/])*$|^([^/]|/+[^/*])*\\*/)", \
370 COLOR_COMMENT, \
371 true, /* multiline */ \
374 #define SYNTAX_SINGLE_LINE_COMMENT { \
375 "(//.*)", \
376 COLOR_COMMENT, \
379 #define SYNTAX_LITERAL { \
380 "('(\\\\.|.)')|"B"(0x[0-9A-Fa-f]+|[0-9]+)"B, \
381 COLOR_LITERAL, \
384 #define SYNTAX_STRING { \
385 "(\"(\\\\.|[^\"])*\")", \
386 COLOR_STRING, \
387 false, /* multiline */ \
390 #define SYNTAX_CONSTANT { \
391 B"[A-Z_][0-9A-Z_]+"B, \
392 COLOR_CONSTANT, \
395 #define SYNTAX_BRACKET { \
396 "(\\(|\\)|\\{|\\}|\\[|\\])", \
397 COLOR_BRACKETS, \
400 #define SYNTAX_C_PREPROCESSOR { \
401 "(^#[\\t ]*(define|include(_next)?|(un|ifn?)def|endif|el(if|se)|if|warning|error|pragma)?)", \
402 COLOR_PREPROCESSOR, \
405 #define SYNTAX_SPACES { "\xC2\xB7", COLOR_SPACES }
406 #define SYNTAX_TABS { "\xE2\x96\xB6", COLOR_TABS }
407 #define SYNTAX_TABS_FILL { " ", COLOR_TABS }
408 #define SYNTAX_EOL { "\xE2\x8F\x8E", COLOR_EOL }
409 #define SYNTAX_EOF { "~", COLOR_EOF }
411 /* these rules are applied top to bottom, first match wins. Therefore more 'greedy'
412 * rules such as for comments should be the first entries.
414 * The array of syntax definition must be terminated with an empty element.
416 static Syntax syntaxes[] = {{
417 .name = "c",
418 .file = "\\.(c(pp|xx)?|h(pp|xx)?|cc)$",
419 .settings = (const char*[]){
420 "set number",
421 "set autoindent",
422 "set show spaces=0 tabs=1 newlines=1",
423 NULL
425 .styles = styles,
426 .symbols = {
427 SYNTAX_SPACES,
428 SYNTAX_TABS,
429 SYNTAX_TABS_FILL,
430 SYNTAX_EOL,
431 SYNTAX_EOF,
433 .rules = {
434 SYNTAX_MULTILINE_COMMENT,
435 SYNTAX_SINGLE_LINE_COMMENT,
436 SYNTAX_LITERAL,
437 SYNTAX_STRING,
438 SYNTAX_CONSTANT,
439 SYNTAX_BRACKET,
441 "<[a-zA-Z0-9\\.\\-_/]+\\.(c(pp|xx)?|h(pp|xx)?|cc)>",
442 COLOR_STRING,
444 SYNTAX_C_PREPROCESSOR,
446 B"(for|if|while|do|else|case|default|switch|try|throw|catch|operator|new|delete)"B,
447 COLOR_KEYWORD,
449 B"(float|double|bool|char|int|short|long|sizeof|enum|void|static|const|struct|union|"
450 "typedef|extern|(un)?signed|inline|((s?size)|((u_?)?int(8|16|32|64|ptr)))_t|class|"
451 "namespace|template|public|protected|private|typename|this|friend|virtual|using|"
452 "mutable|volatile|register|explicit)"B,
453 COLOR_DATATYPE,
455 B"(goto|continue|break|return)"B,
456 COLOR_CONTROL,
459 .name = "sh",
460 .file = "\\.sh$",
461 .styles = styles,
462 .rules = {{
463 "#.*$",
464 COLOR_COMMENT,
466 SYNTAX_STRING,
468 "^[0-9A-Z_]+\\(\\)",
469 COLOR_CONSTANT,
471 "\\$[?!@#$?*-]",
472 COLOR_VARIABLE,
474 "\\$\\{[A-Za-z_][0-9A-Za-z_]+\\}",
475 COLOR_VARIABLE,
477 "\\$[A-Za-z_][0-9A-Za-z_]+",
478 COLOR_VARIABLE,
480 B"(case|do|done|elif|else|esac|exit|fi|for|function|if|in|local|read|return|select|shift|then|time|until|while)"B,
481 COLOR_KEYWORD,
483 "(\\{|\\}|\\(|\\)|\\;|\\]|\\[|`|\\\\|\\$|<|>|!|=|&|\\|)",
484 COLOR_BRACKETS,
487 .name = "makefile",
488 .file = "(Makefile[^/]*|\\.mk)$",
489 .styles = styles,
490 .rules = {{
491 "#.*$",
492 COLOR_COMMENT,
494 "\\$+[{(][a-zA-Z0-9_-]+[})]",
495 COLOR_VARIABLE,
497 B"(if|ifeq|else|endif)"B,
498 COLOR_CONTROL,
500 "^[^ ]+:",
501 COLOR_TARGET,
503 "[:(+?=)]",
504 COLOR_BRACKETS,
507 .name = "man",
508 .file = "\\.[1-9]x?$",
509 .styles = styles,
510 .rules = {{
511 "\\.(BR?|I[PR]?).*$",
512 COLOR_SYNTAX0,
514 "\\.(S|T)H.*$",
515 COLOR_SYNTAX2,
517 "\\.(br|DS|RS|RE|PD)",
518 COLOR_SYNTAX3,
520 "(\\.(S|T)H|\\.TP)",
521 COLOR_SYNTAX4,
523 "\\.(BR?|I[PR]?|PP)",
524 COLOR_SYNTAX5,
526 "\\\\f[BIPR]",
527 COLOR_SYNTAX6,
530 .name = "vala",
531 .file = "\\.(vapi|vala)$",
532 .styles = styles,
533 .rules = {
534 SYNTAX_MULTILINE_COMMENT,
535 SYNTAX_SINGLE_LINE_COMMENT,
536 SYNTAX_LITERAL,
537 SYNTAX_STRING,
538 SYNTAX_CONSTANT,
539 SYNTAX_BRACKET,
541 B"(for|if|while|do|else|case|default|switch|get|set|value|out|ref|enum)"B,
542 COLOR_KEYWORD,
544 B"(uint|uint8|uint16|uint32|uint64|bool|byte|ssize_t|size_t|char|double|string|float|int|long|short|this|base|transient|void|true|false|null|unowned|owned)"B,
545 COLOR_DATATYPE,
547 B"(try|catch|throw|finally|continue|break|return|new|sizeof|signal|delegate)"B,
548 COLOR_CONTROL,
550 B"(abstract|class|final|implements|import|instanceof|interface|using|private|public|static|strictfp|super|throws)"B,
551 COLOR_KEYWORD2,
554 .name = "java",
555 .file = "\\.java$",
556 .styles = styles,
557 .rules = {
558 SYNTAX_MULTILINE_COMMENT,
559 SYNTAX_SINGLE_LINE_COMMENT,
560 SYNTAX_LITERAL,
561 SYNTAX_STRING,
562 SYNTAX_CONSTANT,
563 SYNTAX_BRACKET,
565 B"(for|if|while|do|else|case|default|switch)"B,
566 COLOR_KEYWORD,
568 B"(boolean|byte|char|double|float|int|long|short|transient|void|true|false|null)"B,
569 COLOR_DATATYPE,
571 B"(try|catch|throw|finally|continue|break|return|new)"B,
572 COLOR_CONTROL,
574 B"(abstract|class|extends|final|implements|import|instanceof|interface|native|package|private|protected|public|static|strictfp|this|super|synchronized|throws|volatile)"B,
575 COLOR_KEYWORD2,
578 .name = "javascript",
579 .file = "\\.(js|json)$",
580 .styles = styles,
581 .rules = {
582 SYNTAX_SINGLE_LINE_COMMENT,
583 SYNTAX_LITERAL,
584 SYNTAX_STRING,
585 SYNTAX_BRACKET,
587 B"(true|false|null|undefined)"B,
588 COLOR_DATATYPE,
590 B"(NaN|Infinity)"B,
591 COLOR_LITERAL,
593 "(\"(\\\\.|[^\"])*\"|\'(\\\\.|[^\'])*\')",
594 COLOR_STRING,
596 B"(for|if|while|do|in|else|case|default|switch|try|throw|catch|operator|new|delete)"B,
597 COLOR_KEYWORD,
599 B"(continue|break|return)"B,
600 COLOR_CONTROL,
602 B"(case|class|const|debugger|default|enum|export|extends|finally|function|implements|import|instanceof|let|this|typeof|var|with|yield)"B,
603 COLOR_KEYWORD2,
606 .name = "lua",
607 .file = "\\.lua$",
608 .settings = (const char*[]){
609 "set number",
610 "set autoindent",
611 NULL
613 .styles = styles,
614 .rules = {{
615 "--\\[(=*)\\[([^]]*)\\](=*)\\]",
616 COLOR_COMMENT,
617 true,
619 "--.*$",
620 COLOR_COMMENT,
622 "(\\[(=*)\\[([^]]*)\\](=*)\\]|^([^][]*)\\](=*)\\])",
623 COLOR_STRING,
624 true,
626 SYNTAX_STRING,
628 B"([0-9]*\\.)?[0-9]+([eE]([\\+-])?[0-9]+)?"B,
629 COLOR_LITERAL,
631 B"0x[0-9a-fA-F]+"B,
632 COLOR_LITERAL,
634 B"(false|nil|true)"B,
635 COLOR_CONSTANT,
637 "(\\.\\.\\.)",
638 COLOR_CONSTANT,
640 B"(break|do|else|elseif|end|for|function|if|in|local|repeat|return|then|until|while)"B,
641 COLOR_KEYWORD,
643 B"(and|not|or)"B,
644 COLOR_OPERATOR,
646 "(\\+|-|\\*|/|%|\\^|#|[=~<>]=|<|>|\\.\\.)",
647 COLOR_OPERATOR,
649 SYNTAX_BRACKET,
652 .name = "ruby",
653 .file = "\\.rb$",
654 .styles = styles,
655 .rules = {{
656 "(#[^{].*$|#$)",
657 COLOR_COMMENT,
659 "(\\$|@|@@)?"B"[A-Z]+[0-9A-Z_a-z]*",
660 COLOR_VARIABLE,
662 B"(__FILE__|__LINE__|BEGIN|END|alias|and|begin|break|case|class|def|defined\?|do|else|elsif|end|ensure|false|for|if|in|module|next|nil|not|or|redo|rescue|retry|return|self|super|then|true|undef|unless|until|when|while|yield)"B,
663 COLOR_KEYWORD,
665 "([ ]|^):[0-9A-Z_]+"B,
666 COLOR_SYNTAX2,
668 "(/([^/]|(\\/))*/[iomx]*|%r\\{([^}]|(\\}))*\\}[iomx]*)",
669 COLOR_SYNTAX3,
671 "(`[^`]*`|%x\\{[^}]*\\})",
672 COLOR_SYNTAX4,
674 "(\"([^\"]|(\\\\\"))*\"|%[QW]?\\{[^}]*\\}|%[QW]?\\([^)]*\\)|%[QW]?<[^>]*>|%[QW]?\\[[^]]*\\]|%[QW]?\\$[^$]*\\$|%[QW]?\\^[^^]*\\^|%[QW]?![^!]*!|\'([^\']|(\\\\\'))*\'|%[qw]\\{[^}]*\\}|%[qw]\\([^)]*\\)|%[qw]<[^>]*>|%[qw]\\[[^]]*\\]|%[qw]\\$[^$]*\\$|%[qw]\\^[^^]*\\^|%[qw]![^!]*!)",
675 COLOR_SYNTAX5,
677 "#\\{[^}]*\\}",
678 COLOR_SYNTAX6,
681 .name = "python",
682 .file = "\\.py$",
683 .styles = styles,
684 .rules = {{
685 "(#.*$|#$)",
686 COLOR_COMMENT,
688 "(\"\"\".*\"\"\")",
689 COLOR_COMMENT,
690 true, /* multiline */
692 B"(and|class|def|not|or|return|yield|is)"B,
693 COLOR_KEYWORD2,
695 B"(from|import|as)"B,
696 COLOR_KEYWORD,
698 B"(if|elif|else|while|for|in|try|with|except|in|break|continue|finally)"B,
699 COLOR_CONTROL,
701 B"(int|str|float|unicode|int|bool|chr|type|list|dict|tuple)",
702 COLOR_DATATYPE,
704 "(True|False|None)",
705 COLOR_LITERAL,
707 B"[0-9]+\\.[0-9]+([eE][-+]?[0-9]+)?"B,
708 COLOR_LITERAL,
710 B"[0-9]+"B"|"B"0[xX][0-9a-fA-F]+"B"|"B"0[oO][0-7]+"B,
711 COLOR_LITERAL,
713 "(\"(\\\\.|[^\"])*\"|\'(\\\\.|[^\'])*\')",
714 COLOR_STRING,
715 false, /* multiline */
717 "(__init__|__str__|__unicode__|__gt__|__lt__|__eq__|__enter__|__exit__|__next__|__getattr__|__getitem__|__setitem__|__call__|__contains__|__iter__|__bool__|__all__|__name__)",
718 COLOR_SYNTAX2,
721 .name = "php",
722 .file = "\\.php$",
723 .styles = styles,
724 .rules = {
725 SYNTAX_MULTILINE_COMMENT,
726 SYNTAX_SINGLE_LINE_COMMENT,
727 SYNTAX_BRACKET,
729 "(#.*$|#$)",
730 COLOR_COMMENT,
732 "(\"\"\".*\"\"\")",
733 COLOR_COMMENT,
734 true, /* multiline */
736 B"(class|interface|extends|implements|new|__construct|__destruct|use|namespace|return)"B,
737 COLOR_KEYWORD2,
739 B"(public|private|protected|const|parent|function|->)"B,
740 COLOR_KEYWORD,
742 B"(if|else|while|do|for|foreach|in|try|catch|finally|switch|case|default|break|continue|as|=>)"B,
743 COLOR_CONTROL,
745 B"(array|true|false|null)",
746 COLOR_DATATYPE,
748 B"[0-9]+\\.[0-9]+([eE][-+]?[0-9]+)?"B,
749 COLOR_LITERAL,
751 B"[0-9]+"B"|"B"0[xX][0-9a-fA-F]+"B"|"B"0[oO][0-7]+"B,
752 COLOR_LITERAL,
754 "\\$[a-zA-Z0-9_\\-]+",
755 COLOR_VARIABLE,
757 "(\"(\\\\.|[^\"])*\"|\'(\\\\.|[^\'])*\')",
758 COLOR_STRING,
759 false, /* multiline */
761 "(php|echo|print|var_dump|print_r)",
762 COLOR_SYNTAX2,
765 .name = "haskell",
766 .file = "\\.hs$",
767 .styles = styles,
768 .rules = {{
769 "\\{-#.*#-\\}",
770 COLOR_PRAGMA,
772 "---*([^-!#$%&\\*\\+./<=>\?@\\^|~].*)?$",
773 COLOR_COMMENT,
774 }, {
775 // These are allowed to be nested, but we can't express that
776 // with regular expressions
777 "\\{-.*-\\}",
778 COLOR_COMMENT,
779 true
781 SYNTAX_STRING,
782 SYNTAX_C_PREPROCESSOR,
784 // as and hiding are only keywords when part of an import, but
785 // I don't want to highlight the whole import line.
786 // capture group coloring or similar would be nice
787 "(^import( qualified)?)|"B"(as|hiding|infix[lr]?)"B,
788 COLOR_KEYWORD2,
790 B"(module|class|data|deriving|instance|default|where|type|newtype)"B,
791 COLOR_KEYWORD,
793 B"(do|case|of|let|in|if|then|else)"B,
794 COLOR_CONTROL,
796 "('(\\\\.|.)')",
797 COLOR_LITERAL,
799 B"[0-9]+\\.[0-9]+([eE][-+]?[0-9]+)?"B,
800 COLOR_LITERAL,
802 B"[0-9]+"B"|"B"0[xX][0-9a-fA-F]+"B"|"B"0[oO][0-7]+"B,
803 COLOR_LITERAL,
805 "("B"[A-Z][a-zA-Z0-9_']*\\.)*"B"[a-zA-Z][a-zA-Z0-9_']*"B,
806 COLOR_NOHILIT,
808 "("B"[A-Z][a-zA-Z0-9_']*\\.)?[-!#$%&\\*\\+/<=>\\?@\\\\^|~:.][-!#$%&\\*\\+/<=>\\?@\\\\^|~:.]*",
809 COLOR_OPERATOR,
811 "`("B"[A-Z][a-zA-Z0-9_']*\\.)?[a-z][a-zA-Z0-9_']*`",
812 COLOR_OPERATOR,
814 "\\(|\\)|\\[|\\]|,|;|_|\\{|\\}",
815 COLOR_BRACKETS,
818 .name = "markdown",
819 .file = "\\.(md|mdwn)$",
820 .styles = styles,
821 .rules = {{
822 "(^#{1,6}.*$)", //titles
823 COLOR_SYNTAX5,
825 "((\\* *){3,}|(_ *){3,}|(- *){3,})", // horizontal rules
826 COLOR_SYNTAX2,
828 "(\\*\\*.*\\*\\*)|(__.*__)", // super-bolds
829 COLOR_SYNTAX4,
831 "(\\*.*\\*)|(_.*_)", // bolds
832 COLOR_SYNTAX3,
834 "(\\[.*\\]\\(.*\\))", //links
835 COLOR_SYNTAX6,
837 "(^ *([-\\*\\+]|[0-9]+\\.))", //lists
838 COLOR_SYNTAX2,
840 "(^( {4,}|\t+).*$)", // code blocks
841 COLOR_SYNTAX7,
843 "(`+.*`+)", // inline code
844 COLOR_SYNTAX7,
846 "(^>+.*)", // quotes
847 COLOR_SYNTAX7,
850 .name = "ledger",
851 .file = "\\.(journal|ledger)$",
852 .styles = styles,
853 .rules = {
854 { /* comment */
855 "^[;#].*",
856 COLOR_COMMENT,
857 },{ /* value tag */
858 "( |\t|^ )*; :([^ ][^:]*:)+[ \\t]*$",
859 COLOR_DATATYPE,
860 },{ /* typed tag */
861 "( |\t|^ )*; [^:]+::.*",
862 COLOR_DATATYPE,
863 },{ /* tag */
864 "( |\t|^ )*; [^:]+:.*",
865 COLOR_TYPE,
866 },{ /* metadata */
867 "( |\t|^ )*;.*",
868 COLOR_CONSTANT,
869 },{ /* date */
870 "^[0-9][^ \t]+",
871 COLOR_LITERAL,
872 },{ /* account */
873 "^[ \t]+[a-zA-Z:'!*()%&]+",
874 COLOR_IDENTIFIER,
875 },{ /* amount */
876 "( |\t)[^;]*",
877 COLOR_LITERAL,
878 },{ /* automated transaction */
879 "^[=~].*",
880 COLOR_TYPE,
881 },{ /* directives */
882 "^[!@]?(account|alias|assert|bucket|capture|check|comment|commodity|define|end|fixed|endfixed|include|payee|apply|tag|test|year|[AYNDCIiOobh])"B".*",
883 COLOR_DATATYPE,
886 .name = "apl",
887 .file = "\\.apl$",
888 .settings = (const char*[]){
889 "set number",
890 NULL
892 .styles = styles,
893 .rules = {{
894 "(⍝|#).*$",
895 COLOR_COMMENT,
897 "('([^']|'')*')|(\"([^\"]|\"\")*\")",
898 COLOR_STRING,
900 "^ *(∇|⍫)",
901 COLOR_SYNTAX9,
903 "(⎕[a-zA-Z]*)|[⍞χ⍺⍶⍵⍹]",
904 COLOR_KEYWORD,
906 "[∆⍙_a-zA-Z][∆⍙_¯a-zA-Z0-9]* *:",
907 COLOR_SYNTAX2,
909 "[∆⍙_a-zA-Z][∆⍙_¯a-zA-Z0-9]*",
910 COLOR_IDENTIFIER,
912 "¯?(([0-9]+(\\.[0-9]+)?)|\\.[0-9]+)([eE]¯?[0-9]+)?([jJ]¯?(([0-9]+(\\.[0-9]+)?)|\\.[0-9]+)([eE]¯?[0-9]+)?)?",
913 COLOR_CONSTANT,
915 "[][(){}]",
916 COLOR_BRACKETS,
918 "[←→◊]",
919 COLOR_SYNTAX3,
922 /* empty last element, array terminator */