]> git.eshelyaron.com Git - emacs.git/commit
Improve treesit settings for js-ts-mode (bug#73404)
authorJuri Linkov <juri@linkov.net>
Mon, 3 Mar 2025 18:38:40 +0000 (20:38 +0200)
committerEshel Yaron <me@eshelyaron.com>
Tue, 4 Mar 2025 21:04:40 +0000 (22:04 +0100)
commite82a2dfced7b9b57571c4d727bf78d408621f100
treeee6062cfe4724b5828c3aab78f0112f1ffa8e33f
parenta2370bb043b2236a6fb0e54b5652feeb2992b8e9
Improve treesit settings for js-ts-mode (bug#73404)

* lisp/progmodes/js.el (js--treesit-font-lock-settings):
Add 'class' alongside 'class_declaration'.
(js--treesit-defun-name): Add "variable_declaration"
alongside "lexical_declaration".
(js--treesit-valid-imenu-entry): Add "variable_declaration"
and provide the predicate to 'treesit-node-top-level'.
(js--treesit-sentence-nodes): Add "jsx_attribute" like in html-ts-mode
instead of jsx elements matched in 'js--treesit-list-nodes'.
(js--treesit-list-nodes): Add "jsx_element" and "jsx_self_closing_element"
instead of "_jsx_string".
(js--treesit-simple-imenu-settings): Move "method_definition" to separate
section "Method" from the "Class" section.  Add "variable_declaration"
to the "Variable" section.
(js-ts-mode--outline-predicate): New variable.
(js--treesit-defun-type-regexp): Add bos/eos.
(js--treesit-jsdoc-comment-regexp): Add bos/eos.
(js-ts-mode): Set treesit-outline-predicate to
'js-ts-mode--outline-predicate'.

* lisp/textmodes/mhtml-ts-mode.el (mhtml-ts-mode--html-defun-name):
Remove unused function.
(mhtml-ts-mode): Use 'js-ts-mode--outline-predicate' in
'treesit-aggregated-outline-predicate'.

* lisp/textmodes/yaml-ts-mode.el (yaml-ts-mode--outline-predicate):
Use 'treesit-node-top-level' instead of 'treesit-parent-until'.

(cherry picked from commit dbc0e5a52d855773a495e0ca89b738f8f2246df9)
lisp/progmodes/js.el
lisp/textmodes/mhtml-ts-mode.el
lisp/textmodes/yaml-ts-mode.el