[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Validating tree-sitter major modes and grammar
From: |
Yuan Fu |
Subject: |
Validating tree-sitter major modes and grammar |
Date: |
Fri, 20 Dec 2024 01:09:10 -0800 |
Continuing from the tree-sitter maternity thread, I cooked up some script to go
over each builtin tree-sitter mode, clone the grammars it uses, and check
whether the font-lock queries are compatible with the latest version of the
grammar. If everything works fine, the script adds some comment in the source
file listing the version that was checked.
For example, I ran the script for c-ts-mode and c++-ts-mode, and this is the
comment inserted to c-ts-mode.el:
;;; Tree-sitter language versions
;;
;; c-ts-mode is known to work with the following languages and version:
;; - tree-sitter-c: v0.20.8-61-g3efee11
;;
;; c++-ts-mode is known to work with the following languages and version:
;; - tree-sitter-cpp: v0.20.5-49-gf41b4f6
;;
;; We try our best to make builtin modes work with latest grammar
;; versions, so a more recent grammar version has a good chance to work.
;; Send us a bug report if it doesn't.
The version is taken from “git describe”. If the grammar isn’t versioned, it’ll
just be the hash of HEAD. In order for “git describe” to work, I had to do full
clones, and some tree-sitter grammar’s repo is very slow to clone. I wonder if
there’s anything we can do to speed it up?
Any thoughts/comments? I pushed the code to master so others can play with it.
BTW, the script revealed that cmake-ts-mode isn’t compatible with the latest
grammar. I’ll try fix it later.
Yuan