With the recent archiving of the language-crystal repository which housed the language grammars, I think this would be the best time to get started on an official tree-sitter for Crystal under the crystal-lang-tools organisation. This has been a long-requested tool for the Crystal community and would help with Crystal tooling support. We could also house new language configurations in the repository, such as the query files and syntax highlighting. Several attempts have been made already, but none of them complete and with very little maintenance. This would be a good opportunity for people to collaborate on this and build a better/more usable tree sitter.
I’ve been following keidax’s treesitter implementation for awhile, seems to be the most complete one so far. Personally, I would love this, as an active Neovim user using treesitter already on every other language.
How close to completion would you say Keidax’s implementation is? We could probably use it as a reference or even copy parts of it for the official tree sitter.
I’m not going to pretend I’m an expert, I think we should just ask keidax.
This grammar is still under construction.
Syntax highlighting has not been implemented yet, and many syntax features are incomplete.
Looks like it potentially still has a lot of work before being completed.
As far as I tried the keidax’s implementation, the parser seems to work well for relatively simple files but fails with more complex, big files and sometimes crashes at the C scanner which seems to be handwritten and has about 2000 lines of code (vs about 1000 lines for tree-sitter-ruby and none for will’s tree-sitter-crystal implementation).
The test files give us some idea about all the syntax features currently implemented and they seem extensive enough that we could use it as a reference for sure.
I tested out Keidax’s implementation recently and apart from the lack of syntax highlighting, it worked pretty well. Perhaps we could get some movement on this to get the tree sitter up to speed.
I’m doing the same, I also did tree-sitter API experimental bindings in the meantime, so people can use tree-sitter in Crystal applications… however the API is far away from being stable or even complete since it’s being done based only on my special needs so far .
Could we get a repo in the organisation setup for this? I’d love to get started on this soon, even if that’s just via issues and PRs.
Are you just looking to create an empty repository? If so I can create one.
Yes, from there we can figure out a good starting point for the tree sitter.