mirror of
git://git.sv.gnu.org/emacs.git
synced 2026-02-16 17:24:23 +00:00
Limit matches of treesit-thing-settings in js-ts-mode (bug#71244)
* lisp/progmodes/js.el (js-ts-mode): Use 'js--regexp-opt-symbol' for 'js--treesit-sexp-nodes', 'js--treesit-sentence-nodes' and 'text' that wraps the regexp in \_< and \_> delimiters to avoid false positives such as "expression" used for "expression_statement". (js--treesit-sexp-nodes): Add more useful nodes "parenthesized_expression", "formal_parameters", "statement_block", "object", "object_pattern", "named_imports", "class_body".
This commit is contained in:
parent
b782491630
commit
87e4e1beab
1 changed files with 12 additions and 5 deletions
|
|
@ -3829,6 +3829,8 @@ See `treesit-thing-settings' for more information.")
|
|||
|
||||
(defvar js--treesit-sexp-nodes
|
||||
'("expression"
|
||||
"parenthesized_expression"
|
||||
"formal_parameters"
|
||||
"pattern"
|
||||
"array"
|
||||
"function"
|
||||
|
|
@ -3846,7 +3848,12 @@ See `treesit-thing-settings' for more information.")
|
|||
"undefined"
|
||||
"arguments"
|
||||
"pair"
|
||||
"jsx")
|
||||
"jsx"
|
||||
"statement_block"
|
||||
"object"
|
||||
"object_pattern"
|
||||
"named_imports"
|
||||
"class_body")
|
||||
"Nodes that designate sexps in JavaScript.
|
||||
See `treesit-thing-settings' for more information.")
|
||||
|
||||
|
|
@ -3889,10 +3896,10 @@ See `treesit-thing-settings' for more information.")
|
|||
|
||||
(setq-local treesit-thing-settings
|
||||
`((javascript
|
||||
(sexp ,(regexp-opt js--treesit-sexp-nodes))
|
||||
(sentence ,(regexp-opt js--treesit-sentence-nodes))
|
||||
(text ,(regexp-opt '("comment"
|
||||
"template_string"))))))
|
||||
(sexp ,(js--regexp-opt-symbol js--treesit-sexp-nodes))
|
||||
(sentence ,(js--regexp-opt-symbol js--treesit-sentence-nodes))
|
||||
(text ,(js--regexp-opt-symbol '("comment"
|
||||
"template_string"))))))
|
||||
|
||||
;; Fontification.
|
||||
(setq-local treesit-font-lock-settings js--treesit-font-lock-settings)
|
||||
|
|
|
|||
Loading…
Reference in a new issue