Unnamed repository; edit this file 'description' to name the repository.
-rw-r--r--helix-term/tests/integration.rs1
-rw-r--r--helix-term/tests/test/languages/mod.rs3
-rw-r--r--helix-term/tests/test/languages/yaml.rs598
-rw-r--r--runtime/queries/yaml/indents.scm8
4 files changed, 609 insertions, 1 deletions
diff --git a/helix-term/tests/integration.rs b/helix-term/tests/integration.rs
index d77eefed..35214bcb 100644
--- a/helix-term/tests/integration.rs
+++ b/helix-term/tests/integration.rs
@@ -18,6 +18,7 @@ mod test {
mod auto_indent;
mod auto_pairs;
mod commands;
+ mod languages;
mod movement;
mod prompt;
mod splits;
diff --git a/helix-term/tests/test/languages/mod.rs b/helix-term/tests/test/languages/mod.rs
new file mode 100644
index 00000000..40ebd796
--- /dev/null
+++ b/helix-term/tests/test/languages/mod.rs
@@ -0,0 +1,3 @@
+use super::*;
+
+mod yaml;
diff --git a/helix-term/tests/test/languages/yaml.rs b/helix-term/tests/test/languages/yaml.rs
new file mode 100644
index 00000000..9b7b7b10
--- /dev/null
+++ b/helix-term/tests/test/languages/yaml.rs
@@ -0,0 +1,598 @@
+use super::*;
+
+#[tokio::test(flavor = "multi_thread")]
+async fn auto_indent() -> anyhow::Result<()> {
+ let app = || AppBuilder::new().with_file("foo.yaml", None);
+
+ let below_tests = [
+ (
+ helpers::platform_line(indoc! {r##"
+ #[t|]#op:
+ baz: foo
+ bazi:
+ more: yes
+ why: because
+ quux:
+ - 1
+ - 2
+ bax: foox
+ fook:
+ "##}),
+ "o",
+ helpers::platform_line(indoc! {"\
+ top:
+ #[\n|]#
+ baz: foo
+ bazi:
+ more: yes
+ why: because
+ quux:
+ - 1
+ - 2
+ bax: foox
+ fook:
+ "}),
+ ),
+ (
+ helpers::platform_line(indoc! {r##"
+ top:
+ b#[a|]#z: foo
+ bazi:
+ more: yes
+ why: because
+ quux:
+ - 1
+ - 2
+ bax: foox
+ fook:
+ "##}),
+ "o",
+ helpers::platform_line(indoc! {"\
+ top:
+ baz: foo
+ #[\n|]#
+ bazi:
+ more: yes
+ why: because
+ quux:
+ - 1
+ - 2
+ bax: foox
+ fook:
+ "}),
+ ),
+ (
+ helpers::platform_line(indoc! {r##"
+ top:
+ baz: foo
+ bazi#[:|]#
+ more: yes
+ why: because
+ quux:
+ - 1
+ - 2
+ bax: foox
+ fook:
+ "##}),
+ "o",
+ helpers::platform_line(indoc! {"\
+ top:
+ baz: foo
+ bazi:
+ #[\n|]#
+ more: yes
+ why: because
+ quux:
+ - 1
+ - 2
+ bax: foox
+ fook:
+ "}),
+ ),
+ (
+ helpers::platform_line(indoc! {r##"
+ top:
+ baz: foo
+ bazi:
+ more: #[yes|]#
+ why: because
+ quux:
+ - 1
+ - 2
+ bax: foox
+ fook:
+ "##}),
+ "o",
+ helpers::platform_line(indoc! {"\
+ top:
+ baz: foo
+ bazi:
+ more: yes
+ #[\n|]#
+ why: because
+ quux:
+ - 1
+ - 2
+ bax: foox
+ fook:
+ "}),
+ ),
+ (
+ helpers::platform_line(indoc! {r##"
+ top:
+ baz: foo
+ bazi:
+ more: yes
+ why: becaus#[e|]#
+ quux:
+ - 1
+ - 2
+ bax: foox
+ fook:
+ "##}),
+ "o",
+ helpers::platform_line(indoc! {"\
+ top:
+ baz: foo
+ bazi:
+ more: yes
+ why: because
+ #[\n|]#
+ quux:
+ - 1
+ - 2
+ bax: foox
+ fook:
+ "}),
+ ),
+ (
+ helpers::platform_line(indoc! {"\
+ top:
+ baz: foo
+ bazi:
+ more: yes
+ why: because
+ quux:#[\n|]#
+ - 1
+ - 2
+ bax: foox
+ fook:
+ "}),
+ "o",
+ helpers::platform_line(indoc! {"\
+ top:
+ baz: foo
+ bazi:
+ more: yes
+ why: because
+ quux:
+ #[\n|]#
+ - 1
+ - 2
+ bax: foox
+ fook:
+ "}),
+ ),
+ (
+ helpers::platform_line(indoc! {"\
+ top:
+ baz: foo
+ bazi:
+ more: yes
+ why: because
+ quux:
+ - 1#[\n|]#
+ - 2
+ bax: foox
+ fook:
+ "}),
+ "o",
+ helpers::platform_line(indoc! {"\
+ top:
+ baz: foo
+ bazi:
+ more: yes
+ why: because
+ quux:
+ - 1
+ #[\n|]#
+ - 2
+ bax: foox
+ fook:
+ "}),
+ ),
+ (
+ helpers::platform_line(indoc! {"\
+ top:
+ baz: foo
+ bazi:
+ more: yes
+ why: because
+ quux:
+ - 1
+ - 2
+ bax: foox
+ fook:#[\n|]#
+ "}),
+ "o",
+ helpers::platform_line(indoc! {"\
+ top:
+ baz: foo
+ bazi:
+ more: yes
+ why: because
+ quux:
+ - 1
+ - 2
+ bax: foox
+ fook:
+ #[\n|]#
+ "}),
+ ),
+ (
+ helpers::platform_line(indoc! {"\
+ top:
+ baz: foo
+ bax: |
+ some
+ multi
+ line
+ string#[\n|]#
+ fook:
+ "}),
+ "o",
+ helpers::platform_line(indoc! {"\
+ top:
+ baz: foo
+ bax: |
+ some
+ multi
+ line
+ string
+ #[\n|]#
+ fook:
+ "}),
+ ),
+ (
+ helpers::platform_line(indoc! {"\
+ top:
+ baz: foo
+ bax: >
+ some
+ multi
+ line#[\n|]#
+ string
+ fook:
+ "}),
+ "o",
+ helpers::platform_line(indoc! {"\
+ top:
+ baz: foo
+ bax: >
+ some
+ multi
+ line
+ #[\n|]#
+ string
+ fook:
+ "}),
+ ),
+ (
+ helpers::platform_line(indoc! {"\
+ top:
+ baz: foo
+ bax: >#[\n|]#
+ fook:
+ "}),
+ "o",
+ helpers::platform_line(indoc! {"\
+ top:
+ baz: foo
+ bax: >
+ #[\n|]#
+ fook:
+ "}),
+ ),
+ ];
+
+ for test in below_tests {
+ test_with_config(app(), test).await?;
+ }
+
+ let above_tests = [
+ (
+ helpers::platform_line(indoc! {r##"
+ #[t|]#op:
+ baz: foo
+ bazi:
+ more: yes
+ why: because
+ quux:
+ - 1
+ - 2
+ bax: foox
+ fook:
+ "##}),
+ "O",
+ helpers::platform_line(indoc! {"\
+ #[\n|]#
+ top:
+ baz: foo
+ bazi:
+ more: yes
+ why: because
+ quux:
+ - 1
+ - 2
+ bax: foox
+ fook:
+ "}),
+ ),
+ (
+ helpers::platform_line(indoc! {r##"
+ top:
+ b#[a|]#z: foo
+ bazi:
+ more: yes
+ why: because
+ quux:
+ - 1
+ - 2
+ bax: foox
+ fook:
+ "##}),
+ "O",
+ helpers::platform_line(indoc! {"\
+ top:
+ #[\n|]#
+ baz: foo
+ bazi:
+ more: yes
+ why: because
+ quux:
+ - 1
+ - 2
+ bax: foox
+ fook:
+ "}),
+ ),
+ (
+ helpers::platform_line(indoc! {r##"
+ top:
+ baz: foo
+ bazi#[:|]#
+ more: yes
+ why: because
+ quux:
+ - 1
+ - 2
+ bax: foox
+ fook:
+ "##}),
+ "O",
+ helpers::platform_line(indoc! {"\
+ top:
+ baz: foo
+ #[\n|]#
+ bazi:
+ more: yes
+ why: because
+ quux:
+ - 1
+ - 2
+ bax: foox
+ fook:
+ "}),
+ ),
+ (
+ helpers::platform_line(indoc! {r##"
+ top:
+ baz: foo
+ bazi:
+ more: #[yes|]#
+ why: because
+ quux:
+ - 1
+ - 2
+ bax: foox
+ fook:
+ "##}),
+ "O",
+ helpers::platform_line(indoc! {"\
+ top:
+ baz: foo
+ bazi:
+ #[\n|]#
+ more: yes
+ why: because
+ quux:
+ - 1
+ - 2
+ bax: foox
+ fook:
+ "}),
+ ),
+ (
+ helpers::platform_line(indoc! {r##"
+ top:
+ baz: foo
+ bazi:
+ more: yes
+ why: becaus#[e|]#
+ quux:
+ - 1
+ - 2
+ bax: foox
+ fook:
+ "##}),
+ "O",
+ helpers::platform_line(indoc! {"\
+ top:
+ baz: foo
+ bazi:
+ more: yes
+ #[\n|]#
+ why: because
+ quux:
+ - 1
+ - 2
+ bax: foox
+ fook:
+ "}),
+ ),
+ (
+ helpers::platform_line(indoc! {"\
+ top:
+ baz: foo
+ bazi:
+ more: yes
+ why: because
+ quux:#[\n|]#
+ - 1
+ - 2
+ bax: foox
+ fook:
+ "}),
+ "O",
+ helpers::platform_line(indoc! {"\
+ top:
+ baz: foo
+ bazi:
+ more: yes
+ why: because
+ #[\n|]#
+ quux:
+ - 1
+ - 2
+ bax: foox
+ fook:
+ "}),
+ ),
+ (
+ helpers::platform_line(indoc! {"\
+ top:
+ baz: foo
+ bazi:
+ more: yes
+ why: because
+ quux:
+ - 1#[\n|]#
+ - 2
+ bax: foox
+ fook:
+ "}),
+ "O",
+ helpers::platform_line(indoc! {"\
+ top:
+ baz: foo
+ bazi:
+ more: yes
+ why: because
+ quux:
+ #[\n|]#
+ - 1
+ - 2
+ bax: foox
+ fook:
+ "}),
+ ),
+ (
+ helpers::platform_line(indoc! {"\
+ top:
+ baz: foo
+ bazi:
+ more: yes
+ why: because
+ quux:
+ - 1
+ - 2
+ bax: foox
+ fook:#[\n|]#
+ "}),
+ "O",
+ helpers::platform_line(indoc! {"\
+ top:
+ baz: foo
+ bazi:
+ more: yes
+ why: because
+ quux:
+ - 1
+ - 2
+ bax: foox
+ #[\n|]#
+ fook:
+ "}),
+ ),
+ (
+ helpers::platform_line(indoc! {"\
+ top:
+ baz: foo
+ bax: |
+ some
+ multi
+ line
+ string#[\n|]#
+ fook:
+ "}),
+ "O",
+ helpers::platform_line(indoc! {"\
+ top:
+ baz: foo
+ bax: |
+ some
+ multi
+ line
+ #[\n|]#
+ string
+ fook:
+ "}),
+ ),
+ (
+ helpers::platform_line(indoc! {"\
+ top:
+ baz: foo
+ bax: >
+ some#[\n|]#
+ multi
+ line
+ string
+ fook:
+ "}),
+ "O",
+ helpers::platform_line(indoc! {"\
+ top:
+ baz: foo
+ bax: >
+ #[\n|]#
+ some
+ multi
+ line
+ string
+ fook:
+ "}),
+ ),
+ (
+ helpers::platform_line(indoc! {"\
+ top:
+ baz: foo
+ bax: >
+ fook:#[\n|]#
+ "}),
+ "O",
+ helpers::platform_line(indoc! {"\
+ top:
+ baz: foo
+ bax: >
+ #[\n|]#
+ fook:
+ "}),
+ ),
+ ];
+
+ for test in above_tests {
+ test_with_config(app(), test).await?;
+ }
+
+ Ok(())
+}
diff --git a/runtime/queries/yaml/indents.scm b/runtime/queries/yaml/indents.scm
index 70a00b69..1ca487bf 100644
--- a/runtime/queries/yaml/indents.scm
+++ b/runtime/queries/yaml/indents.scm
@@ -1,2 +1,8 @@
-(block_mapping_pair) @indent
+(block_scalar) @indent @extend
+((block_mapping_pair
+ key: (_) @key
+ value: (_)? @val
+ (#not-same-line? @key @val)
+ ) @indent @extend
+)