tree-sitter-typst icon indicating copy to clipboard operation
tree-sitter-typst copied to clipboard

Query Support

Open Alex-Muirhead opened this issue 2 years ago • 7 comments

This is more of a question than an issue, but do you intend on supporting Tree-Sitter queries in the near future? I couldn't see any mention of it in the README, however I'm aware this is a young project.

I haven't worked on a tree-sitter grammar before, but I'd be happy to try and help if there's basic grunt work to do.

Alex-Muirhead avatar Mar 28 '23 03:03 Alex-Muirhead

Yes! I plan to implement all possible features within neovim especially conceal!

I'm moving at a slow pace because this language is tough to parse. It uses whitespace as a token separator SOMETIMES, so I had to rewrite everything to follow the language spec. Once I'm done with this rewrite that covers all the features I've had so far, it should be straightforward to implement the rest!

SeniorMars avatar Mar 28 '23 03:03 SeniorMars

Amazing, I'm keen to have all those features! I'm using it from helix myself, so that will work great for me too.

Argh yes, I've noticed those complications as I've scrolled through some of your notes and implementation.

Alex-Muirhead avatar Mar 28 '23 07:03 Alex-Muirhead

If you run into really funny whitespace behaviour similar to how Python and Haskell use indents in place of braces, you might have to make like tree-sitter-haskell and write a custom lexer, although that is ... not a task for the faint of heart, as a contributor to that one.

lf- avatar Apr 05 '23 05:04 lf-

It's funny you say that, I'm working on the custom scanner right now and looking at python and haskell for so much reference. This language is soo big. It's like a full markdown parser + a python parser + latex math mode. It's not really fun.

SeniorMars avatar Apr 05 '23 05:04 SeniorMars

I've begun writing highlight queries (for neovim, at least). It really doesn't take very long, and I expect to have highlights written for all the currently supported syntax pretty soon.

Slickytail avatar Apr 05 '23 16:04 Slickytail

Highlights and other queries have been low on my priority list as I thought it would be much more important to complete markup. I was super busy last week, but I also realized how to implement the rest of the language: i.e., rewrite scanner.c.

We can leave a lot of the code for code mode intact, but for other markup and math mode the best way would be to write a custom lexer :(. I have time now, so I'll be working on typst-projects again.

SeniorMars avatar Apr 14 '23 02:04 SeniorMars

Any updates on this?

Any way I can help to speed things up?

jooooscha avatar May 11 '23 07:05 jooooscha