emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

How to properly use treesit-range-rules ?


From: Vincenzo Pupillo
Subject: How to properly use treesit-range-rules ?
Date: Mon, 18 Sep 2023 22:58:53 +0200

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: with_html_etc.png
Description: PNG image

Attachment: without_html_etc.png
Description: PNG image


reply via email to

[Prev in Thread] Current Thread [Next in Thread]