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

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

[nongnu] elpa/treesit-fold b52b33357e 300/417: feat: Add Erlang support


From: ELPA Syncer
Subject: [nongnu] elpa/treesit-fold b52b33357e 300/417: feat: Add Erlang support (#83)
Date: Mon, 1 Jul 2024 10:02:39 -0400 (EDT)

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

    feat: Add Erlang support (#83)
    
    * feat: Add Erlang support
    
    * fix checkdoc
---
 CHANGELOG.md       |  1 +
 README.md          |  4 ++--
 ts-fold-parsers.el | 11 +++++++++++
 ts-fold-summary.el |  1 +
 ts-fold.el         | 28 ++++++++++++++++++++++++++++
 5 files changed, 43 insertions(+), 2 deletions(-)

diff --git a/CHANGELOG.md b/CHANGELOG.md
index 125493831f..2f1e1e7546 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -14,6 +14,7 @@ Check [Keep a Changelog](http://keepachangelog.com/) for 
recommendations on how
 * Add XML support (#80)
 * Add Jsonnet support (#81)
 * Add Zig support (#82)
+* Add Erlang support (#83)
 
 ## 0.2.0
 > Released Sep 01, 2023
diff --git a/README.md b/README.md
index 32628a53b1..6626109eb6 100644
--- a/README.md
+++ b/README.md
@@ -115,7 +115,7 @@ These languages are fairly complete:
 - Bash / Beancount
 - C / C++ / C# / Clojure / CSS
 - Dart
-- Elisp / Elixir
+- Elisp / Elixir / Erlang
 - GDScript / Go
 - Haskell / HTML
 - Jai / Java / JavaScript / JSX / JSON / Jsonnet / Julia
@@ -137,7 +137,7 @@ These languages are in development:
 
 - Ada
 - Agda
-- Elm / Erlang
+- Elm
 
 ## 📝 Customization
 
diff --git a/ts-fold-parsers.el b/ts-fold-parsers.el
index 380ac522f0..d4984ad578 100644
--- a/ts-fold-parsers.el
+++ b/ts-fold-parsers.el
@@ -47,6 +47,8 @@
 (declare-function ts-fold-range-c-preproc-else "ts-fold.el")
 (declare-function ts-fold-range-elisp-function "ts-fold.el")
 (declare-function ts-fold-range-elixir "ts-fold.el")
+(declare-function ts-fold-range-erlang-clause-body "ts-fold.el")
+(declare-function ts-fold-range-erlang-type-guards "ts-fold.el")
 (declare-function ts-fold-range-haskell-function "ts-fold.el")
 (declare-function ts-fold-range-html "ts-fold.el")
 (declare-function ts-fold-range-julia "ts-fold.el")
@@ -171,6 +173,15 @@
      . (lambda (node offset)
          (ts-fold-range-line-comment node offset "#")))))
 
+(defun ts-fold-parsers-erlang ()
+  "Rules set for Erlang."
+  '((list        . ts-fold-range-seq)
+    (clause_body . ts-fold-range-erlang-clause-body)
+    (type_guards . ts-fold-range-erlang-type-guards)
+    (comment
+     . (lambda (node offset)
+         (ts-fold-range-line-comment node offset "%")))))
+
 (defun ts-fold-parsers-gdscript ()
   "Rule set for GGScript."
   '((body . (ts-fold-range-seq -1 1))
diff --git a/ts-fold-summary.el b/ts-fold-summary.el
index fdd9da7148..9e4f2e2145 100644
--- a/ts-fold-summary.el
+++ b/ts-fold-summary.el
@@ -218,6 +218,7 @@ type of content by checking the word boundary's existence."
     (dart-mode         . ts-fold-summary-javadoc)
     (emacs-lisp-mode   . ts-fold-summary-elisp)
     (elixir-mode       . ts-fold-summary-ruby-doc)
+    (erlang-mode       . ts-fold-summary-tex-doc)
     (gdscript-mode     . ts-fold-summary-ruby-doc)
     (go-mode           . ts-fold-summary-go)
     (haskell-mode      . ts-fold-summary-lua-doc)
diff --git a/ts-fold.el b/ts-fold.el
index 51c5b26b3e..bfe5bd8790 100644
--- a/ts-fold.el
+++ b/ts-fold.el
@@ -70,6 +70,7 @@
     (dart-mode       . ,(ts-fold-parsers-dart))
     (emacs-lisp-mode . ,(ts-fold-parsers-elisp))
     (elixir-mode     . ,(ts-fold-parsers-elixir))
+    (erlang-mode     . ,(ts-fold-parsers-erlang))
     (ess-r-mode      . ,(ts-fold-parsers-r))
     (gdscript-mode   . ,(ts-fold-parsers-gdscript))
     (go-mode         . ,(ts-fold-parsers-go))
@@ -597,6 +598,33 @@ more information."
       (setq end (ts-fold--last-eol end)))
     (ts-fold--cons-add (cons beg end) offset)))
 
+(defun ts-fold-range-erlang-signature (node offset start)
+  "Return the fold range for generic signature NODE in Erlang.
+
+For arguments NODE and OFFSET, see function `ts-fold-range-seq' for
+more information.
+
+Argument START is a string to target for the first node we use to find the
+start of the position."
+  (when-let* ((start-node (car (ts-fold-find-children node start)))
+              (beg (tsc-node-end-position start-node))
+              (end (tsc-node-end-position node)))
+    (ts-fold--cons-add (cons beg end) offset)))
+
+(defun ts-fold-range-erlang-clause-body (node offset)
+  "Return the fold range for `clause_body' NODE in Erlang.
+
+For arguments NODE and OFFSET, see function `ts-fold-range-seq' for
+more information."
+  (ts-fold-range-erlang-signature node offset "->"))
+
+(defun ts-fold-range-erlang-type-guards (node offset)
+  "Return the fold range for `type_guards' NODE in Erlang.
+
+For arguments NODE and OFFSET, see function `ts-fold-range-seq' for
+more information."
+  (ts-fold-range-erlang-signature node offset "when"))
+
 (defun ts-fold-range-haskell-function (node offset)
   "Define fold range for `function' in Haskell.
 



reply via email to

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