tree-sitter-muttrc 0.0.6 → 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/grammar.js CHANGED
@@ -1,14 +1,23 @@
1
1
  /// <reference types="tree-sitter-cli/dsl" />
2
2
 
3
- module.exports = grammar({
3
+ export default grammar({
4
4
  name: "muttrc",
5
5
 
6
- extras: (_) => [/\s/, /\\\r?\n/],
6
+ extras: $ => [/\s/, /\\\r?\n/, $.comment, /\\( |\t|\v|\f)/],
7
7
 
8
8
  rules: {
9
- file: ($) => repeat(seq(optional($._command), $._end)),
9
+ file: $ => optional($._statements),
10
+
11
+ _statements: $ => seq(
12
+ repeat(seq(
13
+ $._statement,
14
+ $._terminator,
15
+ )),
16
+ $._statement,
17
+ optional($._terminator),
18
+ ),
10
19
 
11
- _command: ($) =>
20
+ _statement: $ =>
12
21
  choice(
13
22
  $.alias_directive,
14
23
  $.alternates_directive,
@@ -94,19 +103,19 @@ module.exports = grammar({
94
103
  $.unsubscribe_from_directive
95
104
  ),
96
105
 
97
- account_hook_directive: ($) =>
98
- command($, "account-hook", $._string, $._command),
106
+ account_hook_directive: $ =>
107
+ command($, "account-hook", $._string, $._statement),
99
108
 
100
- group_name: ($) => $._string,
101
- // TODO: support more `group_name`s
102
- _group: ($) => seq(alias("-group", $.command_line_option), $.group_name),
103
- _addresses: ($) => commaSep1($.address),
104
- 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: $ =>
105
114
  command($, "alias", optional($._group), $.key, $._addresses),
106
- address: ($) => $._string,
107
- unalias_directive: ($) =>
115
+ address: $ => $._string,
116
+ unalias_directive: $ =>
108
117
  command($, "unalias", optional($._group), choice("*", $.key)),
109
- key: ($) =>
118
+ key: $ =>
110
119
  repeat1(
111
120
  choice(
112
121
  seq("<", alias(/[a-zA-Z-]+/, $.key_name), ">"),
@@ -115,22 +124,22 @@ module.exports = grammar({
115
124
  )
116
125
  ),
117
126
 
118
- _regexes: ($) => spaceSep1($._regex),
119
- alternates_directive: ($) =>
127
+ _regexes: $ => repeat1($._regex),
128
+ alternates_directive: $ =>
120
129
  command($, "alternates", optional($._group), $._regexes),
121
- unalternates_directive: ($) =>
130
+ unalternates_directive: $ =>
122
131
  command($, "unalternates", optional($._group), choice("*", $._regexes)),
123
- alternative_order_directive: ($) =>
132
+ alternative_order_directive: $ =>
124
133
  command($, "alternative_order", $._mimes),
125
- unalternative_order_directive: ($) =>
134
+ unalternative_order_directive: $ =>
126
135
  command($, "unalternative_order", choice("*", $._mimes)),
127
- mime_type: (_) => /[-.a-zA-Z\d]+/,
128
- mime: ($) =>
136
+ mime_type: _ => /[-.a-zA-Z\d]+/,
137
+ mime: $ =>
129
138
  seq($.mime_type, optional(seq("/", alias($.mime_type, $.sub_mime_type)))),
130
- _mime_types: ($) => spaceSep1($.mime_type),
131
- _mimes: ($) => spaceSep1($.mime),
132
- disposition: ($) => $._string,
133
- attachments_directive: ($) =>
139
+ _mime_types: $ => repeat1($.mime_type),
140
+ _mimes: $ => repeat1($.mime),
141
+ disposition: $ => $._string,
142
+ attachments_directive: $ =>
134
143
  command(
135
144
  $,
136
145
  "attachments",
@@ -139,7 +148,7 @@ module.exports = grammar({
139
148
  "?"
140
149
  )
141
150
  ),
142
- unattachments_directive: ($) =>
151
+ unattachments_directive: $ =>
143
152
  command(
144
153
  $,
145
154
  "unattachments",
@@ -148,11 +157,11 @@ module.exports = grammar({
148
157
  "*"
149
158
  )
150
159
  ),
151
- auto_view_directive: ($) => command($, "auto_view", $._mimes),
152
- unauto_view_directive: ($) =>
160
+ auto_view_directive: $ => command($, "auto_view", $._mimes),
161
+ unauto_view_directive: $ =>
153
162
  command($, "unauto_view", choice("*", $._mimes)),
154
163
 
155
- map: (_) =>
164
+ map: _ =>
156
165
  choice(
157
166
  "alias",
158
167
  "attach",
@@ -168,20 +177,20 @@ module.exports = grammar({
168
177
  "query",
169
178
  "smime"
170
179
  ),
171
- _maps: ($) => commaSep1($.map),
172
- function: (_) => /[a-z-]+/,
173
- _functions: ($) => spaceSep1($.function),
174
- bind_directive: ($) => command($, "bind", $._maps, $.key, $.function),
175
- unbind_directive: ($) => command($, "unbind", choice("*", $._maps), $.key),
176
-
177
- alias: ($) => $._string,
178
- charset: ($) => $._string,
179
- 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: $ =>
180
189
  command($, "charset-hook", $.alias, $.charset),
181
- iconv_hook_directive: ($) => command($, "iconv-hook", $.charset, $.charset),
190
+ iconv_hook_directive: $ => command($, "iconv-hook", $.charset, $.charset),
182
191
 
183
- pattern: ($) => $._string,
184
- object: (_) =>
192
+ pattern: $ => $._string,
193
+ object: _ =>
185
194
  choice(
186
195
  "attach_headers",
187
196
  "attachment",
@@ -223,7 +232,7 @@ module.exports = grammar({
223
232
  "sidebar_ordinary",
224
233
  "sidebar_spool_file"
225
234
  ),
226
- composeobject: (_) =>
235
+ composeobject: _ =>
227
236
  choice(
228
237
  "header",
229
238
  "security_encrypt",
@@ -231,7 +240,7 @@ module.exports = grammar({
231
240
  "security_both",
232
241
  "security_none"
233
242
  ),
234
- color: (_) =>
243
+ color: _ =>
235
244
  choice(
236
245
  "default",
237
246
  "black",
@@ -243,14 +252,14 @@ module.exports = grammar({
243
252
  "cyan",
244
253
  "white",
245
254
  /#\d{6}/,
246
- /color\d+/
255
+ /(bright)?color\d+/
247
256
  ),
248
- attribute: (_) =>
257
+ attribute: _ =>
249
258
  choice("none", "bold", "underline", "reverse", "standout"),
250
- _attributes: ($) => spaceSep1($.attribute),
251
- foreground: ($) => $.color,
252
- background: ($) => $.color,
253
- color_directive: ($) =>
259
+ _attributes: $ => repeat1($.attribute),
260
+ foreground: $ => $.color,
261
+ background: $ => $.color,
262
+ color_directive: $ =>
254
263
  command(
255
264
  $,
256
265
  "color",
@@ -271,13 +280,13 @@ module.exports = grammar({
271
280
  )
272
281
  )
273
282
  ),
274
- uncolor_directive: ($) =>
283
+ uncolor_directive: $ =>
275
284
  command($, "uncolor", $.pattern, choice("*", $.pattern)),
276
285
 
277
- keyid: ($) => $._string,
278
- crypt_hook_directive: ($) => command($, "crypt-hook", $._regex, $.keyid),
279
- name: ($) => $._string,
280
- index_format_hook_directive: ($) =>
286
+ keyid: $ => $._string,
287
+ crypt_hook_directive: $ => command($, "crypt-hook", $._regex, $.keyid),
288
+ name: $ => $._string,
289
+ index_format_hook_directive: $ =>
281
290
  command(
282
291
  $,
283
292
  "index-format-hook",
@@ -287,126 +296,131 @@ module.exports = grammar({
287
296
  $._string
288
297
  ),
289
298
 
290
- exec_directive: ($) => command($, "exec", $._functions),
291
- fcc_save_hook_directive: ($) =>
299
+ exec_directive: $ => command($, "exec", $._functions),
300
+ fcc_save_hook_directive: $ =>
292
301
  command($, "fcc-save-hook", $.pattern, $.mailbox),
293
- fcc_hook_directive: ($) => command($, "fcc-hook", $.pattern, $.mailbox),
294
- save_hook_directive: ($) => command($, "save-hook", $.pattern, $.mailbox),
295
- 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: $ =>
296
305
  command(
297
306
  $,
298
307
  "folder-hook",
299
308
  optional(alias("-noregex", $.command_line_option)),
300
309
  $._regex,
301
- $._command
310
+ $._statement
302
311
  ),
303
312
 
304
- _rx_addr: ($) =>
313
+ _rx_addr: $ =>
305
314
  choice(
306
315
  seq(alias("-rx", $.command_line_option), $._regexes),
307
316
  seq(alias("-addr", $.command_line_option), $._addresses)
308
317
  ),
309
- group_directive: ($) => command($, "group", optional($._group), $._rx_addr),
310
- ungroup_directive: ($) =>
318
+ group_directive: $ => command($, "group", optional($._group), $._rx_addr),
319
+ ungroup_directive: $ =>
311
320
  command($, "ungroup", optional($._group), choice("*", $._rx_addr)),
312
321
 
313
- header: ($) => $._string,
314
- _headers: ($) => spaceSep1($.header),
315
- hdr_order_directive: ($) => command($, "hdr_order", $._headers),
316
- unhdr_order_directive: ($) =>
322
+ header: $ => $._string,
323
+ _headers: $ => repeat1($.header),
324
+ hdr_order_directive: $ => command($, "hdr_order", $._headers),
325
+ unhdr_order_directive: $ =>
317
326
  command($, "unhdr_order", choice("*", $._headers)),
318
327
 
319
- symbol: ($) => $._string,
320
- ifdef_directive: ($) => command($, "ifdef", $.symbol, $._command),
321
- ifndef_directive: ($) => command($, "ifndef", $.symbol, $._command),
322
- finish_directive: ($) => command($, "finish"),
328
+ symbol: $ => $._string,
329
+ ifdef_directive: $ => command($, "ifdef", $.symbol, $._statement),
330
+ ifndef_directive: $ => command($, "ifndef", $.symbol, $._statement),
331
+ finish_directive: $ => command($, "finish"),
323
332
 
324
- _strings: ($) => spaceSep1($._string),
325
- ignore_directive: ($) => command($, "ignore", $._strings),
326
- unignore_directive: ($) => command($, "unignore", choice("*", $._strings)),
333
+ _strings: $ => repeat1($._string),
334
+ ignore_directive: $ => command($, "ignore", $._strings),
335
+ unignore_directive: $ => command($, "unignore", choice("*", $._strings)),
327
336
 
328
- lists_directive: ($) => command($, "lists", $._group, $._regexes),
329
- unlists_directive: ($) =>
337
+ lists_directive: $ => command($, "lists", $._group, $._regexes),
338
+ unlists_directive: $ =>
330
339
  command($, "unlists", $._group, choice("*", $._regexes)),
331
- subscribe_directive: ($) => command($, "subscribe", $._group, $._regexes),
332
- unsubscribe_directive: ($) =>
340
+ subscribe_directive: $ => command($, "subscribe", $._group, $._regexes),
341
+ unsubscribe_directive: $ =>
333
342
  command($, "unsubscribe", $._group, choice("*", $._regexes)),
334
343
 
335
- sequence: ($) => $._string,
336
- macro_directive: ($) => command($, "macro", $._maps, $.key, $.sequence),
337
- unmacro_directive: ($) =>
344
+ sequence: $ => $._string,
345
+ macro_directive: $ => command($, "macro", $._maps, $.key, $.sequence, optional($.description)),
346
+ unmacro_directive: $ =>
338
347
  command($, "unmacro", choice("*", $._maps), $.key),
339
348
 
340
- mailbox: ($) => $._string,
341
- _mailboxes: ($) => spaceSep1($.mailbox),
342
- description: ($) => $._string,
343
- mailboxes_directive: ($) => command($, "mailboxes", $._mailboxes),
344
- named_mailboxes_directive: ($) =>
345
- command($, "named-mailboxes", spaceSep1(seq($.description, $.mailbox))),
346
- 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: $ =>
347
356
  command($, "unmailboxes", choice("*", $._mailboxes)),
348
357
 
349
- header_field: ($) => $._string,
350
- _header_fields: ($) => spaceSep1($.header_field),
351
- mailto_allow_directive: ($) =>
358
+ header_field: $ => $._string,
359
+ _header_fields: $ => repeat1($.header_field),
360
+ mailto_allow_directive: $ =>
352
361
  command($, "mailto_allow", choice("*", $._header_fields)),
353
- unmailto_allow_directive: ($) =>
362
+ unmailto_allow_directive: $ =>
354
363
  command($, "unmailto_allow", choice("*", $._header_fields)),
355
364
 
356
- message: ($) => $._string,
357
- echo_directive: ($) => command($, "echo", $.message),
358
- directory: ($) => $._string,
359
- cd_directive: ($) => command($, "cd", $.directory),
365
+ message: $ => $._string,
366
+ echo_directive: $ => command($, "echo", $.message),
367
+ directory: $ => $._string,
368
+ cd_directive: $ => command($, "cd", $.directory),
360
369
 
361
- mbox_hook_directive: ($) =>
370
+ mbox_hook_directive: $ =>
362
371
  command($, "mbox-hook", optional("-noregex"), $._regex, $.mailbox),
363
- message_hook_directive: ($) =>
364
- command($, "message-hook", $.pattern, $._command),
372
+ message_hook_directive: $ =>
373
+ command($, "message-hook", $.pattern, $._statement),
365
374
 
366
- mime_lookup_directive: ($) => command($, "mime_lookup", $._mimes),
367
- unmime_lookup_directive: ($) =>
375
+ mime_lookup_directive: $ => command($, "mime_lookup", $._mimes),
376
+ unmime_lookup_directive: $ =>
368
377
  command($, "unmime_lookup", choice("*", $._mimes)),
369
- mono_directive: ($) =>
378
+ mono_directive: $ =>
370
379
  command($, "mono", choice($.object, $.pattern), $.attribute, $._regex),
371
- unmono_directive: ($) =>
380
+ unmono_directive: $ =>
372
381
  command($, "unmono", $.pattern, choice("*", $.pattern)),
373
- my_hdr_directive: ($) => command($, "my_hdr", $._string),
374
- unmy_hdr_directive: ($) =>
382
+ my_hdr_directive: $ => command($, "my_hdr", $._string),
383
+ unmy_hdr_directive: $ =>
375
384
  command($, "unmy_hdr", choice("*", $.header_field)),
376
385
 
377
- shell_command: ($) => $._string,
378
- open_hook_directive: ($) =>
379
- command($, "open-hook", $._regex, $.shell_command),
380
- close_hook_directive: ($) =>
381
- command($, "close-hook", $._regex, $.shell_command),
382
- append_hook_directive: ($) =>
383
- command($, "append-hook", $._regex, $.shell_command),
384
-
385
- push_directive: ($) => command($, "push", $._string),
386
-
387
- reply_hook_directive: ($) =>
388
- command($, "reply-hook", $.pattern, $._command),
389
- send_hook_directive: ($) => command($, "send-hook", $.pattern, $._command),
390
- send2_hook_directive: ($) =>
391
- command($, "send2-hook", $.pattern, $._command),
392
-
393
- format: ($) => $._string,
394
- spam_directive: ($) => command($, "spam", $._regex, $.format),
395
- nospam_directive: ($) => command($, "nospam", choice("*", $._regex)),
396
- replacement: ($) => $._string,
397
- subjectrx_directive: ($) =>
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: $ =>
398
412
  command($, "subjectrx", $._regex, $.replacement),
399
- unsubjectrx_directive: ($) =>
413
+ unsubjectrx_directive: $ =>
400
414
  command($, "unsubjectrx", choice("*", $._regex)),
401
- uri: ($) => $._string,
402
- subscribe_to_directive: ($) => command($, "subscribe-to", $.uri),
403
- unsubscribe_from_directive: ($) => command($, "unsubscribe-from", $.uri),
415
+ uri: $ => $._string,
416
+ subscribe_to_directive: $ => command($, "subscribe-to", $.uri),
417
+ unsubscribe_from_directive: $ => command($, "unsubscribe-from", $.uri),
404
418
 
405
- timeout_hook_directive: ($) => command($, "timeout-hook", $._command),
406
- startup_hook_directive: ($) => command($, "startup-hook", $._command),
407
- shutdown_hook_directive: ($) => command($, "shutdown-hook", $._command),
419
+ timeout_hook_directive: $ => command($, "timeout-hook", $._statement),
420
+ startup_hook_directive: $ => command($, "startup-hook", $._statement),
421
+ shutdown_hook_directive: $ => command($, "shutdown-hook", $._statement),
408
422
 
409
- hook_type: (_) =>
423
+ hook_type: _ =>
410
424
  choice(
411
425
  "account-hook",
412
426
  "charset-hook",
@@ -427,64 +441,61 @@ module.exports = grammar({
427
441
  "startup-hook",
428
442
  "shutdown-hook"
429
443
  ),
430
- unhook_directive: ($) => command($, "unhook", choice("*", $.hook_type)),
431
-
432
- set_directive: ($) => command($, "set", choice($._options2, $._options3)),
433
- _options3: ($) =>
434
- spaceSep1(
435
- seq(
436
- $.option,
437
- optional(" "),
438
- choice("+=", "-=", "="),
439
- optional(" "),
440
- choice($.int, $.quadoption, $._string)
441
- )
442
- ),
443
- _options2: ($) => spaceSep1(seq(optional(choice("&", "?")), $.option)),
444
- _options: ($) => spaceSep1($.option),
445
- unset_directive: ($) => command($, "unset", $._options),
446
- reset_directive: ($) => command($, "reset", $._options),
447
- toggle_directive: ($) => command($, "toggle", $._options),
444
+ unhook_directive: $ => command($, "unhook", choice("*", $.hook_type)),
448
445
 
449
- setenv_directive: ($) =>
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: $ =>
450
464
  command(
451
465
  $,
452
466
  "setenv",
453
467
  choice(seq("?", $.option), seq($.option, alias(/\S+/, $.value)))
454
468
  ),
455
- unsetenv_directive: ($) => command($, "unsetenv", $.option),
456
- sidebar_pin_directive: ($) => command($, "sidebar_pin", $._mailboxes),
457
- sidebar_unpin_directive: ($) =>
469
+ unsetenv_directive: $ => command($, "unsetenv", $.option),
470
+ sidebar_pin_directive: $ => command($, "sidebar_pin", $._mailboxes),
471
+ sidebar_unpin_directive: $ =>
458
472
  command($, "sidebar_unpin", choice("*", $._mailboxes)),
459
- score_directive: ($) => command($, "score", $.pattern, $.int),
460
- unscore_directive: ($) => command($, "unscore", choice("*", $.pattern)),
473
+ score_directive: $ => command($, "score", $.pattern, $.int),
474
+ unscore_directive: $ => command($, "unscore", choice("*", $.pattern)),
475
+ source_directive: $ => command($, "source", alias($._string, $.path)),
461
476
 
462
- option: (_) => /[a-z_\d]+/,
477
+ option: _ => /[a-z_\d]+/,
463
478
 
464
- quadoption: (_) => choice("yes", "no", "ask-yes", "ask-no"),
465
- int: (_) => /-?\d+/,
466
- _string: ($) =>
479
+ quadoption: _ => choice("yes", "no", "ask-yes", "ask-no"),
480
+ int: _ => /-?\d+/,
481
+ _string: $ =>
467
482
  choice(
468
483
  quoted_string("'", $.string),
469
- quoted_string('"', $.shell),
484
+ quoted_string('"', $.string),
470
485
  quoted_string("`", $.shell),
471
- alias($._word, $.shell),
486
+ alias($._word, $.string),
472
487
  ),
473
- _regex: ($) =>
488
+ _regex: $ =>
474
489
  choice(
475
490
  quoted_string("'", $.regex),
476
491
  quoted_string('"', $.regex),
477
492
  quoted_string("`", $.shell),
478
493
  alias($._word, $.regex),
479
494
  ),
480
- _word: (_) => /(\\\r?\n|[^"'`\s])(\S|\\\s)*/,
481
-
482
- source_directive: ($) => command($, "source", alias($._string, $.path)),
495
+ _word: _ => /([^"'`#;\s]|\\.)+/,
483
496
 
484
- comment: (_) => /#[^\n]*/,
485
- _eol: (_) => /\r?\n/,
486
- _space: (_) => prec(-1, repeat1(/[ \t]/)),
487
- _end: ($) => seq(optional($._space), optional($.comment), $._eol),
497
+ comment: _ => seq('#', /[^\n]*/),
498
+ _terminator: _ => choice(';', /\n/),
488
499
  },
489
500
  });
490
501
 
@@ -492,16 +503,8 @@ function command($, cmd, ...args) {
492
503
  return seq(alias(cmd, $.command), ...args);
493
504
  }
494
505
 
495
- function sep1(rule, separator) {
496
- return seq(rule, repeat(seq(separator, rule)));
497
- }
498
-
499
506
  function commaSep1(rule) {
500
- return sep1(rule, ",");
501
- }
502
-
503
- function spaceSep1(rule) {
504
- return sep1(rule, " ");
507
+ return seq(rule, repeat(seq(token.immediate(","), rule)));
505
508
  }
506
509
 
507
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.6",
4
- "description": "Muttrc grammar for tree-sitter",
5
- "repository": "github:tree-sitter/tree-sitter-muttrc",
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": "^7.1.0",
25
- "node-gyp-build": "^4.8.0"
36
+ "node-addon-api": "^8.5.0",
37
+ "node-gyp-build": "^4.8.4"
26
38
  },
27
39
  "devDependencies": {
28
- "prebuildify": "^6.0.0",
29
- "tree-sitter-cli": "^0.22.2"
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.21.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
- "prebuildify": "prebuildify --napi --strip",
42
- "build": "tree-sitter generate --no-bindings",
43
- "build-wasm": "tree-sitter build --wasm",
44
- "test": "tree-sitter test",
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