branch: elpa/treesit-fold
commit 41103496f2228cd07130e0d302a9d96cf19ecce2
Author: Jen-Chieh <[email protected]>
Commit: Jen-Chieh <[email protected]>
up
---
README.md | 30 ++++++++++++++++++++++++++++--
1 file changed, 28 insertions(+), 2 deletions(-)
diff --git a/README.md b/README.md
index 46c3f3e3ea..e2b932e47a 100644
--- a/README.md
+++ b/README.md
@@ -28,6 +28,7 @@ to provide code folding base on the tree-sitter syntax tree.
- [How to write a parser?](#how-to-write-a-parser)
- [Where can I look for tree-sitter
node?](#where-can-i-look-for-tree-sitter-node)
- [How do I create the function for the corresponding
node?](#how-do-i-create-the-function-for-the-corresponding-node)
+ - [Register to parsers alist!](#register-to-parsers-alist)
<!-- markdown-toc end -->
@@ -220,5 +221,30 @@ targeting node.
* `offset` - (optiona) a cons consist of two integers. This is handy when you
have
a similar rule with little of positioning adjustment.
-> `tree-sitter-[lang]` parsers are generally integrated with different authors,
-> hence their naming and ruling are slightly different (+1/-1 position).
+`tree-sitter-[lang]` parsers are generally integrated with different authors,
+hence their naming and ruling are slightly different (+1/-1 position).
+
+Let's look at function `ts-fold-range-seq` for better understanding,
+
+```elisp
+(defun ts-fold-range-seq (node offset)
+ "..."
+ (let ((beg (1+ (tsc-node-start-position node))) ; node beginning position
(from Rust layer)
+ (end (1- (tsc-node-end-position node)))) ; node end position (from
Rust layer)
+ (ts-fold--cons-add (cons beg end) offset))) ; return fold range
+```
+
+#### Register to parsers alist!
+
+Don't get to add your parsers to entry alist.
+
+```elisp
+(defcustom ts-fold-range-alist
+ `((agda-mode . ,(ts-fold-parsers-agda))
+ (sh-mode . ,(ts-fold-parsers-bash))
+ (c-mode . ,(ts-fold-parsers-c))
+ (c++-mode . ,(ts-fold-parsers-c++))
+ ...
+```
+
+This variable is defined in package main file, `ts-fold.el`.