Completion Provider Odd Behaviour

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 injects php, which in turn injects html

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 extension blade.php are Blade, 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 :point_down:
<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

  1. Notice the provider does NOT work when the Syntax is Blade
    • The reason is as it follows, when I press @ completion comes, when I type p we move on from blade to html (injection starts), so Nova gets confused, and completion disappear!
  2. I change to PHP and it start working as it should
  3. BUT when I go back to Blade and create a html skeleton, it works! :grimacing:
  4. 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 another p 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.

blade

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!

Also the issue might sort of relate to this topic I raised a few months ago :thinking: without AST it is hard to say tbh