]> git.eshelyaron.com Git - emacs.git/commitdiff
Add jsdoc support to php-ts-mode in <script> element
authorVincenzo Pupillo <v.pupillo@gmail.com>
Tue, 25 Jun 2024 09:29:54 +0000 (11:29 +0200)
committerEshel Yaron <me@eshelyaron.com>
Mon, 1 Jul 2024 07:38:55 +0000 (09:38 +0200)
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)

(cherry picked from commit 736b7cad406b28e95b1119feea7b083d8711d09e)

lisp/progmodes/php-ts-mode.el

index 826c131ca70cd8fbe97f40a31ee8c45aa228931e..1298b39311bf76ca0c1904f54acfdc60cbadf7c1 100644 (file)
@@ -36,6 +36,7 @@
 ;; * https://github.com/tree-sitter/tree-sitter-php
 ;; * https://github.com/tree-sitter/tree-sitter-html
 ;; * 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/claytonrcarter/tree-sitter-phpdoc
 ;;
@@ -86,6 +87,7 @@
     (phpdoc . ("https://github.com/claytonrcarter/tree-sitter-phpdoc"))
     (html . ("https://github.com/tree-sitter/tree-sitter-html"  "v0.20.3"))
     (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")))
   "Treesitter language parsers required by `php-ts-mode'.
 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 'html)
             (treesit-ready-p 'javascript)
+            (treesit-ready-p 'jsdoc)
             (treesit-ready-p 'css)))
       (error "Tree-sitter for PHP isn't
     available.  You can install the parsers with M-x
@@ -1334,6 +1337,12 @@ Depends on `c-ts-common-comment-setup'."
                     (start_tag (tag_name))
                     (raw_text) @cap))
 
+                 :embed 'jsdoc
+                 :host 'javascript
+                 :local t
+                 `(((comment) @cap
+                    (:match ,js--treesit-jsdoc-beginning-regexp @cap)))
+
                  :embed 'css
                  :host 'html
                  :offset '(1 . -1)