[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Fri, 10 Feb 2023 11:40:32 +0000
Yuan Fu <firstname.lastname@example.org> writes:
Thanks for trying this out! Feedbacks like this are very welcome.
Hi Yuan, you're very welcome! I'm glad to be able to help.
On Feb 9, 2023, at 4:45 AM, Simon Pugnet <email@example.com>
1. Based on my rules for embedding ='html= within ='php= above,
should I expect ~(treesit-language-at (point))~ to return ='php=
when the point is within a PHP region?
Because we don’t have much experience with tree-sitter and its
interfaces, I made treesit-language-at simply delegate work to
treesit-language-at-point-function, which can be an arbitrary
function, giving developers maximum flexibility. You need to set
variables to a function, otherwise treesit-language-at simply
the first parser in the parser list.
Ah, that makes sense, thank you. I must have missed that in the
documentation as I thought this was just used when overriding the
I've added the following implementation and this appears to work
(defun php-ts--language-at-point (point)
"Return the language at POINT, used to determine which tree sitter
parser to use."
(let* ((php-node-at-point (treesit-node-at point 'php))
(parent-node (treesit-node-parent php-node-at-point)))
(if (and (string-equal "text" (treesit-node-type
(or (string-equal "program" (treesit-node-type
The next step will be to run further tests on the current node in
cases where the language is 'html in order to determine if the actual
2. Is my goal of embedding HTML within PHP, then embedding CSS and
about this in the right way?
It should be. Although I didn’t thought of having multiple layers of
embedded language (in this case PHP embedding HTML embedding
you do now (outer most host language, then embedded language, then
embedded embedded language), it should work. Try setting
treesit-language-at-point-function and it should work right. If not…
then we need to look into it.
I'll try this next and I'll be sure to let you know how it goes.
Thanks for your advice, and kind regards,
Description: PGP signature