]> git.eshelyaron.com Git - emacs.git/commitdiff
Add treesit thing 'sexp-list' to some ts-modes (bug#73404)
authorJuri Linkov <juri@linkov.net>
Thu, 19 Dec 2024 07:33:22 +0000 (09:33 +0200)
committerEshel Yaron <me@eshelyaron.com>
Mon, 23 Dec 2024 15:15:34 +0000 (16:15 +0100)
* lisp/progmodes/c-ts-mode.el (c-ts-mode--thing-settings):
* lisp/progmodes/js.el (js-ts-mode):
* lisp/progmodes/ruby-ts-mode.el (ruby-ts-mode):
* lisp/textmodes/html-ts-mode.el (html-ts-mode):
Add 'sexp-list' to treesit-thing-settings.
* lisp/progmodes/js.el (js--treesit-sexp-list-nodes): New variable.

(cherry picked from commit ea865c98cf3c8a4e0216a81be1b9357a48e7b9a3)

lisp/progmodes/c-ts-mode.el
lisp/progmodes/js.el
lisp/progmodes/ruby-ts-mode.el
lisp/textmodes/html-ts-mode.el

index 5e3194dd82ee8946091f52ab283d5558d8f60c77..cf1721d66ee20f7fd465699f57c6a147473262b6 100644 (file)
@@ -1139,6 +1139,27 @@ if `c-ts-mode-emacs-sources-support' is non-nil."
   `(;; It's more useful to include semicolons as sexp so
     ;; that users can move to the end of a statement.
     (sexp (not ,(rx (or "{" "}" "[" "]" "(" ")" ","))))
+    (sexp-list
+     ,(regexp-opt '("preproc_params"
+                    "preproc_parenthesized_expression"
+                    "preproc_argument_list"
+                    "attribute_declaration"
+                    "declaration_list"
+                    "parenthesized_declarator"
+                    "parenthesized_field_declarator"
+                    "parenthesized_type_declarator"
+                    "abstract_parenthesized_declarator"
+                    "compound_statement"
+                    "enumerator_list"
+                    "field_declaration_list"
+                    "parameter_list"
+                    "argument_list"
+                    "parenthesized_expression"
+                    "initializer_list"
+                    "subscript_designator"
+                    "subscript_range_designator"
+                    "string_literal")
+                  'symbols))
     ;; compound_statement makes us jump over too big units
     ;; of code, so skip that one, and include the other
     ;; statements.
index 1c5865169d7a2e2352ccf65ee6863f8945f92c7e..d5bf4e9c71625f7b3661fb092385f8d029ece0ff 100644 (file)
@@ -3863,6 +3863,28 @@ See `treesit-thing-settings' for more information.")
   "Nodes that designate sexps in JavaScript.
 See `treesit-thing-settings' for more information.")
 
+(defvar js--treesit-sexp-list-nodes
+  '("export_clause"
+    "named_imports"
+    "statement_block"
+    "_for_header"
+    "switch_body"
+    "parenthesized_expression"
+    "object"
+    "object_pattern"
+    "array"
+    "array_pattern"
+    "jsx_expression"
+    "_jsx_string"
+    "string"
+    "regex"
+    "arguments"
+    "class_body"
+    "formal_parameters"
+    "computed_property_name")
+  "Nodes that designate lists in JavaScript.
+See `treesit-thing-settings' for more information.")
+
 (defvar js--treesit-jsdoc-beginning-regexp (rx bos "/**")
   "Regular expression matching the beginning of a jsdoc block comment.")
 
@@ -3904,6 +3926,7 @@ See `treesit-thing-settings' for more information.")
     (setq-local treesit-thing-settings
                 `((javascript
                    (sexp ,(js--regexp-opt-symbol js--treesit-sexp-nodes))
+                   (sexp-list ,(js--regexp-opt-symbol js--treesit-sexp-list-nodes))
                    (sentence ,(js--regexp-opt-symbol js--treesit-sentence-nodes))
                    (text ,(js--regexp-opt-symbol '("comment"
                                                    "string_fragment"))))))
index 58a7eab0d1a8a35af9d5ff3d7c5d1c7236c02084..4ef0cb18eae57b73ab3858504e0d5493f0a64ecd 100644 (file)
@@ -1195,6 +1195,47 @@ leading double colon is not added."
                                 )
                                eol)
                               #'ruby-ts--sexp-p))
+                 (sexp-list
+                  ,(cons (rx
+                          bol
+                          (or
+                           "begin_block"
+                           "end_block"
+                           "method"
+                           "singleton_method"
+                           "method_parameters"
+                           "parameters"
+                           "block_parameters"
+                           "class"
+                           "singleton_class"
+                           "module"
+                           "do"
+                           "case"
+                           "case_match"
+                           "array_pattern"
+                           "find_pattern"
+                           "hash_pattern"
+                           "parenthesized_pattern"
+                           "expression_reference_pattern"
+                           "if"
+                           "unless"
+                           "begin"
+                           "parenthesized_statements"
+                           "argument_list"
+                           "do_block"
+                           "block"
+                           "destructured_left_assignment"
+                           "interpolation"
+                           "string"
+                           "string_array"
+                           "symbol_array"
+                           "delimited_symbol"
+                           "regex"
+                           "heredoc_body"
+                           "array"
+                           "hash")
+                          eol)
+                         #'ruby-ts--sexp-p))
                  (text ,(lambda (node)
                           (or (member (treesit-node-type node)
                                       '("comment" "string_content" "heredoc_content"))
index f78fbdde1da065152492f33e9fb284c721f4b9e3..875ab267fd8b9b3b3faf8e1a76f14afd48e0a4f1 100644 (file)
@@ -108,6 +108,7 @@ Return nil if there is no name or if NODE is not a defun node."
                                       "text"
                                       "attribute"
                                       "value")))
+                 (sexp-list ,(regexp-opt '("element")) 'symbols)
                  (sentence "tag")
                  (text ,(regexp-opt '("comment" "text"))))))