I use #sqlx, and I wanted syntax highlighting for embedded #SQL queries in my #Rust code. Making that work in #Neovim led me to learning a few things about #Treesitter, and #NixOS packaging conventions. Here's my write-up!

Public replies to this post will appear in a comments section under the blog post.

https://sitr.us/2026/05/03/embedded-sql-highlighting-in-neovim/

Embedded SQL highlighting in Neovim, a look into Treesitter, and some NixOS patching

This is the story of the rabbit hole I went down because I wanted pretty syntax highlighting for embedded SQL queries in my Rust code. I’m a fan of sqlx, which provides macros for writing inline SQL with real-time type checking. Because the queries are in Rust strings the whole query is highlighted uniform green by default. That’s not acceptable! By the end of my journey I had highlighting looking like this: In most cases this kind of embedded syntax highlighting is easy in Neovim, and it’s often set up by default if you use the nvim-treesitter plugin. But I ran into some issues in this particular case. That led me to learn some things about Treesitter, and about how nixpkgs packages Neovim plugins, and Treesitter packages. If you care to follow along, you’ll hear a tale of Neovim, Treesitter, injection queries, patching, NixOS, and more patching!…

sitr.us

I decided to work on this #treesitter parser a little bit more and put together some documentation for it:

https://tree-sitter-fasta.jrhawley.ca/

This won't come as a surprise to software maintainers, but writing good documentation is hard! It takes a lot of time to make sure it's right and that things are understandable.

In this case, I found Tree-sitter's support across editors to be ... sparse. #HelixEditor is by far the easiest, which is why I've documented that one first.

tree-sitter-fasta - tree-sitter-fasta

A parser for the FASTA sequencing file format.

Experimenting what I can do with #treesitter and #AdaLang :)

```
(compilation (compilation_unit (subprogram_body (procedure_specification name: (identifier)) (handled_sequence_of_statements (null_statement)) endname: (identifier))))
```

#Emacs repeat-mode also combines really well with #expreg (expand-region). expreg looks like a worthy successor to Magnars' `expand-region` package, which many of us have grown to love.

I have it set so `C-c y` marks the semantic 'thing' at point, and subsequent presses of `y` or `u` expand or contract to the next semantic unit.

Works well out of the box. Should work even better if/when I get my head around #treesitter.

This is my config:

(repeat-mode 1)
(defvar expreg-expand-keymap
(define-keymap
"y" #'expreg-expand
"u" #'expreg-contract))

(put #'expreg-expand 'repeat-map 'expreg-expand-keymap)
(put #'expreg-contract 'repeat-map 'expreg-expand-keymap)

(global-set-key (kbd "C-c y") #'expreg-expand)

The Helix modal editor has built-in support for treesitter, but it only ships with some of the R queries: (syntax) highlight, injection, and locals. It does not have yet queries for text objects, tags, indentation or rainbow brackets. At least three of these are available elsewhere; I wonder how hard would it be to adapt those for Helix?

#HelixEditor #RStats #treesitter

I tried something new in the last few days: I built a #treesitter grammar for the FASTA file format!

https://jrhawley.ca/2026/04/19/tree-sitter-fasta

This was a fun learning experience and I'm quite happy with the result. I intentionally ignored "prior art" and built something for myself, so that I could see what kinds of questions and trade-offs I would need to grapple with.

If parsers, domain-specific languages, or bioinformatics are your interest, feel free to give this a try!

Making a Tree-sitter parser for FASTA

Here I try to write a simple Tree-sitter parser for the FASTA file type.

It's a real shame that the #neovim #treesitter plugin maintainer got burnt out by demanding users. It's terrible for them - burnout is awful - and now the rest of us users are poorer for it: we can have neovim 0.11 and install treesitter easily, or neovim 0.12+ and in order to get treesitter you have to jump through loads of hoops, have a C-compiler handy etc.

I haven't got the brain space/energy for figuring it all out, so I'm working without treesitter now.

Episode 26 of our technology podcast @RuntimeArguments (http://RuntimeArguments.fm) — and it's our one-year anniversary! This one's called "Why You'll Never Switch Editors (And What You're Missing)".

Wolf @YesJustWolf surveys the text editor landscape — Vim, Emacs, VS Code, Helix, and some new AI-powered contenders — while Jim @jammcq defends his 42-year Vim habit (and gets talked into looking at TreeSitter and LSPs).

As always, we want to know what you think:

[email protected]

https://www.buzzsprout.com/2469780/episodes/19034506

#TextEditors #Vim #NeoVim #Emacs #VSCode #HelixEditor #LSP #TreeSitter #AICoding #Podcast #TechPodcast

A Better R Programming Experience Thanks to Tree-sitter

Modern tooling for parsing, searching, formatting, editing R code, just like for other programming languages.

@technomancy @mcc It's as if they looked at the existing problems and requirements, and then tried coming up with the dumbest "solutions" just for shits and giggles.

Even if I tried, I wouldn't be able to come up with the sheer density of painfully wrong decisions they made.

It's all "I'd love to understand the state of their mind that led them to believing that shit to be a valid design/engineering option" the way down.

#treesitter