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

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

[nongnu] elpa/treesit-fold cd7963038f 318/417: feat: Add Fish support (#


From: ELPA Syncer
Subject: [nongnu] elpa/treesit-fold cd7963038f 318/417: feat: Add Fish support (#96)
Date: Mon, 1 Jul 2024 10:02:58 -0400 (EDT)

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

    feat: Add Fish support (#96)
    
    * feat: Add Fish support
    
    * complete
---
 CHANGELOG.md       |  1 +
 README.md          |  1 +
 ts-fold-parsers.el | 15 +++++++++++++++
 ts-fold-summary.el |  1 +
 ts-fold.el         | 38 ++++++++++++++++++++++++++++++++++++++
 5 files changed, 56 insertions(+)

diff --git a/CHANGELOG.md b/CHANGELOG.md
index f71b2dff2d..ac45833d17 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -26,6 +26,7 @@ Check [Keep a Changelog](http://keepachangelog.com/) for 
recommendations on how
 * Add `HLSL` support (#93)
 * Add `GLSL` support (#94)
 * Add `Arduino` support (#95)
+* Add `Fish` support (#96)
 
 ## 0.2.0
 > Released Sep 01, 2023
diff --git a/README.md b/README.md
index 575e878da9..e73c1f60b4 100644
--- a/README.md
+++ b/README.md
@@ -117,6 +117,7 @@ These languages are fairly complete:
 - C / C++ / C# / Clojure / CMake / CSS
 - Dart
 - Elisp / Elixir / Erlang
+- Fish
 - GDScript / GLSL / Go
 - Haskell / HLSL / HTML
 - Jai / Java / JavaScript / JSX / JSON / Jsonnet / Julia
diff --git a/ts-fold-parsers.el b/ts-fold-parsers.el
index 0448b0a7e6..3ae5b4961a 100644
--- a/ts-fold-parsers.el
+++ b/ts-fold-parsers.el
@@ -50,6 +50,9 @@
 (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-fish-function "ts-fold.el")
+(declare-function ts-fold-range-fish-if "ts-fold.el")
+(declare-function ts-fold-range-fish-case "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")
@@ -207,6 +210,18 @@
      . (lambda (node offset)
          (ts-fold-range-line-comment node offset "%")))))
 
+(defun ts-fold-parsers-fish ()
+  "Rules set for Fish."
+  '((function_definition . ts-fold-range-fish-function)
+    (if_statement        . ts-fold-range-fish-if)
+    (switch_statement    . ts-fold-range-fish-if)
+    (for_statement       . ts-fold-range-fish-if)
+    (while_statement     . ts-fold-range-fish-if)
+    (case_clause         . ts-fold-range-fish-case)
+    (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 5d314e3cfe..193d30a542 100644
--- a/ts-fold-summary.el
+++ b/ts-fold-summary.el
@@ -234,6 +234,7 @@ type of content by checking the word boundary's existence."
     (emacs-lisp-mode        . ts-fold-summary-elisp)
     (elixir-mode            . ts-fold-summary-ruby-doc)
     (erlang-mode            . ts-fold-summary-tex-doc)
+    (fish-mode              . ts-fold-summary-javadoc)
     (gdscript-mode          . ts-fold-summary-ruby-doc)
     (glsl-mode              . ts-fold-summary-c)
     (go-mode                . ts-fold-summary-go)
diff --git a/ts-fold.el b/ts-fold.el
index e75ab1c3e4..e1527e7565 100644
--- a/ts-fold.el
+++ b/ts-fold.el
@@ -77,6 +77,7 @@
     (elixir-mode            . ,(ts-fold-parsers-elixir))
     (erlang-mode            . ,(ts-fold-parsers-erlang))
     (ess-r-mode             . ,(ts-fold-parsers-r))
+    (fish-mode              . ,(ts-fold-parsers-fish))
     (gdscript-mode          . ,(ts-fold-parsers-gdscript))
     (glsl-mode              . ,(ts-fold-parsers-glsl))
     (go-mode                . ,(ts-fold-parsers-go))
@@ -692,6 +693,43 @@ 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-fish-function (node offset)
+  "Define fold range for `function' in Fish.
+
+For arguments NODE and OFFSET, see function `ts-fold-range-seq' for
+more information."
+  (when-let* ((func-name (tsc-get-nth-child node 1))
+              (beg (tsc-node-end-position func-name))
+              (end (tsc-node-end-position node))
+              (end (- end 3)))
+    (when ts-fold-on-next-line  ; display nicely
+      (setq end (ts-fold--last-eol end)))
+    (ts-fold--cons-add (cons beg end) offset)))
+
+(defun ts-fold-range-fish-if (node offset)
+  "Define fold range for `if_statement' in Fish.
+
+For arguments NODE and OFFSET, see function `ts-fold-range-seq' for
+more information."
+  (when-let* ((beg (tsc-node-start-position node))
+              (beg (ts-fold--eol beg))
+              (end (tsc-node-end-position node))
+              (end (- end 3)))
+    (when ts-fold-on-next-line  ; display nicely
+      (setq end (ts-fold--last-eol end)))
+    (ts-fold--cons-add (cons beg end) offset)))
+
+(defun ts-fold-range-fish-case (node offset)
+  "Define fold range for `case_clause' in Fish.
+
+For arguments NODE and OFFSET, see function `ts-fold-range-seq' for
+more information."
+  (when-let* ((beg (tsc-node-start-position node))
+              (beg (ts-fold--eol beg))
+              (end (tsc-node-end-position node))
+              (end (1- end)))
+    (ts-fold--cons-add (cons beg end) offset)))
+
 (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]