Use keyword :commit with full hashes for treesit-language-source-alist.

* lisp/treesit.el (treesit-language-source-alist):
Document the format that uses keywords.
(treesit--install-language-grammar-1): Remove args
'revision', 'source-dir', 'cc', 'c++', 'commit'.
Use 'args' to process the keywords, and use the remaining
list as the previous list of arguments.
(treesit--install-language-grammar-1): Let-bind
'treesit--install-language-grammar-full-clone' and
'treesit--install-language-grammar-blobless' to t
when 'commit' is non-nil (bug#78542).

* lisp/progmodes/c-ts-mode.el:
* lisp/progmodes/cmake-ts-mode.el:
* lisp/progmodes/csharp-mode.el:
* lisp/progmodes/dockerfile-ts-mode.el:
* lisp/progmodes/elixir-ts-mode.el:
* lisp/progmodes/go-ts-mode.el:
* lisp/progmodes/heex-ts-mode.el:
* lisp/progmodes/java-ts-mode.el:
* lisp/progmodes/js.el:
* lisp/progmodes/json-ts-mode.el:
* lisp/progmodes/php-ts-mode.el:
* lisp/progmodes/python.el:
* lisp/progmodes/ruby-ts-mode.el:
* lisp/progmodes/rust-ts-mode.el:
* lisp/progmodes/sh-script.el:
* lisp/progmodes/typescript-ts-mode.el:
* lisp/textmodes/css-mode.el:
* lisp/textmodes/html-ts-mode.el:
* lisp/textmodes/markdown-ts-mode.el:
* lisp/textmodes/toml-ts-mode.el:
* lisp/textmodes/yaml-ts-mode.el:
Use the keyword :commit with full hashes instead of tags
in 'treesit-language-source-alist'.

* lisp/treesit-x.el (define-treesit-generic-mode):
Simplify the keyword :copy-queries.
(gitattributes-generic-ts-mode, liquid-generic-ts-mode):
Add keywords :commit and :copy-queries to :source.

* admin/tree-sitter/treesit-admin.el
(treesit-admin--unversioned-treesit-language-source-alist):
Handle :revision and :commit as well.
(treesit-admin--find-latest-compatible-revision):
Process the keywords in the recipe.
This commit is contained in:
Juri Linkov 2025-06-20 19:56:01 +03:00
parent e3660a32c7
commit 1a76b527ac
26 changed files with 201 additions and 90 deletions

View file

@ -134,11 +134,21 @@ This is done by `require'ing all of the features that extend it."
"Return a copy of treesit-language-source-alist, with any revisions removed."
(mapcar
(lambda (source)
(if (nthcdr 2 source)
(cond ((or (memq :revision source)
(memq :commit source))
(when (memq :revision source)
(let ((unversioned-source (copy-sequence source)))
(setcar (cdr (memq :revision unversioned-source)) nil)
unversioned-source))
(when (memq :commit source)
(let ((unversioned-source (copy-sequence source)))
(setcar (cdr (memq :commit unversioned-source)) nil)
unversioned-source)))
((nthcdr 2 source)
(let ((unversioned-source (copy-sequence source)))
(setcar (nthcdr 2 unversioned-source) nil)
unversioned-source)
source))
unversioned-source))
(t source)))
(treesit-admin--populated-treesit-language-source-alist)))
(defun treesit-admin--verify-major-mode-queries (modes source-alist grammar-dir)
@ -343,8 +353,26 @@ epoch format."
head-version version exit-code timestamp)
(when (not recipe)
(signal 'treesit-error `("Cannot find recipe" ,language)))
(pcase-let ((`(,url ,revision ,source-dir ,cc ,c++ ,commit)
recipe))
(let ((url (pop recipe))
revision source-dir cc c++ commit copy-queries)
;; Process the keywords.
(while (keywordp (car recipe))
(pcase (pop recipe)
(:revision (setq revision (pop recipe)))
(:source-dir (setq source-dir (pop recipe)))
(:cc (setq cc (pop recipe)))
(:c++ (setq c++ (pop recipe)))
(:commit (setq commit (pop recipe)))
(:copy-queries (setq copy-queries (pop recipe)))))
;; Old positional convention for backward-compatibility.
(unless revision (setq revision (nth 0 recipe)))
(unless source-dir (setq source-dir (nth 1 recipe)))
(unless cc (setq cc (nth 2 recipe)))
(unless c++ (setq c++ (nth 3 recipe)))
(unless commit (setq commit (nth 4 recipe)))
(with-temp-buffer
(treesit--git-clone-repo url revision workdir)
(when commit

View file

@ -604,6 +604,10 @@ It controls the automatic installation of tree-sitter grammar libraries
needed for tree-sitter based modes, if these grammar libraries are not
available when such modes are turned on.
*** 'treesit-language-source-alist' supports keywords.
The language and URL are mandatory, but remaining data can use keywords:
'(json "https://github.com/tree-sitter/tree-sitter-json" :commit "4d770d3")
*** The file treesit-x.el defines a number of simple tree-sitter modes.
Using the new macro 'define-treesit-generic-mode', generic modes are
defined including, but not limited to, 'gitattributes-generic-ts-mode'.

View file

@ -24,14 +24,14 @@
;;; Tree-sitter language versions
;;
;; c-ts-mode is known to work with the following languages and version:
;; c-ts-mode has been tested with the following grammars and version:
;; - tree-sitter-c: v0.23.4-1-g3aa2995
;;
;; c++-ts-mode is known to work with the following languages and version:
;; c++-ts-mode has been tested with the following grammars and version:
;; - tree-sitter-cpp: v0.23.4-1-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.
;; versions, so a more recent grammar has a good chance to work too.
;; Send us a bug report if it doesn't.
;;; Commentary:
@ -88,15 +88,18 @@
(add-to-list
'treesit-language-source-alist
'(c "https://github.com/tree-sitter/tree-sitter-c" "v0.23.4")
'(c "https://github.com/tree-sitter/tree-sitter-c"
:commit "3aa2995549d5d8b26928e8d3fa2770fd4327414e")
t)
(add-to-list
'treesit-language-source-alist
'(cpp "https://github.com/tree-sitter/tree-sitter-cpp" "v0.23.4")
'(cpp "https://github.com/tree-sitter/tree-sitter-cpp"
:commit "f41b4f66a42100be405f96bdc4ebc4a61095d3e8")
t)
(add-to-list
'treesit-language-source-alist
'(doxygen "https://github.com/tree-sitter-grammars/tree-sitter-doxygen" "v1.1.0")
'(doxygen "https://github.com/tree-sitter-grammars/tree-sitter-doxygen"
:commit "1e28054cb5be80d5febac082706225e42eff14e6")
t)
;;; Custom variables

View file

@ -24,11 +24,11 @@
;;; Tree-sitter language versions
;;
;; cmake-ts-mode is known to work with the following languages and version:
;; cmake-ts-mode has been tested with the following grammars and version:
;; - tree-sitter-cmake: v0.5.0-5-ge409ae3
;;
;; 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.
;; versions, so a more recent grammar has a good chance to work too.
;; Send us a bug report if it doesn't.
;;; Commentary:
@ -42,7 +42,8 @@
(add-to-list
'treesit-language-source-alist
'(cmake "https://github.com/uyha/tree-sitter-cmake" "v0.5.0")
'(cmake "https://github.com/uyha/tree-sitter-cmake"
:commit "e409ae33f00e04cde30f2bcffb979caf1a33562a")
t)
(defcustom cmake-ts-mode-indent-offset 2

View file

@ -651,7 +651,8 @@ compilation and evaluation time conflicts."
(add-to-list
'treesit-language-source-alist
'(c-sharp "https://github.com/tree-sitter/tree-sitter-c-sharp" "v0.23.1")
'(c-sharp "https://github.com/tree-sitter/tree-sitter-c-sharp"
:commit "362a8a41b265056592a0c3771664a21d23a71392")
t)
(defcustom csharp-ts-mode-indent-offset 4

View file

@ -24,11 +24,11 @@
;;; Tree-sitter language versions
;;
;; dockerfile-ts-mode is known to work with the following languages and version:
;; dockerfile-ts-mode has been tested with the following grammars and version:
;; - tree-sitter-dockerfile: v0.2.0-1-g087daa2
;;
;; 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.
;; versions, so a more recent grammar has a good chance to work too.
;; Send us a bug report if it doesn't.
;;; Commentary:
@ -42,7 +42,8 @@
(add-to-list
'treesit-language-source-alist
'(dockerfile "https://github.com/camdencheek/tree-sitter-dockerfile" "v0.2.0")
'(dockerfile "https://github.com/camdencheek/tree-sitter-dockerfile"
:commit "087daa20438a6cc01fa5e6fe6906d77c869d19fe")
t)
(defvar dockerfile-ts-mode--syntax-table

View file

@ -23,12 +23,12 @@
;;; Tree-sitter language versions
;;
;; elixir-ts-mode is known to work with the following languages and version:
;; - tree-sitter-heex: v0.7.0
;; elixir-ts-mode has been tested with the following grammars and version:
;; - tree-sitter-elixir: v0.3.3
;; - tree-sitter-heex: v0.7.0
;;
;; 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.
;; versions, so a more recent grammar has a good chance to work too.
;; Send us a bug report if it doesn't.
;;; Commentary:
@ -59,11 +59,13 @@
(add-to-list
'treesit-language-source-alist
'(elixir "https://github.com/elixir-lang/tree-sitter-elixir" "v0.3.3")
'(elixir "https://github.com/elixir-lang/tree-sitter-elixir"
:commit "02a6f7fd4be28dd94ee4dd2ca19cb777053ea74e")
t)
(add-to-list
'treesit-language-source-alist
'(heex "https://github.com/phoenixframework/tree-sitter-heex" "v0.7.0")
'(heex "https://github.com/phoenixframework/tree-sitter-heex"
:commit "f6b83f305a755cd49cf5f6a66b2b789be93dc7b9")
t)
(defgroup elixir-ts nil

View file

@ -24,13 +24,13 @@
;;; Tree-sitter language versions
;;
;; go-ts-mode is known to work with the following languages and version:
;; go-ts-mode has been tested with the following grammars and version:
;; - tree-sitter-go: v0.23.4-1-g12fe553
;; - tree-sitter-go-mod: v1.1.0-3b01edce
;; - tree-sitter-go-work: 949a8a47
;;
;; 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.
;; versions, so a more recent grammar has a good chance to work too.
;; Send us a bug report if it doesn't.
;;; Commentary:
@ -48,15 +48,18 @@
(add-to-list
'treesit-language-source-alist
'(go "https://github.com/tree-sitter/tree-sitter-go" "v0.23.4")
'(go "https://github.com/tree-sitter/tree-sitter-go"
:commit "12fe553fdaaa7449f764bc876fd777704d4fb752")
t)
(add-to-list
'treesit-language-source-alist
'(gomod "https://github.com/camdencheek/tree-sitter-go-mod" "v1.1.0")
'(gomod "https://github.com/camdencheek/tree-sitter-go-mod"
:commit "3b01edce2b9ea6766ca19328d1850e456fde3103")
t)
(add-to-list
'treesit-language-source-alist
'(gowork "https://github.com/omertuc/tree-sitter-go-work")
'(gowork "https://github.com/omertuc/tree-sitter-go-work"
:commit "949a8a470559543857a62102c84700d291fc984c")
t)
(defcustom go-ts-mode-indent-offset 8

View file

@ -23,11 +23,12 @@
;;; Tree-sitter language versions
;;
;; heex-ts-mode is known to work with the following languages and version:
;; heex-ts-mode has been tested with the following grammars and version:
;; - tree-sitter-heex: v0.7.0
;; - tree-sitter-elixir: v0.3.3
;;
;; 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.
;; versions, so a more recent grammar has a good chance to work too.
;; Send us a bug report if it doesn't.
;;; Commentary:
@ -46,11 +47,13 @@
(add-to-list
'treesit-language-source-alist
'(heex "https://github.com/phoenixframework/tree-sitter-heex" "v0.7.0")
'(heex "https://github.com/phoenixframework/tree-sitter-heex"
:commit "f6b83f305a755cd49cf5f6a66b2b789be93dc7b9")
t)
(add-to-list
'treesit-language-source-alist
'(elixir "https://github.com/elixir-lang/tree-sitter-elixir" "v0.3.3")
'(elixir "https://github.com/elixir-lang/tree-sitter-elixir"
:commit "02a6f7fd4be28dd94ee4dd2ca19cb777053ea74e")
t)
(defgroup heex-ts nil

View file

@ -24,11 +24,11 @@
;;; Tree-sitter language versions
;;
;; java-ts-mode is known to work with the following languages and version:
;; java-ts-mode has been tested with the following grammars and version:
;; - tree-sitter-java: v0.23.5
;;
;; 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.
;; versions, so a more recent grammar has a good chance to work too.
;; Send us a bug report if it doesn't.
;;; Commentary:
@ -45,11 +45,13 @@
(add-to-list
'treesit-language-source-alist
'(java "https://github.com/tree-sitter/tree-sitter-java" "v0.23.5")
'(java "https://github.com/tree-sitter/tree-sitter-java"
:commit "94703d5a6bed02b98e438d7cad1136c01a60ba2c")
t)
(add-to-list
'treesit-language-source-alist
'(doxygen "https://github.com/tree-sitter-grammars/tree-sitter-doxygen" "v1.1.0")
'(doxygen "https://github.com/tree-sitter-grammars/tree-sitter-doxygen"
:commit "1e28054cb5be80d5febac082706225e42eff14e6")
t)
(defcustom java-ts-mode-indent-offset 4

View file

@ -26,12 +26,12 @@
;;; Tree-sitter language versions
;;
;; js-ts-mode is known to work with the following languages and version:
;; js-ts-mode has been tested with the following grammars and version:
;; - tree-sitter-jsdoc: v0.23.2
;; - tree-sitter-javascript: v0.23.1-2-g108b2d4
;;
;; 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.
;; versions, so a more recent grammar has a good chance to work too.
;; Send us a bug report if it doesn't.
;;; Commentary:
@ -3410,11 +3410,13 @@ This function is intended for use in `after-change-functions'."
(add-to-list
'treesit-language-source-alist
'(javascript "https://github.com/tree-sitter/tree-sitter-javascript" "v0.23.1")
'(javascript "https://github.com/tree-sitter/tree-sitter-javascript"
:commit "108b2d4d17a04356a340aea809e4dd5b801eb40d")
t)
(add-to-list
'treesit-language-source-alist
'(jsdoc "https://github.com/tree-sitter/tree-sitter-jsdoc" "v0.23.2")
'(jsdoc "https://github.com/tree-sitter/tree-sitter-jsdoc"
:commit "b253abf68a73217b7a52c0ec254f4b6a7bb86665")
t)
(defun js--treesit-font-lock-compatibility-definition-feature ()

View file

@ -24,11 +24,11 @@
;;; Tree-sitter language versions
;;
;; json-ts-mode is known to work with the following languages and version:
;; json-ts-mode has been tested with the following grammars and version:
;; - tree-sitter-json: v0.24.8-1-g4d770d3
;;
;; 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.
;; versions, so a more recent grammar has a good chance to work too.
;; Send us a bug report if it doesn't.
;;; Commentary:
@ -42,7 +42,8 @@
(add-to-list
'treesit-language-source-alist
'(json "https://github.com/tree-sitter/tree-sitter-json" "v0.24.8")
'(json "https://github.com/tree-sitter/tree-sitter-json"
:commit "4d770d31f732d50d3ec373865822fbe659e47c75")
t)
(defcustom json-ts-mode-indent-offset 2

View file

@ -50,7 +50,8 @@
(add-to-list
'treesit-language-source-alist
'(lua "https://github.com/tree-sitter-grammars/tree-sitter-lua" "v0.3.0")
'(lua "https://github.com/tree-sitter-grammars/tree-sitter-lua"
:commit "db16e76558122e834ee214c8dc755b4a3edc82a9")
t)
(defgroup lua-ts nil

View file

@ -24,8 +24,8 @@
;;; Tree-sitter language versions
;;
;; php-ts-mode is known to work with the following languages and version:
;; - tree-sitter-phpdoc: fe3202e468bc17332bec8969f2b50ff1f1da3a46
;; php-ts-mode has been tested with the following grammars and version:
;; - tree-sitter-phpdoc: v0.1.5
;; - tree-sitter-css: v0.23.1-1-g6a442a3
;; - tree-sitter-jsdoc: v0.23.2
;; - tree-sitter-javascript: v0.23.1-2-g108b2d4
@ -33,7 +33,7 @@
;; - tree-sitter-php: v0.23.11
;;
;; 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.
;; versions, so a more recent grammar has a good chance to work too.
;; Send us a bug report if it doesn't.
;;; Commentary:
@ -82,8 +82,11 @@
;;; Install treesitter language parsers
(defvar php-ts-mode--language-source-alist
'((php "https://github.com/tree-sitter/tree-sitter-php" "v0.23.11" "php/src")
(phpdoc "https://github.com/claytonrcarter/tree-sitter-phpdoc"))
'((php "https://github.com/tree-sitter/tree-sitter-php"
:commit "43aad2b9a98aa8e603ea0cf5bb630728a5591ad8"
:source-dir "php/src")
(phpdoc "https://github.com/claytonrcarter/tree-sitter-phpdoc"
:commit "fe3202e468bc17332bec8969f2b50ff1f1da3a46"))
"Treesitter language parsers required by `php-ts-mode'.
You can customize `treesit-language-source-alist' if you want
to stick to a specific commit and/or use different parsers.")

View file

@ -271,7 +271,8 @@
(add-to-list
'treesit-language-source-alist
'(python "https://github.com/tree-sitter/tree-sitter-python" "v0.23.6")
'(python "https://github.com/tree-sitter/tree-sitter-python"
:commit "bffb65a8cfe4e46290331dfef0dbf0ef3679de11")
t)
;; Avoid compiler warnings

View file

@ -24,11 +24,11 @@
;;; Tree-sitter language versions
;;
;; ruby-ts-mode is known to work with the following languages and version:
;; ruby-ts-mode has been tested with the following grammars and version:
;; - tree-sitter-ruby: v0.23.1
;;
;; 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.
;; versions, so a more recent grammar has a good chance to work too.
;; Send us a bug report if it doesn't.
;;; Commentary:
@ -125,7 +125,8 @@
(add-to-list
'treesit-language-source-alist
'(ruby "https://github.com/tree-sitter/tree-sitter-ruby" "v0.23.1")
'(ruby "https://github.com/tree-sitter/tree-sitter-ruby"
:commit "71bd32fb7607035768799732addba884a37a6210")
t)
(defgroup ruby-ts nil

View file

@ -24,11 +24,11 @@
;;; Tree-sitter language versions
;;
;; rust-ts-mode is known to work with the following languages and version:
;; - tree-sitter-rust: v0.23.2-1-g1f63b33
;; rust-ts-mode has been tested with the following grammars and version:
;; - tree-sitter-rust: v0.24.0
;;
;; 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.
;; versions, so a more recent grammar has a good chance to work too.
;; Send us a bug report if it doesn't.
;;; Commentary:
@ -44,8 +44,10 @@
(add-to-list
'treesit-language-source-alist
`(rust "https://github.com/tree-sitter/tree-sitter-rust"
,(when (treesit-available-p)
(if (< (treesit-library-abi-version) 15) "v0.23.2" "v0.24.0")))
:commit ,(if (and (treesit-available-p)
(< (treesit-library-abi-version) 15))
"1f63b33efee17e833e0ea29266dd3d713e27e321"
"18b0515fca567f5a10aee9978c6d2640e878671a"))
t)
(defcustom rust-ts-mode-indent-offset 4

View file

@ -3267,7 +3267,8 @@ member of `flymake-diagnostic-functions'."
(add-to-list
'treesit-language-source-alist
'(bash "https://github.com/tree-sitter/tree-sitter-bash" "v0.23.3")
'(bash "https://github.com/tree-sitter/tree-sitter-bash"
:commit "487734f87fd87118028a65a4599352fa99c9cde8")
t)
(defvar sh-mode--treesit-operators

View file

@ -24,11 +24,14 @@
;;; Tree-sitter language versions
;;
;; typescript-ts-mode is known to work with the following languages and version:
;; typescript-ts-mode has been tested with the following grammars and version:
;; - tree-sitter-typescript: v0.23.2-2-g8e13e1d
;;
;; tsx-ts-mode has been tested with the following grammars and version:
;; - tree-sitter-tsx: v0.23.2-2-g8e13e1d
;;
;; 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.
;; versions, so a more recent grammar has a good chance to work too.
;; Send us a bug report if it doesn't.
;;; Commentary:
@ -45,14 +48,16 @@
(add-to-list
'treesit-language-source-alist
'(typescript
"https://github.com/tree-sitter/tree-sitter-typescript" "v0.23.2"
"typescript/src")
"https://github.com/tree-sitter/tree-sitter-typescript"
:commit "8e13e1db35b941fc57f2bd2dd4628180448c17d5"
:source-dir "typescript/src")
t)
(add-to-list
'treesit-language-source-alist
'(tsx
"https://github.com/tree-sitter/tree-sitter-typescript" "v0.23.2"
"tsx/src")
"https://github.com/tree-sitter/tree-sitter-typescript"
:commit "8e13e1db35b941fc57f2bd2dd4628180448c17d5"
:source-dir "tsx/src")
t)
(defcustom typescript-ts-mode-indent-offset 2

View file

@ -23,11 +23,11 @@
;;; Tree-sitter language versions
;;
;; css-ts-mode is known to work with the following languages and version:
;; css-ts-mode has been tested with the following grammars and version:
;; - tree-sitter-css: v0.23.1-1-g6a442a3
;;
;; 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.
;; versions, so a more recent grammar has a good chance to work too.
;; Send us a bug report if it doesn't.
;;; Commentary:
@ -1343,7 +1343,8 @@ for determining whether point is within a selector."
(add-to-list
'treesit-language-source-alist
'(css "https://github.com/tree-sitter/tree-sitter-css" "v0.23.1")
'(css "https://github.com/tree-sitter/tree-sitter-css"
:commit "6a442a3cf461b0ce275339e5afa178693484c927")
t)
(defvar css-ts-mode-map (copy-keymap css-mode-map)

View file

@ -24,11 +24,11 @@
;;; Tree-sitter language versions
;;
;; html-ts-mode is known to work with the following languages and version:
;; html-ts-mode has been tested with the following grammars and version:
;; - tree-sitter-html: v0.23.2-1-gd9219ad
;;
;; 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.
;; versions, so a more recent grammar has a good chance to work too.
;; Send us a bug report if it doesn't.
;;; Commentary:
@ -45,7 +45,8 @@
(add-to-list
'treesit-language-source-alist
'(html "https://github.com/tree-sitter/tree-sitter-html" "v0.23.2")
'(html "https://github.com/tree-sitter/tree-sitter-html"
:commit "d9219ada6e1a2c8f0ab0304a8bd9ca4285ae0468")
t)
(defcustom html-ts-mode-indent-offset 2

View file

@ -22,6 +22,16 @@
;; You should have received a copy of the GNU General Public License
;; along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>.
;;; Tree-sitter language versions
;;
;; markdown-ts-mode has been tested with the following grammars and version:
;; - tree-sitter-markdown: v0.4.1
;; - tree-sitter-markdown-inline: v0.4.1
;;
;; We try our best to make builtin modes work with latest grammar
;; versions, so a more recent grammar has a good chance to work too.
;; Send us a bug report if it doesn't.
;;; Commentary:
;;
@ -38,14 +48,16 @@
(add-to-list
'treesit-language-source-alist
'(markdown
"https://github.com/tree-sitter-grammars/tree-sitter-markdown" "v0.4.1"
"tree-sitter-markdown/src")
"https://github.com/tree-sitter-grammars/tree-sitter-markdown"
:commit "413285231ce8fa8b11e7074bbe265b48aa7277f9"
:source-dir "tree-sitter-markdown/src")
t)
(add-to-list
'treesit-language-source-alist
'(markdown-inline
"https://github.com/tree-sitter-grammars/tree-sitter-markdown" "v0.4.1"
"tree-sitter-markdown-inline/src")
"https://github.com/tree-sitter-grammars/tree-sitter-markdown"
:commit "413285231ce8fa8b11e7074bbe265b48aa7277f9"
:source-dir "tree-sitter-markdown-inline/src")
t)
;;; Helper functions

View file

@ -38,7 +38,8 @@
(add-to-list
'treesit-language-source-alist
'(toml "https://github.com/tree-sitter-grammars/tree-sitter-toml" "v0.7.0")
'(toml "https://github.com/tree-sitter-grammars/tree-sitter-toml"
:commit "64b56832c2cffe41758f28e05c756a3a98d16f41")
t)
(defcustom toml-ts-mode-indent-offset 2

View file

@ -37,7 +37,8 @@
(add-to-list
'treesit-language-source-alist
'(yaml "https://github.com/tree-sitter-grammars/tree-sitter-yaml" "v0.7.0")
'(yaml "https://github.com/tree-sitter-grammars/tree-sitter-yaml"
:commit "b733d3f5f5005890f324333dd57e1f0badec5c87")
t)
(defvar yaml-ts-mode--syntax-table

View file

@ -110,7 +110,7 @@ of `define-treesit-generic-mode'.
(_ (pop body))))
(when (stringp source)
(setq source (list 'quote (list source nil nil nil nil nil :copy-queries t))))
(setq source (list 'quote (list source :copy-queries t))))
(when (stringp auto-mode)
(setq auto-mode (list 'quote (ensure-list auto-mode))))
@ -203,7 +203,9 @@ of `define-treesit-generic-mode'.
(define-treesit-generic-mode gitattributes-generic-ts-mode
"Tree-sitter generic mode for .gitattributes files."
:lang 'gitattributes
:source "https://github.com/tree-sitter-grammars/tree-sitter-gitattributes"
:source '("https://github.com/tree-sitter-grammars/tree-sitter-gitattributes"
:commit "5425944fd61bf2b3bad2c17c2dc9f53172b0f01d"
:copy-queries t)
:auto-mode "gitattributes\\'"
:name "Git-Attributes"
(setq-local comment-start "# ")
@ -212,7 +214,9 @@ of `define-treesit-generic-mode'.
(define-treesit-generic-mode liquid-generic-ts-mode
"Tree-sitter generic mode for Liquid templates."
:lang 'liquid
:source "https://github.com/hankthetank27/tree-sitter-liquid"
:source '("https://github.com/hankthetank27/tree-sitter-liquid"
:commit "d6ebde3974742cd1b61b55d1d94aab1dacb41056"
:copy-queries t)
:auto-mode "\\.liquid\\'"
:name "Liquid"
:parent 'mhtml-ts-mode

View file

@ -4998,7 +4998,7 @@ window."
The value should be an alist where each element has the form
(LANG . (URL REVISION SOURCE-DIR CC C++ COMMIT [KEYWORD VALUE]...))
(LANG . (URL REVISION SOURCE-DIR CC C++ COMMIT))
Only LANG and URL are mandatory. LANG is the language symbol.
URL is the URL of the grammar's Git repository or a directory
@ -5015,8 +5015,17 @@ the grammar's parser.c file resides, defaulting to \"src\".
CC and C++ are C and C++ compilers, defaulting to \"cc\" and
\"c++\", respectively.
Another way to specify optional data is to use keywords:
(LANG . (URL [KEYWORD VALUE]...))
The currently supported keywords:
`:revision' is the same as REVISION above.
`:source-dir' is the same as SOURCE-DIR above.
`:cc' is the same as CC above.
`:c++' is the same as C++ above.
`:commit' is the same as COMMIT above.
`:copy-queries' when non-nil specifies whether to copy the files
in the \"queries\" directory from the source directory to the
installation directory.")
@ -5203,7 +5212,7 @@ clone if `treesit--install-language-grammar-blobless' is t."
(apply #'treesit--call-process-signal args)))
(defun treesit--install-language-grammar-1
(out-dir lang url &optional revision source-dir cc c++ commit &rest args)
(out-dir lang url &rest args)
"Compile and install a tree-sitter language grammar library.
OUT-DIR is the directory to put the compiled library file. If it
@ -5211,8 +5220,7 @@ is nil, the \"tree-sitter\" directory under user's Emacs
configuration directory is used (and automatically created if it
does not exist).
For LANG, URL, REVISION, SOURCE-DIR, GRAMMAR-DIR, CC, C++, COMMIT, see
`treesit-language-source-alist'.
For ARGS, see `treesit-language-source-alist'.
Return the git revision of the installed grammar. The revision is
generated by \"git describe\". It only works when
@ -5225,20 +5233,38 @@ If anything goes wrong, this function signals an `treesit-error'."
(workdir (if url-is-dir
maybe-repo-dir
(expand-file-name "repo")))
copy-queries version)
version
revision source-dir cc c++ commit copy-queries)
;; Process the keyword args.
(while (keywordp (car args))
(pcase (pop args)
(:copy-queries (setq copy-queries (pop args)))
(_ (pop args))))
(:revision (setq revision (pop args)))
(:source-dir (setq source-dir (pop args)))
(:cc (setq cc (pop args)))
(:c++ (setq c++ (pop args)))
(:commit (setq commit (pop args)))
(:copy-queries (setq copy-queries (pop args)))))
;; Old positional convention for backward-compatibility.
(unless revision (setq revision (nth 0 args)))
(unless source-dir (setq source-dir (nth 1 args)))
(unless cc (setq cc (nth 2 args)))
(unless c++ (setq c++ (nth 3 args)))
(unless commit (setq commit (nth 4 args)))
(unwind-protect
(with-temp-buffer
(if url-is-dir
(when revision
(treesit--git-checkout-branch workdir revision))
(if commit
;; Force blobless full clone to be able later
;; to checkout a commit (bug#78542).
(let ((treesit--install-language-grammar-full-clone t)
(treesit--install-language-grammar-blobless t))
(treesit--git-clone-repo url revision workdir))
(treesit--git-clone-repo url revision workdir)))
(when commit
(treesit--git-checkout-branch workdir commit))
(setq version (treesit--language-git-revision workdir))