unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#71771: 31.0.50; [PATCH] php-ts-mode: jsdoc support in javascript
@ 2024-06-25  9:52 Vincenzo Pupillo
  2024-06-27  9:45 ` Eli Zaretskii
  0 siblings, 1 reply; 7+ messages in thread
From: Vincenzo Pupillo @ 2024-06-25  9:52 UTC (permalink / raw)
  To: 71771

[-- Attachment #1: Type: text/plain, Size: 171 bytes --]

Hi, 
this patch add support for embedding jsdoc into inline javascript element.

Thanks

Vincenzo

p.s. Damien's patch broke php-ts-mode if jsdoc parser is not installed.

[-- Attachment #2: 0001-Add-jsdoc-support-to-php-ts-mode-in-script-element.patch --]
[-- Type: text/x-patch, Size: 2500 bytes --]

From 31e4f30c4a7f867e1bb690a0f53918326b7aaa00 Mon Sep 17 00:00:00 2001
From: Vincenzo Pupillo <v.pupillo@gmail.com>
Date: Tue, 25 Jun 2024 11:29:54 +0200
Subject: [PATCH] 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.

* lisp/progmodes/php-ts-mode.el (php-ts-mode):
Add jsdoc parser check and a new rule for treesit-range-settings.

* lisp/progmodes/php-ts-mode.el: Updated the commentary section.
---
 lisp/progmodes/php-ts-mode.el | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/lisp/progmodes/php-ts-mode.el b/lisp/progmodes/php-ts-mode.el
index 826c131ca70..8eade9ef112 100644
--- a/lisp/progmodes/php-ts-mode.el
+++ b/lisp/progmodes/php-ts-mode.el
@@ -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 @@ php-ts-mode--language-source-alist
     (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 @@ php-ts-mode
             (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,11 @@ php-ts-mode
                     (start_tag (tag_name))
                     (raw_text) @cap))
 
+                 :embed 'jsdoc
+                 :host 'javascript
+                 `(((comment) @capture
+                    (:match ,js--treesit-jsdoc-beginning-regexp @capture)))
+
                  :embed 'css
                  :host 'html
                  :offset '(1 . -1)
-- 
2.45.2


^ permalink raw reply related	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2024-06-29 12:09 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-06-25  9:52 bug#71771: 31.0.50; [PATCH] php-ts-mode: jsdoc support in javascript Vincenzo Pupillo
2024-06-27  9:45 ` Eli Zaretskii
2024-06-27 10:29   ` Vincenzo Pupillo
2024-06-27 19:44     ` Vincenzo Pupillo
2024-06-28  0:52     ` Dmitry Gutov
2024-06-28  8:00       ` Vincenzo Pupillo
2024-06-29 12:09         ` Eli Zaretskii

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).