all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* How to properly use treesit-range-rules ?
@ 2023-09-18 20:58 Vincenzo Pupillo
  2023-09-19  4:11 ` Yuan Fu
  0 siblings, 1 reply; 3+ messages in thread
From: Vincenzo Pupillo @ 2023-09-18 20:58 UTC (permalink / raw)
  To: emacs-devel

[-- 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 --]

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2023-09-19 13:09 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-09-18 20:58 How to properly use treesit-range-rules ? Vincenzo Pupillo
2023-09-19  4:11 ` Yuan Fu
2023-09-19 13:09   ` Vincenzo Pupillo

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.