forked from emacs-tree-sitter/ts-fold
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ts-fold-parsers.el
620 lines (542 loc) · 23 KB
/
ts-fold-parsers.el
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
;;; ts-fold-parsers.el --- Adapter layer to Tree-Sitter -*- lexical-binding: t; -*-
;; Copyright (C) 2021-2023 Shen, Jen-Chieh
;; Created date 2021-10-04 17:45:48
;; This file is NOT part of GNU Emacs.
;; This program is free software; you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation, either version 3 of the License, or
;; (at your option) any later version.
;; This program is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;; GNU General Public License for more details.
;; You should have received a copy of the GNU General Public License
;; along with this program. If not, see <https://www.gnu.org/licenses/>.
;;; Commentary:
;;
;; Adapter layer to Tree-Sitter
;;
;; This isn't a real parser implementation, but records down the rule
;; in order to let the Tree-Sitter to parse things correctly. Think of
;; the rule sets!
;;
;;; Code:
;;
;; (@* "Externals" )
;;
;; TODO(everyone): keep the forward declared alphabetically sorted
(declare-function ts-fold-range-seq "ts-fold.el")
(declare-function ts-fold-range-line-comment "ts-fold.el")
(declare-function ts-fold-range-block-comment "ts-fold.el")
(declare-function ts-fold-range-c-like-comment "ts-fold.el")
(declare-function ts-fold-range-asm-label "ts-fold.el")
(declare-function ts-fold-range-beancount-transaction "ts-fold.el")
(declare-function ts-fold-range-c-preproc-ifdef "ts-fold.el")
(declare-function ts-fold-range-c-preproc-if "ts-fold.el")
(declare-function ts-fold-range-c-preproc-elif "ts-fold.el")
(declare-function ts-fold-range-c-preproc-else "ts-fold.el")
(declare-function ts-fold-range-elisp-function "ts-fold.el")
(declare-function ts-fold-range-elixir "ts-fold.el")
(declare-function ts-fold-range-erlang-clause-body "ts-fold.el")
(declare-function ts-fold-range-erlang-type-guards "ts-fold.el")
(declare-function ts-fold-range-fish-function "ts-fold.el")
(declare-function ts-fold-range-fish-if "ts-fold.el")
(declare-function ts-fold-range-fish-case "ts-fold.el")
(declare-function ts-fold-range-haskell-function "ts-fold.el")
(declare-function ts-fold-range-html "ts-fold.el")
(declare-function ts-fold-range-julia-function "ts-fold.el")
(declare-function ts-fold-range-julia-if "ts-fold.el")
(declare-function ts-fold-range-julia-let "ts-fold.el")
(declare-function ts-fold-range-kotlin-when "ts-fold.el")
(declare-function ts-fold-range-lisp-function "ts-fold.el")
(declare-function ts-fold-range-llvm-label "ts-fold.el")
(declare-function ts-fold-range-llvm-mir-label "ts-fold.el")
(declare-function ts-fold-range-lua-comment "ts-fold.el")
(declare-function ts-fold-range-lua-function "ts-fold.el")
(declare-function ts-fold-range-lua-if "ts-fold.el")
(declare-function ts-fold-range-lua-elseif "ts-fold.el")
(declare-function ts-fold-range-lua-else "ts-fold.el")
(declare-function ts-fold-range-lua-do-loop "ts-fold.el")
(declare-function ts-fold-range-lua-repeat "ts-fold.el")
(declare-function ts-fold-range-make-recipe "ts-fold.el")
(declare-function ts-fold-range-mermaid-diagram "ts-fold.el")
(declare-function ts-fold-range-mermaid-block "ts-fold.el")
(declare-function ts-fold-range-ocaml-comment "ts-fold.el")
(declare-function ts-fold-range-ocaml-module-definition "ts-fold.el")
(declare-function ts-fold-range-ocaml-type-definition "ts-fold.el")
(declare-function ts-fold-range-ocaml-value-definition "ts-fold.el")
(declare-function ts-fold-range-org-body "ts-fold.el")
(declare-function ts-fold-range-clojure-function "ts-fold.el")
(declare-function ts-fold-range-pascal-comment "ts-fold.el")
(declare-function ts-fold-range-python-def "ts-fold.el")
(declare-function ts-fold-range-python-expression-statement "ts-fold.el")
(declare-function ts-fold-range-rst-body "ts-fold.el")
(declare-function ts-fold-range-ruby-class-def "ts-fold.el")
(declare-function ts-fold-range-ruby-if "ts-fold.el")
(declare-function ts-fold-range-rust-macro "ts-fold.el")
(declare-function ts-fold-range-sql-block "ts-fold.el")
(declare-function ts-fold-range-toml-table "ts-fold.el")
(declare-function ts-fold-range-verilog-list "ts-fold.el")
(declare-function ts-fold-range-verilog-initial-construct "ts-fold.el")
(declare-function ts-fold-range-verilog-module "ts-fold.el")
(declare-function ts-fold-range-vhdl-package "ts-fold.el")
(declare-function ts-fold-range-vhdl-type "ts-fold.el")
;;
;; (@* "Parsers" )
;;
;; TODO(everyone): keep the function alphabetically sorted
(defun ts-fold-parsers-actionscript ()
"Rule set for ActionScript."
'((statement_block . ts-fold-range-seq)
(line_comment . ts-fold-range-c-like-comment)
(block_comment . ts-fold-range-c-like-comment)))
(defun ts-fold-parsers-agda ()
"Rule set for Agda."
'(()))
(defun ts-fold-parsers-arduino ()
"Rule set for Arduino."
(append (ts-fold-parsers-c++)))
(defun ts-fold-parsers-asm ()
"Rule set for Assembly."
'((label . ts-fold-range-asm-label)
(line_comment
. (lambda (node offset)
(ts-fold-range-line-comment node offset ";;")))))
(defun ts-fold-parsers-bash ()
"Rule set for Bash."
'((compound_statement . ts-fold-range-seq)
(do_group . (ts-fold-range-seq 1 -3))
(comment
. (lambda (node offset)
(ts-fold-range-line-comment node offset "#")))))
(defun ts-fold-parsers-beancount ()
"Rule set for Beancount."
'((transaction . ts-fold-range-beancount-transaction)
(comment
. (lambda (node offset)
(ts-fold-range-line-comment node offset ";;")))))
(defun ts-fold-parsers-c ()
"Rule set for C."
'((compound_statement . ts-fold-range-seq)
(declaration_list . ts-fold-range-seq)
(enumerator_list . ts-fold-range-seq)
(field_declaration_list . ts-fold-range-seq)
(preproc_if . ts-fold-range-c-preproc-if)
(preproc_ifdef . ts-fold-range-c-preproc-ifdef)
(preproc_elif . ts-fold-range-c-preproc-elif)
(preproc_else . ts-fold-range-c-preproc-else)
(comment . ts-fold-range-c-like-comment)))
(defun ts-fold-parsers-c++ ()
"Rule set for C++."
(append (ts-fold-parsers-c)))
(defun ts-fold-parsers-clojure ()
"Rule set for Clojure."
'((list_lit . ts-fold-range-clojure-function)
(map_lit . ts-fold-range-seq)
(str_lit . ts-fold-range-seq)
(comment
. (lambda (node offset)
(ts-fold-range-line-comment node offset ";;")))))
(defun ts-fold-parsers-cmake ()
"Rule set for CMake."
'((body . ts-fold-range-seq)
(line_comment
. (lambda (node offset)
(ts-fold-range-line-comment node offset "#")))))
(defun ts-fold-parsers-csharp ()
"Rule set for C#."
'((block . ts-fold-range-seq)
(accessor_list . ts-fold-range-seq)
(enum_member_declaration_list . ts-fold-range-seq)
(declaration_list . ts-fold-range-seq)
(switch_body . ts-fold-range-seq)
(anonymous_object_creation_expression . ts-fold-range-seq)
(initializer_expression . ts-fold-range-seq)
;;(if_directive . ts-fold-range-seq)
;;(else_directive . ts-fold-range-seq)
;;(elif_directive . ts-fold-range-seq)
;;(endif_directive . ts-fold-range-seq)
;;(region_directive . ts-fold-range-seq)
;;(endregion_directive . ts-fold-range-seq)
(comment . ts-fold-range-c-like-comment)))
(defun ts-fold-parsers-css ()
"Rule set for CSS."
'((keyframe_block_list . ts-fold-range-seq)
(block . ts-fold-range-seq)
(comment . ts-fold-range-c-like-comment)))
(defun ts-fold-parsers-dart ()
"Rule set for Dart."
'((block . ts-fold-range-seq)
(class_body . ts-fold-range-seq)
(arguments . ts-fold-range-seq)
(comment . ts-fold-range-c-like-comment)
(documentation_comment . ts-fold-range-c-like-comment)
(list_literal . ts-fold-range-seq))) ; array
(defun ts-fold-parsers-elisp ()
"Rule set for Elisp."
'((macro_definition . ts-fold-range-elisp-function)
(function_definition . ts-fold-range-elisp-function)
(comment
. (lambda (node offset)
(ts-fold-range-line-comment node offset ";;")))))
(defun ts-fold-parsers-elixir ()
"Rules set for Elixir."
'((list . ts-fold-range-seq)
(map . ts-fold-range-seq)
(tuple . ts-fold-range-seq)
(do_block . ts-fold-range-elixir)
(comment
. (lambda (node offset)
(ts-fold-range-line-comment node offset "#")))))
(defun ts-fold-parsers-erlang ()
"Rules set for Erlang."
'((list . ts-fold-range-seq)
(clause_body . ts-fold-range-erlang-clause-body)
(type_guards . ts-fold-range-erlang-type-guards)
(comment
. (lambda (node offset)
(ts-fold-range-line-comment node offset "%")))))
(defun ts-fold-parsers-fish ()
"Rules set for Fish."
'((function_definition . ts-fold-range-fish-function)
(if_statement . ts-fold-range-fish-if)
(switch_statement . ts-fold-range-fish-if)
(for_statement . ts-fold-range-fish-if)
(while_statement . ts-fold-range-fish-if)
(case_clause . ts-fold-range-fish-case)
(comment
. (lambda (node offset)
(ts-fold-range-line-comment node offset "#")))))
(defun ts-fold-parsers-gdscript ()
"Rule set for GGScript."
'((body . (ts-fold-range-seq -1 1))
(comment
. (lambda (node offset)
(ts-fold-range-line-comment node offset "#")))))
(defun ts-fold-parsers-glsl ()
"Rule set for GLSL."
'((field_declaration_list . ts-fold-range-seq)
(compound_statement . ts-fold-range-seq)
(comment . ts-fold-range-c-like-comment)))
(defun ts-fold-parsers-go ()
"Rule set for Go."
'((block . ts-fold-range-seq)
(comment . ts-fold-range-c-like-comment)
(const_declaration . (lambda (node offset)
(ts-fold-range-markers node offset "(" ")")))
(field_declaration_list . ts-fold-range-seq)
(import_spec_list . ts-fold-range-seq)
(interface_type . (lambda (node offset)
(ts-fold-range-markers node offset "{" "}")))))
(defun ts-fold-parsers-groovy ()
"Rule set for Groovy."
'((block . ts-fold-range-groovy-block)
(line_comment . ts-fold-range-c-like-comment)
(block_comment . ts-fold-range-c-like-comment)))
(defun ts-fold-parsers-haskell ()
"Rule set for Haskell."
'((function . ts-fold-range-haskell-function)
(comment . ts-fold-range-lua-comment)))
(defun ts-fold-parsers-hlsl ()
"Rule set for HLSL."
'((field_declaration_list . ts-fold-range-seq)
(compound_statement . ts-fold-range-seq)
(comment . ts-fold-range-c-like-comment)))
(defun ts-fold-parsers-html ()
"Rule set for HTML."
'((element . ts-fold-range-html)
(comment . (ts-fold-range-seq 1 -1))))
(defun ts-fold-parsers-jai ()
"Rule set for Jai."
'((imperative_scope . ts-fold-range-seq)
(data_scope . ts-fold-range-seq)
(block_comment . ts-fold-range-block-comment)
(inline_comment . ts-fold-range-c-like-comment)))
(defun ts-fold-parsers-java ()
"Rule set for Java."
'((switch_block . ts-fold-range-seq)
(block . ts-fold-range-seq)
(element_value_array_initializer . ts-fold-range-seq)
(module_body . ts-fold-range-seq)
(enum_body . ts-fold-range-seq)
(class_body . ts-fold-range-seq)
(constructor_body . ts-fold-range-seq)
(annotation_type_body . ts-fold-range-seq)
(interface_body . ts-fold-range-seq)
(array_initializer . ts-fold-range-seq)
(block_comment . ts-fold-range-block-comment)
(line_comment . ts-fold-range-c-like-comment)))
(defun ts-fold-parsers-javascript ()
"Rule set for JavaScript."
'((export_clause . ts-fold-range-seq)
(statement_block . ts-fold-range-seq)
(object . ts-fold-range-seq)
(array . ts-fold-range-seq)
(comment . ts-fold-range-c-like-comment)))
(defun ts-fold-parsers-json ()
"Rule set for JSON."
'((object . ts-fold-range-seq)
(array . ts-fold-range-seq)))
(defun ts-fold-parsers-jsonnet ()
"Rule set for Jsonnet."
'((object . ts-fold-range-seq)
(array . ts-fold-range-seq)
(comment . ts-fold-range-c-like-comment)))
(defun ts-fold-parsers-julia ()
"Rule set for Julia."
'((block_comment . (ts-fold-range-seq 1 -1))
(for_statement . ts-fold-range-julia-if-for-while)
(function_definition . ts-fold-range-julia-function)
(function_expression . ts-fold-range-julia-function)
(if_statement . ts-fold-range-julia-if-for-while)
(let_statement . ts-fold-range-julia-let)
(macro_definition . ts-fold-range-julia-function)
(module_definition . ts-fold-range-julia-function)
(quote_statement . ts-fold-range-julia-function)
(struct_definition . ts-fold-range-julia-function)
(triple_string . (ts-fold-range-seq 2 -2))
(try_statement . (ts-fold-range-seq 2 -2))
(while_statement . ts-fold-range-julia-if-for-while)
(comment
. (lambda (node offset)
(ts-fold-range-line-comment node offset "#")))))
(defun ts-fold-parsers-kotlin ()
"Rule set for Kotlin."
'((function_body . ts-fold-range-seq)
(control_structure_body . ts-fold-range-seq)
(lambda_literal . ts-fold-range-seq)
(enum_class_body . ts-fold-range-seq)
(class_body . ts-fold-range-seq)
(when_expression . ts-fold-range-kotlin-when)
(multiline_comment . ts-fold-range-c-like-comment)
(line_comment . ts-fold-range-c-like-comment)))
(defun ts-fold-parsers-latex ()
"Rule set for LaTex."
'((curly_group . ts-fold-range-seq)
(line_comment
. (lambda (node offset)
(ts-fold-range-line-comment node offset "%")))))
(defun ts-fold-parsers-lisp ()
"Rule set for Lisp."
'((defun . ts-fold-range-lisp-function)
(comment
. (lambda (node offset)
(ts-fold-range-line-comment node
(ts-fold--cons-add offset '(0 . -1))
";;")))))
(defun ts-fold-parsers-llvm ()
"Rule set for LLVM."
'((function_body . ts-fold-range-seq)
(label . ts-fold-range-llvm-label)
(comment
. (lambda (node offset)
(ts-fold-range-line-comment node offset ";;")))))
(defun ts-fold-parsers-llvm-mir ()
"Rule set for LLVM MIR."
'((basic_block . ts-fold-range-llvm-mir-label)
(comment
. (lambda (node offset)
(ts-fold-range-line-comment node offset ";;")))))
(defun ts-fold-parsers-lua ()
"Rule set for Lua."
'((expression_list . ts-fold-range-seq)
(function_declaration . ts-fold-range-lua-function)
(if_statement . ts-fold-range-lua-if)
(elseif_statement . ts-fold-range-lua-elseif)
(else_statement . ts-fold-range-lua-else)
(while_statement . ts-fold-range-lua-do-loop)
(for_statement . ts-fold-range-lua-do-loop)
(repeat_statement . ts-fold-range-lua-repeat)
(comment . ts-fold-range-lua-comment)))
(defun ts-fold-parsers-make ()
"Rule set for Make."
'((recipe . ts-fold-range-make-recipe)
(comment
. (lambda (node offset)
(ts-fold-range-line-comment node offset "#")))))
(defun ts-fold-parsers-markdown ()
"Rule set for Markdown."
'((fenced_code_block . (ts-fold-range-seq 2 -2))
(html_block . ts-fold-range-html)))
(defun ts-fold-parsers-mermaid ()
"Rule set for Mermaid."
'((diagram_flow . ts-fold-range-mermaid-diagram)
(diagram_sequence . ts-fold-range-mermaid-diagram)
(diagram_class . ts-fold-range-mermaid-diagram)
(diagram_er . ts-fold-range-mermaid-diagram)
(class_stmt_class . ts-fold-range-mermaid-block)
(er_stmt_entity_block . ts-fold-range-mermaid-block)
(comment
. (lambda (node offset)
(ts-fold-range-line-comment node
(ts-fold--cons-add offset '(0 . -1))
"%%")))))
(defun ts-fold-parsers-noir ()
"Rule set for Noir."
'((body . ts-fold-range-seq)
(comment . ts-fold-range-c-like-comment)))
(defun ts-fold-parsers-nix ()
"Rule set for Nix."
'((attrset_expression . ts-fold-range-seq)
(interpolation . ts-fold-range-seq)
(list_expression . ts-fold-range-seq)
(comment
. (lambda (node offset)
(ts-fold-range-line-comment node offset "#")))))
(defun ts-fold-parsers-ocaml ()
"Rule set for OCaml."
'((comment . ts-fold-range-ocaml-comment)
(module_definition . ts-fold-range-ocaml-module-definition)
(type_definition . ts-fold-range-ocaml-type-definition)
(value_definition . ts-fold-range-ocaml-value-definition)))
(defun ts-fold-parsers-org ()
"Rule set for Org."
'((body . ts-fold-range-org-body)
(block . ts-fold-range-seq)
(comment . ts-fold-range-seq)))
(defun ts-fold-parsers-pascal ()
"Rule set for Pascal."
'((comment . ts-fold-range-pascal-comment)))
(defun ts-fold-parsers-perl ()
"Rule set for Perl."
'((block . ts-fold-range-seq)
(list_expression . ts-fold-range-seq)
(comment
. (lambda (node offset)
(ts-fold-range-line-comment node offset "#")))))
(defun ts-fold-parsers-php ()
"Rule set for PHP."
'((namespace_use_group . ts-fold-range-seq)
(declaration_list . ts-fold-range-seq)
(use_list . ts-fold-range-seq)
(switch_block . ts-fold-range-seq)
(compound_statement . ts-fold-range-seq)
(comment
. (lambda (node offset)
(if (string-prefix-p "#" (tsc-node-text node))
(ts-fold-range-line-comment node offset "#")
(ts-fold-range-c-like-comment node offset))))))
(defun ts-fold-parsers-python ()
"Rule set for Python."
'((function_definition . ts-fold-range-python-def)
(class_definition . ts-fold-range-python-def)
(list . ts-fold-range-seq)
(dictionary . ts-fold-range-seq)
(expression_statement . ts-fold-range-python-expression-statement)
(comment
. (lambda (node offset)
(ts-fold-range-line-comment node offset "#")))))
(defun ts-fold-parsers-qss ()
"Rule set for QSS."
(append (ts-fold-parsers-css)))
(defun ts-fold-parsers-r ()
"Rule set for R."
'((brace_list . ts-fold-range-seq)))
(defun ts-fold-parsers-rst ()
"Rule set for reStructuredText."
'((body . ts-fold-range-rst-body)
(comment . (ts-fold-range-seq 1 0))))
(defun ts-fold-parsers-ruby ()
"Rule set for Ruby."
'((class . ts-fold-range-ruby-class-def)
(method . ts-fold-range-ruby-class-def)
(array . ts-fold-range-seq)
(do . (ts-fold-range-seq 1 -2)) ; match with `end`
(do_block . (ts-fold-range-seq 1 -2)) ; match with `end`, in spec file
(then . ts-fold-range-ruby-if) ; `if` and `elsif` block
(else . (ts-fold-range-ruby-if 4 0)) ; `else` block
(comment
. (lambda (node offset)
(ts-fold-range-line-comment node offset "#")))))
(defun ts-fold-parsers-rust ()
"Rule set for Rust."
'((declaration_list . ts-fold-range-seq)
(enum_variant_list . ts-fold-range-seq)
(field_declaration_list . ts-fold-range-seq)
(use_list . ts-fold-range-seq)
(field_initializer_list . ts-fold-range-seq)
(match_block . ts-fold-range-seq)
(macro_definition . (ts-fold-range-rust-macro 1 -1))
(block . ts-fold-range-seq)
(line_comment . (lambda (node offset)
(ts-fold-range-line-comment node offset "///")))
(block_comment . ts-fold-range-block-comment)))
(defun ts-fold-parsers-scala ()
"Rule set for Scala."
'((import_selectors . ts-fold-range-seq)
(template_body . ts-fold-range-seq)
(block . ts-fold-range-seq)
(comment . ts-fold-range-c-like-comment)))
(defun ts-fold-parsers-scheme ()
"Rule set for Scheme."
'((list . ts-fold-range-seq)
(comment
. (lambda (node offset)
(ts-fold-range-line-comment node offset ";;")))))
(defun ts-fold-parsers-sql ()
"Rule set for SQL."
'((block . ts-fold-range-sql-block)
(subquery . ts-fold-range-seq)
(list . ts-fold-range-seq)
(marginalia . ts-fold-range-c-like-comment))) ; This is the comment!
(defun ts-fold-parsers-swift ()
"Rule set for Swift."
'((switch_statement . ts-fold-range-seq)
(function_declaration . ts-fold-range-seq)
(enum_declaration . ts-fold-range-seq)
(struct_declaration . ts-fold-range-seq)
(class_declaration . ts-fold-range-seq)
(protocol_declaration . ts-fold-range-seq)
(extension_declaration . ts-fold-range-seq)
(comment . ts-fold-range-c-like-comment)))
(defun ts-fold-parsers-tablegen ()
"Rule set for Tablegen."
'((record_body . ts-fold-range-seq)
(multiline_comment . ts-fold-range-c-like-comment)
(comment . ts-fold-range-c-like-comment)))
(defun ts-fold-parsers-toml ()
"Rule set for TOML."
'((table . ts-fold-range-toml-table)
(array . ts-fold-range-seq)
(comment
. (lambda (node offset)
(ts-fold-range-line-comment node offset "#")))))
(defun ts-fold-parsers-typescript ()
"Rule set for TypeScript."
(append
(ts-fold-parsers-javascript)
'((class_body . ts-fold-range-seq)
(enum_body . ts-fold-range-seq)
(named_imports . ts-fold-range-seq)
(object_type . ts-fold-range-seq))))
(defun ts-fold-parsers-verilog ()
"Rule set for Verilog."
'((module_declaration . ts-fold-range-verilog-module)
(list_of_port_connections . ts-fold-range-verilog-list)
(initial_construct . ts-fold-range-verilog-initial-construct)
(comment . ts-fold-range-c-like-comment)))
(defun ts-fold-parsers-vhdl ()
"Rule set for VHDL."
'((package_declaration . ts-fold-range-vhdl-package)
(full_type_declaration . ts-fold-range-vhdl-type)
(enumeration_type_definition . ts-fold-range-seq)
(comment . ts-fold-range-lua-comment)))
(defun ts-fold-parsers-xml ()
"Rule set for XML."
'((element . ts-fold-range-html)
(Comment . (ts-fold-range-seq 3 -2))))
(defun ts-fold-parsers-yaml ()
"Rule set for YAML."
'((comment
. (lambda (node offset)
(ts-fold-range-line-comment node offset "#")))
(block_mapping_pair
. ((lambda (node offset)
(ts-fold-range-markers node offset ":"))
0 1))))
(defun ts-fold-parsers-zig ()
"Rule set for Zig."
'((Block . ts-fold-range-seq)
(line_comment . ts-fold-range-c-like-comment)))
(provide 'ts-fold-parsers)
;;; ts-fold-parsers.el ends here