4 ms·
Nice work! I keep wondering, there a reason everything isn’t just based off treesitter these days? If I were tasked with writing tsserver, my instinct would be
by aidos 3y ago
Nice work!
I keep wondering, there a reason everything isn’t just based off treesitter these days? If I were tasked with writing tsserver, my instinct would be to layer it over treesitter. Does anyone know if there are practical reasons that doesn’t happen, or is it just legacy?
The neovim world is slowly converging on using it for syntax. This project for formatting. I personally use it in neovim for things like highlighting and formatting sql within strings in python.
- yewenjie 3y agoVS Code or Monaco still doesn't support tree-sitter.
- ckolkey 3y agoThe tree-sitter ecosystem continues to expand thanks in large part to neovim's enthusiastic adoption. It's a shame Atom was sunset in favor of VS-code - having spawned both Electron and Tree-sitter, I think it's clear which was more visionary.
- ajoberstar 3y agoVS Code brought Language Server Protocol, so I don't think the "vision" balance is as one-sided as you imply.
- dbalatero 3y agoAnd the debug adapter protocol IIRC.
- vkazanov 3y agoIt continues to expand because there's nothing else like it: a language and editor agnostic tool for implementing parsers for IDEs. All of the editors come up with all kinds of niche hacks and DSLs. All editors keep reimplementing broken, partial, regexp soups.. I can only see more editors just giving up on this and going all in of treesitter. It's not only neovim, btw, the next emacs is also gonna have it included.
- rowanG077 3y agoDoesn't LSP subsume tree-sitter?
- deleted 3y ago[deleted]
- hardwaregeek 3y agoIt's really annoying to produce an AST from tree-sitter. I tried writing my programming language parser with tree-sitter and it was a huge pain[1]. Anything with error recovery or good error messages is hard to customize too. If you want the ability to work with partial pieces of code in a homogeneous syntax tree and not an AST, then tree-sitter is great. Otherwise it's definitely rough around the edges. [1]: https://uptointerpretation.com/posts/vicuna-update/ https://uptointerpretation.com/posts/vicuna-update/
- vkazanov 3y agoI hope the author of the blog post realizes that treesitter was never mean to be "an editable ast" or something. It is a partial ast parser taking into account presence of errors and error reporting. It is written in C for a reason: it needs to quickly get a partial ast and report errors in it. There SO MANY perfect tools for language implementation and ast manipulation..! Starting with ML family languages that are very good at this.
- hardwaregeek 3y agoThere aren’t that many great tools that also buy you into a syntax highlighting, code searching and the general tree-sitter ecosystem. If tree-sitter could produce an AST, it’d be a very compelling option for writing a compiler. Not to mention the robust, fast incremental parsing is precisely what modern compilers need, see Roslyn’s red green trees or rust analyzer’s Rowan crate.
- vkazanov 3y agoHaving a reasonable formal grammar is like 90% percent of making a parser. Tresitter or not.
- hardwaregeek 3y agoIf you’re writing a parser for a simple language, sure. But most programming languages have a sophisticated enough grammar, with stringent enough performance requirements and error handling requirements, that a library that can function as a single source of truth for your compiler and your tooling is very valuable. Take JavaScript, which has extremely hairy logic around JSX parsing and arrow functions. Or C’s issues with preprocessing.
- junon 3y agoTree sitter isn't exactly the most ergonomic API or structure to use. In my opinion Neovim stuff moving entirely to TS made it worse that the existing tools that were out there. But for something like this, I think TS fits pretty nicely into the use case.
- IshKebab 3y agoTreeSitter is easy to use, pretty language neutral and it is tolerant to errors. Plus at this point people have already implemented support for a ton of languages. My only issue with it is that it really only does half the job. You get a CST of sorts, but if you want to do anything with it you pretty much have to hand write another parser for that node tree. In contrast parser combinator libraries like Nom and Chumsky give you "the final output".
- hardwaregeek 3y agoChumsky is so good for parsing. I’m not a huge combinator fan but man, it works so well. If only the errors weren’t so horrendous.