emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Validating tree-sitter major modes and grammar


From: Yuan Fu
Subject: Re: Validating tree-sitter major modes and grammar
Date: Mon, 23 Dec 2024 17:16:13 -0800


> On Dec 23, 2024, at 3:41 AM, Arsen Arsenović <arsen@aarsen.me> wrote:
> 
> Hi Yuan,
> 
> Yuan Fu <casouri@gmail.com> writes:
> 
>> 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?
> 
> Maybe this:
> 
>  ~$ time git clone --filter=blob:none 
> https://github.com/tree-sitter/tree-sitter-c/
>  [...]
> 
>  real 0m1.380s
>  user 0m0.104s
>  sys 0m0.069s
>  ~$ cd tree-sitter-c
>  ~/tree-sitter-c$ git describe HEAD
>  v0.20.8-61-g3efee11
> 
> A normal clone was 7.2 seconds, for reference.  Note that all future
> checkouts will be slowed down (as they will need to fetch fresh blobs),
> but if you're only cloning for HEAD anyway, that's fine.
> -- 
> Arsen Arsenović

Thanks! This is exactly what I need.

Yuan


reply via email to

[Prev in Thread] Current Thread [Next in Thread]