Tools built on tree-sitter's concrete syntax trees

Posted on 2025-05-31

What is this all about?

Lots of surprisingly powerful tools have been built on top of tree sitter, and I just found out about them!

I thought we’d need real AST tools, which tree sitter doesn’t have. I was wrong, there’s so much awesome!

If you’re not interested in the background, or you already know it, skip down to the tools section!

Refactoring and abstract syntax trees

Decades ago I got excited about refactoring browsers and read all the research. A refactoring browser parses your source code to an abstract syntax tree, modifies that structured representation, and then unparses back to source code. I figured all languages would have these amazingly powerful tools by 2010, but it hasn’t happened.

(Also, I can’t find any good descriptions of the power of a refactoring browser on the internet, so that goes into my list of blog post ideas.)

concrete syntax trees?

Microsoft came up with this cool idea, the language server protocol. The idea is that each programming language can build their own tools for interactive use, and use a single API to hook them into any editor. LSP is ok, I guess.

Github came up with tree sitter, a parser generator. In my view it’s another editor agnostic slice of the interactive software development experience, but for incremental parsing of source code.

At first I was excited, maybe tree sitter would be a good base for editor agnostic refactoring tools?

I found this issue, which says roughly “no, you cannot make a refactoring browser with tree-sitter”.

Turns out, you can get pretty close though!

COOL TOOLS

difftastic

Honestly, difftastic is just better than any diff program that does not use a syntax tree. The linked image doesn’t do it justice if you haven’t spent much time puzzling over a git diff. Install it now!

If you use emacs and magit like I do, I recommend the difftastic.el library.

After I linked difftastic, one of my friends immediately used difftastic to find a stealthy bug, five stars!

combobulate for emacs

What if you want to navigate (and edit) your program via the parsed source code? Try combobulate! Like most of these tools, the description doesn’t do it justice, you have to try it!

Since it uses all the same emacs key bindings, my navigation was instantly improved. I’m still wrapping my head around the large amount of editing functionality, but being able to smoothly reorder definitions in a file is immediately useful to me.

cursorless for voice navigation

I know two people who damaged their arms from too much code, and they’ve switched to using cursorless so they can fluently (voice pun?) navigate source code.

This yet another case where the description might not sound impressive, but after watching one friend use cursorless, I’m considering using this myself.

mergiraf

So you tried difftastic and it was AMAZING, right?

Wouldn’t you like that same functionality to simplify complicated merges in git?

You want mergiraf! I haven’t started using this yet, but if it’s the same power increase I got from difftastic, it’s gonna be great!

I ended up asking on mastodon if there were more cool tools in this area and got a list:

What about languages that don’t exist yet?

From what I’ve seen, all the above tools focus cool tricks with existing languages.

I heard from bugarela that Topiary uses tree sitter to make language formatters like rust-fmt or gofmt, but for your own custom language. (In this case, bugarela is the lead dev on Quint, an updated take on TLA+)

What did I miss?

If you know of a cool tree sitter related tool that I didn’t mention, or especially if you know of research papers comparing the expressive power of ASTs and CSTs, I want to hear about it!