Closed unansweredocd closed 1 year ago
Hi @unansweredocd I am not a neovim user. However based on the fact that you face problems by enabling php
injections, it might be very well due to #5.
Can you wrap your php injection points inside <?php x ?>
like the following and feedback here?
@extend(<?php 'test' ?>
){{<?php $user->name}}
and so forth.If so, I will merge this to #5 .
Unfortunately until the split parser is merged into the main branch of tree-sitter-php
I would suggest withholding the php
injection for time being.
Feel free to subscribe to both issues, so that you stay up to date with any new developments.
Hey @EmranMR, that's alright. The beauty of treesitter is that everyone can benefit without paying for expensive options like phpstorm.
I've tried below, in the injections file, and that seems to fix stuff a bit. It doesn't fix the extends example, but that seems a weird thing to do anyway.
Here's the injection file
((html) @injection.content
(#set! injection.combined)
(#set! injection.language html))
((php) @injection.content
(#set! injection.language php))
Ah perfect!
In the future for the parameters you need to add the following to the injections.scm
as well. I realised in Nova it actually adds a nice syntax highlighting when you do that! Especially for loops
and if_statements.
((parameter) @injection.content
(#set! injection.language php))
The reason I kept this one separate is because in the php
nodes, you could possibly do(#set! injection.combined)
, as technically all {{}}
are in the same scope, unlike the parameters.
Although I am yet to test this, when the tree-sitter-php
split parser is out, because in blade
the semicolon is optional, so it might actually cause more syntax highlighting problems down the line when doing injection.combined
If that happens to be the case, I will just change all injection nodes to php
for ease of use. 😜
I will close this for now so that we can follow the thread on #5
Hey,
Thanks for doing this once again. After messing around with this parser I finally got it to work a bit. For one, I struggled with the filetype at first, turns out I had to add it to neovim. After that I couldn't get highlighting to work, but I figured that out too.
Here's what I put in my init.lua, which is the starting point for most nvim configurations.
This resulted in having two things working, Neovim understanding that .blade.php files are of the blade filetype, and the :InspectTree command from seeing the things that are in the parser you wrote.
After that, highlighting. Couldn't get it to work at all, but when I copied the contents of highlights.scm and injections.scm to ~/.config/nvim/queries/blade/{highlights,injections.scm} I finally reached a point where things started working.
The contents of ~/.config/nvim/queries/blade/highlights.scm are
And the contents of ~/.config/nvim/querie/blade/injections.scm are
Which results in the screenshot below. If I enable php, things break a bit, same goes for the directive parameters bit.
Now, let it be clear. I don't know what I'm doing, so other Neovim users should definitely tell me what I'm doing wrong. For now, it kind of works, which beats all the blade experiences in Neovim before this one.