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
) },
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
) },
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. */
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>
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 "(/\\*([^*]|\\*+[^*/])*\\*+/|/\\*([^*]|\\*+[^*/])*$|^([^/]|/+[^/*])*\\*/)", \
371 true, /* multiline */ \
374 #define SYNTAX_SINGLE_LINE_COMMENT { \
379 #define SYNTAX_LITERAL { \
380 "('(\\\\.|.)')|"B"(0x[0-9A-Fa-f]+|[0-9]+)"B, \
384 #define SYNTAX_STRING { \
385 "(\"(\\\\.|[^\"])*\")", \
387 false, /* multiline */ \
390 #define SYNTAX_CONSTANT { \
391 B"[A-Z_][0-9A-Z_]+"B, \
395 #define SYNTAX_BRACKET { \
396 "(\\(|\\)|\\{|\\}|\\[|\\])", \
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
[] = {{
418 .file
= "\\.(c(pp|xx)?|h(pp|xx)?|cc)$",
419 .settings
= (const char*[]){
422 "set show spaces=0 tabs=1 newlines=1",
434 SYNTAX_MULTILINE_COMMENT
,
435 SYNTAX_SINGLE_LINE_COMMENT
,
441 "<[a-zA-Z0-9\\.\\-_/]+\\.(c(pp|xx)?|h(pp|xx)?|cc)>",
444 SYNTAX_C_PREPROCESSOR
,
446 B
"(for|if|while|do|else|case|default|switch|try|throw|catch|operator|new|delete)"B
,
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
,
455 B
"(goto|continue|break|return)"B
,
474 "\\$\\{[A-Za-z_][0-9A-Za-z_]+\\}",
477 "\\$[A-Za-z_][0-9A-Za-z_]+",
480 B
"(case|do|done|elif|else|esac|exit|fi|for|function|if|in|local|read|return|select|shift|then|time|until|while)"B
,
483 "(\\{|\\}|\\(|\\)|\\;|\\]|\\[|`|\\\\|\\$|<|>|!|=|&|\\|)",
488 .file
= "(Makefile[^/]*|\\.mk)$",
494 "\\$+[{(][a-zA-Z0-9_-]+[})]",
497 B
"(if|ifeq|else|endif)"B
,
508 .file
= "\\.[1-9]x?$",
511 "\\.(BR?|I[PR]?).*$",
517 "\\.(br|DS|RS|RE|PD)",
523 "\\.(BR?|I[PR]?|PP)",
531 .file
= "\\.(vapi|vala)$",
534 SYNTAX_MULTILINE_COMMENT
,
535 SYNTAX_SINGLE_LINE_COMMENT
,
541 B
"(for|if|while|do|else|case|default|switch|get|set|value|out|ref|enum)"B
,
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
,
547 B
"(try|catch|throw|finally|continue|break|return|new|sizeof|signal|delegate)"B
,
550 B
"(abstract|class|final|implements|import|instanceof|interface|using|private|public|static|strictfp|super|throws)"B
,
558 SYNTAX_MULTILINE_COMMENT
,
559 SYNTAX_SINGLE_LINE_COMMENT
,
565 B
"(for|if|while|do|else|case|default|switch)"B
,
568 B
"(boolean|byte|char|double|float|int|long|short|transient|void|true|false|null)"B
,
571 B
"(try|catch|throw|finally|continue|break|return|new)"B
,
574 B
"(abstract|class|extends|final|implements|import|instanceof|interface|native|package|private|protected|public|static|strictfp|this|super|synchronized|throws|volatile)"B
,
578 .name
= "javascript",
579 .file
= "\\.(js|json)$",
582 SYNTAX_SINGLE_LINE_COMMENT
,
587 B
"(true|false|null|undefined)"B
,
593 "(\"(\\\\.|[^\"])*\"|\'(\\\\.|[^\'])*\')",
596 B
"(for|if|while|do|in|else|case|default|switch|try|throw|catch|operator|new|delete)"B
,
599 B
"(continue|break|return)"B
,
602 B
"(case|class|const|debugger|default|enum|export|extends|finally|function|implements|import|instanceof|let|this|typeof|var|with|yield)"B
,
608 .settings
= (const char*[]){
615 "--\\[(=*)\\[([^]]*)\\](=*)\\]",
622 "(\\[(=*)\\[([^]]*)\\](=*)\\]|^([^][]*)\\](=*)\\])",
628 B
"([0-9]*\\.)?[0-9]+([eE]([\\+-])?[0-9]+)?"B
,
634 B
"(false|nil|true)"B
,
640 B
"(break|do|else|elseif|end|for|function|if|in|local|repeat|return|then|until|while)"B
,
646 "(\\+|-|\\*|/|%|\\^|#|[=~<>]=|<|>|\\.\\.)",
659 "(\\$|@|@@)?"B
"[A-Z]+[0-9A-Z_a-z]*",
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
,
665 "([ ]|^):[0-9A-Z_]+"B
,
668 "(/([^/]|(\\/))*/[iomx]*|%r\\{([^}]|(\\}))*\\}[iomx]*)",
671 "(`[^`]*`|%x\\{[^}]*\\})",
674 "(\"([^\"]|(\\\\\"))*\"|%[QW]?\\{[^}]*\\}|%[QW]?\\([^)]*\\)|%[QW]?<[^>]*>|%[QW]?\\[[^]]*\\]|%[QW]?\\$[^$]*\\$|%[QW]?\\^[^^]*\\^|%[QW]?![^!]*!|\'([^\']|(\\\\\'))*\'|%[qw]\\{[^}]*\\}|%[qw]\\([^)]*\\)|%[qw]<[^>]*>|%[qw]\\[[^]]*\\]|%[qw]\\$[^$]*\\$|%[qw]\\^[^^]*\\^|%[qw]![^!]*!)",
690 true, /* multiline */
692 B
"(and|class|def|not|or|return|yield|is)"B
,
695 B
"(from|import|as)"B
,
698 B
"(if|elif|else|while|for|in|try|with|except|in|break|continue|finally)"B
,
701 B
"(int|str|float|unicode|int|bool|chr|type|list|dict|tuple)",
707 B
"[0-9]+\\.[0-9]+([eE][-+]?[0-9]+)?"B
,
710 B
"[0-9]+"B
"|"B
"0[xX][0-9a-fA-F]+"B
"|"B
"0[oO][0-7]+"B
,
713 "(\"(\\\\.|[^\"])*\"|\'(\\\\.|[^\'])*\')",
715 false, /* multiline */
717 "(__init__|__str__|__unicode__|__gt__|__lt__|__eq__|__enter__|__exit__|__next__|__getattr__|__getitem__|__setitem__|__call__|__contains__|__iter__|__bool__|__all__|__name__)",
725 SYNTAX_MULTILINE_COMMENT
,
726 SYNTAX_SINGLE_LINE_COMMENT
,
734 true, /* multiline */
736 B
"(class|interface|extends|implements|new|__construct|__destruct|use|namespace|return)"B
,
739 B
"(public|private|protected|const|parent|function|->)"B
,
742 B
"(if|else|while|do|for|foreach|in|try|catch|finally|switch|case|default|break|continue|as|=>)"B
,
745 B
"(array|true|false|null)",
748 B
"[0-9]+\\.[0-9]+([eE][-+]?[0-9]+)?"B
,
751 B
"[0-9]+"B
"|"B
"0[xX][0-9a-fA-F]+"B
"|"B
"0[oO][0-7]+"B
,
754 "\\$[a-zA-Z0-9_\\-]+",
757 "(\"(\\\\.|[^\"])*\"|\'(\\\\.|[^\'])*\')",
759 false, /* multiline */
761 "(php|echo|print|var_dump|print_r)",
772 "---*([^-!#$%&\\*\\+./<=>\?@\\^|~].*)?$",
775 // These are allowed to be nested, but we can't express that
776 // with regular expressions
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
,
790 B
"(module|class|data|deriving|instance|default|where|type|newtype)"B
,
793 B
"(do|case|of|let|in|if|then|else)"B
,
799 B
"[0-9]+\\.[0-9]+([eE][-+]?[0-9]+)?"B
,
802 B
"[0-9]+"B
"|"B
"0[xX][0-9a-fA-F]+"B
"|"B
"0[oO][0-7]+"B
,
805 "("B
"[A-Z][a-zA-Z0-9_']*\\.)*"B
"[a-zA-Z][a-zA-Z0-9_']*"B
,
808 "("B
"[A-Z][a-zA-Z0-9_']*\\.)?[-!#$%&\\*\\+/<=>\\?@\\\\^|~:.][-!#$%&\\*\\+/<=>\\?@\\\\^|~:.]*",
811 "`("B
"[A-Z][a-zA-Z0-9_']*\\.)?[a-z][a-zA-Z0-9_']*`",
814 "\\(|\\)|\\[|\\]|,|;|_|\\{|\\}",
819 .file
= "\\.(md|mdwn)$",
822 "(^#{1,6}.*$)", //titles
825 "((\\* *){3,}|(_ *){3,}|(- *){3,})", // horizontal rules
828 "(\\*\\*.*\\*\\*)|(__.*__)", // super-bolds
831 "(\\*.*\\*)|(_.*_)", // bolds
834 "(\\[.*\\]\\(.*\\))", //links
837 "(^ *([-\\*\\+]|[0-9]+\\.))", //lists
840 "(^( {4,}|\t+).*$)", // code blocks
843 "(`+.*`+)", // inline code
851 .file
= "\\.(journal|ledger)$",
858 "( |\t|^ )*; :([^ ][^:]*:)+[ \\t]*$",
861 "( |\t|^ )*; [^:]+::.*",
864 "( |\t|^ )*; [^:]+:.*",
873 "^[ \t]+[a-zA-Z:'!*()%&]+",
878 },{ /* automated transaction */
882 "^[!@]?(account|alias|assert|bucket|capture|check|comment|commodity|define|end|fixed|endfixed|include|payee|apply|tag|test|year|[AYNDCIiOobh])"B
".*",
888 .settings
= (const char*[]){
897 "('([^']|'')*')|(\"([^\"]|\"\")*\")",
903 "(⎕[a-zA-Z]*)|[⍞χ⍺⍶⍵⍹]",
906 "[∆⍙_a-zA-Z][∆⍙_¯a-zA-Z0-9]* *:",
909 "[∆⍙_a-zA-Z][∆⍙_¯a-zA-Z0-9]*",
912 "¯?(([0-9]+(\\.[0-9]+)?)|\\.[0-9]+)([eE]¯?[0-9]+)?([jJ]¯?(([0-9]+(\\.[0-9]+)?)|\\.[0-9]+)([eE]¯?[0-9]+)?)?",
922 /* empty last element, array terminator */