SQL folding between keywords

I’m trying to understand and make changes to SQL’s Lezer grammar but it isn’t quite doing what I hope yet.

Essentially I’m trying to get it to recognise foldable sections between keywords and not just on the entire statement.

I would like to go from:

+ SELECT name, age
      FROM users
      WHERE active = 1;

…which collapsed is:

SELECT ...

to:

+ SELECT name, age
+    FROM users
+    WHERE active = 1;

…which collapsed is:

SELECT ... FROM ... WHERE ...

What changes should I look to make?

The “grammar” in @codemirror/lang-sql is just a crude tokenizer that groups tokens together into statements using semicolons. It is that way because SQL’s syntax is huge, complicated, and very different between dialects. If you want to set up a real parser for a specific dialect, you’ll probably want to start from scratch with an entirely different grammar.

Thanks. What you mention is what I’m finding and was considering starting from scratch - I’ll likely do that then.