Lock tree-sitter language grammars to verified versions.

* admin/notes/tree-sitter/build-module/build.sh:
Update org for toml/yaml.

* admin/tree-sitter/treesit-admin.el
(treesit-admin--builtin-language-sources):
Add verified versions.

* lisp/progmodes/c-ts-mode.el:
Append language source to treesit-language-source-alist.
(c-ts-mode, c++-ts-mode): Use treesit-ensure-installed.

* lisp/progmodes/cmake-ts-mode.el:
Append language source to treesit-language-source-alist.
(cmake-ts-mode): Use treesit-ensure-installed.

* lisp/progmodes/csharp-mode.el:
Append language source to treesit-language-source-alist.
(csharp-ts-mode): Use treesit-ensure-installed.

* lisp/progmodes/dockerfile-ts-mode.el:
Append language source to treesit-language-source-alist.
(dockerfile-ts-mode): Use treesit-ensure-installed.

* lisp/progmodes/elixir-ts-mode.el:
Append language source to treesit-language-source-alist.
(elixir-ts-mode): Use treesit-ensure-installed.

* lisp/progmodes/go-ts-mode.el:
Append language source to treesit-language-source-alist.
(go-ts-mode, go-mod-ts-mode, go-work-ts-mode):
Use treesit-ensure-installed.

* lisp/progmodes/heex-ts-mode.el:
Append language source to treesit-language-source-alist.
(heex-ts-mode): Use treesit-ensure-installed.

* lisp/progmodes/java-ts-mode.el:
Append language source to treesit-language-source-alist.
(java-ts-mode): Use treesit-ensure-installed.

* lisp/progmodes/js.el:
Append language source to treesit-language-source-alist.
(js-ts-mode): Use treesit-ensure-installed.

* lisp/progmodes/json-ts-mode.el:
Append language source to treesit-language-source-alist.
(json-ts-mode): Use treesit-ensure-installed.

* lisp/progmodes/lua-ts-mode.el:
Append language source to treesit-language-source-alist.
(lua-ts-mode): Use treesit-ensure-installed.

* lisp/progmodes/php-ts-mode.el
(php-ts-mode--language-source-alist):
Update versions from comments in ts-modes.
Append to treesit-language-source-alist.
(php-ts-mode-install-parsers):
Use treesit-language-source-alist directly.
(php-ts-mode): Use treesit-ensure-installed.

* lisp/progmodes/ruby-ts-mode.el:
Append language source to treesit-language-source-alist.
(ruby-ts-mode): Use treesit-ensure-installed.

* lisp/progmodes/rust-ts-mode.el:
Append language source to treesit-language-source-alist.
(rust-ts-mode): Use treesit-ensure-installed.

* lisp/progmodes/sh-script.el:
Append language source to treesit-language-source-alist.
(bash-ts-mode): Use treesit-ensure-installed.

* lisp/progmodes/typescript-ts-mode.el:
Append language source to treesit-language-source-alist.
(typescript-ts-mode, tsx-ts-mode): Use treesit-ensure-installed.

* lisp/textmodes/css-mode.el:
Append language source to treesit-language-source-alist.
(css-ts-mode): Use treesit-ensure-installed.

* lisp/textmodes/html-ts-mode.el:
Append language source to treesit-language-source-alist.
(html-ts-mode): Use treesit-ensure-installed.

* lisp/textmodes/markdown-ts-mode.el:
Append language source to treesit-language-source-alist.
(markdown-ts-mode): Use treesit-ensure-installed.

* lisp/textmodes/mhtml-ts-mode.el
(mhtml-ts-mode--language-source-alist):
Append to treesit-language-source-alist.
(mhtml-ts-mode-install-parsers):
Use treesit-language-source-alist directly.
(mhtml-ts-mode): Use treesit-ensure-installed.

* lisp/textmodes/toml-ts-mode.el:
Append language source to treesit-language-source-alist.
(toml-ts-mode): Use treesit-ensure-installed.

* lisp/textmodes/yaml-ts-mode.el:
Append language source to treesit-language-source-alist.
(yaml-ts-mode): Use treesit-ensure-installed.

* test/infra/Dockerfile.emba: Add verified versions
to treesit-language-source-alist.
This commit is contained in:
Juri Linkov 2025-04-18 19:22:50 +03:00
parent c9b6be7d27
commit 3d3be6dd0e
25 changed files with 267 additions and 108 deletions

View file

@ -59,8 +59,11 @@ case "${lang}" in
sourcedir="tree-sitter-typescript/tsx/src"
grammardir="tree-sitter-typescript/tsx"
;;
"toml")
org="tree-sitter-grammars"
;;
"yaml")
org="ikatyang"
org="tree-sitter-grammars"
;;
esac

View file

