tree-sitter-muttrc 0.0.5 → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +12 -0
- package/binding.gyp +17 -3
- package/bindings/node/binding.cc +1 -2
- package/bindings/node/binding_test.js +11 -0
- package/bindings/node/index.d.ts +36 -4
- package/bindings/node/index.js +34 -4
- package/grammar.js +186 -181
- package/package.json +26 -21
- package/queries/highlights.scm +61 -0
- package/queries/injections.scm +30 -0
- package/src/grammar.json +353 -585
- package/src/node-types.json +55 -78
- package/src/parser.c +20398 -13114
- package/src/tree_sitter/alloc.h +4 -4
- package/src/tree_sitter/array.h +120 -74
- package/src/tree_sitter/parser.h +68 -12
- package/tree-sitter.json +42 -0
package/grammar.js
CHANGED
|
@@ -1,12 +1,23 @@
|
|
|
1
|
-
|
|
1
|
+
/// <reference types="tree-sitter-cli/dsl" />
|
|
2
|
+
|
|
3
|
+
export default grammar({
|
|
2
4
|
name: "muttrc",
|
|
3
5
|
|
|
4
|
-
extras:
|
|
6
|
+
extras: $ => [/\s/, /\\\r?\n/, $.comment, /\\( |\t|\v|\f)/],
|
|
5
7
|
|
|
6
8
|
rules: {
|
|
7
|
-
file:
|
|
9
|
+
file: $ => optional($._statements),
|
|
10
|
+
|
|
11
|
+
_statements: $ => seq(
|
|
12
|
+
repeat(seq(
|
|
13
|
+
$._statement,
|
|
14
|
+
$._terminator,
|
|
15
|
+
)),
|
|
16
|
+
$._statement,
|
|
17
|
+
optional($._terminator),
|
|
18
|
+
),
|
|
8
19
|
|
|
9
|
-
|
|
20
|
+
_statement: $ =>
|
|
10
21
|
choice(
|
|
11
22
|
$.alias_directive,
|
|
12
23
|
$.alternates_directive,
|
|
@@ -92,19 +103,19 @@ module.exports = grammar({
|
|
|
92
103
|
$.unsubscribe_from_directive
|
|
93
104
|
),
|
|
94
105
|
|
|
95
|
-
account_hook_directive:
|
|
96
|
-
command($, "account-hook", $._string, $.
|
|
106
|
+
account_hook_directive: $ =>
|
|
107
|
+
command($, "account-hook", $._string, $._statement),
|
|
97
108
|
|
|
98
|
-
group_name:
|
|
99
|
-
|
|
100
|
-
_group:
|
|
101
|
-
_addresses:
|
|
102
|
-
alias_directive:
|
|
109
|
+
group_name: _ => /[^-]\S*/,
|
|
110
|
+
_group_names: $ => repeat1($.group_name),
|
|
111
|
+
_group: $ => seq(alias("-group", $.command_line_option), $._group_names),
|
|
112
|
+
_addresses: $ => commaSep1($.address),
|
|
113
|
+
alias_directive: $ =>
|
|
103
114
|
command($, "alias", optional($._group), $.key, $._addresses),
|
|
104
|
-
address:
|
|
105
|
-
unalias_directive:
|
|
115
|
+
address: $ => $._string,
|
|
116
|
+
unalias_directive: $ =>
|
|
106
117
|
command($, "unalias", optional($._group), choice("*", $.key)),
|
|
107
|
-
key:
|
|
118
|
+
key: $ =>
|
|
108
119
|
repeat1(
|
|
109
120
|
choice(
|
|
110
121
|
seq("<", alias(/[a-zA-Z-]+/, $.key_name), ">"),
|
|
@@ -113,22 +124,22 @@ module.exports = grammar({
|
|
|
113
124
|
)
|
|
114
125
|
),
|
|
115
126
|
|
|
116
|
-
_regexes:
|
|
117
|
-
alternates_directive:
|
|
127
|
+
_regexes: $ => repeat1($._regex),
|
|
128
|
+
alternates_directive: $ =>
|
|
118
129
|
command($, "alternates", optional($._group), $._regexes),
|
|
119
|
-
unalternates_directive:
|
|
130
|
+
unalternates_directive: $ =>
|
|
120
131
|
command($, "unalternates", optional($._group), choice("*", $._regexes)),
|
|
121
|
-
alternative_order_directive:
|
|
132
|
+
alternative_order_directive: $ =>
|
|
122
133
|
command($, "alternative_order", $._mimes),
|
|
123
|
-
unalternative_order_directive:
|
|
134
|
+
unalternative_order_directive: $ =>
|
|
124
135
|
command($, "unalternative_order", choice("*", $._mimes)),
|
|
125
|
-
mime_type:
|
|
126
|
-
mime:
|
|
136
|
+
mime_type: _ => /[-.a-zA-Z\d]+/,
|
|
137
|
+
mime: $ =>
|
|
127
138
|
seq($.mime_type, optional(seq("/", alias($.mime_type, $.sub_mime_type)))),
|
|
128
|
-
_mime_types:
|
|
129
|
-
_mimes:
|
|
130
|
-
disposition:
|
|
131
|
-
attachments_directive:
|
|
139
|
+
_mime_types: $ => repeat1($.mime_type),
|
|
140
|
+
_mimes: $ => repeat1($.mime),
|
|
141
|
+
disposition: $ => $._string,
|
|
142
|
+
attachments_directive: $ =>
|
|
132
143
|
command(
|
|
133
144
|
$,
|
|
134
145
|
"attachments",
|
|
@@ -137,7 +148,7 @@ module.exports = grammar({
|
|
|
137
148
|
"?"
|
|
138
149
|
)
|
|
139
150
|
),
|
|
140
|
-
unattachments_directive:
|
|
151
|
+
unattachments_directive: $ =>
|
|
141
152
|
command(
|
|
142
153
|
$,
|
|
143
154
|
"unattachments",
|
|
@@ -146,11 +157,11 @@ module.exports = grammar({
|
|
|
146
157
|
"*"
|
|
147
158
|
)
|
|
148
159
|
),
|
|
149
|
-
auto_view_directive:
|
|
150
|
-
unauto_view_directive:
|
|
160
|
+
auto_view_directive: $ => command($, "auto_view", $._mimes),
|
|
161
|
+
unauto_view_directive: $ =>
|
|
151
162
|
command($, "unauto_view", choice("*", $._mimes)),
|
|
152
163
|
|
|
153
|
-
map:
|
|
164
|
+
map: _ =>
|
|
154
165
|
choice(
|
|
155
166
|
"alias",
|
|
156
167
|
"attach",
|
|
@@ -166,20 +177,20 @@ module.exports = grammar({
|
|
|
166
177
|
"query",
|
|
167
178
|
"smime"
|
|
168
179
|
),
|
|
169
|
-
_maps:
|
|
170
|
-
function:
|
|
171
|
-
_functions:
|
|
172
|
-
bind_directive:
|
|
173
|
-
unbind_directive:
|
|
174
|
-
|
|
175
|
-
alias:
|
|
176
|
-
charset:
|
|
177
|
-
charset_hook_directive:
|
|
180
|
+
_maps: $ => commaSep1($.map),
|
|
181
|
+
function: _ => /[a-z-]+/,
|
|
182
|
+
_functions: $ => repeat1($.function),
|
|
183
|
+
bind_directive: $ => command($, "bind", $._maps, $.key, $.function),
|
|
184
|
+
unbind_directive: $ => command($, "unbind", choice("*", $._maps), $.key),
|
|
185
|
+
|
|
186
|
+
alias: $ => $._string,
|
|
187
|
+
charset: $ => $._string,
|
|
188
|
+
charset_hook_directive: $ =>
|
|
178
189
|
command($, "charset-hook", $.alias, $.charset),
|
|
179
|
-
iconv_hook_directive:
|
|
190
|
+
iconv_hook_directive: $ => command($, "iconv-hook", $.charset, $.charset),
|
|
180
191
|
|
|
181
|
-
pattern:
|
|
182
|
-
object:
|
|
192
|
+
pattern: $ => $._string,
|
|
193
|
+
object: _ =>
|
|
183
194
|
choice(
|
|
184
195
|
"attach_headers",
|
|
185
196
|
"attachment",
|
|
@@ -221,7 +232,7 @@ module.exports = grammar({
|
|
|
221
232
|
"sidebar_ordinary",
|
|
222
233
|
"sidebar_spool_file"
|
|
223
234
|
),
|
|
224
|
-
composeobject:
|
|
235
|
+
composeobject: _ =>
|
|
225
236
|
choice(
|
|
226
237
|
"header",
|
|
227
238
|
"security_encrypt",
|
|
@@ -229,7 +240,7 @@ module.exports = grammar({
|
|
|
229
240
|
"security_both",
|
|
230
241
|
"security_none"
|
|
231
242
|
),
|
|
232
|
-
color:
|
|
243
|
+
color: _ =>
|
|
233
244
|
choice(
|
|
234
245
|
"default",
|
|
235
246
|
"black",
|
|
@@ -241,14 +252,14 @@ module.exports = grammar({
|
|
|
241
252
|
"cyan",
|
|
242
253
|
"white",
|
|
243
254
|
/#\d{6}/,
|
|
244
|
-
/color\d+/
|
|
255
|
+
/(bright)?color\d+/
|
|
245
256
|
),
|
|
246
|
-
attribute:
|
|
257
|
+
attribute: _ =>
|
|
247
258
|
choice("none", "bold", "underline", "reverse", "standout"),
|
|
248
|
-
_attributes:
|
|
249
|
-
foreground:
|
|
250
|
-
background:
|
|
251
|
-
color_directive:
|
|
259
|
+
_attributes: $ => repeat1($.attribute),
|
|
260
|
+
foreground: $ => $.color,
|
|
261
|
+
background: $ => $.color,
|
|
262
|
+
color_directive: $ =>
|
|
252
263
|
command(
|
|
253
264
|
$,
|
|
254
265
|
"color",
|
|
@@ -269,13 +280,13 @@ module.exports = grammar({
|
|
|
269
280
|
)
|
|
270
281
|
)
|
|
271
282
|
),
|
|
272
|
-
uncolor_directive:
|
|
283
|
+
uncolor_directive: $ =>
|
|
273
284
|
command($, "uncolor", $.pattern, choice("*", $.pattern)),
|
|
274
285
|
|
|
275
|
-
keyid:
|
|
276
|
-
crypt_hook_directive:
|
|
277
|
-
name:
|
|
278
|
-
index_format_hook_directive:
|
|
286
|
+
keyid: $ => $._string,
|
|
287
|
+
crypt_hook_directive: $ => command($, "crypt-hook", $._regex, $.keyid),
|
|
288
|
+
name: $ => $._string,
|
|
289
|
+
index_format_hook_directive: $ =>
|
|
279
290
|
command(
|
|
280
291
|
$,
|
|
281
292
|
"index-format-hook",
|
|
@@ -285,126 +296,131 @@ module.exports = grammar({
|
|
|
285
296
|
$._string
|
|
286
297
|
),
|
|
287
298
|
|
|
288
|
-
exec_directive:
|
|
289
|
-
fcc_save_hook_directive:
|
|
299
|
+
exec_directive: $ => command($, "exec", $._functions),
|
|
300
|
+
fcc_save_hook_directive: $ =>
|
|
290
301
|
command($, "fcc-save-hook", $.pattern, $.mailbox),
|
|
291
|
-
fcc_hook_directive:
|
|
292
|
-
save_hook_directive:
|
|
293
|
-
folder_hook_directive:
|
|
302
|
+
fcc_hook_directive: $ => command($, "fcc-hook", $.pattern, $.mailbox),
|
|
303
|
+
save_hook_directive: $ => command($, "save-hook", $.pattern, $.mailbox),
|
|
304
|
+
folder_hook_directive: $ =>
|
|
294
305
|
command(
|
|
295
306
|
$,
|
|
296
307
|
"folder-hook",
|
|
297
308
|
optional(alias("-noregex", $.command_line_option)),
|
|
298
309
|
$._regex,
|
|
299
|
-
$.
|
|
310
|
+
$._statement
|
|
300
311
|
),
|
|
301
312
|
|
|
302
|
-
_rx_addr:
|
|
313
|
+
_rx_addr: $ =>
|
|
303
314
|
choice(
|
|
304
315
|
seq(alias("-rx", $.command_line_option), $._regexes),
|
|
305
316
|
seq(alias("-addr", $.command_line_option), $._addresses)
|
|
306
317
|
),
|
|
307
|
-
group_directive:
|
|
308
|
-
ungroup_directive:
|
|
318
|
+
group_directive: $ => command($, "group", optional($._group), $._rx_addr),
|
|
319
|
+
ungroup_directive: $ =>
|
|
309
320
|
command($, "ungroup", optional($._group), choice("*", $._rx_addr)),
|
|
310
321
|
|
|
311
|
-
header:
|
|
312
|
-
_headers:
|
|
313
|
-
hdr_order_directive:
|
|
314
|
-
unhdr_order_directive:
|
|
322
|
+
header: $ => $._string,
|
|
323
|
+
_headers: $ => repeat1($.header),
|
|
324
|
+
hdr_order_directive: $ => command($, "hdr_order", $._headers),
|
|
325
|
+
unhdr_order_directive: $ =>
|
|
315
326
|
command($, "unhdr_order", choice("*", $._headers)),
|
|
316
327
|
|
|
317
|
-
symbol:
|
|
318
|
-
ifdef_directive:
|
|
319
|
-
ifndef_directive:
|
|
320
|
-
finish_directive:
|
|
328
|
+
symbol: $ => $._string,
|
|
329
|
+
ifdef_directive: $ => command($, "ifdef", $.symbol, $._statement),
|
|
330
|
+
ifndef_directive: $ => command($, "ifndef", $.symbol, $._statement),
|
|
331
|
+
finish_directive: $ => command($, "finish"),
|
|
321
332
|
|
|
322
|
-
_strings:
|
|
323
|
-
ignore_directive:
|
|
324
|
-
unignore_directive:
|
|
333
|
+
_strings: $ => repeat1($._string),
|
|
334
|
+
ignore_directive: $ => command($, "ignore", $._strings),
|
|
335
|
+
unignore_directive: $ => command($, "unignore", choice("*", $._strings)),
|
|
325
336
|
|
|
326
|
-
lists_directive:
|
|
327
|
-
unlists_directive:
|
|
337
|
+
lists_directive: $ => command($, "lists", $._group, $._regexes),
|
|
338
|
+
unlists_directive: $ =>
|
|
328
339
|
command($, "unlists", $._group, choice("*", $._regexes)),
|
|
329
|
-
subscribe_directive:
|
|
330
|
-
unsubscribe_directive:
|
|
340
|
+
subscribe_directive: $ => command($, "subscribe", $._group, $._regexes),
|
|
341
|
+
unsubscribe_directive: $ =>
|
|
331
342
|
command($, "unsubscribe", $._group, choice("*", $._regexes)),
|
|
332
343
|
|
|
333
|
-
sequence:
|
|
334
|
-
macro_directive:
|
|
335
|
-
unmacro_directive:
|
|
344
|
+
sequence: $ => $._string,
|
|
345
|
+
macro_directive: $ => command($, "macro", $._maps, $.key, $.sequence, optional($.description)),
|
|
346
|
+
unmacro_directive: $ =>
|
|
336
347
|
command($, "unmacro", choice("*", $._maps), $.key),
|
|
337
348
|
|
|
338
|
-
mailbox:
|
|
339
|
-
_mailboxes:
|
|
340
|
-
description:
|
|
341
|
-
mailboxes_directive:
|
|
342
|
-
named_mailboxes_directive:
|
|
343
|
-
command($, "named-mailboxes",
|
|
344
|
-
unmailboxes_directive:
|
|
349
|
+
mailbox: $ => $._string,
|
|
350
|
+
_mailboxes: $ => repeat1($.mailbox),
|
|
351
|
+
description: $ => $._string,
|
|
352
|
+
mailboxes_directive: $ => command($, "mailboxes", $._mailboxes),
|
|
353
|
+
named_mailboxes_directive: $ =>
|
|
354
|
+
command($, "named-mailboxes", repeat1(seq($.description, $.mailbox))),
|
|
355
|
+
unmailboxes_directive: $ =>
|
|
345
356
|
command($, "unmailboxes", choice("*", $._mailboxes)),
|
|
346
357
|
|
|
347
|
-
header_field:
|
|
348
|
-
_header_fields:
|
|
349
|
-
mailto_allow_directive:
|
|
358
|
+
header_field: $ => $._string,
|
|
359
|
+
_header_fields: $ => repeat1($.header_field),
|
|
360
|
+
mailto_allow_directive: $ =>
|
|
350
361
|
command($, "mailto_allow", choice("*", $._header_fields)),
|
|
351
|
-
unmailto_allow_directive:
|
|
362
|
+
unmailto_allow_directive: $ =>
|
|
352
363
|
command($, "unmailto_allow", choice("*", $._header_fields)),
|
|
353
364
|
|
|
354
|
-
message:
|
|
355
|
-
echo_directive:
|
|
356
|
-
directory:
|
|
357
|
-
cd_directive:
|
|
365
|
+
message: $ => $._string,
|
|
366
|
+
echo_directive: $ => command($, "echo", $.message),
|
|
367
|
+
directory: $ => $._string,
|
|
368
|
+
cd_directive: $ => command($, "cd", $.directory),
|
|
358
369
|
|
|
359
|
-
mbox_hook_directive:
|
|
370
|
+
mbox_hook_directive: $ =>
|
|
360
371
|
command($, "mbox-hook", optional("-noregex"), $._regex, $.mailbox),
|
|
361
|
-
message_hook_directive:
|
|
362
|
-
command($, "message-hook", $.pattern, $.
|
|
372
|
+
message_hook_directive: $ =>
|
|
373
|
+
command($, "message-hook", $.pattern, $._statement),
|
|
363
374
|
|
|
364
|
-
mime_lookup_directive:
|
|
365
|
-
unmime_lookup_directive:
|
|
375
|
+
mime_lookup_directive: $ => command($, "mime_lookup", $._mimes),
|
|
376
|
+
unmime_lookup_directive: $ =>
|
|
366
377
|
command($, "unmime_lookup", choice("*", $._mimes)),
|
|
367
|
-
mono_directive:
|
|
378
|
+
mono_directive: $ =>
|
|
368
379
|
command($, "mono", choice($.object, $.pattern), $.attribute, $._regex),
|
|
369
|
-
unmono_directive:
|
|
380
|
+
unmono_directive: $ =>
|
|
370
381
|
command($, "unmono", $.pattern, choice("*", $.pattern)),
|
|
371
|
-
my_hdr_directive:
|
|
372
|
-
unmy_hdr_directive:
|
|
382
|
+
my_hdr_directive: $ => command($, "my_hdr", $._string),
|
|
383
|
+
unmy_hdr_directive: $ =>
|
|
373
384
|
command($, "unmy_hdr", choice("*", $.header_field)),
|
|
374
385
|
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
command($, "
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
386
|
+
shell_statement: $ => choice(
|
|
387
|
+
quoted_string("'", $.shell),
|
|
388
|
+
quoted_string('"', $.shell),
|
|
389
|
+
quoted_string("`", $.shell),
|
|
390
|
+
alias($._word, $.shell),
|
|
391
|
+
),
|
|
392
|
+
open_hook_directive: $ =>
|
|
393
|
+
command($, "open-hook", $._regex, $.shell_statement),
|
|
394
|
+
close_hook_directive: $ =>
|
|
395
|
+
command($, "close-hook", $._regex, $.shell_statement),
|
|
396
|
+
append_hook_directive: $ =>
|
|
397
|
+
command($, "append-hook", $._regex, $.shell_statement),
|
|
398
|
+
|
|
399
|
+
push_directive: $ => command($, "push", $._string),
|
|
400
|
+
|
|
401
|
+
reply_hook_directive: $ =>
|
|
402
|
+
command($, "reply-hook", $.pattern, $._statement),
|
|
403
|
+
send_hook_directive: $ => command($, "send-hook", $.pattern, $._statement),
|
|
404
|
+
send2_hook_directive: $ =>
|
|
405
|
+
command($, "send2-hook", $.pattern, $._statement),
|
|
406
|
+
|
|
407
|
+
format: $ => $._string,
|
|
408
|
+
spam_directive: $ => command($, "spam", $._regex, $.format),
|
|
409
|
+
nospam_directive: $ => command($, "nospam", choice("*", $._regex)),
|
|
410
|
+
replacement: $ => $._string,
|
|
411
|
+
subjectrx_directive: $ =>
|
|
396
412
|
command($, "subjectrx", $._regex, $.replacement),
|
|
397
|
-
unsubjectrx_directive:
|
|
413
|
+
unsubjectrx_directive: $ =>
|
|
398
414
|
command($, "unsubjectrx", choice("*", $._regex)),
|
|
399
|
-
uri:
|
|
400
|
-
subscribe_to_directive:
|
|
401
|
-
unsubscribe_from_directive:
|
|
415
|
+
uri: $ => $._string,
|
|
416
|
+
subscribe_to_directive: $ => command($, "subscribe-to", $.uri),
|
|
417
|
+
unsubscribe_from_directive: $ => command($, "unsubscribe-from", $.uri),
|
|
402
418
|
|
|
403
|
-
timeout_hook_directive:
|
|
404
|
-
startup_hook_directive:
|
|
405
|
-
shutdown_hook_directive:
|
|
419
|
+
timeout_hook_directive: $ => command($, "timeout-hook", $._statement),
|
|
420
|
+
startup_hook_directive: $ => command($, "startup-hook", $._statement),
|
|
421
|
+
shutdown_hook_directive: $ => command($, "shutdown-hook", $._statement),
|
|
406
422
|
|
|
407
|
-
hook_type:
|
|
423
|
+
hook_type: _ =>
|
|
408
424
|
choice(
|
|
409
425
|
"account-hook",
|
|
410
426
|
"charset-hook",
|
|
@@ -425,64 +441,61 @@ module.exports = grammar({
|
|
|
425
441
|
"startup-hook",
|
|
426
442
|
"shutdown-hook"
|
|
427
443
|
),
|
|
428
|
-
unhook_directive:
|
|
429
|
-
|
|
430
|
-
set_directive: ($) => command($, "set", choice($._options2, $._options3)),
|
|
431
|
-
_options3: ($) =>
|
|
432
|
-
spaceSep1(
|
|
433
|
-
seq(
|
|
434
|
-
$.option,
|
|
435
|
-
optional(" "),
|
|
436
|
-
choice("+=", "-=", "="),
|
|
437
|
-
optional(" "),
|
|
438
|
-
choice($.int, $.quadoption, $._string)
|
|
439
|
-
)
|
|
440
|
-
),
|
|
441
|
-
_options2: ($) => spaceSep1(seq(optional(choice("&", "?")), $.option)),
|
|
442
|
-
_options: ($) => spaceSep1($.option),
|
|
443
|
-
unset_directive: ($) => command($, "unset", $._options),
|
|
444
|
-
reset_directive: ($) => command($, "reset", $._options),
|
|
445
|
-
toggle_directive: ($) => command($, "toggle", $._options),
|
|
444
|
+
unhook_directive: $ => command($, "unhook", choice("*", $.hook_type)),
|
|
446
445
|
|
|
447
|
-
|
|
446
|
+
set_directive: $ => command($, "set", repeat1(choice(
|
|
447
|
+
seq(
|
|
448
|
+
optional(choice("&", "?")),
|
|
449
|
+
$.option,
|
|
450
|
+
),
|
|
451
|
+
seq(
|
|
452
|
+
$.option,
|
|
453
|
+
optional(seq(
|
|
454
|
+
choice("+=", "-=", "="),
|
|
455
|
+
choice($.int, $.quadoption, $._string))
|
|
456
|
+
))
|
|
457
|
+
))),
|
|
458
|
+
_options: $ => repeat1($.option),
|
|
459
|
+
unset_directive: $ => command($, "unset", $._options),
|
|
460
|
+
reset_directive: $ => command($, "reset", $._options),
|
|
461
|
+
toggle_directive: $ => command($, "toggle", $._options),
|
|
462
|
+
|
|
463
|
+
setenv_directive: $ =>
|
|
448
464
|
command(
|
|
449
465
|
$,
|
|
450
466
|
"setenv",
|
|
451
467
|
choice(seq("?", $.option), seq($.option, alias(/\S+/, $.value)))
|
|
452
468
|
),
|
|
453
|
-
unsetenv_directive:
|
|
454
|
-
sidebar_pin_directive:
|
|
455
|
-
sidebar_unpin_directive:
|
|
469
|
+
unsetenv_directive: $ => command($, "unsetenv", $.option),
|
|
470
|
+
sidebar_pin_directive: $ => command($, "sidebar_pin", $._mailboxes),
|
|
471
|
+
sidebar_unpin_directive: $ =>
|
|
456
472
|
command($, "sidebar_unpin", choice("*", $._mailboxes)),
|
|
457
|
-
score_directive:
|
|
458
|
-
unscore_directive:
|
|
473
|
+
score_directive: $ => command($, "score", $.pattern, $.int),
|
|
474
|
+
unscore_directive: $ => command($, "unscore", choice("*", $.pattern)),
|
|
475
|
+
source_directive: $ => command($, "source", alias($._string, $.path)),
|
|
459
476
|
|
|
460
|
-
option:
|
|
477
|
+
option: _ => /[a-z_\d]+/,
|
|
461
478
|
|
|
462
|
-
quadoption:
|
|
463
|
-
int:
|
|
464
|
-
_string:
|
|
479
|
+
quadoption: _ => choice("yes", "no", "ask-yes", "ask-no"),
|
|
480
|
+
int: _ => /-?\d+/,
|
|
481
|
+
_string: $ =>
|
|
465
482
|
choice(
|
|
466
483
|
quoted_string("'", $.string),
|
|
467
|
-
quoted_string('"', $.
|
|
484
|
+
quoted_string('"', $.string),
|
|
468
485
|
quoted_string("`", $.shell),
|
|
469
|
-
alias($._word, $.
|
|
486
|
+
alias($._word, $.string),
|
|
470
487
|
),
|
|
471
|
-
_regex:
|
|
488
|
+
_regex: $ =>
|
|
472
489
|
choice(
|
|
473
490
|
quoted_string("'", $.regex),
|
|
474
491
|
quoted_string('"', $.regex),
|
|
475
492
|
quoted_string("`", $.shell),
|
|
476
493
|
alias($._word, $.regex),
|
|
477
494
|
),
|
|
478
|
-
_word:
|
|
479
|
-
|
|
480
|
-
source_directive: ($) => command($, "source", alias($._string, $.path)),
|
|
495
|
+
_word: _ => /([^"'`#;\s]|\\.)+/,
|
|
481
496
|
|
|
482
|
-
comment:
|
|
483
|
-
|
|
484
|
-
_space: (_) => prec(-1, repeat1(/[ \t]/)),
|
|
485
|
-
_end: ($) => seq(optional($._space), optional($.comment), $._eol),
|
|
497
|
+
comment: _ => seq('#', /[^\n]*/),
|
|
498
|
+
_terminator: _ => choice(';', /\n/),
|
|
486
499
|
},
|
|
487
500
|
});
|
|
488
501
|
|
|
@@ -490,16 +503,8 @@ function command($, cmd, ...args) {
|
|
|
490
503
|
return seq(alias(cmd, $.command), ...args);
|
|
491
504
|
}
|
|
492
505
|
|
|
493
|
-
function sep1(rule, separator) {
|
|
494
|
-
return seq(rule, repeat(seq(separator, rule)));
|
|
495
|
-
}
|
|
496
|
-
|
|
497
506
|
function commaSep1(rule) {
|
|
498
|
-
return
|
|
499
|
-
}
|
|
500
|
-
|
|
501
|
-
function spaceSep1(rule) {
|
|
502
|
-
return sep1(rule, " ");
|
|
507
|
+
return seq(rule, repeat(seq(token.immediate(","), rule)));
|
|
503
508
|
}
|
|
504
509
|
|
|
505
510
|
function quoted_string(char, name) {
|
package/package.json
CHANGED
|
@@ -1,9 +1,19 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "tree-sitter-muttrc",
|
|
3
|
-
"version": "0.0
|
|
4
|
-
"description": "
|
|
5
|
-
"
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "config file for mutt/neomutt",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"repository": {
|
|
7
|
+
"type": "git",
|
|
8
|
+
"url": "git+https://github.com/neomutt/tree-sitter-muttrc.git"
|
|
9
|
+
},
|
|
10
|
+
"funding": "https://github.com/neomutt/tree-sitter-muttrc",
|
|
6
11
|
"license": "MIT",
|
|
12
|
+
"author": {
|
|
13
|
+
"name": "Wu",
|
|
14
|
+
"email": "wuzhenyu@ustc.edu",
|
|
15
|
+
"url": "https://github.com/Freed-Wu/"
|
|
16
|
+
},
|
|
7
17
|
"main": "bindings/node",
|
|
8
18
|
"types": "bindings/node",
|
|
9
19
|
"keywords": [
|
|
@@ -14,22 +24,25 @@
|
|
|
14
24
|
],
|
|
15
25
|
"files": [
|
|
16
26
|
"grammar.js",
|
|
27
|
+
"tree-sitter.json",
|
|
17
28
|
"binding.gyp",
|
|
18
29
|
"prebuilds/**",
|
|
19
30
|
"bindings/node/*",
|
|
20
31
|
"queries/*",
|
|
21
|
-
"src/**"
|
|
32
|
+
"src/**",
|
|
33
|
+
"*.wasm"
|
|
22
34
|
],
|
|
23
35
|
"dependencies": {
|
|
24
|
-
"node-addon-api": "^
|
|
25
|
-
"node-gyp-build": "^4.8.
|
|
36
|
+
"node-addon-api": "^8.5.0",
|
|
37
|
+
"node-gyp-build": "^4.8.4"
|
|
26
38
|
},
|
|
27
39
|
"devDependencies": {
|
|
28
|
-
"prebuildify": "^6.0.
|
|
29
|
-
"tree-sitter
|
|
40
|
+
"prebuildify": "^6.0.1",
|
|
41
|
+
"tree-sitter": "^0.25.0",
|
|
42
|
+
"tree-sitter-cli": "^0.26.11"
|
|
30
43
|
},
|
|
31
44
|
"peerDependencies": {
|
|
32
|
-
"tree-sitter": "^0.
|
|
45
|
+
"tree-sitter": "^0.25.0"
|
|
33
46
|
},
|
|
34
47
|
"peerDependenciesMeta": {
|
|
35
48
|
"tree-sitter": {
|
|
@@ -38,16 +51,8 @@
|
|
|
38
51
|
},
|
|
39
52
|
"scripts": {
|
|
40
53
|
"install": "node-gyp-build",
|
|
41
|
-
"
|
|
42
|
-
"
|
|
43
|
-
"
|
|
44
|
-
|
|
45
|
-
"parse": "tree-sitter parse"
|
|
46
|
-
},
|
|
47
|
-
"tree-sitter": [
|
|
48
|
-
{
|
|
49
|
-
"scope": "source.muttrc",
|
|
50
|
-
"injection-regex": "^muttrc$"
|
|
51
|
-
}
|
|
52
|
-
]
|
|
54
|
+
"prestart": "tree-sitter build --wasm",
|
|
55
|
+
"start": "tree-sitter playground",
|
|
56
|
+
"test": "node --test bindings/node/*_test.js"
|
|
57
|
+
}
|
|
53
58
|
}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
; Comments
|
|
2
|
+
(comment) @comment @spell
|
|
3
|
+
|
|
4
|
+
; General
|
|
5
|
+
(int) @number
|
|
6
|
+
|
|
7
|
+
(string) @string
|
|
8
|
+
|
|
9
|
+
[
|
|
10
|
+
(map)
|
|
11
|
+
(object)
|
|
12
|
+
(composeobject)
|
|
13
|
+
(color)
|
|
14
|
+
(attribute)
|
|
15
|
+
] @string.special
|
|
16
|
+
|
|
17
|
+
(quadoption) @boolean
|
|
18
|
+
|
|
19
|
+
(path) @string.special.path
|
|
20
|
+
|
|
21
|
+
(regex) @string.regexp
|
|
22
|
+
|
|
23
|
+
(option) @variable
|
|
24
|
+
|
|
25
|
+
(command_line_option) @variable.builtin
|
|
26
|
+
|
|
27
|
+
((option) @variable.builtin
|
|
28
|
+
(#not-lua-match? @variable.builtin "^my_"))
|
|
29
|
+
|
|
30
|
+
(command) @keyword
|
|
31
|
+
|
|
32
|
+
(source_directive
|
|
33
|
+
(command) @keyword.import)
|
|
34
|
+
|
|
35
|
+
(uri) @string.special.url
|
|
36
|
+
|
|
37
|
+
(key_name) @constant.builtin
|
|
38
|
+
|
|
39
|
+
(escape) @string.escape
|
|
40
|
+
|
|
41
|
+
(function) @function.call
|
|
42
|
+
|
|
43
|
+
; Literals
|
|
44
|
+
[
|
|
45
|
+
"<"
|
|
46
|
+
">"
|
|
47
|
+
] @punctuation.bracket
|
|
48
|
+
|
|
49
|
+
"," @punctuation.delimiter
|
|
50
|
+
|
|
51
|
+
[
|
|
52
|
+
"&"
|
|
53
|
+
"?"
|
|
54
|
+
"*"
|
|
55
|
+
] @character.special
|
|
56
|
+
|
|
57
|
+
[
|
|
58
|
+
"="
|
|
59
|
+
"+="
|
|
60
|
+
"-="
|
|
61
|
+
] @operator
|