diff options
Diffstat (limited to 'lisp/progmodes')
-rw-r--r-- | lisp/progmodes/c-ts-mode.el | 6 | ||||
-rw-r--r-- | lisp/progmodes/java-ts-mode.el | 4 | ||||
-rw-r--r-- | lisp/progmodes/js.el | 5 | ||||
-rw-r--r-- | lisp/progmodes/ts-mode.el | 4 |
4 files changed, 17 insertions, 2 deletions
diff --git a/lisp/progmodes/c-ts-mode.el b/lisp/progmodes/c-ts-mode.el index f8e809bb43f..43668a56d96 100644 --- a/lisp/progmodes/c-ts-mode.el +++ b/lisp/progmodes/c-ts-mode.el @@ -84,8 +84,8 @@ MODE is either `c' or `cpp'." ((node-is "else") parent-bol 0) ((node-is "case") parent-bol 0) ((node-is "preproc_arg") no-indent) - ((node-is "comment") no-indent) - ((parent-is "comment") no-indent) + ((and (parent-is "comment") comment-end) comment-start -1) + ((parent-is "comment") comment-start-skip 0) ((node-is "labeled_statement") parent-bol 0) ((parent-is "labeled_statement") parent-bol c-ts-mode-indent-offset) ((match "preproc_ifdef" "compound_statement") point-min 0) @@ -503,6 +503,8 @@ the subtrees." (setq-local comment-start "/* ") (setq-local comment-start-skip "\\(?://+\\|/\\*+\\)\\s *") (setq-local comment-end " */") + (setq-local treesit-comment-start (rx "/" (or (+ "/") (+ "*")))) + (setq-local treesit-comment-end (rx (+ (or "*")) "/")) (setq-local treesit-simple-indent-rules (c-ts-mode--set-indent-style 'c)) diff --git a/lisp/progmodes/java-ts-mode.el b/lisp/progmodes/java-ts-mode.el index ee757530279..d3cae1dcca1 100644 --- a/lisp/progmodes/java-ts-mode.el +++ b/lisp/progmodes/java-ts-mode.el @@ -61,6 +61,8 @@ ((node-is "}") (and parent parent-bol) 0) ((node-is ")") parent-bol 0) ((node-is "]") parent-bol 0) + ((and (parent-is "comment") comment-end) comment-start -1) + ((parent-is "comment") comment-start-skip 0) ((parent-is "class_body") parent-bol java-ts-mode-indent-offset) ((parent-is "interface_body") parent-bol java-ts-mode-indent-offset) ((parent-is "constructor_body") parent-bol java-ts-mode-indent-offset) @@ -284,6 +286,8 @@ the subtrees." (setq-local comment-start "// ") (setq-local comment-start-skip "\\(?://+\\|/\\*+\\)\\s *") (setq-local comment-end "") + (setq-local treesit-comment-start (rx "/" (or (+ "/") (+ "*")))) + (setq-local treesit-comment-end (rx (+ (or "*")) "/")) ;; Indent. (setq-local treesit-simple-indent-rules java-ts-mode--indent-rules) diff --git a/lisp/progmodes/js.el b/lisp/progmodes/js.el index c37cef977b2..159c32ca2ae 100644 --- a/lisp/progmodes/js.el +++ b/lisp/progmodes/js.el @@ -3412,6 +3412,9 @@ This function is intended for use in `after-change-functions'." ((node-is ")") parent-bol 0) ((node-is "]") parent-bol 0) ((node-is ">") parent-bol 0) + ((parent-is "comment") comment-start 0) + ((and (parent-is "comment") comment-end) comment-start -1) + ((parent-is "comment") comment-start-skip 0) ((parent-is "ternary_expression") parent-bol js-indent-level) ((parent-is "member_expression") parent-bol js-indent-level) ((node-is ,switch-case) parent-bol 0) @@ -3807,6 +3810,8 @@ Currently there are `js-mode' and `js-ts-mode'." (setq-local comment-start-skip "\\(?://+\\|/\\*+\\)\\s *") (setq-local comment-end "") (setq-local comment-multi-line t) + (setq-local treesit-comment-start (rx "/" (or (+ "/") (+ "*")))) + (setq-local treesit-comment-end (rx (+ (or "*")) "/")) ;; Electric-indent. (setq-local electric-indent-chars (append "{}():;," electric-indent-chars)) ;FIXME: js2-mode adds "[]*". diff --git a/lisp/progmodes/ts-mode.el b/lisp/progmodes/ts-mode.el index c826302c7ac..a6f8e0a65ee 100644 --- a/lisp/progmodes/ts-mode.el +++ b/lisp/progmodes/ts-mode.el @@ -61,6 +61,8 @@ ((node-is ")") parent-bol 0) ((node-is "]") parent-bol 0) ((node-is ">") parent-bol 0) + ((and (parent-is "comment") comment-end) comment-start -1) + ((parent-is "comment") comment-start-skip 0) ((parent-is "ternary_expression") parent-bol ts-mode-indent-offset) ((parent-is "member_expression") parent-bol ts-mode-indent-offset) ((parent-is "named_imports") parent-bol ts-mode-indent-offset) @@ -273,6 +275,8 @@ (setq-local comment-start "// ") (setq-local comment-start-skip "\\(?://+\\|/\\*+\\)\\s *") (setq-local comment-end "") + (setq-local treesit-comment-start (rx "/" (or (+ "/") (+ "*")))) + (setq-local treesit-comment-end (rx (+ (or "*")) "/")) ;; Electric (setq-local electric-indent-chars |