diff options
| -rw-r--r-- | queries/gdscript/indents.scm | 24 | ||||
| -rw-r--r-- | tests/indent/gdscript/basic_blocks.gd | 16 | ||||
| -rw-r--r-- | tests/indent/gdscript_spec.lua | 20 |
3 files changed, 60 insertions, 0 deletions
diff --git a/queries/gdscript/indents.scm b/queries/gdscript/indents.scm new file mode 100644 index 000000000..80b78234d --- /dev/null +++ b/queries/gdscript/indents.scm @@ -0,0 +1,24 @@ +[ + (if_statement) + + (for_statement) + (while_statement) + + (parenthesized_expression) + + (function_definition) + (class_definition) +] @indent + +((argument_list) @aligned_indent + (#set! "delimiter" "()")) +((parameters) @aligned_indent + (#set! "delimiter" "()")) + +[ + ")" + "]" + "}" + (elif_clause) + (else_clause) +] @branch diff --git a/tests/indent/gdscript/basic_blocks.gd b/tests/indent/gdscript/basic_blocks.gd new file mode 100644 index 000000000..3bc048543 --- /dev/null +++ b/tests/indent/gdscript/basic_blocks.gd @@ -0,0 +1,16 @@ +extends Node + +func _ready(): + var x := 2 + for i in range(x): + prints(i) + + while x > 0: + print(x) + + if x > 0: + print("if test") + elif x < 0: + print("if test") + else: + print("if test") diff --git a/tests/indent/gdscript_spec.lua b/tests/indent/gdscript_spec.lua new file mode 100644 index 000000000..c1770f41a --- /dev/null +++ b/tests/indent/gdscript_spec.lua @@ -0,0 +1,20 @@ +local Runner = require("tests.indent.common").Runner + +local run = Runner:new(it, "tests/indent/gdscript", { + tabstop = 4, + shiftwidth = 4, + softtabstop = 0, + expandtab = false, +}) + +describe("indent GDScript:", function() + describe("whole file:", function() + run:whole_file(".", { + expected_failures = {}, + }) + end) + + describe("new line:", function() + run:new_line("basic_blocks.gd", { on_line = 1, text = "var member := 0", indent = 0 }) + end) +end) |
