emacs 2026-04-21

Is anyone else having treesitter errors when opening clojure files in emacs recently? (last day or three) I did an update of my OS (Omarchy), I believe the treesitter lib was updated. Today when I opened a clojure project, the treesitter integration is broken. I updated all of the elisp packages, but still not working. I'll paste the actual error in the thread.

[eglot] Connected! Server 'EGLOT (api-gateway/(clojure-mode clojurescript-mode clojurec-mode clojure-ts-mode))' now managing '(clojure-mode clojurescript-mode clojurec-mode clojure-ts-mode)' buffers in project 'api-gateway'.
Error muted by safe_call: (treesit--font-lock-mark-ranges-to-fontify ((1 . 7235)) #<treesit-parser for clojure>) signaled (treesit-query-error "Syntax error at" 233 "((list_lit . [(comment) (meta_lit) (old_meta_lit)] * . (sym_lit) @_def_symbol . [(comment) (meta_lit) (old_meta_lit)] * . (sym_lit) . [(comment) (meta_lit) (old_meta_lit)] * . (str_lit (str_content) @capture) @_ignore . (_)) (#match \"^def$\" @_def_symbol)) ((list_lit . [(comment) (meta_lit) (old_meta_lit)] * . (sym_lit) @_def_symbol . (comment) * . (meta_lit value: (map_lit (kwd_lit) @_doc-keyword . (str_lit (str_content) @capture) @_ignore))) (#match \"^\\\\(?:def\\\\(?:in\\\\(?:\\\\(?:lin\\\\|terfac\\\\)e\\\\)\\\\|m\\\\(?:acro\\\\|ulti\\\\)\\\\|n-?\\\\|once\\\\|protocol\\\\|record\\\\|struct\\\\|t\\\\(?:est-?\\\\|ype\\\\)\\\\)?\\\\|ns\\\\)$\" @_def_symbol) (#equal @_doc-keyword \":doc\")) ((list_lit . [(comment) (meta_lit) (old_meta_lit)] * . (sym_lit) @_def_symbol . [(comment) (meta_lit) (old_meta_lit)] * . (sym_lit) . [(comment) (meta_lit) (old_meta_lit)] * . (str_lit (str_content) @capture) @_ignore) (#match \"^\\\\(?:def\\\\(?:inline\\\\|m\\\\(?:acro\\\\|ulti\\\\)\\\\|n-?\\\\|protocol\\\\)\\\\|ns\\\\)$\" @_def_symbol)) ((list_lit . [(comment) (meta_lit) (old_meta_lit)] * . (sym_lit) @_def_symbol (list_lit . (sym_lit) (vec_lit) * (str_lit (str_content) @capture) @_ignore)) (#match \"^\\\\(?:def\\\\(?:interface\\\\|protocol\\\\)\\\\)$\" @_def_symbol))" "Debug the query with `treesit-query-validate'")
Error during redisplay: (jit-lock-function 1) signaled (treesit-query-error "Syntax error at" 233 "((list_lit . [(comment) (meta_lit) (old_meta_lit)] * . (sym_lit) @_def_symbol . [(comment) (meta_lit) (old_meta_lit)] * . (sym_lit) . [(comment) (meta_lit) (old_meta_lit)] * . (str_lit (str_content) @capture) @_ignore . (_)) (#match \"^def$\" @_def_symbol)) ((list_lit . [(comment) (meta_lit) (old_meta_lit)] * . (sym_lit) @_def_symbol . (comment) * . (meta_lit value: (map_lit (kwd_lit) @_doc-keyword . (str_lit (str_content) @capture) @_ignore))) (#match \"^\\\\(?:def\\\\(?:in\\\\(?:\\\\(?:lin\\\\|terfac\\\\)e\\\\)\\\\|m\\\\(?:acro\\\\|ulti\\\\)\\\\|n-?\\\\|once\\\\|protocol\\\\|record\\\\|struct\\\\|t\\\\(?:est-?\\\\|ype\\\\)\\\\)?\\\\|ns\\\\)$\" @_def_symbol) (#equal @_doc-keyword \":doc\")) ((list_lit . [(comment) (meta_lit) (old_meta_lit)] * . (sym_lit) @_def_symbol . [(comment) (meta_lit) (old_meta_lit)] * . (sym_lit) . [(comment) (meta_lit) (old_meta_lit)] * . (str_lit (str_content) @capture) @_ignore) (#match \"^\\\\(?:def\\\\(?:inline\\\\|m\\\\(?:acro\\\\|ulti\\\\)\\\\|n-?\\\\|protocol\\\\)\\\\|ns\\\\)$\" @_def_symbol)) ((list_lit . [(comment) (meta_lit) (old_meta_lit)] * . (sym_lit) @_def_symbol (list_lit . (sym_lit) (vec_lit) * (str_lit (str_content) @capture) @_ignore)) (#match \"^\\\\(?:def\\\\(?:interface\\\\|protocol\\\\)\\\\)$\" @_def_symbol))" "Debug the query with `treesit-query-validate'")
QuitError during redisplay: (jit-lock-function 1501) signaled (treesit-query-error "Syntax error at" 233 "((list_lit . [(comment) (meta_lit) (old_meta_lit)] * . (sym_lit) @_def_symbol . [(comment) (meta_lit) (old_meta_lit)] * . (sym_lit) . [(comment) (meta_lit) (old_meta_lit)] * . (str_lit (str_content) @capture) @_ignore . (_)) (#match \"^def$\" @_def_symbol)) ((list_lit . [(comment) (meta_lit) (old_meta_lit)] * . (sym_lit) @_def_symbol . (comment) * . (meta_lit value: (map_lit (kwd_lit) @_doc-keyword . (str_lit (str_content) @capture) @_ignore))) (#match \"^\\\\(?:def\\\\(?:in\\\\(?:\\\\(?:lin\\\\|terfac\\\\)e\\\\)\\\\|m\\\\(?:acro\\\\|ulti\\\\)\\\\|n-?\\\\|once\\\\|protocol\\\\|record\\\\|struct\\\\|t\\\\(?:est-?\\\\|ype\\\\)\\\\)?\\\\|ns\\\\)$\" @_def_symbol) (#equal @_doc-keyword \":doc\")) ((list_lit . [(comment) (meta_lit) (old_meta_lit)] * . (sym_lit) @_def_symbol . [(comment) (meta_lit) (old_meta_lit)] * . (sym_lit) . [(comment) (meta_lit) (old_meta_lit)] * . (str_lit (str_content) @capture) @_ignore) (#match \"^\\\\(?:def\\\\(?:inline\\\\|m\\\\(?:acro\\\\|ulti\\\\)\\\\|n-?\\\\|protocol\\\\)\\\\|ns\\\\)$\" @_def_symbol)) ((list_lit . [(comment) (meta_lit) (old_meta_lit)] * . (sym_lit) @_def_symbol (list_lit . (sym_lit) (vec_lit) * (str_lit (str_content) @capture) @_ignore)) (#match \"^\\\\(?:def\\\\(?:interface\\\\|protocol\\\\)\\\\)$\" @_def_symbol))" "Debug the query with `treesit-query-validate'")

(I'm sorry, I don't have the chops to debug this myself...) claude used up all of my credits in one prompt to come up with the following tidbit: > • In tree-sitter 0.26, #match and #equal without ? suffix are invalid — only #match? and #equal? work. > • tree-sitter 0.25.x accepts #match without ?

I've gone back to clojure-mode for now...

I think you are using the wrong grammar version

How did I get to using the wrong one if it was the right one before?

maybe your OS provides the grammar in the repo?

could it be installed system-wide?

So I'm not 100% on the how treesitter works; are you talking about libtree-sitter-clojure.so? This file is in my $/.emacs.d/tree-sitter/

yes. But in this directory grammars are installed by Emacs itself or manually. Did you use something to install grammars? Maybe this https://github.com/casouri/tree-sitter-module?

I would try M-x clojure-ts-reinstall-grammars and restart emacs

I'm pretty sure my init.el cause those grammar files to be installed

I'll try that

I think there is a chance that the required version was overwritten by "stable" version, which is incompatible with clojure-ts-mode

re-installing the grammars did not fix the issue.

have you restarted emacs?

ok, that's interesting. Is the error reproducible in any clojure buffer? What if you open a very minimal Clojure file with just a namespace declaration for example?

the error says that one query is invalid, maybe there is a bug

Same error:

Error running timer: (treesit-query-error "Syntax error at" 233 "((list_lit . [(comment) (meta_lit) (old_meta_lit)] * . (sym_lit) @_def_symbol . [(comment) (meta_lit) (old_meta_lit)] * . (sym_lit) . [(comment) (meta_lit) (old_meta_lit)] * . (str_lit (str_content) @capture) @_ignore . (_)) (#match \"^def$\" @_def_symbol)) ((list_lit . [(comment) (meta_lit) (old_meta_lit)] * . (sym_lit) @_def_symbol . (comment) * . (meta_lit value: (map_lit (kwd_lit) @_doc-keyword . (str_lit (str_content) @capture) @_ignore))) (#match \"^\\\\(?:def\\\\(?:in\\\\(?:\\\\(?:lin\\\\|terfac\\\\)e\\\\)\\\\|m\\\\(?:acro\\\\|ulti\\\\)\\\\|n-?\\\\|once\\\\|protocol\\\\|record\\\\|struct\\\\|t\\\\(?:est-?\\\\|ype\\\\)\\\\)?\\\\|ns\\\\)$\" @_def_symbol) (#equal @_doc-keyword \":doc\")) ((list_lit . [(comment) (meta_lit) (old_meta_lit)] * . (sym_lit) @_def_symbol . [(comment) (meta_lit) (old_meta_lit)] * . (sym_lit) . [(comment) (meta_lit) (old_meta_lit)] * . (str_lit (str_content) @capture) @_ignore) (#match \"^\\\\(?:def\\\\(?:inline\\\\|m\\\\(?:acro\\\\|ulti\\\\)\\\\|n-?\\\\|protocol\\\\)\\\\|ns\\\\)$\" @_def_symbol)) ((list_lit . [(comment) (meta_lit) (old_meta_lit)] * . (sym_lit) @_def_symbol (list_lit . (sym_lit) (vec_lit) * (str_lit (str_content) @capture) @_ignore)) (#match \"^\\\\(?:def\\\\(?:interface\\\\|protocol\\\\)\\\\)$\" @_def_symbol))" "Debug the query with `treesit-query-validate'")e
with clojure file containing this:
(ns gometro.apigw.http.core2
  (:require
   [integrant.core :as ig]
   [taoensso.timbre :as log]
   [java-time.api :as t]
   [afrolabs.components :as -comp]
   [afrolabs.components.http :as -http]
   [ring.util.response :as -http-response]
   [clojure.spec.alpha :as s]
   [clojure.string :as str]))

what version of clojure-ts-mode are you using?

M-x clojure-ts-mode-display-version

👍🏽 1

clojure-ts-mode 0.6.0 (package: <tel:202603252107|20260325.2107>)

Thanks, I cannot reproduce it with my current setup. I'll try to downgrade the grammar and see if the error is the same

no, when the grammar version is incorrect, the error is the following:

stop  Warning (treesit-font-lock-rules-mismatch): Emacs cannot compile every font-lock rules because a mismatch between the grammar and the rules.  This is most likely due to a mismatch between the font-lock rules defined by the major mode and the tree-sitter grammar.

This error can be fixed by either downgrading the grammar (tree-sitter-clojure) on your system, or upgrading the major mode package.  The following are the temporarily disabled features:

- `doc' for clojure,
- `string' for clojure.
What version of Emacs are you using?

GNU Emacs 30.2 (build 1, x86_64-pc-linux-gnu, GTK+ Version 3.24.52, cairo version 1.18.4)

👍 1

Thank you for checking anyway 👍🏽

np. If you have time, could you please try to run emacs -q, evaluate the following in the *scratch* buffer:

(package-initialize)
(require 'clojure-ts-mode)
and try to open your Clojure file? I wonder if there is some configuration issue in your init.el

It failed in the same way

one more thing if you don't mind. Could you please M-x toggle-debug-on-error, then reproduce this error and post here the backtrace?

in any case it looks like a bug and I think we should report it, but the more details we get the better

I'm not sure what must change when this flag is toggled? I get exactly the same behaviour (failure), but no other frames popping up with a trace or anything like that, just the same failure messages in Messages

ah, I guess the error is not signaled, I see in the message "Error muted by safe_call". In this case we won't get a backtrace

👍🏽 1

basically emacs 30.2 is linked with tree-sitter-0.26, but there is a compatibility issue

if emacs-30.2 in your distro was packaged against tree-sitter-0.26.*, there is not much you can do. The best workaround would be to downgrade to emacs-30.1 or switch to master

using clojure-mode has a less severe impact on my life 😉 Thank you so much for helping diagnose this and finding the bug report. I'll follow it and revert my setup once the updates landed.

understandable 🙂 Hopefully the next major release of Emacs will improve the situation with clojure-ts-mode significantly. There are many improvements and fixes, basically the reason I use master branch of Emacs 🙂

👍🏽 1

i think the distribution in question here (omarchy?) is based on arch linux. the link to the emacs bug presented above appears to be for arch linux -- and it looks like there was a fix made. it doesn't seem completely unlikely that omarchy will pick up the change. just my local two currency units

👍 1
👍🏽 1

Usually when omarchy has os updates it will also upgrade all installed packages, and this most likely upgraded emacs, giving you this bug

👍🏽 1