8 February 2023

Emacs with tree-sitter support

by {"name"=>"Blaine Mooers", "avatar"=>"BlaineMooers.png", "bio"=>"Earned PhD in Biochemistry and Biophysics with Shing Ho at Oregon State Univeristy and did post-doc with Brian Matthews at the University of Oregon.", "location"=>"Oklahoma City, OK", "employer"=>"OUHSC", "pubmed"=>"https://www.ncbi.nlm.nih.gov/pubmed/?term=blaine+mooers", "googlescholar"=>"https://scholar.google.com/citations?hl=en&user=ZReXIXoAAAAJ&", "email"=>"blaine-mooers at ouhsc.edu", "researchgate"=>"https://www.researchgate.net/profile/Blaine-Mooers", "uri"=>nil, "bitbucket"=>nil, "codepen"=>nil, "dribbble"=>nil, "flickr"=>nil, "facebook"=>nil, "foursquare"=>nil, "github"=>"MooersLab", "google_plus"=>nil, "keybase"=>nil, "instagram"=>nil, "impactstory"=>nil, "lastfm"=>nil, "linkedin"=>nil, "orcid"=>"https://orcid.org/0000-0001-8181-8987", "pinterest"=>nil, "soundcloud"=>nil, "stackoverflow"=>nil, "steam"=>nil, "tumblr"=>nil, "twitter"=>"@BlaineMooers", "vine"=>nil, "weibo"=>nil, "xing"=>nil, "youtube"=>nil, "wikipedia"=>nil}

Tree-sitter is a C library that supports editing code with a concrete syntax tree. This syntax tree enables more powerful editing commands that save time and reduce tedium. Emacs and other leading text editors are still in the process of harnessing tree-sitter.

Emacs must be compiled with the tree-sitter C library already installed on your computer. I provide a protocol for doing so on a fresh installation of Ubuntu 22.04 LTS. I also succeeded with macOS 13.2 (Ventura) after I figured out that I needed to specify the path to the giflib library. Note that this library is different from the tree-sitter.el package that will be built into Emacs version 29.

Many thanks go to Jeff Bowman for inspiring me to compile Emacs from source and for sharing his notes on installing and running tree-sitter. He has posted a corrected version of these notes on his blog.

Note that tree-sitter is available on Anaconda as tree_sitter (note the underscore) and can be installed wherever you have permission to install conda packages, including some remote servers.

tags: agile code editing - tree-sitter - Emacs - Ubuntu