Nova Language Extension - Invalid Node Type error in folds.scm

Hello all.

Nova Extension development newbie here.

Yesterday, I started developing a new Nova language extension using Tree-sitter, which I’ve never used before. I am also not a Javascript nor web developer by nature so many of underlying concepts are fairly new to me, but I’m a quick study.

I’ve got a pretty good toolchain setup and I’ve been able to get an initial grammar.js file put together which Tree-sitter parses without any issues and compiles into a valid .dylib that I place into my .novaextension package which Nova has no issues with. The inspector correctly identifies the parts as I’ve designed them.

Now I am experimenting with a folds.scm file to define the folding reqions of the top level “blocks” of the language, but I am stuck here.

Here are the relevant grammar nodes that I’ve defined in grammar.js:

		forms: $ => choice(
			$.procedure_form
		),

        procedure_form_header: $ => seq(
            'PROCEDURE_FORM',
            $.form_name
        ),

        procedure_form: $ => seq(
            $.procedure_form_header,
            optional($.body),
            $.end_form 
        ),

        form_name: $ => /[A-Z_]+/,
		end_form: $ => 'END_FORM',
        body: $ => /.*/

And here is the folds.scm file:

(source_file
  (forms
    (procedure_form
      (procedure_form_header) @start
      (end_form) @end.after
    )
  )
)

Nova’s Extension Console complains about:

Error evaluating structure query: Invalid node type:
      (procedure_form_header) @start
~~~~~~~^

The idea is that I want the following sample program in the language that I am defining:

PROCEDURE_FORM FORM_NAME
     ! Stuff
END_FORM

to fold down to:

PROCEDURE_FORM FORM_NAME[...]

Unfortunately I don’t know why procedure_form_header would be an invalid node type. What types of nodes are valid? I’m not sure where to find that answer. ChatGPT tells me that there are terminal and non-terminal node types, so perhaps it has something to do with that. I’ve tried reconfiguring the grammar in various different ways but alas I couldn’t find anything that worked.

Can anyone help with a solution, a tip or where I can read about what I might be doing wrong?

Thanks!

Hello!

Unfortunately, I’m not sure I can offer good advice with your issue. I can’t find fault with what you’ve described. You might be able to get some help from the Tree-sitter user’s group, who might be a bit more versed in building grammars and debugging query errors. They have a both a discussion board and Discord with a lot of helpful folks.

It might be because you are compiling and using tree-sitter v.0.25?

I think editors are still catching up with the new tree-sitter release. @logan If I am not mistaking that could be an issue? v0.25 was a big release and I have had issues getting my compiled grammar work in some editors. For example, NeoVim is still in the process of using ABI 15

Also do we still need to use Panic script for creating .dylib or can we use what is generated via tree-sitter-cli 0.25 from now on? The new version creates pretty much all the various bindings