@ -72,31 +72,33 @@
;;; Query validation
(defvar treesit-admin--builtin-language-sources
'((c "https://github.com/tree-sitter/tree-sitter-c")
(cpp "https://github.com/tree-sitter/tree-sitter-cpp")
(cmake "https://github.com/uyha/tree-sitter-cmake")
(dockerfile "https://github.com/camdencheek/tree-sitter-dockerfile")
(go "https://github.com/tree-sitter/tree-sitter-go")
(ruby "https://github.com/tree-sitter/tree-sitter-ruby")
(javascript "https://github.com/tree-sitter/tree-sitter-javascript")
'((c "https://github.com/tree-sitter/tree-sitter-c" "v0.23.4")
(cpp "https://github.com/tree-sitter/tree-sitter-cpp" "v0.23.4")
(cmake "https://github.com/uyha/tree-sitter-cmake" "v0.5.0")
(dockerfile "https://github.com/camdencheek/tree-sitter-dockerfile" "v0.2.0")
(go "https://github.com/tree-sitter/tree-sitter-go" "v0.23.4")
(ruby "https://github.com/tree-sitter/tree-sitter-ruby" "v0.23.1")
(javascript "https://github.com/tree-sitter/tree-sitter-javascript" "v0.23.1")
(typescript "https://github.com/tree-sitter/tree-sitter-typescript"
nil "typescript/src")
"v0.23.2" "typescript/src")
(tsx "https://github.com/tree-sitter/tree-sitter-typescript"
nil "tsx/src")
(json "https://github.com/tree-sitter/tree-sitter-json")
(rust "https://github.com/tree-sitter/tree-sitter-rust")
"v0.23.2" "tsx/src")
(json "https://github.com/tree-sitter/tree-sitter-json" "v0.24.8")
(rust "https://github.com/tree-sitter/tree-sitter-rust" "v0.23.2")
(php "https://github.com/tree-sitter/tree-sitter-php"
nil "php/src")
(css "https://github.com/tree-sitter/tree-sitter-css")
"v0.23.11" "php/src")
(css "https://github.com/tree-sitter/tree-sitter-css" "v0.23.1")
(phpdoc "https://github.com/claytonrcarter/tree-sitter-phpdoc")
(doxygen "https://github.com/tree-sitter-grammars/tree-sitter-doxygen")
(lua "https://github.com/tree-sitter-grammars/tree-sitter-lua")
(python "https://github.com/tree-sitter/tree-sitter-python")
(html "https://github.com/tree-sitter/tree-sitter-html")
(elixir "https://github.com/elixir-lang/tree-sitter-elixir")
(heex "https://github.com/phoenixframework/tree-sitter-heex")
(java "https://github.com/tree-sitter/tree-sitter-java")
(jsdoc "https://github.com/tree-sitter/tree-sitter-jsdoc"))
(doxygen "https://github.com/tree-sitter-grammars/tree-sitter-doxygen" "v1.1.0")
(lua "https://github.com/tree-sitter-grammars/tree-sitter-lua" "v0.3.0")
(python "https://github.com/tree-sitter/tree-sitter-python" "v0.23.6")
(html "https://github.com/tree-sitter/tree-sitter-html" "v0.23.2")
(elixir "https://github.com/elixir-lang/tree-sitter-elixir" "v0.3.3")
(heex "https://github.com/phoenixframework/tree-sitter-heex" "v0.7.0")
(java "https://github.com/tree-sitter/tree-sitter-java" "v0.23.5")
(jsdoc "https://github.com/tree-sitter/tree-sitter-jsdoc" "v0.23.2")
(toml "https://github.com/tree-sitter-grammars/tree-sitter-toml" "v0.7.0")
(yaml "https://github.com/tree-sitter-grammars/tree-sitter-yaml" "v0.7.0"))
"A list of sources for the builtin modes.
The source information are in the format of
`treesit-language-source-alist'. This is for development only.")

View file

@ -86,6 +86,19 @@
(eval-when-compile (require 'rx))
(treesit-declare-unavailable-functions)
(add-to-list
'treesit-language-source-alist
'(c "https://github.com/tree-sitter/tree-sitter-c" "v0.23.4")
t)
(add-to-list
'treesit-language-source-alist
'(cpp "https://github.com/tree-sitter/tree-sitter-cpp" "v0.23.4")
t)
(add-to-list
'treesit-language-source-alist
'(doxygen "https://github.com/tree-sitter-grammars/tree-sitter-doxygen" "v1.1.0")
t)
;;; Custom variables
(defcustom c-ts-mode-indent-offset 2
@ -1460,7 +1473,7 @@ in your init files."
:group 'c
:after-hook (c-ts-mode-set-modeline)
(when (treesit-ready-p 'c)
(when (treesit-ensure-installed 'c)
;; Create an "for-each" parser, see `c-ts-mode--emacs-set-ranges'
;; for more.
(when c-ts-mode-emacs-sources-support
@ -1495,7 +1508,8 @@ in your init files."
(treesit-font-lock-recompute-features '(emacs-devel)))
;; Inject doxygen parser for comment.
(when (and c-ts-mode-enable-doxygen (treesit-ready-p 'doxygen t))
(when (and c-ts-mode-enable-doxygen
(treesit-ensure-installed 'doxygen))
(setq-local treesit-primary-parser primary-parser)
(setq-local treesit-font-lock-settings
(append
@ -1535,7 +1549,7 @@ recommended to enable `electric-pair-mode' with this mode."
:group 'c++
:after-hook (c-ts-mode-set-modeline)
(when (treesit-ready-p 'cpp)
(when (treesit-ensure-installed 'cpp)
(let ((primary-parser (treesit-parser-create 'cpp)))
;; Syntax.
@ -1557,7 +1571,8 @@ recommended to enable `electric-pair-mode' with this mode."
#'c-ts-mode--emacs-current-defun-name))
;; Inject doxygen parser for comment.
(when (and c-ts-mode-enable-doxygen (treesit-ready-p 'doxygen t))
(when (and c-ts-mode-enable-doxygen
(treesit-ensure-installed 'doxygen))
(setq-local treesit-primary-parser primary-parser)
(setq-local treesit-font-lock-settings
(append
@ -1670,9 +1685,6 @@ the code is C or C++, and based on that chooses whether to enable
(assq-delete-all 'c-or-c++-mode major-mode-remap-defaults))
(add-to-list 'major-mode-remap-defaults '(c-or-c++-mode . c-or-c++-ts-mode)))
(when (and c-ts-mode-enable-doxygen (not (treesit-ready-p 'doxygen t)))
(message "Doxygen syntax highlighting can't be enabled, please install the language grammar."))
(provide 'c-ts-mode)
(provide 'c++-ts-mode)

View file

@ -40,6 +40,11 @@
(eval-when-compile (require 'rx))
(treesit-declare-unavailable-functions)
(add-to-list
'treesit-language-source-alist
'(cmake "https://github.com/uyha/tree-sitter-cmake" "v0.5.0")
t)
(defcustom cmake-ts-mode-indent-offset 2
"Number of spaces for each indentation step in `cmake-ts-mode'."
:version "29.1"
@ -212,7 +217,7 @@ Return nil if there is no name or if NODE is not a defun node."
:group 'cmake
:syntax-table cmake-ts-mode--syntax-table
(when (treesit-ready-p 'cmake)
(when (treesit-ensure-installed 'cmake)
(setq treesit-primary-parser (treesit-parser-create 'cmake))
;; Comments.

View file

@ -649,6 +649,11 @@ compilation and evaluation time conflicts."
;;; Tree-sitter support
(add-to-list
'treesit-language-source-alist
'(c-sharp "https://github.com/tree-sitter/tree-sitter-c-sharp" "v0.23.1")
t)
(defcustom csharp-ts-mode-indent-offset 4
"Number of spaces for each indentation step in `csharp-ts-mode'."
:type 'integer
@ -1056,7 +1061,7 @@ Key bindings:
"Major mode for editing C# code."
:syntax-table (csharp--make-mode-syntax-table)
(unless (treesit-ready-p 'c-sharp)
(unless (treesit-ensure-installed 'c-sharp)
(error "Tree-sitter for C# isn't available"))
;; Tree-sitter.

View file

@ -40,6 +40,11 @@
(eval-when-compile (require 'rx))
(treesit-declare-unavailable-functions)
(add-to-list
'treesit-language-source-alist
'(dockerfile "https://github.com/camdencheek/tree-sitter-dockerfile" "v0.2.0")
t)
(defvar dockerfile-ts-mode--syntax-table
(let ((table (make-syntax-table)))
(modify-syntax-entry ?# "<" table)
@ -161,7 +166,7 @@ Return nil if there is no name or if NODE is not a stage node."
:group 'dockerfile
:syntax-table dockerfile-ts-mode--syntax-table
(when (treesit-ready-p 'dockerfile)
(when (treesit-ensure-installed 'dockerfile)
(setq treesit-primary-parser (treesit-parser-create 'dockerfile))
;; Comments.

View file

@ -57,6 +57,15 @@
(eval-when-compile (require 'rx))
(treesit-declare-unavailable-functions)
(add-to-list
'treesit-language-source-alist
'(elixir "https://github.com/elixir-lang/tree-sitter-elixir" "v0.3.3")
t)
(add-to-list
'treesit-language-source-alist
'(heex "https://github.com/phoenixframework/tree-sitter-heex" "v0.7.0")
t)
(defgroup elixir-ts nil
"Major mode for editing Elixir code."
:prefix "elixir-ts-"
@ -667,11 +676,11 @@ Return nil if NODE is not a defun node or doesn't have a name."
(add-hook 'post-self-insert-hook
#'elixir-ts--electric-pair-string-delimiter 'append t)
(when (treesit-ready-p 'elixir)
(when (treesit-ensure-installed 'elixir)
;; The HEEx parser has to be created first for elixir to ensure elixir
;; is the first language when looking for treesit ranges.
;; (In Emacs 31 this requirement is removed.)
(when (treesit-ready-p 'heex)
(when (treesit-ensure-installed 'heex)
;; Require heex-ts-mode only when we load elixir-ts-mode
;; so that we don't get a tree-sitter compilation warning for
;; elixir-ts-mode.
@ -737,7 +746,7 @@ Return nil if NODE is not a defun node or doesn't have a name."
(setq-local treesit-defun-name-function #'elixir-ts--defun-name)
;; Embedded Heex.
(when (treesit-ready-p 'heex)
(when (treesit-ensure-installed 'heex)
(setq-local treesit-range-settings elixir-ts--treesit-range-rules)
(setq-local treesit-font-lock-settings

View file

@ -46,6 +46,19 @@
(eval-when-compile (require 'rx))
(treesit-declare-unavailable-functions)
(add-to-list
'treesit-language-source-alist
'(go "https://github.com/tree-sitter/tree-sitter-go" "v0.23.4")
t)
(add-to-list
'treesit-language-source-alist
'(gomod "https://github.com/camdencheek/tree-sitter-go-mod" "v1.1.0")
t)
(add-to-list
'treesit-language-source-alist
'(gowork "https://github.com/omertuc/tree-sitter-go-work")
t)
(defcustom go-ts-mode-indent-offset 8
"Number of spaces for each indentation step in `go-ts-mode'."
:version "29.1"
@ -277,7 +290,7 @@
:group 'go
:syntax-table go-ts-mode--syntax-table
(when (treesit-ready-p 'go)
(when (treesit-ensure-installed 'go)
(setq treesit-primary-parser (treesit-parser-create 'go))
;; Comments.
@ -584,7 +597,7 @@ what the parent of the node would be if it were a node."
:group 'go
:syntax-table go-mod-ts-mode--syntax-table
(when (treesit-ready-p 'gomod)
(when (treesit-ensure-installed 'gomod)
(setq treesit-primary-parser (treesit-parser-create 'gomod))
;; Comments.
@ -672,7 +685,7 @@ what the parent of the node would be if it were a node."
"Major mode for editing go.work files, powered by tree-sitter."
:group 'go
(when (treesit-ready-p 'gowork)
(when (treesit-ensure-installed 'gowork)
(setq treesit-primary-parser (treesit-parser-create 'gowork))
;; Comments.

View file

@ -44,6 +44,15 @@
(eval-when-compile (require 'rx))
(treesit-declare-unavailable-functions)
(add-to-list
'treesit-language-source-alist
'(heex "https://github.com/phoenixframework/tree-sitter-heex" "v0.7.0")
t)
(add-to-list
'treesit-language-source-alist
'(elixir "https://github.com/elixir-lang/tree-sitter-elixir" "v0.3.3")
t)
(defgroup heex-ts nil
"Major mode for editing HEEx code."
:prefix "heex-ts-"
@ -162,7 +171,7 @@ Return nil if NODE is not a defun node or doesn't have a name."
"Major mode for editing HEEx, powered by tree-sitter."
:group 'heex-ts
(when (treesit-ready-p 'heex)
(when (treesit-ensure-installed 'heex)
(setq treesit-primary-parser (treesit-parser-create 'heex))
;; Comments

View file

@ -43,6 +43,15 @@
(require 'c-ts-common) ; For comment indent and filling.
(treesit-declare-unavailable-functions)
(add-to-list
'treesit-language-source-alist
'(java "https://github.com/tree-sitter/tree-sitter-java" "v0.23.5")
t)
(add-to-list
'treesit-language-source-alist
'(doxygen "https://github.com/tree-sitter-grammars/tree-sitter-doxygen" "v1.1.0")
t)
(defcustom java-ts-mode-indent-offset 4
"Number of spaces for each indentation step in `java-ts-mode'."
:version "29.1"
@ -385,7 +394,7 @@ Return nil if there is no name or if NODE is not a defun node."
:group 'java
:syntax-table java-ts-mode--syntax-table
(unless (treesit-ready-p 'java)
(unless (treesit-ensure-installed 'java)
(error "Tree-sitter for Java isn't available"))
(let ((primary-parser (treesit-parser-create 'java)))
@ -480,7 +489,8 @@ Return nil if there is no name or if NODE is not a defun node."
java-ts-mode--font-lock-settings)
;; Inject doxygen parser for comment.
(when (and java-ts-mode-enable-doxygen (treesit-ready-p 'doxygen t))
(when (and java-ts-mode-enable-doxygen
(treesit-ensure-installed 'doxygen))
(setq-local treesit-primary-parser primary-parser)
(setq-local treesit-font-lock-settings
(append treesit-font-lock-settings
@ -515,9 +525,6 @@ Return nil if there is no name or if NODE is not a defun node."
(if (treesit-ready-p 'java)
(add-to-list 'auto-mode-alist '("\\.java\\'" . java-ts-mode)))
(when (and java-ts-mode-enable-doxygen (not (treesit-ready-p 'doxygen t)))
(message "Doxygen syntax highlighting can't be enabled, please install the language grammar."))
(provide 'java-ts-mode)
;;; java-ts-mode.el ends here

View file

@ -3408,6 +3408,15 @@ This function is intended for use in `after-change-functions'."
;;; Tree sitter integration
(add-to-list
'treesit-language-source-alist
'(javascript "https://github.com/tree-sitter/tree-sitter-javascript" "v0.23.1")
t)
(add-to-list
'treesit-language-source-alist
'(jsdoc "https://github.com/tree-sitter/tree-sitter-jsdoc" "v0.23.2")
t)
(defun js--treesit-font-lock-compatibility-definition-feature ()
"Font lock helper, to handle different releases of tree-sitter-javascript.
Check if a node type is available, then return the right font lock rules
@ -3973,7 +3982,7 @@ See `treesit-thing-settings' for more information.")
\\<js-ts-mode-map>"
:group 'js
:syntax-table js-mode-syntax-table
(when (treesit-ready-p 'javascript)
(when (treesit-ensure-installed 'javascript)
;; Borrowed from `js-mode'.
(setq-local prettify-symbols-alist js--prettify-symbols-alist)
(setq-local parse-sexp-ignore-comments t)
@ -4004,7 +4013,7 @@ See `treesit-thing-settings' for more information.")
(setq-local treesit-font-lock-settings js--treesit-font-lock-settings)
(setq-local treesit-font-lock-feature-list js--treesit-font-lock-feature-list)
(when (treesit-ready-p 'jsdoc t)
(when (treesit-ensure-installed 'jsdoc)
(setq-local treesit-range-settings
(treesit-range-rules
:embed 'jsdoc

View file

@ -40,6 +40,11 @@
(require 'rx)
(treesit-declare-unavailable-functions)
(add-to-list
'treesit-language-source-alist
'(json "https://github.com/tree-sitter/tree-sitter-json" "v0.24.8")
t)
(defcustom json-ts-mode-indent-offset 2
"Number of spaces for each indentation step in `json-ts-mode'."
:version "29.1"
@ -128,7 +133,7 @@ Return nil if there is no name or if NODE is not a defun node."
:group 'json
:syntax-table json-ts-mode--syntax-table
(unless (treesit-ready-p 'json)
(unless (treesit-ensure-installed 'json)
(error "Tree-sitter for JSON isn't available"))
(setq treesit-primary-parser (treesit-parser-create 'json))

View file

@ -48,6 +48,11 @@
(eval-when-compile
(require 'rx))
(add-to-list
'treesit-language-source-alist
'(lua "https://github.com/tree-sitter-grammars/tree-sitter-lua" "v0.3.0")
t)
(defgroup lua-ts nil
"Major mode for editing Lua files."
:prefix "lua-ts-"
@ -661,7 +666,7 @@ Calls REPORT-FN directly."
:syntax-table lua-ts--syntax-table
(use-local-map lua-ts-mode-map)
(when (treesit-ready-p 'lua)
(when (treesit-ensure-installed 'lua)
(setq treesit-primary-parser (treesit-parser-create 'lua))
;; Comments.

View file

@ -81,23 +81,26 @@
;;; 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"))
(html . ("https://github.com/tree-sitter/tree-sitter-html" "v0.23.0"))
(javascript . ("https://github.com/tree-sitter/tree-sitter-javascript" "v0.23.0"))
(jsdoc . ("https://github.com/tree-sitter/tree-sitter-jsdoc" "v0.23.0"))
(css . ("https://github.com/tree-sitter/tree-sitter-css" "v0.23.0")))
'((php "https://github.com/tree-sitter/tree-sitter-php" "v0.23.11" "php/src")
(phpdoc "https://github.com/claytonrcarter/tree-sitter-phpdoc")
(html "https://github.com/tree-sitter/tree-sitter-html" "v0.23.2")
(javascript "https://github.com/tree-sitter/tree-sitter-javascript" "v0.23.1")
(jsdoc "https://github.com/tree-sitter/tree-sitter-jsdoc" "v0.23.2")
(css "https://github.com/tree-sitter/tree-sitter-css" "v0.23.1"))
"Treesitter language parsers required by `php-ts-mode'.
You can customize this variable if you want to stick to a specific
commit and/or use different parsers.")
You can customize `treesit-language-source-alist' if you want
to stick to a specific commit and/or use different parsers.")
(setq treesit-language-source-alist
(append treesit-language-source-alist
php-ts-mode--language-source-alist))
(defun php-ts-mode-install-parsers ()
"Install all the required treesitter parsers.
`php-ts-mode--language-source-alist' defines which parsers to install."
(interactive)
(let ((treesit-language-source-alist php-ts-mode--language-source-alist))
(dolist (item php-ts-mode--language-source-alist)
(treesit-install-language-grammar (car item)))))
(dolist (item php-ts-mode--language-source-alist)
(treesit-install-language-grammar (car item))))
;;; Custom variables
@ -1384,12 +1387,12 @@ Depends on `c-ts-common-comment-setup'."
:syntax-table php-ts-mode--syntax-table
(if (not (and
(treesit-ready-p 'php)
(treesit-ready-p 'phpdoc)
(treesit-ready-p 'html)
(treesit-ready-p 'javascript)
(treesit-ready-p 'jsdoc)
(treesit-ready-p 'css)))
(treesit-ensure-installed 'php)
(treesit-ensure-installed 'phpdoc)
(treesit-ensure-installed 'html)
(treesit-ensure-installed 'javascript)
(treesit-ensure-installed 'jsdoc)
(treesit-ensure-installed 'css)))
(error "Tree-sitter for PHP isn't
available. You can install the parsers with M-x
`php-ts-mode-install-parsers'")

View file

@ -123,6 +123,11 @@
(require 'ruby-mode)
(treesit-declare-unavailable-functions)
(add-to-list
'treesit-language-source-alist
'(ruby "https://github.com/tree-sitter/tree-sitter-ruby" "v0.23.1")
t)
(defgroup ruby-ts nil
"Major mode for editing Ruby code."
:prefix "ruby-ts-"
@ -1155,7 +1160,7 @@ leading double colon is not added."
:group 'ruby
:syntax-table ruby-mode-syntax-table
(unless (treesit-ready-p 'ruby)
(unless (treesit-ensure-installed 'ruby)
(error "Tree-sitter for Ruby isn't available"))
(setq treesit-primary-parser (treesit-parser-create 'ruby))

View file

@ -41,6 +41,11 @@
(require 'c-ts-common) ; For comment indent and filling.
(treesit-declare-unavailable-functions)
(add-to-list
'treesit-language-source-alist
'(rust "https://github.com/tree-sitter/tree-sitter-rust" "v0.23.2")
t)
(defcustom rust-ts-mode-indent-offset 4
"Number of spaces for each indentation step in `rust-ts-mode'."
:version "29.1"
@ -545,7 +550,7 @@ See `prettify-symbols-compose-predicate'."
:group 'rust
:syntax-table rust-ts-mode--syntax-table
(when (treesit-ready-p 'rust)
(when (treesit-ensure-installed 'rust)
(setq treesit-primary-parser (treesit-parser-create 'rust))
;; Syntax.

View file

@ -1630,7 +1630,7 @@ with your script for an edit-interpret-debug cycle."
This mode automatically falls back to `sh-mode' if the buffer is
not written in Bash or sh."
:syntax-table sh-mode-syntax-table
(when (treesit-ready-p 'bash)
(when (treesit-ensure-installed 'bash)
(sh-set-shell "bash" nil nil)
(add-hook 'flymake-diagnostic-functions #'sh-shellcheck-flymake nil t)
(add-hook 'hack-local-variables-hook
@ -3312,6 +3312,11 @@ member of `flymake-diagnostic-functions'."
;;; Tree-sitter font-lock
(add-to-list
'treesit-language-source-alist
'(bash "https://github.com/tree-sitter/tree-sitter-bash" "v0.23.3")
t)
(defvar sh-mode--treesit-operators
'("|" "|&" "||" "&&" ">" ">>" "<" "<<" "<<-" "<<<" "==" "!=" ";&" ";;&")
"A list of `sh-mode' operators to fontify.")

View file

@ -42,6 +42,19 @@
(require 'c-ts-common) ; For comment indent and filling.
(treesit-declare-unavailable-functions)
(add-to-list
'treesit-language-source-alist
'(typescript
"https://github.com/tree-sitter/tree-sitter-typescript" "v0.23.2"
"typescript/src")
t)
(add-to-list
'treesit-language-source-alist
'(tsx
"https://github.com/tree-sitter/tree-sitter-typescript" "v0.23.2"
"tsx/src")
t)
(defcustom typescript-ts-mode-indent-offset 2
"Number of spaces for each indentation step in `typescript-ts-mode'."
:version "29.1"
@ -608,7 +621,7 @@ This mode is intended to be inherited by concrete major modes."
:group 'typescript
:syntax-table typescript-ts-mode--syntax-table
(when (treesit-ready-p 'typescript)
(when (treesit-ensure-installed 'typescript)
(setq treesit-primary-parser (treesit-parser-create 'typescript))
;; Indent.
@ -646,7 +659,7 @@ at least 3 (which is the default value)."
:group 'typescript
:syntax-table typescript-ts-mode--syntax-table
(when (treesit-ready-p 'tsx)
(when (treesit-ensure-installed 'tsx)
(setq treesit-primary-parser (treesit-parser-create 'tsx))
;; Comments.

View file

@ -1341,6 +1341,11 @@ for determining whether point is within a selector."
;;; Tree-sitter
(add-to-list
'treesit-language-source-alist
'(css "https://github.com/tree-sitter/tree-sitter-css" "v0.23.1")
t)
(defvar css-ts-mode-map (copy-keymap css-mode-map)
"Keymap used in `css-ts-mode'.")
@ -1884,7 +1889,7 @@ can also be used to fill comments.
\\{css-mode-map}"
:syntax-table css-mode-syntax-table
(when (treesit-ready-p 'css)
(when (treesit-ensure-installed 'css)
;; Borrowed from `css-mode'.
(setq-local syntax-propertize-function
css-syntax-propertize-function)

View file

@ -43,6 +43,11 @@
(declare-function treesit-node-type "treesit.c")
(declare-function treesit-search-subtree "treesit.c")
(add-to-list
'treesit-language-source-alist
'(html "https://github.com/tree-sitter/tree-sitter-html" "v0.23.2")
t)
(defcustom html-ts-mode-indent-offset 2
"Number of spaces for each indentation step in `html-ts-mode'."
:version "29.1"
@ -144,7 +149,7 @@ Return nil if there is no name or if NODE is not a defun node."
"Major mode for editing Html, powered by tree-sitter."
:group 'html
(unless (treesit-ready-p 'html t)
(unless (treesit-ensure-installed 'html)
(error "Tree-sitter for HTML isn't available"))
(setq treesit-primary-parser (treesit-parser-create 'html))

View file

@ -34,6 +34,19 @@
(declare-function treesit-node-type "treesit.c")
(declare-function treesit-parser-create "treesit.c")
(add-to-list
'treesit-language-source-alist
'(markdown
"https://github.com/tree-sitter-grammars/tree-sitter-markdown" "v0.4.1"
"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")
t)
;;; Helper functions
(defvar markdown-ts--code-block-language-map
@ -304,7 +317,8 @@ the same features enabled in MODE."
`(("Headings" markdown-ts-imenu-node-p nil markdown-ts-imenu-name-function)))
(setq-local treesit-outline-predicate "section")
(when (treesit-ready-p 'markdown)
(when (and (treesit-ensure-installed 'markdown)
(treesit-ensure-installed 'markdown-inline))
(treesit-parser-create 'markdown-inline)
(treesit-parser-create 'markdown)
(markdown-ts-setup)))

View file

@ -65,21 +65,24 @@
;; In a multi-language major mode can be useful to have an "installer" to
;; simplify the installation of the grammars supported by the major-mode.
(defvar mhtml-ts-mode--language-source-alist
'((html . ("https://github.com/tree-sitter/tree-sitter-html" "v0.23.2"))
(javascript . ("https://github.com/tree-sitter/tree-sitter-javascript" "v0.23.1"))
(jsdoc . ("https://github.com/tree-sitter/tree-sitter-jsdoc" "v0.23.2"))
(css . ("https://github.com/tree-sitter/tree-sitter-css" "v0.23.1")))
'((html "https://github.com/tree-sitter/tree-sitter-html" "v0.23.2")
(javascript "https://github.com/tree-sitter/tree-sitter-javascript" "v0.23.1")
(jsdoc "https://github.com/tree-sitter/tree-sitter-jsdoc" "v0.23.2")
(css "https://github.com/tree-sitter/tree-sitter-css" "v0.23.1"))
"Treesitter language parsers required by `mhtml-ts-mode'.
You can customize this variable if you want to stick to a specific
commit and/or use different parsers.")
You can customize `treesit-language-source-alist' if you want
to stick to a specific commit and/or use different parsers.")
(setq treesit-language-source-alist
(append treesit-language-source-alist
mhtml-ts-mode--language-source-alist))
(defun mhtml-ts-mode-install-parsers ()
"Install all the required treesitter parsers.
`mhtml-ts-mode--language-source-alist' defines which parsers to install."
(interactive)
(let ((treesit-language-source-alist mhtml-ts-mode--language-source-alist))
(dolist (item mhtml-ts-mode--language-source-alist)
(treesit-install-language-grammar (car item)))))
(dolist (item mhtml-ts-mode--language-source-alist)
(treesit-install-language-grammar (car item))))
;;; Custom variables
@ -432,9 +435,9 @@ Calls REPORT-FN directly. Requires tidy."
"Major mode for editing HTML with embedded JavaScript and CSS.
Powered by tree-sitter."
(if (not (and
(treesit-ready-p 'html t)
(treesit-ready-p 'javascript t)
(treesit-ready-p 'css t)))
(treesit-ensure-installed 'html)
(treesit-ensure-installed 'javascript)
(treesit-ensure-installed 'css)))
(error "Tree-sitter parsers for HTML isn't available. You can
install the parsers with M-x `mhtml-ts-mode-install-parsers'")
@ -487,7 +490,7 @@ Powered by tree-sitter."
;; jsdoc is not mandatory for js-ts-mode, so we respect this by
;; adding jsdoc range rules only when jsdoc is available.
(when (treesit-ready-p 'jsdoc t)
(when (treesit-ensure-installed 'jsdoc)
(setq-local treesit-range-settings
(append treesit-range-settings
(treesit-range-rules

View file

@ -36,6 +36,11 @@
(declare-function treesit-node-child "treesit.c")
(declare-function treesit-node-child-by-field-name "treesit.c")
(add-to-list
'treesit-language-source-alist
'(toml "https://github.com/tree-sitter-grammars/tree-sitter-toml" "v0.7.0")
t)
(defcustom toml-ts-mode-indent-offset 2
"Number of spaces for each indentation step in `toml-ts-mode'."
:version "29.1"
@ -123,7 +128,7 @@ Return nil if there is no name or if NODE is not a defun node."
:group 'toml-mode
:syntax-table toml-ts-mode--syntax-table
(when (treesit-ready-p 'toml)
(when (treesit-ensure-installed 'toml)
(setq treesit-primary-parser (treesit-parser-create 'toml))
;; Comments

View file

@ -35,6 +35,11 @@
(declare-function treesit-node-type "treesit.c")
(declare-function treesit-node-child-by-field-name "treesit.c")
(add-to-list
'treesit-language-source-alist
'(yaml "https://github.com/tree-sitter-grammars/tree-sitter-yaml" "v0.7.0")
t)
(defvar yaml-ts-mode--syntax-table
(let ((table (make-syntax-table)))
(modify-syntax-entry ?# "<" table)
@ -162,7 +167,7 @@ Return nil if there is no name or if NODE is not a defun node."
:group 'yaml
:syntax-table yaml-ts-mode--syntax-table
(when (treesit-ready-p 'yaml)
(when (treesit-ensure-installed 'yaml)
(setq treesit-primary-parser (treesit-parser-create 'yaml))
;; Comments.

View file

@ -123,6 +123,8 @@ RUN make -j `nproc` bootstrap
RUN mkdir -p /root/.emacs.d/tree-sitter
RUN git config --global http.sslverify "false"
# See https://github.com/emacs-tree-sitter/tree-sitter-langs/tree/master/repos
# The verified versions are generated by 'treesit-admin-verify-major-mode-queries`
# at the comments section in ts-mode files.
RUN src/emacs -Q --batch \
--eval \
'(message "ABI min version %d max version %d" \
@ -130,27 +132,27 @@ RUN src/emacs -Q --batch \
--eval '(setq \
treesit-extra-load-path (list "/root/.emacs.d/tree-sitter") \
treesit-language-source-alist \
(quote ((bash "https://github.com/tree-sitter/tree-sitter-bash") \
(c "https://github.com/tree-sitter/tree-sitter-c") \
(c-sharp "https://github.com/tree-sitter/tree-sitter-c-sharp") \
(cpp "https://github.com/tree-sitter/tree-sitter-cpp") \
(css "https://github.com/tree-sitter/tree-sitter-css") \
(elixir "https://github.com/elixir-lang/tree-sitter-elixir") \
(go "https://github.com/tree-sitter/tree-sitter-go") \
(gomod "https://github.com/camdencheek/tree-sitter-go-mod") \
(quote ((bash "https://github.com/tree-sitter/tree-sitter-bash" "v0.23.3") \
(c "https://github.com/tree-sitter/tree-sitter-c" "v0.23.4") \
(c-sharp "https://github.com/tree-sitter/tree-sitter-c-sharp" "v0.23.1") \
(cpp "https://github.com/tree-sitter/tree-sitter-cpp" "v0.23.4") \
(css "https://github.com/tree-sitter/tree-sitter-css" "v0.23.1") \
(elixir "https://github.com/elixir-lang/tree-sitter-elixir" "v0.3.3") \
(go "https://github.com/tree-sitter/tree-sitter-go" "v0.23.4") \
(gomod "https://github.com/camdencheek/tree-sitter-go-mod" "v1.1.0") \
(gowork "https://github.com/omertuc/tree-sitter-go-work") \
(heex "https://github.com/phoenixframework/tree-sitter-heex") \
(html "https://github.com/tree-sitter/tree-sitter-html") \
(java "https://github.com/tree-sitter/tree-sitter-java") \
(javascript "https://github.com/tree-sitter/tree-sitter-javascript") \
(jsdoc "https://github.com/tree-sitter/tree-sitter-jsdoc") \
(json "https://github.com/tree-sitter/tree-sitter-json") \
(lua "https://github.com/tree-sitter-grammars/tree-sitter-lua") \
(python "https://github.com/tree-sitter/tree-sitter-python") \
(ruby "https://github.com/tree-sitter/tree-sitter-ruby") \
(rust "https://github.com/tree-sitter/tree-sitter-rust" "v0.23.3") \
(tsx "https://github.com/tree-sitter/tree-sitter-typescript" "master" "tsx/src") \
(typescript "https://github.com/tree-sitter/tree-sitter-typescript" "master" "typescript/src"))))' \
(heex "https://github.com/phoenixframework/tree-sitter-heex" "v0.7.0") \
(html "https://github.com/tree-sitter/tree-sitter-html" "v0.23.2") \
(java "https://github.com/tree-sitter/tree-sitter-java" "v0.23.5") \
(javascript "https://github.com/tree-sitter/tree-sitter-javascript" "v0.23.1") \
(jsdoc "https://github.com/tree-sitter/tree-sitter-jsdoc" "v0.23.2") \
(json "https://github.com/tree-sitter/tree-sitter-json" "v0.24.8") \
(lua "https://github.com/tree-sitter-grammars/tree-sitter-lua" "v0.3.0") \
(python "https://github.com/tree-sitter/tree-sitter-python" "v0.23.6") \
(ruby "https://github.com/tree-sitter/tree-sitter-ruby" "v0.23.1") \
(rust "https://github.com/tree-sitter/tree-sitter-rust" "v0.23.2") \
(tsx "https://github.com/tree-sitter/tree-sitter-typescript" "v0.23.2" "tsx/src") \
(typescript "https://github.com/tree-sitter/tree-sitter-typescript" "v0.23.2" "typescript/src"))))' \
--eval '(dolist (lang (mapcar (quote car) treesit-language-source-alist)) \
(treesit-install-language-grammar lang "/root/.emacs.d/tree-sitter"))'