From: Juri Linkov Date: Thu, 6 Mar 2025 18:22:50 +0000 (+0200) Subject: Improve treesit settings for js/typescript/ruby-ts-mode (bug#73404) X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=1fd550928d678c6b2ab50f6855b16107d0d76691;p=emacs.git Improve treesit settings for js/typescript/ruby-ts-mode (bug#73404) * lisp/progmodes/js.el (js--treesit-list-nodes): * lisp/progmodes/typescript-ts-mode.el (typescript-ts-mode--list-nodes): Replace leaf "string" with "template_string" and "template_substitution" that can contain more nodes. * lisp/progmodes/ruby-ts-mode.el (ruby-ts-mode): Add the 'sentence' thing to treesit-thing-settings. (cherry picked from commit 63cc542b9402ad0a794f4e05790366bd580b8bd1) --- diff --git a/lisp/progmodes/js.el b/lisp/progmodes/js.el index abe7e15b9c7..d34fd8d627c 100644 --- a/lisp/progmodes/js.el +++ b/lisp/progmodes/js.el @@ -3916,7 +3916,8 @@ See `treesit-thing-settings' for more information.") "jsx_element" "jsx_expression" "jsx_self_closing_element" - "string" + "template_string" + "template_substitution" "regex" "arguments" "class_body" diff --git a/lisp/progmodes/ruby-ts-mode.el b/lisp/progmodes/ruby-ts-mode.el index 551271275d7..6fb71a75a58 100644 --- a/lisp/progmodes/ruby-ts-mode.el +++ b/lisp/progmodes/ruby-ts-mode.el @@ -1253,6 +1253,11 @@ leading double colon is not added." "hash") eos) #'ruby-ts--list-p)) + (sentence ,(rx bos (or "return" + "body_statement" + "call" + "assignment") + eos)) (text ,(lambda (node) (or (member (treesit-node-type node) '("comment" "string_content" "heredoc_content")) diff --git a/lisp/progmodes/typescript-ts-mode.el b/lisp/progmodes/typescript-ts-mode.el index ece8eebd028..94a854a1c8f 100644 --- a/lisp/progmodes/typescript-ts-mode.el +++ b/lisp/progmodes/typescript-ts-mode.el @@ -495,12 +495,14 @@ See `treesit-thing-settings' for more information.") "object_pattern" "array" "array_pattern" - "string" + "template_string" + "template_substitution" "regex" "arguments" "class_body" "formal_parameters" "computed_property_name" + ;; TypeScript "decorator_parenthesized_expression" "enum_body" "parenthesized_type"