Add treesit thing 'sexp-list' to some ts-modes (bug#73404)
* 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.
This commit is contained in:
@@ -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.
|
||||
|
||||
@@ -3866,6 +3866,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.")
|
||||
|
||||
@@ -3909,6 +3931,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"))))))
|
||||
|
||||
@@ -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"))
|
||||
|
||||
@@ -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"))))))
|
||||
|
||||
|
||||
Reference in New Issue
Block a user