Add jsdoc support to php-ts-mode in <script> element

In the <script> element, enable jsdoc embedding in JavaScript.
* lisp/progmodes/php-ts-mode.el
(php-ts-mode--language-source-alist): Add jsdoc to parser recipe.
(php-ts-mode): Add jsdoc parser check and a new rule for
'treesit-range-settings'.  Update the commentary section.
(Bug#71771)
This commit is contained in:
Vincenzo Pupillo 2024-06-25 11:29:54 +02:00 committed by Eli Zaretskii
parent 2d8881d526
commit 736b7cad40

View file

@ -36,6 +36,7 @@
;; * https://github.com/tree-sitter/tree-sitter-php ;; * https://github.com/tree-sitter/tree-sitter-php
;; * https://github.com/tree-sitter/tree-sitter-html ;; * https://github.com/tree-sitter/tree-sitter-html
;; * https://github.com/tree-sitter/tree-sitter-javascript ;; * https://github.com/tree-sitter/tree-sitter-javascript
;; * https://github.com/tree-sitter/tree-sitter-jsdoc
;; * https://github.com/tree-sitter/tree-sitter-css ;; * https://github.com/tree-sitter/tree-sitter-css
;; * https://github.com/claytonrcarter/tree-sitter-phpdoc ;; * https://github.com/claytonrcarter/tree-sitter-phpdoc
;; ;;
@ -86,6 +87,7 @@
(phpdoc . ("https://github.com/claytonrcarter/tree-sitter-phpdoc")) (phpdoc . ("https://github.com/claytonrcarter/tree-sitter-phpdoc"))
(html . ("https://github.com/tree-sitter/tree-sitter-html" "v0.20.3")) (html . ("https://github.com/tree-sitter/tree-sitter-html" "v0.20.3"))
(javascript . ("https://github.com/tree-sitter/tree-sitter-javascript" "v0.21.2")) (javascript . ("https://github.com/tree-sitter/tree-sitter-javascript" "v0.21.2"))
(jsdoc . ("https://github.com/tree-sitter/tree-sitter-jsdoc" "v0.21.0"))
(css . ("https://github.com/tree-sitter/tree-sitter-css" "v0.21.0"))) (css . ("https://github.com/tree-sitter/tree-sitter-css" "v0.21.0")))
"Treesitter language parsers required by `php-ts-mode'. "Treesitter language parsers required by `php-ts-mode'.
You can customize this variable if you want to stick to a specific You can customize this variable if you want to stick to a specific
@ -1296,6 +1298,7 @@ Depends on `c-ts-common-comment-setup'."
(treesit-ready-p 'phpdoc) (treesit-ready-p 'phpdoc)
(treesit-ready-p 'html) (treesit-ready-p 'html)
(treesit-ready-p 'javascript) (treesit-ready-p 'javascript)
(treesit-ready-p 'jsdoc)
(treesit-ready-p 'css))) (treesit-ready-p 'css)))
(error "Tree-sitter for PHP isn't (error "Tree-sitter for PHP isn't
available. You can install the parsers with M-x available. You can install the parsers with M-x
@ -1334,6 +1337,12 @@ Depends on `c-ts-common-comment-setup'."
(start_tag (tag_name)) (start_tag (tag_name))
(raw_text) @cap)) (raw_text) @cap))
:embed 'jsdoc
:host 'javascript
:local t
`(((comment) @cap
(:match ,js--treesit-jsdoc-beginning-regexp @cap)))
:embed 'css :embed 'css
:host 'html :host 'html
:offset '(1 . -1) :offset '(1 . -1)