From 7078e8400736dce923be44a4d26f136a22640f93 Mon Sep 17 00:00:00 2001 From: Skyler Hawthorne Date: Fri, 14 Apr 2023 11:00:15 -0400 Subject: Fix YAML auto indent YAML indents queries are tweaked to fix auto indent behavior. A new capture type `indent.always` is introduced to address use cases where combining indent captures on a single line is desired. Fixes #6661 --- runtime/queries/yaml/indents.scm | 36 +++++++++++++++++++++++++++++++++++- 1 file changed, 35 insertions(+), 1 deletion(-) (limited to 'runtime') 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 -- cgit v1.2.3-70-g09d2