mirror of
git://git.sv.gnu.org/emacs.git
synced 2026-02-16 17:24:23 +00:00
Avoid duplication in defining tree-sitter grammar sources.
* lisp/progmodes/php-ts-mode.el: Require 'html-ts-mode'. (php-ts-mode--language-source-alist): Remove duplicate source info for html, css, javascript, jsdoc. (php-ts-mode-install-parsers): Install pre-defined grammars. (php-ts-mode): Move 'require' to the top. * lisp/textmodes/mhtml-ts-mode.el (mhtml-ts-mode--language-source-alist): Remove variable since 'treesit-language-source-alist' is pre-filled by requiring 'html-ts-mode', 'css-mode', 'js'. (mhtml-ts-mode-install-parsers): Install pre-defined grammars. * test/infra/Dockerfile.emba: Remove 'mhtml-ts-mode' that doesn't define own grammars.
This commit is contained in:
parent
9e75d18151
commit
815dea7b59
3 changed files with 14 additions and 36 deletions
|
|
@ -69,6 +69,7 @@
|
|||
|
||||
(require 'treesit)
|
||||
(require 'c-ts-common) ;; For comment indent and filling.
|
||||
(require 'html-ts-mode) ;; for embed html
|
||||
(require 'css-mode) ;; for embed css into html
|
||||
(require 'js) ;; for embed javascript into html
|
||||
(require 'comint)
|
||||
|
|
@ -82,11 +83,7 @@
|
|||
;;; 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.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"))
|
||||
(phpdoc "https://github.com/claytonrcarter/tree-sitter-phpdoc"))
|
||||
"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.")
|
||||
|
|
@ -96,10 +93,11 @@ to stick to a specific commit and/or use different parsers.")
|
|||
|
||||
(defun php-ts-mode-install-parsers ()
|
||||
"Install all the required treesitter parsers.
|
||||
`php-ts-mode--language-source-alist' defines which parsers to install."
|
||||
`treesit-language-source-alist' defines which parsers to install.
|
||||
It's pre-filled by loading \"html-ts-mode\", \"css-mode\", \"js\"."
|
||||
(interactive)
|
||||
(dolist (item php-ts-mode--language-source-alist)
|
||||
(treesit-install-language-grammar (car item))))
|
||||
(dolist (lang '(php phpdoc html css javascript jsdoc))
|
||||
(treesit-install-language-grammar lang)))
|
||||
|
||||
;;; Custom variables
|
||||
|
||||
|
|
@ -1391,13 +1389,6 @@ Depends on `c-ts-common-comment-setup'."
|
|||
available. You can install the parsers with M-x
|
||||
`php-ts-mode-install-parsers'")
|
||||
|
||||
;; Require html-ts-mode only when we load php-ts-mode
|
||||
;; so that we don't get a tree-sitter compilation warning for
|
||||
;; php-ts-mode.
|
||||
(defvar html-ts-mode--indent-rules)
|
||||
(require 'html-ts-mode)
|
||||
;; For embed html
|
||||
|
||||
;; phpdoc is a local parser, don't create a parser for it
|
||||
(treesit-parser-create 'html)
|
||||
(treesit-parser-create 'css)
|
||||
|
|
|
|||
|
|
@ -50,9 +50,9 @@
|
|||
;;; Code:
|
||||
|
||||
(require 'treesit)
|
||||
(require 'html-ts-mode)
|
||||
(require 'css-mode) ;; for embed css into html
|
||||
(require 'js) ;; for embed javascript into html
|
||||
(require 'html-ts-mode)
|
||||
|
||||
(eval-when-compile
|
||||
(require 'rx))
|
||||
|
|
@ -62,26 +62,13 @@
|
|||
;; in a Emacs not built with tree-sitter library.
|
||||
(treesit-declare-unavailable-functions)
|
||||
|
||||
;; 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"))
|
||||
"Treesitter language parsers required by `mhtml-ts-mode'.
|
||||
You can customize `treesit-language-source-alist' if you want
|
||||
to stick to a specific commit and/or use different parsers.")
|
||||
|
||||
(dolist (item mhtml-ts-mode--language-source-alist)
|
||||
(add-to-list 'treesit-language-source-alist item t))
|
||||
|
||||
(defun mhtml-ts-mode-install-parsers ()
|
||||
"Install all the required treesitter parsers.
|
||||
`mhtml-ts-mode--language-source-alist' defines which parsers to install."
|
||||
`treesit-language-source-alist' defines which parsers to install.
|
||||
It's pre-filled by loading \"html-ts-mode\", \"css-mode\", \"js\"."
|
||||
(interactive)
|
||||
(dolist (item mhtml-ts-mode--language-source-alist)
|
||||
(treesit-install-language-grammar (car item))))
|
||||
(dolist (lang '(html css javascript jsdoc))
|
||||
(treesit-install-language-grammar lang)))
|
||||
|
||||
;;; Custom variables
|
||||
|
||||
|
|
|
|||
|
|
@ -132,9 +132,9 @@ RUN src/emacs -Q --batch \
|
|||
--eval '(setq treesit-extra-load-path (list "/root/.emacs.d/tree-sitter"))' \
|
||||
--eval '(dolist (feature (quote (c-ts-mode cmake-ts-mode csharp-mode \
|
||||
dockerfile-ts-mode elixir-ts-mode heex-ts-mode go-ts-mode java-ts-mode \
|
||||
js json-ts-mode lua-ts-mode python ruby-ts-mode rust-ts-mode sh-script \
|
||||
typescript-ts-mode css-mode html-ts-mode markdown-ts-mode toml-ts-mode \
|
||||
yaml-ts-mode mhtml-ts-mode php-ts-mode treesit-x))) (require feature))' \
|
||||
js json-ts-mode lua-ts-mode php-ts-mode python ruby-ts-mode rust-ts-mode \
|
||||
sh-script typescript-ts-mode css-mode html-ts-mode markdown-ts-mode \
|
||||
toml-ts-mode yaml-ts-mode treesit-x))) (require feature))' \
|
||||
--eval '(dolist (lang (mapcar (quote car) treesit-language-source-alist)) \
|
||||
(treesit-install-language-grammar lang "/root/.emacs.d/tree-sitter"))' \
|
||||
--eval '(message "treesit-language-source-alist\n%s" \
|
||||
|
|
|
|||
Loading…
Reference in a new issue