Tree-sitter based completion help

Hi,
I am writing a blade language grammar for tree-sitter alongside a syntax extension for Nova.

I am having a bit of a problem getting the completions defined in the Completion/blade.xml to work.

Here is my provider

    <provider>
        <syntax>blade</syntax>
        <expression>@[a-zA-Z0-9-]*</expression>
        <query>
            (program)
        </query>
        <trigger>^@</trigger>
        <set>blade.keywords</set>
        <set>blade.keywords.parameters</set>
    </provider>

The issue arises when I am trying to provide the completion at the root of the blank document.

In my tree-sitter grammar the (program) is right at the top of the hierarchy.

Now if I open a blank document and type @ none of the keywords are suggested for completion…

If I do that in other sections such as (program (example)) the completions are provided.

Things I have tried…

  1. If I just have empty <query> nothing will be shown anywhere
    <provider>
        <syntax>blade</syntax>
        <expression>@[a-zA-Z0-9-]*</expression>
        <query></query>
        <trigger>^@</trigger>
        <set>blade.keywords</set>
        <set>blade.keywords.parameters</set>
    </provider>
  1. If I remove the <query> the completion is provided in any children of the (program) such as (program (example)) node, but not in the root…
    <provider>
        <syntax>blade</syntax>
        <expression>@[a-zA-Z0-9-]*</expression>
        <trigger>^@</trigger>
        <set>blade.keywords</set>
        <set>blade.keywords.parameters</set>
    </provider>
  1. Now I thought because the document is blank, so I typed a few words, and still no result.

Is there any ways to provide the completions anywhere in the document tree? including when it is blank, or at the root?

Thanks
Emran

One thing I’ve noticed is that, for whatever reason, if your cursor is at the end the file it won’t give you any completions at all.

If you’re testing in a blank document, try adding a new line at the end and then typing at the start to trigger completions.

1 Like

Thank you so much!! I spent all day fighting with Nova thinking that I am doing something wrong!

You are actually right, no completion is provided on the last line :man_facepalming: I am going to change the tag to bug

hopefully maybe @logan can shed some light? :blush:

No problem, hopefully this would be a simple bug fix!

Thank you for the bug report. We will investigate.

1 Like