[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/treesit-fold b3faaaa40d 015/417: support folding nix funct
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/treesit-fold b3faaaa40d 015/417: support folding nix functions |
Date: |
Mon, 1 Jul 2024 10:02:05 -0400 (EDT) |
branch: elpa/treesit-fold
commit b3faaaa40d5b2f243c4ea7117d0d57554ddab6bb
Author: Junyi Hou <junyi.yi.hou@gmail.com>
Commit: Junyi Hou <junyi.yi.hou@gmail.com>
support folding nix functions
---
tree-sitter-fold.el | 13 +++++++++++--
1 file changed, 11 insertions(+), 2 deletions(-)
diff --git a/tree-sitter-fold.el b/tree-sitter-fold.el
index 91d065f5d8..b012f9ae38 100644
--- a/tree-sitter-fold.el
+++ b/tree-sitter-fold.el
@@ -41,7 +41,8 @@
'((python-mode . ((function_definition . tree-sitter-fold-range-python)
(class_definition . tree-sitter-fold-range-python)))
(ess-r-mode . ((brace_list . tree-sitter-fold-range-r)))
- (nix-mode . ((attrset . tree-sitter-fold-range-nix))))
+ (nix-mode . ((attrset . tree-sitter-fold-range-nix-attrset)
+ (function . tree-sitter-fold-range-nix-function))))
"An alist of (major-mode . (foldable-node-type . function)).
FUNCTION is used to determine where the beginning and end for
FOLDABLE-NODE-TYPE
in MAJOR-MODE. It should take a single argument (the syntax node with type
@@ -239,12 +240,20 @@ If the current syntax node is not foldable, do nothing."
(end (1- (tsc-node-end-position node))))
(cons beg end)))
-(defun tree-sitter-fold-range-nix (node)
+(defun tree-sitter-fold-range-nix-attrset (node)
"Return the fold range for `attrset' NODE in Nix express language."
(let ((beg (tsc-node-end-position (tsc-get-nth-child node 0)))
(end (1- (tsc-node-end-position node))))
(cons beg end)))
+(defun tree-sitter-fold-range-nix-function (node)
+ "Return the fold range for `function' NODE in Nix express language."
+ (let ((beg (thread-first node
+ (tsc-get-child-by-field :formals)
+ (tsc-get-next-sibling)
+ (tsc-node-end-position)))
+ (end (tsc-node-end-position node)))
+ (cons beg end)))
(provide 'tree-sitter-fold)
- [nongnu] elpa/treesit-fold 6f15c1735a 125/417: Support javascript comment, (continued)
- [nongnu] elpa/treesit-fold 6f15c1735a 125/417: Support javascript comment, ELPA Syncer, 2024/07/01
- [nongnu] elpa/treesit-fold eeb9c03bcc 127/417: Fix conitouse line, ELPA Syncer, 2024/07/01
- [nongnu] elpa/treesit-fold c33e5e7e0c 128/417: Temporily disable csharp, ELPA Syncer, 2024/07/01
- [nongnu] elpa/treesit-fold 6b6f30eb4a 142/417: Add emoji, ELPA Syncer, 2024/07/01
- [nongnu] elpa/treesit-fold 6aabbc6256 147/417: Update doc, ELPA Syncer, 2024/07/01
- [nongnu] elpa/treesit-fold e6ac78f0e2 154/417: SCALE AND CENTER, ELPA Syncer, 2024/07/01
- [nongnu] elpa/treesit-fold a806886568 161/417: Update support language list, ELPA Syncer, 2024/07/01
- [nongnu] elpa/treesit-fold 2409596f33 004/417: readme: fix typo, ELPA Syncer, 2024/07/01
- [nongnu] elpa/treesit-fold 362fc74774 011/417: R: fold brace_list instead, ELPA Syncer, 2024/07/01
- [nongnu] elpa/treesit-fold f0858f1dbc 009/417: add support for R, ELPA Syncer, 2024/07/01
- [nongnu] elpa/treesit-fold b3faaaa40d 015/417: support folding nix functions,
ELPA Syncer <=
- [nongnu] elpa/treesit-fold de5ad4b2f2 063/417: Split uitl, ELPA Syncer, 2024/07/01
- [nongnu] elpa/treesit-fold d07b2bae49 065/417: Complete indicators, ELPA Syncer, 2024/07/01
- [nongnu] elpa/treesit-fold d2c13aac81 069/417: Clean compile, ELPA Syncer, 2024/07/01
- [nongnu] elpa/treesit-fold 4d4526ffb3 073/417: Update core, ELPA Syncer, 2024/07/01
- [nongnu] elpa/treesit-fold 2dfd8c1656 083/417: Add support lang, ELPA Syncer, 2024/07/01
- [nongnu] elpa/treesit-fold 5c9981872e 095/417: Restrict one, ELPA Syncer, 2024/07/01
- [nongnu] elpa/treesit-fold 2ba784bea0 093/417: Fix externals, ELPA Syncer, 2024/07/01
- [nongnu] elpa/treesit-fold f13f0c371b 102/417: Core, ELPA Syncer, 2024/07/01
- [nongnu] elpa/treesit-fold 80b8e2b6dc 138/417: Fix code block syntax, ELPA Syncer, 2024/07/01
- [nongnu] elpa/treesit-fold fe9b69359c 150/417: Correct external calls, ELPA Syncer, 2024/07/01