[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/treesit-fold 630b896b3f 277/417: feat: Add Haskell support
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/treesit-fold 630b896b3f 277/417: feat: Add Haskell support (#65) |
Date: |
Mon, 1 Jul 2024 10:02:35 -0400 (EDT) |
branch: elpa/treesit-fold
commit 630b896b3fa8019849d90dfd4cf16a8907b6edf0
Author: Jen-Chieh Shen <jcs090218@gmail.com>
Commit: GitHub <noreply@github.com>
feat: Add Haskell support (#65)
* feat: Add Haskell support
* simp
* changelog
* fix compile
---
CHANGELOG.md | 2 ++
README.md | 2 +-
ts-fold-parsers.el | 6 ++++++
ts-fold-summary.el | 1 +
ts-fold-util.el | 6 ++++++
ts-fold.el | 20 +++++++++++++++-----
6 files changed, 31 insertions(+), 6 deletions(-)
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 291a43c9d6..b6f08fd5fa 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -22,6 +22,8 @@ Check [Keep a Changelog](http://keepachangelog.com/) for
recommendations on how
* Add support for Python docstring (#58)
* Add Dart support (#62)
* Add Elisp support (#63)
+* Add Clojure support (#64)
+* Add Haskell support (#65)
## 0.1.0
> Released Oct 18, 2021
diff --git a/README.md b/README.md
index 403087c0c1..b7d075db77 100644
--- a/README.md
+++ b/README.md
@@ -117,7 +117,7 @@ These languages are fairly complete:
- Dart
- Elisp / Elixir
- Go
-- HTML
+- Haskell / HTML
- Java / JavaScript / JSX / JSON / Julia
- Lua
- Nix
diff --git a/ts-fold-parsers.el b/ts-fold-parsers.el
index 02c4cbb5cc..17916a4708 100644
--- a/ts-fold-parsers.el
+++ b/ts-fold-parsers.el
@@ -44,6 +44,7 @@
(declare-function ts-fold-range-c-preproc-if "ts-fold.el")
(declare-function ts-fold-range-c-preproc-elif "ts-fold.el")
(declare-function ts-fold-range-c-preproc-else "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")
(declare-function ts-fold-range-lua-comment "ts-fold.el")
@@ -167,6 +168,11 @@
(interface_type . (lambda (node offset)
(ts-fold-range-markers node offset "{" "}")))))
+(defun ts-fold-parsers-haskell ()
+ "Rule set for Haskell."
+ '((function . ts-fold-range-haskell-function)
+ (comment . ts-fold-range-lua-comment)))
+
(defun ts-fold-parsers-html ()
"Rule set for HTML."
'((element . ts-fold-range-html)
diff --git a/ts-fold-summary.el b/ts-fold-summary.el
index a3360741fe..b6eff07665 100644
--- a/ts-fold-summary.el
+++ b/ts-fold-summary.el
@@ -213,6 +213,7 @@ type of content by checking the word boundary's existence."
(dart-mode . ts-fold-summary-javadoc)
(emacs-lisp-mode . ts-fold-summary-elisp)
(go-mode . ts-fold-summary-go)
+ (haskell-mode . ts-fold-summary-lua-doc)
(html-mode . ts-fold-summary-xml)
(java-mode . ts-fold-summary-javadoc)
(javascript-mode . ts-fold-summary-javadoc)
diff --git a/ts-fold-util.el b/ts-fold-util.el
index b3500c612a..58face2122 100644
--- a/ts-fold-util.el
+++ b/ts-fold-util.el
@@ -133,5 +133,11 @@ information."
(setq parent (tsc-get-parent parent))))
parent))
+(defun ts-fold-last-child (node)
+ "Return last child node from parent NODE."
+ (when-let* ((count (tsc-count-children node))
+ ((not (= count 0))))
+ (tsc-get-nth-child node (1- count))))
+
(provide 'ts-fold-util)
;;; ts-fold-util.el ends here
diff --git a/ts-fold.el b/ts-fold.el
index dd8cba6d2a..87f2b20ec2 100644
--- a/ts-fold.el
+++ b/ts-fold.el
@@ -71,6 +71,7 @@
(elixir-mode . ,(ts-fold-parsers-elixir))
(ess-r-mode . ,(ts-fold-parsers-r))
(go-mode . ,(ts-fold-parsers-go))
+ (haskell-mode . ,(ts-fold-parsers-haskell))
(html-mode . ,(ts-fold-parsers-html))
(java-mode . ,(ts-fold-parsers-java))
(javascript-mode . ,(ts-fold-parsers-javascript))
@@ -532,13 +533,24 @@ more information."
(end (1- (tsc-node-start-position next))))
(ts-fold--cons-add (cons beg end) offset)))
+(defun ts-fold-range-haskell-function (node offset)
+ "Define fold range for `function' in Haskell.
+
+For arguments NODE and OFFSET, see function `ts-fold-range-seq' for
+more information."
+ (when-let* ((beg (tsc-node-start-position node))
+ (beg (save-excursion (goto-char beg) (line-end-position)))
+ (end-node (ts-fold-last-child node))
+ (end (tsc-node-end-position end-node)))
+ (ts-fold--cons-add (cons beg end) offset)))
+
(defun ts-fold-range-html (node offset)
"Define fold range for tag in HTML.
For arguments NODE and OFFSET, see function `ts-fold-range-seq' for
more information."
(let* ((beg (tsc-node-end-position (tsc-get-nth-child node 0)))
- (end-node (tsc-get-nth-child node (1- (tsc-count-children node))))
+ (end-node (ts-fold-last-child node))
(end (tsc-node-start-position end-node)))
(ts-fold--cons-add (cons beg end) offset)))
@@ -675,8 +687,7 @@ more information."
For arguments NODE and OFFSET, see function `ts-fold-range-seq' for
more information."
- (when-let* ((children (tsc-count-children node))
- (last_bracket (tsc-get-nth-child node (- children 1)))
+ (when-let* ((last_bracket (ts-fold-last-child node))
(first_bracket (tsc-get-nth-child node 2))
(beg (tsc-node-start-position first_bracket))
(end (1+ (tsc-node-start-position last_bracket))))
@@ -698,8 +709,7 @@ more information."
For arguments NODE and OFFSET, see function `ts-fold-range-seq' for
more information."
- (when-let* ((children (tsc-count-children node))
- (end_child (tsc-get-nth-child node (- children 1)))
+ (when-let* ((end_child (ts-fold-last-child node))
(do_child (tsc-get-nth-child node 1))
(beg (tsc-node-start-position do_child))
(end (tsc-node-start-position end_child)))
- [nongnu] elpa/treesit-fold 17d131f69a 228/417: feat(ocaml): Support for ocaml-mode and caml-mode (#24), (continued)
- [nongnu] elpa/treesit-fold 17d131f69a 228/417: feat(ocaml): Support for ocaml-mode and caml-mode (#24), ELPA Syncer, 2024/07/01
- [nongnu] elpa/treesit-fold 28409a0cee 232/417: docs: Update repo link (#32), ELPA Syncer, 2024/07/01
- [nongnu] elpa/treesit-fold 017402713b 236/417: Fix typo/grammar in error message (#34), ELPA Syncer, 2024/07/01
- [nongnu] elpa/treesit-fold fb91989a94 238/417: Setup node is no longer required, ELPA Syncer, 2024/07/01
- [nongnu] elpa/treesit-fold f581febc6f 243/417: Update README (#39), ELPA Syncer, 2024/07/01
- [nongnu] elpa/treesit-fold a5ba7ce60b 248/417: README.md: fix typo (#43), ELPA Syncer, 2024/07/01
- [nongnu] elpa/treesit-fold 5b0535c1af 256/417: test(Makefile); Ignore package-lint test, ELPA Syncer, 2024/07/01
- [nongnu] elpa/treesit-fold cde9c90b07 259/417: docs(README.md): Metnion YAML support, ELPA Syncer, 2024/07/01
- [nongnu] elpa/treesit-fold 5ebe65e85d 262/417: docs: Fix more typo, ELPA Syncer, 2024/07/01
- [nongnu] elpa/treesit-fold 8386b5b714 280/417: feat: Add Markdown support (#67), ELPA Syncer, 2024/07/01
- [nongnu] elpa/treesit-fold 630b896b3f 277/417: feat: Add Haskell support (#65),
ELPA Syncer <=
- [nongnu] elpa/treesit-fold 08abd98ba4 272/417: feat: Add Dart support (#62), ELPA Syncer, 2024/07/01
- [nongnu] elpa/treesit-fold d20c3663f9 380/417: Update desc, ELPA Syncer, 2024/07/01
- [nongnu] elpa/treesit-fold 2bb351bcf3 385/417: feat: Add on fold hook, ELPA Syncer, 2024/07/01
- [nongnu] elpa/treesit-fold c14893d4ff 343/417: perf: Use built-in function for indentation, ELPA Syncer, 2024/07/01
- [nongnu] elpa/treesit-fold 858fb6fe1c 325/417: Update CHANGELOG.md, ELPA Syncer, 2024/07/01
- [nongnu] elpa/treesit-fold 581af904c1 286/417: feat: Add GDScript support (#72), ELPA Syncer, 2024/07/01
- [nongnu] elpa/treesit-fold 07da6590aa 348/417: feat: Add LLVM MIR support, ELPA Syncer, 2024/07/01
- [nongnu] elpa/treesit-fold 03644fb5fa 341/417: fix(indicators): Rely on range itself, ELPA Syncer, 2024/07/01
- [nongnu] elpa/treesit-fold 6ec049b140 310/417: feat: Add Make support (#90), ELPA Syncer, 2024/07/01
- [nongnu] elpa/treesit-fold 75e72c658a 332/417: feat: Add Org support, ELPA Syncer, 2024/07/01