Emacs Tree-sitter custom highlighting
Published on: 2025-07-08 09:17:29
Thursday, February 27, 2025
A few years ago I blogged about custom tree-sitter-based syntax highlighting in emacs. I started out with highlighting certain keywords in red. I wanted to show the keywords that interrupt control flow:
Screenshot showing syntax highlighting of keywords in black or red
I highlight regular keywords ( while , if ) in bold. I highlight control flow interrupting keywords ( return , continue ) in red.
That's syntax highlighting.
But I also wanted to highlight names based on their meaning.
In some projects I'm working with horizontal and vertical measurements, and I thought it would be nice to highlight those variable names differently. In some projects I'm working with Delaunay+Voronoi meshes, and I wanted to highlight the triangles, edges, and polygons differently. In some projects I'm working with hexagonal grids, and I wanted to highlight the three axes differently, like I do in my guide to hexagonal grids. In some projects I am working with html+js mixe
... Read full article.