Hi,
I do not think this is a bug, but maybe the way Nova handles the Completion files. But it is sort of frustrating and unpredictable. Nova also doesn’t provide us with AST (yet) so I am not even sure where the cursor is or how Nova handles the completion.
Context
- Extension in question is Laravel Suite
- it uses
tree-sitter-blade
that injectsphp
, which in turn injectshtml
Problem
So, the problem is Nova gets very confused if it is in Blade or HTML or PHP.
But in reality it should not, I presumed even if html
is injected, it would be a subtree of (blade)
which is the root of the tree in tree-sitter-blade
.
Syntax/blade.xml
definition says files with extensionblade.php
areBlade
, very odd that I need to use<syntax>html</syntax>
. I understand the uses but would be nicer to be able to define something like: “provide inside html as a subtree of blade”, because otherwise the completions are provided in the normal.html
files as well. Here is a sample provider
<completions name="blade">
...
<!-- practically no effect.... -->
<syntax>Blade</syntax>
<!-- This turns on completion but also in html files... -->
<!-- I want completions in .blade.php files -->
<syntax>html</syntax>
...
</provider>
</completions>
I have tried <query>
as well to see if I can override the behaviour but no luck…
<provider>
<query>
(blade)
</query>
<!-- OR -->
<query>
((blade) @provider.subtree)
</query>
</provider>
example
- Notice the provider does NOT work when the Syntax is
Blade
- The reason is as it follows, when I press
@
completion comes, when I typep
we move on from blade to html (injection starts), so Nova gets confused, and completion disappear!
- The reason is as it follows, when I press
- I change to
PHP
and it start working as it should - BUT when I go back to
Blade
and create ahtml
skeleton, it works! - Also note that, when in Blade, and step 3 condition is met, when the user types
@ph
it works, but as soon as they press anotherp
to make@php
the completion disappears…- As you saw in step 2, that was not the case in
php
- Reason for this is the reverse, as soon as
@php
is formed, we are back into blade, so again Nova gets confused in the transition.
- As you saw in step 2, that was not the case in
If there are any work around or I am doing something wrong please do let me know! Here is the link to the provider file!