aboutsummaryrefslogtreecommitdiff
path: root/runtime
diff options
context:
space:
mode:
Diffstat (limited to 'runtime')
-rw-r--r--runtime/queries/yaml/indents.scm36
1 files changed, 35 insertions, 1 deletions
diff --git a/runtime/queries/yaml/indents.scm b/runtime/queries/yaml/indents.scm
index 70a00b69..87853eb6 100644
--- a/runtime/queries/yaml/indents.scm
+++ b/runtime/queries/yaml/indents.scm
@@ -1,2 +1,36 @@
-(block_mapping_pair) @indent
+(block_scalar) @indent @extend
+; indent sequence items only if they span more than one line, e.g.
+;
+; - foo:
+; bar: baz
+; - quux:
+; bar: baz
+;
+; but not
+;
+; - foo
+; - bar
+; - baz
+((block_sequence_item) @item @indent.always @extend
+ (#not-one-line? @item))
+
+; map pair where without a key
+;
+; foo:
+((block_mapping_pair
+ key: (_) @key
+ !value
+ ) @indent.always @extend
+)
+
+; map pair where the key and value are on different lines
+;
+; foo:
+; bar: baz
+((block_mapping_pair
+ key: (_) @key
+ value: (_) @val
+ (#not-same-line? @key @val)
+ ) @indent.always @extend
+) \ No newline at end of file