]> git.eshelyaron.com Git - emacs.git/commit
Improve treesit settings for {json,html,toml,yaml}-ts-mode (bug#73404)
authorJuri Linkov <juri@linkov.net>
Sun, 9 Feb 2025 17:54:02 +0000 (19:54 +0200)
committerEshel Yaron <me@eshelyaron.com>
Mon, 10 Feb 2025 20:56:06 +0000 (21:56 +0100)
commit4a6bb2f53572b39b1dfc13d75a443c08b5513bc0
tree6322018c072c8d2aa2039120146f230d5f6e9c14
parent3d9e655378031eb9456ba97ee1a67db81f4a10ff
Improve treesit settings for {json,html,toml,yaml}-ts-mode (bug#73404)

* lisp/progmodes/json-ts-mode.el (json-ts-mode): Add 'list' thing
to 'treesit-thing-settings'.
(json-ts-mode): Disable outlines.

* lisp/textmodes/html-ts-mode.el (html-ts-mode--defun-name):
Get a grandchild 'tag_name' from 'element' that was already
defined by 'treesit-defun-type-regexp'.
(html-ts-mode--outline-predicate): New function.
(html-ts-mode): Add "comment" to the 'list' thing
in 'treesit-thing-settings'.  Use "tag_name" and "attribute"
in 'sentence' to conform to sentence navigating arguments
in other ts-modes.  Remove unnecessary heading
from 'treesit-simple-imenu-settings' and use "element"
supported by 'html-ts-mode--defun-name'.
Set 'treesit-outline-predicate' to 'html-ts-mode--outline-predicate'.

* lisp/textmodes/toml-ts-mode.el (toml-ts-mode):
Add 'treesit-thing-settings'.

* lisp/textmodes/yaml-ts-mode.el (yaml-ts-mode--defun-name)
(yaml-ts-mode--outline-predicate): New functions.
(yaml-ts-mode): Set 'treesit-defun-type-regexp',
'treesit-defun-name-function', 'treesit-defun-tactic'.
Add 'sentence' to 'treesit-thing-settings'.
Set 'treesit-simple-imenu-settings' and 'treesit-outline-predicate'.
Use 'kill-local-variable' for 'forward-sexp-function'
and 'show-paren-data-function' instead of resetting their value.

* lisp/treesit.el (treesit-outline-search): Check for the thing
before the end of the line to support such case when the thing
fits on the current line and ends before the end of the line
such as e.g. '<h1>...</h1>' in html-ts-mode.
(treesit-hs-find-next-block, treesit-hs-inside-comment-p):
Use anchors for "\\`comment\\'" (bug#75609).

(cherry picked from commit e9d17e41971c887675d52e1dcee21978d4247130)
lisp/progmodes/json-ts-mode.el
lisp/textmodes/html-ts-mode.el
lisp/textmodes/toml-ts-mode.el
lisp/textmodes/yaml-ts-mode.el
lisp/treesit.el