From ee3e9f4dc0e5ee9e2bfb1ee47638375840b8fe0f Mon Sep 17 00:00:00 2001 From: Michael Hoffmann Date: Fri, 2 Dec 2022 23:47:19 +0100 Subject: feat(hcl,terraform): split terraform from hcl, add specialized queries for tf This enables us to have different queries for terraform and general hcl. It solve the situation where other dialects of hcl (nomad, packer, etc) might use a terraform keyword and get highlighted out of place. --- tests/indent/hcl/function_call.tf | 6 ---- tests/indent/hcl/indent-in-multiline-objects.tf | 6 ---- tests/indent/hcl/indent-in-multiline-tuples.tf | 6 ---- tests/indent/hcl/multiline-comments.tf | 7 ----- tests/indent/hcl/multiple-attributes.tf | 4 --- tests/indent/hcl/multiple-blocks.tf | 6 ---- tests/indent/hcl/nested_blocks.tf | 5 ---- tests/indent/hcl/no-indent-after-brace.tf | 4 --- tests/indent/hcl_spec.lua | 35 ---------------------- tests/indent/terraform/function_call.tf | 6 ++++ .../terraform/indent-in-multiline-objects.tf | 6 ++++ .../indent/terraform/indent-in-multiline-tuples.tf | 6 ++++ tests/indent/terraform/multiline-comments.tf | 7 +++++ tests/indent/terraform/multiple-attributes.tf | 4 +++ tests/indent/terraform/multiple-blocks.tf | 6 ++++ tests/indent/terraform/nested_blocks.tf | 5 ++++ tests/indent/terraform/no-indent-after-brace.tf | 4 +++ tests/indent/terraform_spec.lua | 35 ++++++++++++++++++++++ 18 files changed, 79 insertions(+), 79 deletions(-) delete mode 100644 tests/indent/hcl/function_call.tf delete mode 100644 tests/indent/hcl/indent-in-multiline-objects.tf delete mode 100644 tests/indent/hcl/indent-in-multiline-tuples.tf delete mode 100644 tests/indent/hcl/multiline-comments.tf delete mode 100644 tests/indent/hcl/multiple-attributes.tf delete mode 100644 tests/indent/hcl/multiple-blocks.tf delete mode 100644 tests/indent/hcl/nested_blocks.tf delete mode 100644 tests/indent/hcl/no-indent-after-brace.tf delete mode 100644 tests/indent/hcl_spec.lua create mode 100644 tests/indent/terraform/function_call.tf create mode 100644 tests/indent/terraform/indent-in-multiline-objects.tf create mode 100644 tests/indent/terraform/indent-in-multiline-tuples.tf create mode 100644 tests/indent/terraform/multiline-comments.tf create mode 100644 tests/indent/terraform/multiple-attributes.tf create mode 100644 tests/indent/terraform/multiple-blocks.tf create mode 100644 tests/indent/terraform/nested_blocks.tf create mode 100644 tests/indent/terraform/no-indent-after-brace.tf create mode 100644 tests/indent/terraform_spec.lua (limited to 'tests') diff --git a/tests/indent/hcl/function_call.tf b/tests/indent/hcl/function_call.tf deleted file mode 100644 index 44c477e48..000000000 --- a/tests/indent/hcl/function_call.tf +++ /dev/null @@ -1,6 +0,0 @@ -test { - x = f( - a, - b, - ) -} diff --git a/tests/indent/hcl/indent-in-multiline-objects.tf b/tests/indent/hcl/indent-in-multiline-objects.tf deleted file mode 100644 index 00ee9c958..000000000 --- a/tests/indent/hcl/indent-in-multiline-objects.tf +++ /dev/null @@ -1,6 +0,0 @@ -test { - x = { - 1: "foo", - 2: "bar", - } -} diff --git a/tests/indent/hcl/indent-in-multiline-tuples.tf b/tests/indent/hcl/indent-in-multiline-tuples.tf deleted file mode 100644 index 402487890..000000000 --- a/tests/indent/hcl/indent-in-multiline-tuples.tf +++ /dev/null @@ -1,6 +0,0 @@ -test { - x = [ - 1, - 2, - ] -} diff --git a/tests/indent/hcl/multiline-comments.tf b/tests/indent/hcl/multiline-comments.tf deleted file mode 100644 index 494aaba9c..000000000 --- a/tests/indent/hcl/multiline-comments.tf +++ /dev/null @@ -1,7 +0,0 @@ -test { - /* - foo - bar - baz - */ -} diff --git a/tests/indent/hcl/multiple-attributes.tf b/tests/indent/hcl/multiple-attributes.tf deleted file mode 100644 index da6a85fb0..000000000 --- a/tests/indent/hcl/multiple-attributes.tf +++ /dev/null @@ -1,4 +0,0 @@ -test { - x = ["foo", "bar"] - y = {"fizz": "buzz"} -} diff --git a/tests/indent/hcl/multiple-blocks.tf b/tests/indent/hcl/multiple-blocks.tf deleted file mode 100644 index b9826c889..000000000 --- a/tests/indent/hcl/multiple-blocks.tf +++ /dev/null @@ -1,6 +0,0 @@ -test { - x = "foo" -} -test { - y = "bar" -} diff --git a/tests/indent/hcl/nested_blocks.tf b/tests/indent/hcl/nested_blocks.tf deleted file mode 100644 index 7be6492cc..000000000 --- a/tests/indent/hcl/nested_blocks.tf +++ /dev/null @@ -1,5 +0,0 @@ -test { - nest { - x = "bar" - } -} diff --git a/tests/indent/hcl/no-indent-after-brace.tf b/tests/indent/hcl/no-indent-after-brace.tf deleted file mode 100644 index e670ad8d7..000000000 --- a/tests/indent/hcl/no-indent-after-brace.tf +++ /dev/null @@ -1,4 +0,0 @@ -# Issue #2590 -locals { - titles = ["test0", "test1"] -} diff --git a/tests/indent/hcl_spec.lua b/tests/indent/hcl_spec.lua deleted file mode 100644 index ee53d89fc..000000000 --- a/tests/indent/hcl_spec.lua +++ /dev/null @@ -1,35 +0,0 @@ -local Runner = require("tests.indent.common").Runner ---local XFAIL = require("tests.indent.common").XFAIL - -local run = Runner:new(it, "tests/indent/hcl", { - tabstop = 2, - shiftwidth = 2, - expandtab = true, -}) - -describe("indent HCL:", function() - describe("whole file:", function() - run:whole_file(".", { - expected_failures = {}, - }) - end) - - describe("new line:", function() - run:new_line("no-indent-after-brace.tf", { on_line = 4, text = "# Wow, no indent here please", indent = 0 }) - run:new_line("indent-in-multiline-tuples.tf", { on_line = 4, text = "3,", indent = 4 }) - run:new_line("indent-in-multiline-tuples.tf", { on_line = 3, text = "# as elements", indent = 4 }) - run:new_line("indent-in-multiline-tuples.tf", { on_line = 5, text = "# as outer block", indent = 2 }) - run:new_line("indent-in-multiline-tuples.tf", { on_line = 1, text = "# as outer block", indent = 2 }) - run:new_line("indent-in-multiline-objects.tf", { on_line = 4, text = '3: "baz",', indent = 4 }) - run:new_line("indent-in-multiline-objects.tf", { on_line = 3, text = "# as elements", indent = 4 }) - run:new_line("indent-in-multiline-objects.tf", { on_line = 5, text = "# as outer block", indent = 2 }) - run:new_line("indent-in-multiline-objects.tf", { on_line = 1, text = "# as outer block", indent = 2 }) - run:new_line("multiple-attributes.tf", { on_line = 2, text = "a = 1", indent = 2 }) - run:new_line("multiple-attributes.tf", { on_line = 3, text = "a = 1", indent = 2 }) - run:new_line("multiple-attributes.tf", { on_line = 4, text = "a = 1", indent = 0 }) - run:new_line("nested_blocks.tf", { on_line = 3, text = "a = 1", indent = 4 }) - run:new_line("nested_blocks.tf", { on_line = 4, text = "a = 1", indent = 2 }) - run:new_line("function_call.tf", { on_line = 4, text = "c,", indent = 4 }) - run:new_line("function_call.tf", { on_line = 5, text = "a = 1", indent = 2 }) - end) -end) diff --git a/tests/indent/terraform/function_call.tf b/tests/indent/terraform/function_call.tf new file mode 100644 index 000000000..44c477e48 --- /dev/null +++ b/tests/indent/terraform/function_call.tf @@ -0,0 +1,6 @@ +test { + x = f( + a, + b, + ) +} diff --git a/tests/indent/terraform/indent-in-multiline-objects.tf b/tests/indent/terraform/indent-in-multiline-objects.tf new file mode 100644 index 000000000..00ee9c958 --- /dev/null +++ b/tests/indent/terraform/indent-in-multiline-objects.tf @@ -0,0 +1,6 @@ +test { + x = { + 1: "foo", + 2: "bar", + } +} diff --git a/tests/indent/terraform/indent-in-multiline-tuples.tf b/tests/indent/terraform/indent-in-multiline-tuples.tf new file mode 100644 index 000000000..402487890 --- /dev/null +++ b/tests/indent/terraform/indent-in-multiline-tuples.tf @@ -0,0 +1,6 @@ +test { + x = [ + 1, + 2, + ] +} diff --git a/tests/indent/terraform/multiline-comments.tf b/tests/indent/terraform/multiline-comments.tf new file mode 100644 index 000000000..494aaba9c --- /dev/null +++ b/tests/indent/terraform/multiline-comments.tf @@ -0,0 +1,7 @@ +test { + /* + foo + bar + baz + */ +} diff --git a/tests/indent/terraform/multiple-attributes.tf b/tests/indent/terraform/multiple-attributes.tf new file mode 100644 index 000000000..da6a85fb0 --- /dev/null +++ b/tests/indent/terraform/multiple-attributes.tf @@ -0,0 +1,4 @@ +test { + x = ["foo", "bar"] + y = {"fizz": "buzz"} +} diff --git a/tests/indent/terraform/multiple-blocks.tf b/tests/indent/terraform/multiple-blocks.tf new file mode 100644 index 000000000..b9826c889 --- /dev/null +++ b/tests/indent/terraform/multiple-blocks.tf @@ -0,0 +1,6 @@ +test { + x = "foo" +} +test { + y = "bar" +} diff --git a/tests/indent/terraform/nested_blocks.tf b/tests/indent/terraform/nested_blocks.tf new file mode 100644 index 000000000..7be6492cc --- /dev/null +++ b/tests/indent/terraform/nested_blocks.tf @@ -0,0 +1,5 @@ +test { + nest { + x = "bar" + } +} diff --git a/tests/indent/terraform/no-indent-after-brace.tf b/tests/indent/terraform/no-indent-after-brace.tf new file mode 100644 index 000000000..e670ad8d7 --- /dev/null +++ b/tests/indent/terraform/no-indent-after-brace.tf @@ -0,0 +1,4 @@ +# Issue #2590 +locals { + titles = ["test0", "test1"] +} diff --git a/tests/indent/terraform_spec.lua b/tests/indent/terraform_spec.lua new file mode 100644 index 000000000..49fa22c20 --- /dev/null +++ b/tests/indent/terraform_spec.lua @@ -0,0 +1,35 @@ +local Runner = require("tests.indent.common").Runner +--local XFAIL = require("tests.indent.common").XFAIL + +local run = Runner:new(it, "tests/indent/terraform", { + tabstop = 2, + shiftwidth = 2, + expandtab = true, +}) + +describe("indent Terraform:", function() + describe("whole file:", function() + run:whole_file(".", { + expected_failures = {}, + }) + end) + + describe("new line:", function() + run:new_line("no-indent-after-brace.tf", { on_line = 4, text = "# Wow, no indent here please", indent = 0 }) + run:new_line("indent-in-multiline-tuples.tf", { on_line = 4, text = "3,", indent = 4 }) + run:new_line("indent-in-multiline-tuples.tf", { on_line = 3, text = "# as elements", indent = 4 }) + run:new_line("indent-in-multiline-tuples.tf", { on_line = 5, text = "# as outer block", indent = 2 }) + run:new_line("indent-in-multiline-tuples.tf", { on_line = 1, text = "# as outer block", indent = 2 }) + run:new_line("indent-in-multiline-objects.tf", { on_line = 4, text = '3: "baz",', indent = 4 }) + run:new_line("indent-in-multiline-objects.tf", { on_line = 3, text = "# as elements", indent = 4 }) + run:new_line("indent-in-multiline-objects.tf", { on_line = 5, text = "# as outer block", indent = 2 }) + run:new_line("indent-in-multiline-objects.tf", { on_line = 1, text = "# as outer block", indent = 2 }) + run:new_line("multiple-attributes.tf", { on_line = 2, text = "a = 1", indent = 2 }) + run:new_line("multiple-attributes.tf", { on_line = 3, text = "a = 1", indent = 2 }) + run:new_line("multiple-attributes.tf", { on_line = 4, text = "a = 1", indent = 0 }) + run:new_line("nested_blocks.tf", { on_line = 3, text = "a = 1", indent = 4 }) + run:new_line("nested_blocks.tf", { on_line = 4, text = "a = 1", indent = 2 }) + run:new_line("function_call.tf", { on_line = 4, text = "c,", indent = 4 }) + run:new_line("function_call.tf", { on_line = 5, text = "a = 1", indent = 2 }) + end) +end) -- cgit v1.3.1