Fix Emacs with tree-sitter-rust on Arch Linux
As of 2026-04-22, the tree-sitter in the Arch Linux repositories is not
compatible with the emacs in the Arch Linx repositories. Specifically, the
tree-sitter is too new for Emacs 30.2. I couldn’t find anything else
online about this so I’m fixing the problem.
- Uninstall
emacs, make suretree-sittergoes with it. - Download
tree-sitter-0.24.7-1-x86_64.pkg.tar.zstfrom the Arch Linux Archive - Install it manually:
sudo pacman -U tree-sitter-0.24.7-1-x86_64.pkg.tar.zst - Add
tree-sittertoIgnorePkgin/etc/pacman.conf. - Install
emacsfrom source (go to the GNU website; download a tarball; extract;./autogen.sh;./configure; make sure it saysDoes Emacs use -ltree-sitter? yes;make -j16;sudo make install). -
Use tree-sitter grammars at a suitably old version. This diverges based on your setup. I use casouri’s helper, so after cloning that repo, I need to apply the following patch:
diff --git a/build.sh b/build.sh index b0920fb..ab70e13 100755 --- a/build.sh +++ b/build.sh @@ -151,6 +151,9 @@ case "${lang}" in "proto") org="mitchellh" ;; + "rust") + version="v0.21.2" + ;; "scss") org="tree-sitter-grammars" ;; - Then, run
JOBS=16 ./batch.shandcp dist/* ../tree-sitter. - Open a random Rust file to check that it’s all working properly. If you have syntax highlighting, it works.