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!