SeniorMars / tree-sitter-typst

A TreeSitter parser for the Typst File Format
MIT License
136 stars 7 forks source link

Query Support #2

Open Alex-Muirhead opened 1 year ago

Alex-Muirhead commented 1 year ago

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.

SeniorMars commented 1 year ago

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!

Alex-Muirhead commented 1 year ago

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.

lf- commented 1 year ago

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.

SeniorMars commented 1 year ago

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.

Slickytail commented 1 year ago

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.

SeniorMars commented 1 year ago

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.

jooooscha commented 1 year ago

Any updates on this?

Any way I can help to speed things up?