aboutsummaryrefslogtreecommitdiffstats
path: root/CONTRIBUTING.md
diff options
context:
space:
mode:
authorRiley Bruins <ribru17@hotmail.com>2025-06-29 19:53:33 +0200
committerChristian Clason <ch.clason+github@icloud.com>2025-07-15 10:53:32 +0200
commit8d8ca0996c79348cd59cf31065954f40fcf1679f (patch)
tree60dde5089dddc493c6891ef5f2006d693491d935 /CONTRIBUTING.md
parentfix(c_sharp): "<", ">" in type param lists are brackets (#8003) (diff)
downloadnvim-treesitter-8d8ca0996c79348cd59cf31065954f40fcf1679f.tar
nvim-treesitter-8d8ca0996c79348cd59cf31065954f40fcf1679f.tar.gz
nvim-treesitter-8d8ca0996c79348cd59cf31065954f40fcf1679f.tar.bz2
nvim-treesitter-8d8ca0996c79348cd59cf31065954f40fcf1679f.tar.lz
nvim-treesitter-8d8ca0996c79348cd59cf31065954f40fcf1679f.tar.xz
nvim-treesitter-8d8ca0996c79348cd59cf31065954f40fcf1679f.tar.zst
nvim-treesitter-8d8ca0996c79348cd59cf31065954f40fcf1679f.zip
docs: specify fold dos and don'ts
Diffstat (limited to 'CONTRIBUTING.md')
-rw-r--r--CONTRIBUTING.md27
1 files changed, 25 insertions, 2 deletions
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
index f665ce1ed..f376ed802 100644
--- a/CONTRIBUTING.md
+++ b/CONTRIBUTING.md
@@ -345,12 +345,35 @@ The valid captures are:
### Folds
-You can define folds for a given language by adding a `folds.scm` query. This is implemented in Neovim. The only valid capture is
+You can define folds for a given language by adding a `folds.scm` query. This is implemented in Neovim. The only valid capture is `@fold`:
```query
-@fold ; fold this node
+(function_definition) @fold ; fold this node
```
+Folds should be given to nodes with defined start and end delimiters/patterns, or to consecutive nodes which are part of the same conceptual "grouping", such as consecutive line comments or import statements. The following items are valid fold candidates:
+
+- Function/method definitions
+- Class/interface/trait definitions
+- Switch/match statements, and individual match arms
+- Execution blocks (such as those found in conditional statements or loops)
+- Parameter/argument lists
+- Array/object/string expressions
+- Consecutive import statements, consecutive line comments
+
+The following items would *not* be valid fold candidates:
+
+- Multiline assignment statements
+- Multiline property access expressions
+
+As a rule of thumb, these highlight captures usually reside in or around objects which should be folded:
+
+- `@function`, `@function.method`
+- `@keyword.import`, `@keyword.conditional`, `@keyword.repeat`
+- `@comment`, `@comment.documentation`
+- `@string`, `@string.documentation`
+- `@markup.heading.x`, `@markup.list`
+
### Indents
>[!WARNING]