[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/treesit-fold a035da60ad 202/417: apply
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/treesit-fold a035da60ad 202/417: apply |
Date: |
Mon, 1 Jul 2024 10:02:25 -0400 (EDT) |
branch: elpa/treesit-fold
commit a035da60ad036a7d2dd89b69779a6be77161446d
Author: Jen-Chieh <jcs090218@gmail.com>
Commit: Jen-Chieh <jcs090218@gmail.com>
apply
---
README.md | 36 ++++++++++++++++++++++++++++++++++++
1 file changed, 36 insertions(+)
diff --git a/README.md b/README.md
index 3eefe4ee51..a3dab4c831 100644
--- a/README.md
+++ b/README.md
@@ -171,3 +171,39 @@ Enable `tree-sitter-mode` first, then
`tree-sitter-query-builder` is useful to t
out queries that determine what syntax nodes should be foldable and how to fold
them.
[emacs-tree-sitter](https://ubolonton.github.io/emacs-tree-sitter/syntax-highlighting/queries/)
has an excellent documentation on how to write `tree-sitter` queries.
+
+### How to write a parser?
+
+Parsers are ruled in the `ts-fold-parsers.el` file. Parser function follow
+with the prefix `ts-fold-parsers-` plus the `language name`. For example, if
+you want to create a parser for `C` programming language. It should be named:
+`ts-fold-parsers-c`.
+
+The parser is consist of an association list (alist), each item is consist
+of tree-sitter `node` and a function that returns the folding range. See
+the following example:
+
+```elisp
+(defun ts-fold-parsers-csharp ()
+ "Rule sets for C#."
+ '((block . ts-fold-range-seq)
+ ...))
+```
+
+`block` is the tree-sitter node, and `ts-fold-range-seq` is the function
+that will return the folding range.
+
+Let's move into details,
+
+#### Where can I look for tree-sitter node?
+
+To look for the correct node, you should look at the
`tree-sitter-[lang]/grammar.js`
+implementation. In the above example, `block` node is defined in the
+[tree-sitter-c-sharp](https://github.com/tree-sitter/tree-sitter-c-sharp)'s
+`grammar.js` file.
+
+> ⚠️ Warning
+>
+> Make sure you look into the correct repository. Repositories are managed
+> under
[tree-sitter-langs](https://github.com/emacs-tree-sitter/tree-sitter-langs)'s
+> using the git submodule. Some tree-sitter module aren't using the latest
version!
- [nongnu] elpa/treesit-fold 5c9981872e 095/417: Restrict one, (continued)
- [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
- [nongnu] elpa/treesit-fold 946eebf84a 151/417: Update do, ELPA Syncer, 2024/07/01
- [nongnu] elpa/treesit-fold 38cb89733b 156/417: Link indicators mode gif, ELPA Syncer, 2024/07/01
- [nongnu] elpa/treesit-fold 64bb378142 158/417: Scale to 40%, ELPA Syncer, 2024/07/01
- [nongnu] elpa/treesit-fold d3e7f9bb05 152/417: Improve c macro, ELPA Syncer, 2024/07/01
- [nongnu] elpa/treesit-fold 3d40d76ad4 165/417: Fix void mulitline, ELPA Syncer, 2024/07/01
- [nongnu] elpa/treesit-fold a035da60ad 202/417: apply,
ELPA Syncer <=
- [nongnu] elpa/treesit-fold d58795618a 199/417: Update README.md, ELPA Syncer, 2024/07/01
- [nongnu] elpa/treesit-fold afa4f3b9a0 216/417: Merge pull request #11 from jcs-elpa/docs, ELPA Syncer, 2024/07/01
- [nongnu] elpa/treesit-fold 5a94124104 221/417: fix(indicators): Render indicators once it's mode is enabled (#19), ELPA Syncer, 2024/07/01
- [nongnu] elpa/treesit-fold 401aad7380 223/417: Readme update (#20), ELPA Syncer, 2024/07/01
- [nongnu] elpa/treesit-fold 0e83f0e5ef 227/417: docs(CHANGELOG): update, ELPA Syncer, 2024/07/01
- [nongnu] elpa/treesit-fold 9f24d29c07 233/417: Julia language parser. (#33), ELPA Syncer, 2024/07/01
- [nongnu] elpa/treesit-fold bbb1eae1a7 234/417: docs(CHANGELOG): fix PR number for #33, ELPA Syncer, 2024/07/01
- [nongnu] elpa/treesit-fold fe568ebead 246/417: chore: changelog, ELPA Syncer, 2024/07/01
- [nongnu] elpa/treesit-fold ad1d9b2412 258/417: feat(fold): Add support for Lua (#52), ELPA Syncer, 2024/07/01
- [nongnu] elpa/treesit-fold eeff646b21 260/417: Optimize performance of ts-fold-close-all with indicators-mode on (#53), ELPA Syncer, 2024/07/01