]> git.eshelyaron.com Git - emacs.git/commit
Support alternative range function for tree-sitter range settings
authorYuan Fu <casouri@gmail.com>
Fri, 28 Feb 2025 01:18:28 +0000 (17:18 -0800)
committerEshel Yaron <me@eshelyaron.com>
Fri, 28 Feb 2025 11:20:16 +0000 (12:20 +0100)
commitb78af3bcf4ca50ae5d8f8aa9551df260347de504
tree7dc396c73333fae1b2feec37acb34fbf9e7d4261
parent77f6ef53a0f385daedb9f8917f17cbe2be463f3f
Support alternative range function for tree-sitter range settings

Some embedded parser needs to exclude child nodes from the
range, like markdown-inline.  So I added this keyword that
allows users to customize the range for the embedded parser.
This can also be potentially useful for markdown comments in
rust, for example, because we want to exclude the comment
starters (//) from the embedded markdown parser.

* lisp/treesit.el (treesit-query-range):
(treesit-query-range-by-language): Add new parameter RANGE-FN.
(treesit-range-settings): Add new field RANGE-FN.
(treesit-range-rules): Add new keyword RANGE-FN.
(treesit-range-fn-exclude-children): New function.
(treesit--update-ranges-non-local):
(treesit--update-ranges-local):
(treesit--update-range-1): Support the RANGE-FN field.

(cherry picked from commit 8a3e19f4b39be68c22e056d56adb86397e25a673)
lisp/treesit.el