68
68
(modify-syntax-entry ?\\ " \\ " table) ; Escape seq start
69
69
(modify-syntax-entry ?\" " \" " table) ; String start
70
70
(modify-syntax-entry ?' " /" table) ; Char start
71
- (modify-syntax-entry ?/ " < 12 " table) ; Comment seq a, first two char are /
72
- (modify-syntax-entry ?\n " > " table) ; Comment seq a, ends with a newline
73
- (modify-syntax-entry ?/ " . 14b " table) ; Comment seq b, starts and ends with /
74
- (modify-syntax-entry ?* " . 23b " table) ; Comment seq b, second start and first end char is *
71
+ (modify-syntax-entry ?/ " . 124b " table) ; Line/block comment // or /* * /
72
+ (modify-syntax-entry ?* " . 23n " table) ; Block comment /* */
73
+ (modify-syntax-entry ?\n " > b " table) ; Comment ends with newline
74
+ (modify-syntax-entry ?\r " > b " table) ; Comment ends with carriage return
75
75
table)
76
76
" Syntax table for `scala-ts-mode' ." )
77
77
144
144
:feature 'extra
145
145
`([,@scala-ts--brackets ] @font-lock-bracket-face
146
146
[,@scala-ts--delimiters ] @font-lock-delimiter-face)
147
-
147
+
148
148
:language 'scala
149
149
:feature 'comment
150
150
'((comment) @font-lock-comment-face
197
197
(:match " ^[A-Z]" @font-lock-function-call-face))
198
198
(generic_function
199
199
function: (identifier) @font-lock-function-call-face)
200
-
200
+
201
201
202
202
; ; function definitions
203
203
(function_definition
355
355
(string= (treesit-node-type node)
356
356
" then" ))
357
357
0 )
358
-
358
+
359
359
; ; indented and non
360
360
(t offset))))
361
361
392
392
" identifier" )
393
393
offset
394
394
0 )))
395
-
395
+
396
396
((rx (| scala-ts--indent-keywords scala-ts--indent) eol)
397
397
offset)
398
398
408
408
(pcase (treesit-node-type last-node)
409
409
(" ERROR"
410
410
(scala-ts--indent-error-anchor nil last-node pos))
411
-
411
+
412
412
((rx scala-ts--indent-keywords eol)
413
413
(goto-char (treesit-node-start last-node))
414
414
(back-to-indentation )
440
440
(pcase (treesit-node-type last-node)
441
441
(" ERROR"
442
442
(scala-ts--indent-error-offset nil last-node pos))
443
-
443
+
444
444
((rx scala-ts--indent-keywords eol)
445
445
(goto-char (treesit-node-start last-node))
446
446
(back-to-indentation )
@@ -480,21 +480,21 @@ or node matching `treesit-defun-type-regexp' is found."
480
480
(let ((offset scala-ts-indent-offset))
481
481
`((scala
482
482
((node-is " ^comment$" ) no-indent 0 )
483
-
483
+
484
484
((node-is " ^}$" ) parent-bol 0 )
485
485
((node-is " ^)$" ) parent-bol 0 )
486
-
486
+
487
487
((parent-is " ^if_expression$" )
488
488
scala-ts--indent-if-anchor
489
489
scala-ts--indent-if-offset)
490
490
; ; Handle else-if
491
491
((n-p-gp " ^postfix_expression$" " ^indented_block$" " ^if_expression$" ) grand-parent 0 )
492
-
492
+
493
493
((n-p-gp " ^enumerators$" " ^for_expression$" nil ) parent-bol , offset )
494
494
((n-p-gp " ^enumerator$" " ^enumerators$" nil ) parent 0 )
495
495
((n-p-gp " ^ERROR$" " ^enumerators$" nil ) prev-line ,(- offset))
496
496
((n-p-gp " ^yield$" " ^for_expression$" nil ) parent-bol 0 )
497
-
497
+
498
498
((n-p-gp " ^catch_clause$" " ^try_expression$" nil ) parent 0 )
499
499
((n-p-gp " ^finally_clause$" " ^try_expression$" nil ) parent 0 )
500
500
@@ -510,9 +510,9 @@ or node matching `treesit-defun-type-regexp' is found."
510
510
(- , offset )
511
511
, offset )))
512
512
((parent-is " ^case_clause$" ) parent , offset )
513
-
513
+
514
514
((node-is " ^end$" ) scala-ts--indent-end 0 )
515
-
515
+
516
516
; ; Handle function annotations
517
517
((n-p-gp " ^def$" " ^function_definition$" nil ) parent 0 )
518
518
@@ -539,7 +539,7 @@ or node matching `treesit-defun-type-regexp' is found."
539
539
((parent-is " ^parameters$" ) parent-bol , offset )
540
540
((parent-is " ^arguments$" ) parent-bol , offset )
541
541
((parent-is " ^tuple_expression$" ) parent , offset )
542
-
542
+
543
543
((node-is " definition" ) prev-sibling 0 )
544
544
((node-is " declaration" ) prev-sibling 0 )
545
545
((node-is " ^enum_body$" ) prev-sibling 0 )
@@ -555,7 +555,7 @@ or node matching `treesit-defun-type-regexp' is found."
555
555
" finally" ))
556
556
(- , offset )
557
557
0 )))
558
-
558
+
559
559
((n-p-gp " ^call_expression$" " ^indented_block$" nil )
560
560
(lambda (node parent _bol )
561
561
parent
@@ -573,7 +573,7 @@ or node matching `treesit-defun-type-regexp' is found."
573
573
" block" )))
574
574
(- , offset )
575
575
0 )))
576
-
576
+
577
577
((n-p-gp " ^indented_block$" " ^ERROR$" nil ) no-indent 0 )
578
578
((parent-is " ^indented_block$" ) parent 0 )
579
579
((parent-is " ^block$" ) parent-bol , offset )
0 commit comments