* 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)
`(;; 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.
"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.")
(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"))))))
)
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"))
"text"
"attribute"
"value")))
+ (sexp-list ,(regexp-opt '("element")) 'symbols)
(sentence "tag")
(text ,(regexp-opt '("comment" "text"))))))