emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[nongnu] elpa/treesit-fold 7a7bd70185 295/417: feat: Add VHDL support (#


From: ELPA Syncer
Subject: [nongnu] elpa/treesit-fold 7a7bd70185 295/417: feat: Add VHDL support (#79)
Date: Mon, 1 Jul 2024 10:02:37 -0400 (EDT)

branch: elpa/treesit-fold
commit 7a7bd701850438768504aed1ff48d1d2b266cd74
Author: Jen-Chieh Shen <jcs090218@gmail.com>
Commit: GitHub <noreply@github.com>

    feat: Add VHDL support (#79)
    
    * feat: Add VHDL support
    
    * fix ext
---
 CHANGELOG.md       |  1 +
 README.md          |  2 +-
 ts-fold-parsers.el |  9 +++++++++
 ts-fold-summary.el |  1 +
 ts-fold.el         | 29 +++++++++++++++++++++++++++++
 5 files changed, 41 insertions(+), 1 deletion(-)

diff --git a/CHANGELOG.md b/CHANGELOG.md
index f3bbfbe5f0..0dec1f9837 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -10,6 +10,7 @@ Check [Keep a Changelog](http://keepachangelog.com/) for 
recommendations on how
 
 * Add Noir support (#77)
 * Improve Elixir UX (#78)
+* Add VHDL support (#79)
 
 ## 0.2.0
 > Released Sep 01, 2023
diff --git a/README.md b/README.md
index 95056e670f..22c8ee762c 100644
--- a/README.md
+++ b/README.md
@@ -127,7 +127,7 @@ These languages are fairly complete:
 - R / Ruby / Rust
 - Scala / Scheme / Swift
 - TOML / TypeScript / TSX
-- Verilog
+- Verilog / VHDL
 - YAML
 
 These languages are in development:
diff --git a/ts-fold-parsers.el b/ts-fold-parsers.el
index bf862327d4..148fb4312f 100644
--- a/ts-fold-parsers.el
+++ b/ts-fold-parsers.el
@@ -68,6 +68,8 @@
 (declare-function ts-fold-range-toml-table "ts-fold.el")
 (declare-function ts-fold-range-verilog-list "ts-fold.el")
 (declare-function ts-fold-range-verilog-module "ts-fold.el")
+(declare-function ts-fold-range-vhdl-package "ts-fold.el")
+(declare-function ts-fold-range-vhdl-type "ts-fold.el")
 
 ;;
 ;; (@* "Parsers" )
@@ -410,6 +412,13 @@
     (initial_construct        . ts-fold-range-initial-construct)
     (comment                  . ts-fold-range-c-like-comment)))
 
+(defun ts-fold-parsers-vhdl ()
+  "Rule set for VHDL."
+  '((package_declaration         . ts-fold-range-vhdl-package)
+    (full_type_declaration       . ts-fold-range-vhdl-type)
+    (enumeration_type_definition . ts-fold-range-seq)
+    (comment                     . ts-fold-range-lua-comment)))
+
 (defun ts-fold-parsers-yaml ()
   "Rule set for YAML."
   '((comment
diff --git a/ts-fold-summary.el b/ts-fold-summary.el
index 705eb29256..dc5e6ab552 100644
--- a/ts-fold-summary.el
+++ b/ts-fold-summary.el
@@ -251,6 +251,7 @@ type of content by checking the word boundary's existence."
     (conf-toml-mode    . ts-fold-summary-javadoc)
     (typescript-mode   . ts-fold-summary-javadoc)
     (verilog-mode      . ts-fold-summary-javadoc)
+    (vhdl-mode         . ts-fold-summary-lua-doc)
     (nxml-mode         . ts-fold-summary-xml))
   "Alist mapping `major-mode' to doc parser function."
   :type '(alist :key-type symbol :value-type function)
diff --git a/ts-fold.el b/ts-fold.el
index 80a7ed689b..e39fc3b8d6 100644
--- a/ts-fold.el
+++ b/ts-fold.el
@@ -107,6 +107,7 @@
     (tuareg-mode     . ,(ts-fold-parsers-ocaml))
     (typescript-mode . ,(ts-fold-parsers-typescript))
     (verilog-mode    . ,(ts-fold-parsers-verilog))
+    (vhdl-mode       . ,(ts-fold-parsers-vhdl))
     (yaml-mode       . ,(ts-fold-parsers-yaml)))
   "An alist of (major-mode . (foldable-node-type . function)).
 
@@ -906,5 +907,33 @@ more information."
       (setq end (ts-fold--last-eol end)))
     (ts-fold--cons-add (cons beg end) offset)))
 
+(defun ts-fold-range-vhdl-package (node offset)
+  "Return the fold range for `package' NODE in VHDL.
+
+For arguments NODE and OFFSET, see function `ts-fold-range-seq' for
+more information."
+  (when-let* ((start-child (car (ts-fold-find-children node 
"declarative_part")))
+              (beg (tsc-node-start-position start-child))
+              (beg (ts-fold--last-eol beg))
+              (end-child (car (ts-fold-find-children node "end")))
+              (end (tsc-node-start-position end-child)))
+    (when ts-fold-on-next-line
+      (setq end (ts-fold--last-eol end)))
+    (ts-fold--cons-add (cons beg end) offset)))
+
+(defun ts-fold-range-vhdl-type (node offset)
+  "Return the fold range for `type' NODE in VHDL.
+
+For arguments NODE and OFFSET, see function `ts-fold-range-seq' for
+more information."
+  (when-let* ((start-child (car (ts-fold-find-children node 
"record_type_definition")))
+              (record (car (ts-fold-find-children start-child "record")))
+              (beg (tsc-node-end-position record))
+              (end-child (car (ts-fold-find-children start-child "end")))
+              (end (tsc-node-start-position end-child)))
+    (when ts-fold-on-next-line
+      (setq end (ts-fold--last-eol end)))
+    (ts-fold--cons-add (cons beg end) offset)))
+
 (provide 'ts-fold)
 ;;; ts-fold.el ends here



reply via email to

[Prev in Thread] Current Thread [Next in Thread]