[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.
- [nongnu] elpa/treesit-fold 22ffb18db6 303/417: feat: Add Pascal support (#85), (continued)
- [nongnu] elpa/treesit-fold 22ffb18db6 303/417: feat: Add Pascal support (#85), ELPA Syncer, 2024/07/01
- [nongnu] elpa/treesit-fold aafc4c0a5f 373/417: Changelog, ELPA Syncer, 2024/07/01
- [nongnu] elpa/treesit-fold 47c58282f7 335/417: Release, ELPA Syncer, 2024/07/01
- [nongnu] elpa/treesit-fold 9cbc292502 394/417: fix: Use handle dependent, ELPA Syncer, 2024/07/01
- [nongnu] elpa/treesit-fold c7a9d62e4c 363/417: feat: Add Ninja support, ELPA Syncer, 2024/07/01
- [nongnu] elpa/treesit-fold 2236641e53 397/417: chore: changelog, ELPA Syncer, 2024/07/01
- [nongnu] elpa/treesit-fold f2650076af 382/417: fix: Clean compile warngins, ELPA Syncer, 2024/07/01
- [nongnu] elpa/treesit-fold 882c4faae8 271/417: fix(parsers): update nix definitions (#37), ELPA Syncer, 2024/07/01
- [nongnu] elpa/treesit-fold bb5bd2e31e 276/417: feat: Add Clojure support (#64), ELPA Syncer, 2024/07/01
- [nongnu] elpa/treesit-fold dcf6fdcb85 292/417: Bump version for next version, ELPA Syncer, 2024/07/01
- [nongnu] elpa/treesit-fold b52b33357e 300/417: feat: Add Erlang support (#83),
ELPA Syncer <=
- [nongnu] elpa/treesit-fold cd7963038f 318/417: feat: Add Fish support (#96), ELPA Syncer, 2024/07/01
- [nongnu] elpa/treesit-fold 8972eb674e 391/417: feat: Fully support isearch and modification conditions (#1), ELPA Syncer, 2024/07/01
- [nongnu] elpa/treesit-fold 3dd7c477fb 305/417: feat: Add CMake support (#86), ELPA Syncer, 2024/07/01
- [nongnu] elpa/treesit-fold 250567abd2 345/417: Register qss-mode with CSS, ELPA Syncer, 2024/07/01
- [nongnu] elpa/treesit-fold 648f75ef06 342/417: fix(indicators): Add option for rendering method, ELPA Syncer, 2024/07/01
- [nongnu] elpa/treesit-fold db35c17409 331/417: lint, ELPA Syncer, 2024/07/01
- [nongnu] elpa/treesit-fold c70ac04ea5 358/417: Fixed linting warnings, untabified, tested locally with eask., ELPA Syncer, 2024/07/01
- [nongnu] elpa/treesit-fold 4ef65016fd 396/417: fix: Respect same line folding from close all, ELPA Syncer, 2024/07/01
- [nongnu] elpa/treesit-fold dd36cd388a 360/417: Untabified, reorganized alphabetically: parsers, ELPA Syncer, 2024/07/01
- [nongnu] elpa/treesit-fold 4e9492c2f8 370/417: fix changelog, ELPA Syncer, 2024/07/01