From 6ff5026e0b0178a2655fe1c9c2350122cc30e553 Mon Sep 17 00:00:00 2001 From: Juri Linkov Date: Fri, 20 Jun 2025 19:56:01 +0300 Subject: [PATCH] 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. (cherry picked from commit 1a76b527ac35de179530249f5defc6646c96129e) --- admin/tree-sitter/treesit-admin.el | 42 +++++++++++++++++++++++----- lisp/progmodes/c-ts-mode.el | 15 ++++++---- lisp/progmodes/cmake-ts-mode.el | 7 +++-- lisp/progmodes/csharp-mode.el | 3 +- lisp/progmodes/dockerfile-ts-mode.el | 7 +++-- lisp/progmodes/elixir-ts-mode.el | 12 ++++---- lisp/progmodes/go-ts-mode.el | 13 +++++---- lisp/progmodes/heex-ts-mode.el | 11 +++++--- lisp/progmodes/java-ts-mode.el | 10 ++++--- lisp/progmodes/js.el | 10 ++++--- lisp/progmodes/json-ts-mode.el | 7 +++-- lisp/progmodes/lua-ts-mode.el | 3 +- lisp/progmodes/php-ts-mode.el | 13 +++++---- lisp/progmodes/python.el | 3 +- lisp/progmodes/ruby-ts-mode.el | 7 +++-- lisp/progmodes/rust-ts-mode.el | 12 ++++---- lisp/progmodes/sh-script.el | 3 +- lisp/progmodes/typescript-ts-mode.el | 17 +++++++---- lisp/textmodes/css-mode.el | 7 +++-- lisp/textmodes/html-ts-mode.el | 7 +++-- lisp/textmodes/markdown-ts-mode.el | 20 ++++++++++--- lisp/textmodes/toml-ts-mode.el | 3 +- lisp/textmodes/yaml-ts-mode.el | 3 +- lisp/treesit-x.el | 10 +++++-- lisp/treesit.el | 42 ++++++++++++++++++++++------ 25 files changed, 197 insertions(+), 90 deletions(-) diff --git a/admin/tree-sitter/treesit-admin.el b/admin/tree-sitter/treesit-admin.el index 1bb8b927e5c..8d9b9d7ec9a 100644 --- a/admin/tree-sitter/treesit-admin.el +++ b/admin/tree-sitter/treesit-admin.el @@ -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) - (let ((unversioned-source (copy-sequence source))) - (setcar (nthcdr 2 unversioned-source) nil) - unversioned-source) - 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)) + (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 diff --git a/lisp/progmodes/c-ts-mode.el b/lisp/progmodes/c-ts-mode.el index f63b71f89a3..7b40b4c73d3 100644 --- a/lisp/progmodes/c-ts-mode.el +++ b/lisp/progmodes/c-ts-mode.el @@ -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 diff --git a/lisp/progmodes/cmake-ts-mode.el b/lisp/progmodes/cmake-ts-mode.el index d5008fcc102..2f2d1b6e2a0 100644 --- a/lisp/progmodes/cmake-ts-mode.el +++ b/lisp/progmodes/cmake-ts-mode.el @@ -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 diff --git a/lisp/progmodes/csharp-mode.el b/lisp/progmodes/csharp-mode.el index bec94eed35c..958ccf05672 100644 --- a/lisp/progmodes/csharp-mode.el +++ b/lisp/progmodes/csharp-mode.el @@ -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 diff --git a/lisp/progmodes/dockerfile-ts-mode.el b/lisp/progmodes/dockerfile-ts-mode.el index 5dcc5704c34..fe0c9e23acc 100644 --- a/lisp/progmodes/dockerfile-ts-mode.el +++ b/lisp/progmodes/dockerfile-ts-mode.el @@ -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 diff --git a/lisp/progmodes/elixir-ts-mode.el b/lisp/progmodes/elixir-ts-mode.el index d1a78ca1018..8b43c032424 100644 --- a/lisp/progmodes/elixir-ts-mode.el +++ b/lisp/progmodes/elixir-ts-mode.el @@ -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 diff --git a/lisp/progmodes/go-ts-mode.el b/lisp/progmodes/go-ts-mode.el index 79ad8a2fafd..db609b92767 100644 --- a/lisp/progmodes/go-ts-mode.el +++ b/lisp/progmodes/go-ts-mode.el @@ -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 diff --git a/lisp/progmodes/heex-ts-mode.el b/lisp/progmodes/heex-ts-mode.el index 08c9019e6bc..c478750a73e 100644 --- a/lisp/progmodes/heex-ts-mode.el +++ b/lisp/progmodes/heex-ts-mode.el @@ -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 diff --git a/lisp/progmodes/java-ts-mode.el b/lisp/progmodes/java-ts-mode.el index 96ef6447f9b..10692387b9d 100644 --- a/lisp/progmodes/java-ts-mode.el +++ b/lisp/progmodes/java-ts-mode.el @@ -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: @@ -53,11 +53,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 diff --git a/lisp/progmodes/js.el b/lisp/progmodes/js.el index cc09c92f49b..ec7c2602d33 100644 --- a/lisp/progmodes/js.el +++ b/lisp/progmodes/js.el @@ -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 () diff --git a/lisp/progmodes/json-ts-mode.el b/lisp/progmodes/json-ts-mode.el index 11ec5d5c079..a18f3c342c0 100644 --- a/lisp/progmodes/json-ts-mode.el +++ b/lisp/progmodes/json-ts-mode.el @@ -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 diff --git a/lisp/progmodes/lua-ts-mode.el b/lisp/progmodes/lua-ts-mode.el index 4bc619d8fbf..b8bcf076e33 100644 --- a/lisp/progmodes/lua-ts-mode.el +++ b/lisp/progmodes/lua-ts-mode.el @@ -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 diff --git a/lisp/progmodes/php-ts-mode.el b/lisp/progmodes/php-ts-mode.el index 46217473fe6..567f0bdce74 100644 --- a/lisp/progmodes/php-ts-mode.el +++ b/lisp/progmodes/php-ts-mode.el @@ -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.") diff --git a/lisp/progmodes/python.el b/lisp/progmodes/python.el index e6252de4420..664c00243a9 100644 --- a/lisp/progmodes/python.el +++ b/lisp/progmodes/python.el @@ -267,7 +267,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 diff --git a/lisp/progmodes/ruby-ts-mode.el b/lisp/progmodes/ruby-ts-mode.el index 30882f055d3..c235977084f 100644 --- a/lisp/progmodes/ruby-ts-mode.el +++ b/lisp/progmodes/ruby-ts-mode.el @@ -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 diff --git a/lisp/progmodes/rust-ts-mode.el b/lisp/progmodes/rust-ts-mode.el index 5ae4921287e..6090fcb9c68 100644 --- a/lisp/progmodes/rust-ts-mode.el +++ b/lisp/progmodes/rust-ts-mode.el @@ -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 diff --git a/lisp/progmodes/sh-script.el b/lisp/progmodes/sh-script.el index 6a4da659d45..589e4c80d2b 100644 --- a/lisp/progmodes/sh-script.el +++ b/lisp/progmodes/sh-script.el @@ -3284,7 +3284,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 diff --git a/lisp/progmodes/typescript-ts-mode.el b/lisp/progmodes/typescript-ts-mode.el index 6aa64706d3c..1a2ef2e237f 100644 --- a/lisp/progmodes/typescript-ts-mode.el +++ b/lisp/progmodes/typescript-ts-mode.el @@ -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 diff --git a/lisp/textmodes/css-mode.el b/lisp/textmodes/css-mode.el index fec92d07adc..d0c03a606a7 100644 --- a/lisp/textmodes/css-mode.el +++ b/lisp/textmodes/css-mode.el @@ -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) diff --git a/lisp/textmodes/html-ts-mode.el b/lisp/textmodes/html-ts-mode.el index 15d419b1a37..1bf89ee8f4e 100644 --- a/lisp/textmodes/html-ts-mode.el +++ b/lisp/textmodes/html-ts-mode.el @@ -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 diff --git a/lisp/textmodes/markdown-ts-mode.el b/lisp/textmodes/markdown-ts-mode.el index c7a32d07a89..3398ba7bf5c 100644 --- a/lisp/textmodes/markdown-ts-mode.el +++ b/lisp/textmodes/markdown-ts-mode.el @@ -22,6 +22,16 @@ ;; You should have received a copy of the GNU General Public License ;; along with GNU Emacs. If not, see . +;;; 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 diff --git a/lisp/textmodes/toml-ts-mode.el b/lisp/textmodes/toml-ts-mode.el index 854ff93fd6b..c1c5dea2bd9 100644 --- a/lisp/textmodes/toml-ts-mode.el +++ b/lisp/textmodes/toml-ts-mode.el @@ -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 diff --git a/lisp/textmodes/yaml-ts-mode.el b/lisp/textmodes/yaml-ts-mode.el index 6bd1bd946ae..58ed06de886 100644 --- a/lisp/textmodes/yaml-ts-mode.el +++ b/lisp/textmodes/yaml-ts-mode.el @@ -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 diff --git a/lisp/treesit-x.el b/lisp/treesit-x.el index d13d6b1a35a..65845ed0ac0 100644 --- a/lisp/treesit-x.el +++ b/lisp/treesit-x.el @@ -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 diff --git a/lisp/treesit.el b/lisp/treesit.el index 14979f07887..a9da0fa3a36 100644 --- a/lisp/treesit.el +++ b/lisp/treesit.el @@ -4991,7 +4991,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 @@ -5008,8 +5008,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.") @@ -5194,7 +5203,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 @@ -5202,8 +5211,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 @@ -5216,20 +5224,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)) - (treesit--git-clone-repo url revision workdir)) + (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)) -- 2.39.5