From: Vincenzo Pupillo <v.pupillo@gmail.com>
To: emacs-devel@gnu.org
Subject: How to properly use treesit-range-rules ?
Date: Mon, 18 Sep 2023 22:58:53 +0200 [thread overview]
Message-ID: <8289988.T7Z3S40VBb@fedora> (raw)
[-- Attachment #1: Type: text/plain, Size: 1339 bytes --]
Hi,
I'm trying to figure out how to properly use treesit-range-rules for my
php-ts-mode (you can find it here https://github.com/vpxyz/php-ts-mode, there
are still several things to fix.).
Currently the rules I am using are as follows:
(setq-local treesit-range-settings
(treesit-range-rules
:embed 'html
:host 'php
;;:local t
'((program (text) @cap)
(text_interpolation (text) @cap))
:embed 'javascript
:host 'html
;;:local t
'((script_element
(start_tag (tag_name))
(raw_text) @cap))
:embed 'css
:host 'html
;;:local t
'((style_element
(start_tag (tag_name))
(raw_text) @cap))))
I also tried different combinations, even with the new :local flag. However, I
couldn't find a way to prevent built-in language parsers from modifying
highlighted syntax outside of the ranges captured by queries.
I used php-mode as a comparison. For example you can see how it behaves with
the two files https://github.com/emacs-php/php-mode/blob/master/tests/8.0/
attribute/class.php or https://github.com/emacs-php/php-mode/blob/master/
tests/issue-66-namespace.php.
It is possible to set a php-ts-mode-disable-inject variable to enable or
disable the parsers for html/css/javascript to see the differences.
What am I doing wrong?
Thank you
Vincenzo
[-- Attachment #2: with_html_etc.png --]
[-- Type: image/png, Size: 16941 bytes --]
[-- Attachment #3: without_html_etc.png --]
[-- Type: image/png, Size: 16810 bytes --]
next reply other threads:[~2023-09-18 20:58 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-09-18 20:58 Vincenzo Pupillo [this message]
2023-09-19 4:11 ` How to properly use treesit-range-rules ? Yuan Fu
2023-09-19 13:09 ` Vincenzo Pupillo
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=8289988.T7Z3S40VBb@fedora \
--to=v.pupillo@gmail.com \
--cc=emacs-devel@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.