├── .cargo └── config.toml ├── .editorconfig ├── .gitattributes ├── .github ├── retrieve_test_cases.py ├── run_comparisons.py └── workflows │ ├── benchmark.yml │ ├── ci.yml │ ├── coverage.yml │ ├── extension-release.yml │ ├── extension.yml │ ├── large-scale-test.yml │ ├── npm-build.yml │ ├── release.yml │ └── test-cases.yml ├── .gitignore ├── .pre-commit-hooks.yaml ├── .vscode ├── extensions.json ├── launch.json ├── settings.json └── tasks.json ├── CHANGELOG.md ├── Cargo.lock ├── Cargo.toml ├── Dockerfile ├── LICENSE.md ├── README.md ├── benches ├── date.lua ├── date.rs ├── docgen.lua ├── docgen.rs ├── nested_tables.lua └── nested_tables.rs ├── pyproject.toml ├── src ├── cli │ ├── config.rs │ ├── main.rs │ ├── opt.rs │ └── output_diff.rs ├── context.rs ├── editorconfig.rs ├── formatters │ ├── assignment.rs │ ├── block.rs │ ├── compound_assignment.rs │ ├── expression.rs │ ├── functions.rs │ ├── general.rs │ ├── lua52.rs │ ├── lua54.rs │ ├── luau.rs │ ├── mod.rs │ ├── stmt.rs │ ├── table.rs │ ├── trivia.rs │ └── trivia_util.rs ├── lib.rs ├── shape.rs ├── sort_requires.rs └── verify_ast.rs ├── stylua-npm-bin ├── .gitignore ├── binary.js ├── install.js ├── package-lock.json ├── package.json ├── run.js └── uninstall.js ├── stylua-vscode ├── .editorconfig ├── .eslintrc.json ├── .gitignore ├── .vscode-test.js ├── .vscodeignore ├── CHANGELOG.md ├── README.md ├── assets │ └── icon.png ├── package-lock.json ├── package.json ├── src │ ├── download.ts │ ├── extension.ts │ ├── github.ts │ ├── stylua.ts │ ├── test │ │ └── suite │ │ │ ├── extension.test.ts │ │ │ └── util.test.ts │ └── util.ts ├── tsconfig.json └── webpack.config.js ├── test └── example │ └── test.luau ├── tests ├── inputs-cfxlua │ ├── addition_assignment_operator.lua │ ├── ampersand_equal.lua │ ├── bitwise_xor_assignment_operator.lua │ ├── c_style_comments.lua │ ├── compile_time_jenkins_hashes.lua │ ├── division_assignment_operator.lua │ ├── double_greater_than_equal.lua │ ├── double_less_than_equal.lua │ ├── each_iteration.lua │ ├── in_unpacking.lua │ ├── multiplication_assignment_operator.lua │ ├── pipe_equal.lua │ ├── question_mark_dot.lua │ ├── set_constructor.lua │ └── subtraction_assignment_operator.lua ├── inputs-collapse-single-statement │ ├── complex-conditional-1.lua │ ├── complex-return-1.lua │ ├── complex-return-2.lua │ ├── complex-return-3.lua │ ├── complex-return-4.lua │ ├── conditional-with-function-1.lua │ ├── nested-functions-2.lua │ ├── nested-functions.lua │ ├── over-column-width-2.lua │ ├── over-column-width-3.lua │ ├── over-column-width-4.lua │ ├── over-column-width.lua │ ├── simple-conditional-1.lua │ ├── simple-conditional-2.lua │ ├── simple-conditional-indentation.lua │ ├── simple-conditional-over-width.lua │ ├── simple-conditional-stmt-block-1.lua │ ├── simple-function-argument-1.lua │ ├── simple-function-argument-2.lua │ ├── simple-function-argument-3.lua │ ├── simple-function-stmt-block-1.lua │ ├── simple-function-stmt-block-2.lua │ ├── simple-function-stmt-block-3.lua │ └── simple-function.lua ├── inputs-editorconfig │ ├── .editorconfig │ ├── empty-root │ │ ├── .editorconfig │ │ └── tab-double.lua │ ├── global │ │ └── tab-single.lua │ ├── local │ │ ├── .editorconfig │ │ └── space-4.lua │ ├── space-2.lua │ └── stylua-toml │ │ ├── .editorconfig │ │ ├── single-space-8.lua │ │ └── stylua.toml ├── inputs-full_moon │ ├── anonymous-functions-1.lua │ ├── anonymous-functions-2.lua │ ├── anonymous-functions-3.lua │ ├── anonymous-functions-4.lua │ ├── assignment-1.lua │ ├── assignment-2.lua │ ├── assignment-3.lua │ ├── assignment-4.lua │ ├── assignment-5.lua │ ├── binops.lua │ ├── body-with-spaces.lua │ ├── call-1.lua │ ├── call-2.lua │ ├── do.lua │ ├── empty.lua │ ├── exponents.lua │ ├── fractional-numbers.lua │ ├── function-declaration-1.lua │ ├── function-declaration-2.lua │ ├── function-shortcuts.lua │ ├── generic-for-loop-1.lua │ ├── generic-for-loop-2.lua │ ├── goto-as-identifier.lua │ ├── gt-lt.lua │ ├── if-1.lua │ ├── if-2.lua │ ├── if-3.lua │ ├── if-4.lua │ ├── index-1.lua │ ├── index-2.lua │ ├── local-assignment-1.lua │ ├── local-assignment-2.lua │ ├── local-assignment-3.lua │ ├── local-assignment-4.lua │ ├── local-assignment-5.lua │ ├── local-function-1.lua │ ├── local-function-2.lua │ ├── mixed-indented-comments.lua │ ├── multi-line-comments-1.lua │ ├── multi-line-comments-2.lua │ ├── multi-line-comments-3.lua │ ├── multi-line-comments-4.lua │ ├── multi-line-comments-5.lua │ ├── multi-line-comments-6.lua │ ├── multi-line-comments-7.lua │ ├── multi-line-comments-8.lua │ ├── multi-line-comments-9.lua │ ├── multi-line-string-1.lua │ ├── multi-line-string-2.lua │ ├── multi-line-string-3.lua │ ├── multi-line-string-4.lua │ ├── multi-line-string-5.lua │ ├── multi-line-string-6.lua │ ├── multi-line-string-7.lua │ ├── multi-line-string-8.lua │ ├── negative-numbers.lua │ ├── numbers-1.lua │ ├── numeric-for-loop.lua │ ├── paren-expressions.lua │ ├── repeat-until.lua │ ├── return-break.lua │ ├── semicolons-1.lua │ ├── semicolons-2.lua │ ├── shebang.lua │ ├── single-line-comment-1.lua │ ├── single-line-comment-2.lua │ ├── single-line-comment-3.lua │ ├── single-line-comment-4.lua │ ├── single-line-comment-5.lua │ ├── single-line-comment-6.lua │ ├── single-line-comment-7.lua │ ├── strings-escape-newline.lua │ ├── strings-escape.lua │ ├── strings.lua │ ├── table-constructor-1.lua │ ├── table-constructor-2.lua │ ├── table-constructor-3.lua │ ├── table-constructor-4.lua │ ├── table-constructor-5.lua │ ├── table-constructor-6.lua │ ├── table-constructors-7.lua │ ├── table-constructors-8.lua │ ├── table-constructors-9.lua │ ├── trivia-parsing.lua │ ├── unops.lua │ ├── utf-8.lua │ └── while.lua ├── inputs-ignore │ ├── ignore-table-field.lua │ ├── multiline-block-ignore-1.lua │ ├── multiline-block-ignore-2.lua │ ├── multiline-block-ignore-multiple-comments-leading-trivia.lua │ ├── multiline-block-ignore-no-ending.lua │ ├── multiline-block-ignore-no-starting.lua │ ├── multiline-block-ignore-scope-no-ending.lua │ ├── multiline-block-ignore-scope.lua │ ├── multiline-ignore-table-field.lua │ ├── singleline-ignore-1.lua │ ├── singleline-ignore-2.lua │ ├── singleline-ignore-last-stmt.lua │ └── singleline-ignore-stmt-block.lua ├── inputs-lua52 │ ├── goto-1.lua │ └── goto-2.lua ├── inputs-lua53 │ ├── binary-operators.lua │ └── unary-operators.lua ├── inputs-lua54 │ ├── attributes-1.lua │ └── attributes-2.lua ├── inputs-luau-full_moon │ ├── attributes.lua │ ├── compound_assignment.lua │ ├── continue.lua │ ├── decimal_seperators.lua │ ├── floor_division.lua │ ├── generic_functions.lua │ ├── if_expression.lua │ ├── multiline_expressions.lua │ ├── multiline_typeof_regression.lua │ ├── named_function_arg_types.lua │ ├── no_roblox_syntax.lua │ ├── shorthand_array_type.lua │ ├── string_interpolation_base.lua │ ├── string_interpolation_conformance.lua │ ├── string_interpolation_double_brace.lua │ ├── string_interpolation_regression.lua │ ├── table_access_modifiers.lua │ ├── types.lua │ ├── types_chained_optionals.lua │ ├── types_compound_precedence.lua │ ├── types_exported.lua │ ├── types_function.lua │ ├── types_generic.lua │ ├── types_generic_declaration.lua │ ├── types_generic_no_parameters.lua │ ├── types_indexable.lua │ ├── types_loops.lua │ ├── types_nested_array.lua │ ├── types_packs.lua │ ├── types_parentheses.lua │ ├── types_semicolon_delimeter.lua │ ├── types_variadic.lua │ └── z-escape-string.lua ├── inputs-luau │ ├── anonymous-function-types.lua │ ├── assignment-hang-1.lua │ ├── assignment-hang-2.lua │ ├── attributes-1.lua │ ├── attributes-2.lua │ ├── attributes-3.lua │ ├── compound-assignment-ambiguous-syntax.lua │ ├── compound_operators.lua │ ├── excess-parentheses-type-assertion.lua │ ├── excess-parentheses.lua │ ├── floor-division.lua │ ├── function-call-comments-1.lua │ ├── function_types.lua │ ├── function_types_2.lua │ ├── function_types_3.lua │ ├── generic-for-multiline.lua │ ├── if-expression-2.lua │ ├── if-expression-3.lua │ ├── if-expression-4.lua │ ├── if-expression-5.lua │ ├── if-expression-6.lua │ ├── if-expression-comments-2.lua │ ├── if-expression-comments-3.lua │ ├── if-expression-comments.lua │ ├── if-expression.lua │ ├── large_example.lua │ ├── string-brackets-index.lua │ ├── string-interpolation-table.lua │ ├── type-ascription-ambiguous-syntax.lua │ ├── type-callback-hang-parameters.lua │ ├── type-callback-hanging-2.lua │ ├── type-callback-hanging.lua │ ├── type-comments-2.lua │ ├── type-comments-3.lua │ ├── type-functions-1.lua │ ├── type-generic-comments.lua │ ├── type-generic-variadics.lua │ ├── type-generics-hug-table.lua │ ├── type-hanging-2.lua │ ├── type-hanging-3.lua │ ├── type-hanging-asserted-value.lua │ ├── type-hanging-comments.lua │ ├── type-hanging-intersection.lua │ ├── type-hanging-leading-token-1.lua │ ├── type-hanging-multiline-comment.lua │ ├── type-hanging-table.lua │ ├── type-hanging.lua │ ├── type-multiline-comments.lua │ ├── type-parentheses-comments.lua │ ├── type-parentheses-multiline.lua │ ├── type-tables-comments-2.lua │ ├── type-tables-comments.lua │ ├── type-tables-hang-value.lua │ ├── type-union-comments.lua │ ├── type_parameter_comments.lua │ ├── type_tables.lua │ ├── types-declaration-equal-hang.lua │ ├── types-generic-pack.lua │ ├── types_comments.lua │ ├── types_example.lua │ └── types_parentheses_table_indexer.lua ├── inputs-sort-requires │ ├── basic.lua │ ├── chained-dependency.lua │ ├── dependency.lua │ ├── empty.lua │ ├── groups-2.lua │ ├── groups.lua │ ├── ignore-comment.lua │ ├── ignore-multi-require.lua │ ├── separated-by-comments.lua │ ├── sort-services-2.lua │ ├── sort-services.lua │ └── variable-case.lua ├── inputs │ ├── ambiguous-syntax-2.lua │ ├── ambiguous-syntax-3.lua │ ├── ambiguous-syntax.lua │ ├── anonymous-function-internal-comments.lua │ ├── anonymous-function.lua │ ├── assignment-comments-2.lua │ ├── assignment-comments-3.lua │ ├── assignment-comments.lua │ ├── assignment.lua │ ├── block-empty-lines.lua │ ├── comments-before-punctuation.lua │ ├── comments-buffer.lua │ ├── comments-function-args.lua │ ├── comments-function-params.lua │ ├── comments-indented-block.lua │ ├── comments-keep-multiline.lua │ ├── comments-multiline-expression-2.lua │ ├── comments-multiline-expression.lua │ ├── comments.lua │ ├── complex-args.lua │ ├── condition-operator-precedence.lua │ ├── condition-parentheses-comments.lua │ ├── condition-parentheses.lua │ ├── context-long-lines.lua │ ├── do-block.lua │ ├── double-unary-minus.lua │ ├── empty-function-2.lua │ ├── empty-function.lua │ ├── eof-1.lua │ ├── eof-2.lua │ ├── eof-3.lua │ ├── excess-parentheses-comments.lua │ ├── excess-parentheses-dont-remove.lua │ ├── excess-parentheses.lua │ ├── function-call-2.lua │ ├── function-call-3.lua │ ├── function-call-4.lua │ ├── function-call-5.lua │ ├── function-call-6.lua │ ├── function-call-7.lua │ ├── function-call-8.lua │ ├── function-call-argument-leading-trivia.lua │ ├── function-call-comments-2.lua │ ├── function-call-comments-3.lua │ ├── function-call-comments-4.lua │ ├── function-call-comments.lua │ ├── function-call-multiline-comment.lua │ ├── function-call.lua │ ├── function-def-comments.lua │ ├── function-def-multiline.lua │ ├── function-definition-multiline-2.lua │ ├── generic-for-hug.lua │ ├── generic-for-multiline-2.lua │ ├── generic-for-multiline.lua │ ├── generic-for.lua │ ├── hang-binop-comments-2.lua │ ├── hang-binop-comments.lua │ ├── hang-binop-rhs-precendence.lua │ ├── hang-binop.lua │ ├── hang-call-chain-comments-2.lua │ ├── hang-call-chain-comments-3.lua │ ├── hang-call-chain-comments.lua │ ├── hang-call-chain-small-prefix.lua │ ├── hang-call-chains-2.lua │ ├── hang-call-chains-inline.lua │ ├── hang-call-chains-static.lua │ ├── hang-call-chains.lua │ ├── hang-equality-op.lua │ ├── hang-parens-assign-no-indent.lua │ ├── hang-parens-function-call.lua │ ├── hang-prefix-2.lua │ ├── hang-prefix-ignore-string.lua │ ├── hang-prefix.lua │ ├── if-1.lua │ ├── if-comments-2.lua │ ├── if-comments-3.lua │ ├── if-comments.lua │ ├── indented-multiline-comments.lua │ ├── index-comments.lua │ ├── large-example-2.lua │ ├── large-example.lua │ ├── long-assignment-2.lua │ ├── long-assignment-3.lua │ ├── long-assignment-4.lua │ ├── long-assignment-5.lua │ ├── long-assignment-6.lua │ ├── long-assignment.lua │ ├── multiline-comments.lua │ ├── multiline-expression-comments-1.lua │ ├── multiline-expressions-2.lua │ ├── multiline-expressions-3.lua │ ├── multiline-expressions-4.lua │ ├── multiline-expressions-5.lua │ ├── multiline-expressions-6.lua │ ├── multiline-expressions-indent-block.lua │ ├── multiline-expressions.lua │ ├── multiple-lines-betwen-statements.lua │ ├── number.lua │ ├── punctuated-comments.lua │ ├── repeat-block-2.lua │ ├── repeat-block.lua │ ├── return-comments-1.lua │ ├── return-comments-2.lua │ ├── return-hanging-expression-2.lua │ ├── return-hanging-expression-3.lua │ ├── return-hanging-expression.lua │ ├── return-multiple-functions.lua │ ├── return-multiple-tables.lua │ ├── return-newline-after-token.lua │ ├── semicolon-1.lua │ ├── semicolon-2.lua │ ├── semicolon-comments-ordering.lua │ ├── single-arg-function-calls.lua │ ├── string-brackets-index.lua │ ├── string-escapes-2.lua │ ├── string-escapes.lua │ ├── table-1.lua │ ├── table-2.lua │ ├── table-3.lua │ ├── table-4.lua │ ├── table-5.lua │ ├── table-6.lua │ ├── table-7.lua │ ├── table-8.lua │ ├── table-comments-2.lua │ ├── table-comments.lua │ ├── table-field-comments-2.lua │ ├── table-field-comments-3.lua │ ├── table-field-comments.lua │ ├── table-field-hanging-1.lua │ ├── table-functions.lua │ ├── table-multiline-fields.lua │ ├── table-trailing-comma-comments.lua │ ├── table-wrapping.lua │ ├── var-expression-comments-2.lua │ ├── var-expression-comments.lua │ ├── while-1.lua │ └── while-2.lua ├── snapshots │ ├── test_editorconfig__empty_root.snap │ ├── test_editorconfig__global.snap │ ├── test_editorconfig__local.snap │ ├── test_editorconfig__root.snap │ ├── test_editorconfig__stylua_toml.snap │ ├── tests__cfxlua@addition_assignment_operator.lua.snap │ ├── tests__cfxlua@ampersand_equal.lua.snap │ ├── tests__cfxlua@bitwise_xor_assignment_operator.lua.snap │ ├── tests__cfxlua@c_style_comments.lua.snap │ ├── tests__cfxlua@compile_time_jenkins_hashes.lua.snap │ ├── tests__cfxlua@division_assignment_operator.lua.snap │ ├── tests__cfxlua@double_greater_than_equal.lua.snap │ ├── tests__cfxlua@double_less_than_equal.lua.snap │ ├── tests__cfxlua@each_iteration.lua.snap │ ├── tests__cfxlua@in_unpacking.lua.snap │ ├── tests__cfxlua@multiplication_assignment_operator.lua.snap │ ├── tests__cfxlua@pipe_equal.lua.snap │ ├── tests__cfxlua@question_mark_dot.lua.snap │ ├── tests__cfxlua@set_constructor.lua.snap │ ├── tests__cfxlua@subtraction_assignment_operator.lua.snap │ ├── tests__collapse_single_statement@complex-conditional-1.lua.snap │ ├── tests__collapse_single_statement@complex-return-1.lua.snap │ ├── tests__collapse_single_statement@complex-return-2.lua.snap │ ├── tests__collapse_single_statement@complex-return-3.lua.snap │ ├── tests__collapse_single_statement@complex-return-4.lua.snap │ ├── tests__collapse_single_statement@conditional-with-function-1.lua.snap │ ├── tests__collapse_single_statement@nested-functions-2.lua.snap │ ├── tests__collapse_single_statement@nested-functions.lua.snap │ ├── tests__collapse_single_statement@over-column-width-2.lua.snap │ ├── tests__collapse_single_statement@over-column-width-3.lua.snap │ ├── tests__collapse_single_statement@over-column-width-4.lua.snap │ ├── tests__collapse_single_statement@over-column-width.lua.snap │ ├── tests__collapse_single_statement@simple-conditional-1.lua.snap │ ├── tests__collapse_single_statement@simple-conditional-2.lua.snap │ ├── tests__collapse_single_statement@simple-conditional-indentation.lua.snap │ ├── tests__collapse_single_statement@simple-conditional-over-width.lua.snap │ ├── tests__collapse_single_statement@simple-conditional-stmt-block-1.lua.snap │ ├── tests__collapse_single_statement@simple-function-argument-1.lua.snap │ ├── tests__collapse_single_statement@simple-function-argument-2.lua.snap │ ├── tests__collapse_single_statement@simple-function-argument-3.lua.snap │ ├── tests__collapse_single_statement@simple-function-stmt-block-1.lua.snap │ ├── tests__collapse_single_statement@simple-function-stmt-block-2.lua.snap │ ├── tests__collapse_single_statement@simple-function-stmt-block-3.lua.snap │ ├── tests__collapse_single_statement@simple-function.lua.snap │ ├── tests__full_moon_test_suite@anonymous-functions-1.lua.snap │ ├── tests__full_moon_test_suite@anonymous-functions-2.lua.snap │ ├── tests__full_moon_test_suite@anonymous-functions-3.lua.snap │ ├── tests__full_moon_test_suite@anonymous-functions-4.lua.snap │ ├── tests__full_moon_test_suite@assignment-1.lua.snap │ ├── tests__full_moon_test_suite@assignment-2.lua.snap │ ├── tests__full_moon_test_suite@assignment-3.lua.snap │ ├── tests__full_moon_test_suite@assignment-4.lua.snap │ ├── tests__full_moon_test_suite@assignment-5.lua.snap │ ├── tests__full_moon_test_suite@binops.lua.snap │ ├── tests__full_moon_test_suite@body-with-spaces.lua.snap │ ├── tests__full_moon_test_suite@call-1.lua.snap │ ├── tests__full_moon_test_suite@call-2.lua.snap │ ├── tests__full_moon_test_suite@do.lua.snap │ ├── tests__full_moon_test_suite@empty.lua.snap │ ├── tests__full_moon_test_suite@exponents.lua.snap │ ├── tests__full_moon_test_suite@fractional-numbers.lua.snap │ ├── tests__full_moon_test_suite@function-declaration-1.lua.snap │ ├── tests__full_moon_test_suite@function-declaration-2.lua.snap │ ├── tests__full_moon_test_suite@function-shortcuts.lua.snap │ ├── tests__full_moon_test_suite@generic-for-loop-1.lua.snap │ ├── tests__full_moon_test_suite@generic-for-loop-2.lua.snap │ ├── tests__full_moon_test_suite@goto-as-identifier.lua.snap │ ├── tests__full_moon_test_suite@gt-lt.lua.snap │ ├── tests__full_moon_test_suite@if-1.lua.snap │ ├── tests__full_moon_test_suite@if-2.lua.snap │ ├── tests__full_moon_test_suite@if-3.lua.snap │ ├── tests__full_moon_test_suite@if-4.lua.snap │ ├── tests__full_moon_test_suite@index-1.lua.snap │ ├── tests__full_moon_test_suite@index-2.lua.snap │ ├── tests__full_moon_test_suite@local-assignment-1.lua.snap │ ├── tests__full_moon_test_suite@local-assignment-2.lua.snap │ ├── tests__full_moon_test_suite@local-assignment-3.lua.snap │ ├── tests__full_moon_test_suite@local-assignment-4.lua.snap │ ├── tests__full_moon_test_suite@local-assignment-5.lua.snap │ ├── tests__full_moon_test_suite@local-function-1.lua.snap │ ├── tests__full_moon_test_suite@local-function-2.lua.snap │ ├── tests__full_moon_test_suite@mixed-indented-comments.lua.snap │ ├── tests__full_moon_test_suite@multi-line-comments-1.lua.snap │ ├── tests__full_moon_test_suite@multi-line-comments-2.lua.snap │ ├── tests__full_moon_test_suite@multi-line-comments-3.lua.snap │ ├── tests__full_moon_test_suite@multi-line-comments-4.lua.snap │ ├── tests__full_moon_test_suite@multi-line-comments-5.lua.snap │ ├── tests__full_moon_test_suite@multi-line-comments-6.lua.snap │ ├── tests__full_moon_test_suite@multi-line-comments-7.lua.snap │ ├── tests__full_moon_test_suite@multi-line-comments-8.lua.snap │ ├── tests__full_moon_test_suite@multi-line-comments-9.lua.snap │ ├── tests__full_moon_test_suite@multi-line-string-1.lua.snap │ ├── tests__full_moon_test_suite@multi-line-string-2.lua.snap │ ├── tests__full_moon_test_suite@multi-line-string-3.lua.snap │ ├── tests__full_moon_test_suite@multi-line-string-4.lua.snap │ ├── tests__full_moon_test_suite@multi-line-string-5.lua.snap │ ├── tests__full_moon_test_suite@multi-line-string-6.lua.snap │ ├── tests__full_moon_test_suite@multi-line-string-7.lua.snap │ ├── tests__full_moon_test_suite@multi-line-string-8.lua.snap │ ├── tests__full_moon_test_suite@negative-numbers.lua.snap │ ├── tests__full_moon_test_suite@numbers-1.lua.snap │ ├── tests__full_moon_test_suite@numeric-for-loop.lua.snap │ ├── tests__full_moon_test_suite@paren-expressions.lua.snap │ ├── tests__full_moon_test_suite@repeat-until.lua.snap │ ├── tests__full_moon_test_suite@return-break.lua.snap │ ├── tests__full_moon_test_suite@semicolons-1.lua.snap │ ├── tests__full_moon_test_suite@semicolons-2.lua.snap │ ├── tests__full_moon_test_suite@shebang.lua.snap │ ├── tests__full_moon_test_suite@single-line-comment-1.lua.snap │ ├── tests__full_moon_test_suite@single-line-comment-2.lua.snap │ ├── tests__full_moon_test_suite@single-line-comment-3.lua.snap │ ├── tests__full_moon_test_suite@single-line-comment-4.lua.snap │ ├── tests__full_moon_test_suite@single-line-comment-5.lua.snap │ ├── tests__full_moon_test_suite@single-line-comment-6.lua.snap │ ├── tests__full_moon_test_suite@single-line-comment-7.lua.snap │ ├── tests__full_moon_test_suite@strings-escape-newline.lua.snap │ ├── tests__full_moon_test_suite@strings-escape.lua.snap │ ├── tests__full_moon_test_suite@strings.lua.snap │ ├── tests__full_moon_test_suite@table-constructor-1.lua.snap │ ├── tests__full_moon_test_suite@table-constructor-2.lua.snap │ ├── tests__full_moon_test_suite@table-constructor-3.lua.snap │ ├── tests__full_moon_test_suite@table-constructor-4.lua.snap │ ├── tests__full_moon_test_suite@table-constructor-5.lua.snap │ ├── tests__full_moon_test_suite@table-constructor-6.lua.snap │ ├── tests__full_moon_test_suite@table-constructors-7.lua.snap │ ├── tests__full_moon_test_suite@table-constructors-8.lua.snap │ ├── tests__full_moon_test_suite@table-constructors-9.lua.snap │ ├── tests__full_moon_test_suite@trivia-parsing.lua.snap │ ├── tests__full_moon_test_suite@unops.lua.snap │ ├── tests__full_moon_test_suite@utf-8.lua.snap │ ├── tests__full_moon_test_suite@while.lua.snap │ ├── tests__ignores@ignore-table-field.lua.snap │ ├── tests__ignores@multiline-block-ignore-1.lua.snap │ ├── tests__ignores@multiline-block-ignore-2.lua.snap │ ├── tests__ignores@multiline-block-ignore-multiple-comments-leading-trivia.lua.snap │ ├── tests__ignores@multiline-block-ignore-no-ending.lua.snap │ ├── tests__ignores@multiline-block-ignore-no-starting.lua.snap │ ├── tests__ignores@multiline-block-ignore-scope-no-ending.lua.snap │ ├── tests__ignores@multiline-block-ignore-scope.lua.snap │ ├── tests__ignores@multiline-ignore-table-field.lua.snap │ ├── tests__ignores@singleline-ignore-1.lua.snap │ ├── tests__ignores@singleline-ignore-2.lua.snap │ ├── tests__ignores@singleline-ignore-last-stmt.lua.snap │ ├── tests__ignores@singleline-ignore-stmt-block.lua.snap │ ├── tests__lua52@goto-1.lua.snap │ ├── tests__lua52@goto-2.lua.snap │ ├── tests__lua53@binary-operators.lua.snap │ ├── tests__lua53@unary-operators.lua.snap │ ├── tests__lua54@attributes-1.lua.snap │ ├── tests__lua54@attributes-2.lua.snap │ ├── tests__luau@anonymous-function-types.lua.snap │ ├── tests__luau@assignment-hang-1.lua.snap │ ├── tests__luau@assignment-hang-2.lua.snap │ ├── tests__luau@attributes-1.lua.snap │ ├── tests__luau@attributes-2.lua.snap │ ├── tests__luau@attributes-3.lua.snap │ ├── tests__luau@compound-assignment-ambiguous-syntax.lua.snap │ ├── tests__luau@compound_operators.lua.snap │ ├── tests__luau@excess-parentheses-type-assertion.lua.snap │ ├── tests__luau@excess-parentheses.lua.snap │ ├── tests__luau@floor-division.lua.snap │ ├── tests__luau@function-call-comments-1.lua.snap │ ├── tests__luau@function_types.lua.snap │ ├── tests__luau@function_types_2.lua.snap │ ├── tests__luau@function_types_3.lua.snap │ ├── tests__luau@generic-for-multiline.lua.snap │ ├── tests__luau@if-expression-2.lua.snap │ ├── tests__luau@if-expression-3.lua.snap │ ├── tests__luau@if-expression-4.lua.snap │ ├── tests__luau@if-expression-5.lua.snap │ ├── tests__luau@if-expression-6.lua.snap │ ├── tests__luau@if-expression-comments-2.lua.snap │ ├── tests__luau@if-expression-comments-3.lua.snap │ ├── tests__luau@if-expression-comments.lua.snap │ ├── tests__luau@if-expression.lua.snap │ ├── tests__luau@large_example.lua.snap │ ├── tests__luau@string-brackets-index.lua.snap │ ├── tests__luau@string-interpolation-table.lua.snap │ ├── tests__luau@type-ascription-ambiguous-syntax.lua.snap │ ├── tests__luau@type-callback-hang-parameters.lua.snap │ ├── tests__luau@type-callback-hanging-2.lua.snap │ ├── tests__luau@type-callback-hanging.lua.snap │ ├── tests__luau@type-comments-2.lua.snap │ ├── tests__luau@type-comments-3.lua.snap │ ├── tests__luau@type-functions-1.lua.snap │ ├── tests__luau@type-generic-comments.lua.snap │ ├── tests__luau@type-generic-variadics.lua.snap │ ├── tests__luau@type-generics-hug-table.lua.snap │ ├── tests__luau@type-hanging-2.lua.snap │ ├── tests__luau@type-hanging-3.lua.snap │ ├── tests__luau@type-hanging-asserted-value.lua.snap │ ├── tests__luau@type-hanging-comments.lua.snap │ ├── tests__luau@type-hanging-intersection.lua.snap │ ├── tests__luau@type-hanging-leading-token-1.lua.snap │ ├── tests__luau@type-hanging-multiline-comment.lua.snap │ ├── tests__luau@type-hanging-table.lua.snap │ ├── tests__luau@type-hanging.lua.snap │ ├── tests__luau@type-multiline-comments.lua.snap │ ├── tests__luau@type-parentheses-comments.lua.snap │ ├── tests__luau@type-parentheses-multiline.lua.snap │ ├── tests__luau@type-tables-comments-2.lua.snap │ ├── tests__luau@type-tables-comments.lua.snap │ ├── tests__luau@type-tables-hang-value.lua.snap │ ├── tests__luau@type-union-comments.lua.snap │ ├── tests__luau@type_parameter_comments.lua.snap │ ├── tests__luau@type_tables.lua.snap │ ├── tests__luau@types-declaration-equal-hang.lua.snap │ ├── tests__luau@types-generic-pack.lua.snap │ ├── tests__luau@types_comments.lua.snap │ ├── tests__luau@types_example.lua.snap │ ├── tests__luau@types_parentheses_table_indexer.lua.snap │ ├── tests__luau_full_moon@attributes.lua.snap │ ├── tests__luau_full_moon@compound_assignment.lua.snap │ ├── tests__luau_full_moon@continue.lua.snap │ ├── tests__luau_full_moon@decimal_seperators.lua.snap │ ├── tests__luau_full_moon@floor_division.lua.snap │ ├── tests__luau_full_moon@generic_functions.lua.snap │ ├── tests__luau_full_moon@if_expression.lua.snap │ ├── tests__luau_full_moon@multiline_expressions.lua.snap │ ├── tests__luau_full_moon@multiline_typeof_regression.lua.snap │ ├── tests__luau_full_moon@named_function_arg_types.lua.snap │ ├── tests__luau_full_moon@no_roblox_syntax.lua.snap │ ├── tests__luau_full_moon@shorthand_array_type.lua.snap │ ├── tests__luau_full_moon@string_interpolation_base.lua.snap │ ├── tests__luau_full_moon@string_interpolation_conformance.lua.snap │ ├── tests__luau_full_moon@string_interpolation_double_brace.lua.snap │ ├── tests__luau_full_moon@string_interpolation_regression.lua.snap │ ├── tests__luau_full_moon@table_access_modifiers.lua.snap │ ├── tests__luau_full_moon@types.lua.snap │ ├── tests__luau_full_moon@types_chained_optionals.lua.snap │ ├── tests__luau_full_moon@types_compound_precedence.lua.snap │ ├── tests__luau_full_moon@types_exported.lua.snap │ ├── tests__luau_full_moon@types_function.lua.snap │ ├── tests__luau_full_moon@types_generic.lua.snap │ ├── tests__luau_full_moon@types_generic_declaration.lua.snap │ ├── tests__luau_full_moon@types_generic_no_parameters.lua.snap │ ├── tests__luau_full_moon@types_indexable.lua.snap │ ├── tests__luau_full_moon@types_loops.lua.snap │ ├── tests__luau_full_moon@types_nested_array.lua.snap │ ├── tests__luau_full_moon@types_packs.lua.snap │ ├── tests__luau_full_moon@types_parentheses.lua.snap │ ├── tests__luau_full_moon@types_semicolon_delimeter.lua.snap │ ├── tests__luau_full_moon@types_variadic.lua.snap │ ├── tests__luau_full_moon@z-escape-string.lua.snap │ ├── tests__sort_requires@basic.lua.snap │ ├── tests__sort_requires@chained-dependency.lua.snap │ ├── tests__sort_requires@dependency.lua.snap │ ├── tests__sort_requires@empty.lua.snap │ ├── tests__sort_requires@groups-2.lua.snap │ ├── tests__sort_requires@groups.lua.snap │ ├── tests__sort_requires@ignore-comment.lua.snap │ ├── tests__sort_requires@ignore-multi-require.lua.snap │ ├── tests__sort_requires@separated-by-comments.lua.snap │ ├── tests__sort_requires@sort-services-2.lua.snap │ ├── tests__sort_requires@sort-services.lua.snap │ ├── tests__sort_requires@variable-case.lua.snap │ ├── tests__standard@ambiguous-syntax-2.lua.snap │ ├── tests__standard@ambiguous-syntax-3.lua.snap │ ├── tests__standard@ambiguous-syntax.lua.snap │ ├── tests__standard@anonymous-function-internal-comments.lua.snap │ ├── tests__standard@anonymous-function.lua.snap │ ├── tests__standard@assignment-comments-2.lua.snap │ ├── tests__standard@assignment-comments-3.lua.snap │ ├── tests__standard@assignment-comments.lua.snap │ ├── tests__standard@assignment.lua.snap │ ├── tests__standard@block-empty-lines.lua.snap │ ├── tests__standard@comments-before-punctuation.lua.snap │ ├── tests__standard@comments-buffer.lua.snap │ ├── tests__standard@comments-function-args.lua.snap │ ├── tests__standard@comments-function-params.lua.snap │ ├── tests__standard@comments-indented-block.lua.snap │ ├── tests__standard@comments-keep-multiline.lua.snap │ ├── tests__standard@comments-multiline-expression-2.lua.snap │ ├── tests__standard@comments-multiline-expression.lua.snap │ ├── tests__standard@comments.lua.snap │ ├── tests__standard@complex-args.lua.snap │ ├── tests__standard@condition-operator-precedence.lua.snap │ ├── tests__standard@condition-parentheses-comments.lua.snap │ ├── tests__standard@condition-parentheses.lua.snap │ ├── tests__standard@context-long-lines.lua.snap │ ├── tests__standard@do-block.lua.snap │ ├── tests__standard@double-unary-minus.lua.snap │ ├── tests__standard@empty-function-2.lua.snap │ ├── tests__standard@empty-function.lua.snap │ ├── tests__standard@eof-1.lua.snap │ ├── tests__standard@eof-2.lua.snap │ ├── tests__standard@eof-3.lua.snap │ ├── tests__standard@excess-parentheses-comments.lua.snap │ ├── tests__standard@excess-parentheses-dont-remove.lua.snap │ ├── tests__standard@excess-parentheses.lua.snap │ ├── tests__standard@function-call-2.lua.snap │ ├── tests__standard@function-call-3.lua.snap │ ├── tests__standard@function-call-4.lua.snap │ ├── tests__standard@function-call-5.lua.snap │ ├── tests__standard@function-call-6.lua.snap │ ├── tests__standard@function-call-7.lua.snap │ ├── tests__standard@function-call-8.lua.snap │ ├── tests__standard@function-call-argument-leading-trivia.lua.snap │ ├── tests__standard@function-call-comments-2.lua.snap │ ├── tests__standard@function-call-comments-3.lua.snap │ ├── tests__standard@function-call-comments-4.lua.snap │ ├── tests__standard@function-call-comments.lua.snap │ ├── tests__standard@function-call-multiline-comment.lua.snap │ ├── tests__standard@function-call.lua.snap │ ├── tests__standard@function-def-comments.lua.snap │ ├── tests__standard@function-def-multiline.lua.snap │ ├── tests__standard@function-definition-multiline-2.lua.snap │ ├── tests__standard@generic-for-hug.lua.snap │ ├── tests__standard@generic-for-multiline-2.lua.snap │ ├── tests__standard@generic-for-multiline.lua.snap │ ├── tests__standard@generic-for.lua.snap │ ├── tests__standard@hang-binop-comments-2.lua.snap │ ├── tests__standard@hang-binop-comments.lua.snap │ ├── tests__standard@hang-binop-rhs-precendence.lua.snap │ ├── tests__standard@hang-binop.lua.snap │ ├── tests__standard@hang-call-chain-comments-2.lua.snap │ ├── tests__standard@hang-call-chain-comments-3.lua.snap │ ├── tests__standard@hang-call-chain-comments.lua.snap │ ├── tests__standard@hang-call-chain-small-prefix.lua.snap │ ├── tests__standard@hang-call-chains-2.lua.snap │ ├── tests__standard@hang-call-chains-inline.lua.snap │ ├── tests__standard@hang-call-chains-static.lua.snap │ ├── tests__standard@hang-call-chains.lua.snap │ ├── tests__standard@hang-equality-op.lua.snap │ ├── tests__standard@hang-parens-assign-no-indent.lua.snap │ ├── tests__standard@hang-parens-function-call.lua.snap │ ├── tests__standard@hang-prefix-2.lua.snap │ ├── tests__standard@hang-prefix-ignore-string.lua.snap │ ├── tests__standard@hang-prefix.lua.snap │ ├── tests__standard@if-1.lua.snap │ ├── tests__standard@if-comments-2.lua.snap │ ├── tests__standard@if-comments-3.lua.snap │ ├── tests__standard@if-comments.lua.snap │ ├── tests__standard@indented-multiline-comments.lua.snap │ ├── tests__standard@index-comments.lua.snap │ ├── tests__standard@large-example-2.lua.snap │ ├── tests__standard@large-example.lua.snap │ ├── tests__standard@long-assignment-2.lua.snap │ ├── tests__standard@long-assignment-3.lua.snap │ ├── tests__standard@long-assignment-4.lua.snap │ ├── tests__standard@long-assignment-5.lua.snap │ ├── tests__standard@long-assignment-6.lua.snap │ ├── tests__standard@long-assignment.lua.snap │ ├── tests__standard@multiline-comments.lua.snap │ ├── tests__standard@multiline-expression-comments-1.lua.snap │ ├── tests__standard@multiline-expressions-2.lua.snap │ ├── tests__standard@multiline-expressions-3.lua.snap │ ├── tests__standard@multiline-expressions-4.lua.snap │ ├── tests__standard@multiline-expressions-5.lua.snap │ ├── tests__standard@multiline-expressions-6.lua.snap │ ├── tests__standard@multiline-expressions-indent-block.lua.snap │ ├── tests__standard@multiline-expressions.lua.snap │ ├── tests__standard@multiple-lines-betwen-statements.lua.snap │ ├── tests__standard@number.lua.snap │ ├── tests__standard@punctuated-comments.lua.snap │ ├── tests__standard@repeat-block-2.lua.snap │ ├── tests__standard@repeat-block.lua.snap │ ├── tests__standard@return-comments-1.lua.snap │ ├── tests__standard@return-comments-2.lua.snap │ ├── tests__standard@return-hanging-expression-2.lua.snap │ ├── tests__standard@return-hanging-expression-3.lua.snap │ ├── tests__standard@return-hanging-expression.lua.snap │ ├── tests__standard@return-multiple-functions.lua.snap │ ├── tests__standard@return-multiple-tables.lua.snap │ ├── tests__standard@return-newline-after-token.lua.snap │ ├── tests__standard@semicolon-1.lua.snap │ ├── tests__standard@semicolon-2.lua.snap │ ├── tests__standard@semicolon-comments-ordering.lua.snap │ ├── tests__standard@single-arg-function-calls.lua.snap │ ├── tests__standard@string-brackets-index.lua.snap │ ├── tests__standard@string-escapes-2.lua.snap │ ├── tests__standard@string-escapes.lua.snap │ ├── tests__standard@table-1.lua.snap │ ├── tests__standard@table-2.lua.snap │ ├── tests__standard@table-3.lua.snap │ ├── tests__standard@table-4.lua.snap │ ├── tests__standard@table-5.lua.snap │ ├── tests__standard@table-6.lua.snap │ ├── tests__standard@table-7.lua.snap │ ├── tests__standard@table-8.lua.snap │ ├── tests__standard@table-comments-2.lua.snap │ ├── tests__standard@table-comments.lua.snap │ ├── tests__standard@table-field-comments-2.lua.snap │ ├── tests__standard@table-field-comments-3.lua.snap │ ├── tests__standard@table-field-comments.lua.snap │ ├── tests__standard@table-field-hanging-1.lua.snap │ ├── tests__standard@table-functions.lua.snap │ ├── tests__standard@table-multiline-fields.lua.snap │ ├── tests__standard@table-trailing-comma-comments.lua.snap │ ├── tests__standard@table-wrapping.lua.snap │ ├── tests__standard@var-expression-comments-2.lua.snap │ ├── tests__standard@var-expression-comments.lua.snap │ ├── tests__standard@while-1.lua.snap │ └── tests__standard@while-2.lua.snap ├── test_call_parentheses.rs ├── test_editorconfig.rs ├── test_hint_syntax_config.rs ├── test_no_call_parens.rs ├── test_quote_style.rs ├── test_ranges.rs ├── test_spaces_after_function_names.rs └── tests.rs └── wasm ├── .gitignore ├── build-wasm.sh ├── package.json ├── src └── stylua_lib_node.cjs ├── stylua_lib.d.cts ├── stylua_lib.d.mts ├── stylua_lib.mjs ├── stylua_lib_bundler.d.ts ├── stylua_lib_bundler.js └── stylua_lib_bundler_wbg.cjs /.editorconfig: -------------------------------------------------------------------------------- 1 | root = true 2 | 3 | [*] 4 | end_of_line = lf 5 | charset = utf-8 6 | trim_trailing_whitespace = true 7 | insert_final_newline = true 8 | 9 | [*.{rs,toml}] 10 | indent_style = space 11 | indent_size = 4 12 | 13 | [*.lua] 14 | indent_style = tab 15 | indent_size = 4 16 | 17 | [*.{md,markdown}] 18 | indent_style = space 19 | indent_size = 2 20 | 21 | [*.{yaml,yml}] 22 | indent_style = space 23 | indent_size = 2 24 | -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | * text=auto 2 | *.lua text eol=lf 3 | tests/inputs/* linguist-vendored 4 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | /target -------------------------------------------------------------------------------- /.vscode/extensions.json: -------------------------------------------------------------------------------- 1 | { 2 | // See http://go.microsoft.com/fwlink/?LinkId=827846 3 | // for the documentation about the extensions.json format 4 | "recommendations": ["dbaeumer.vscode-eslint", "amodio.tsl-problem-matcher"] 5 | } 6 | -------------------------------------------------------------------------------- /Dockerfile: -------------------------------------------------------------------------------- 1 | FROM rust:1.78 AS build 2 | ARG CARGO_FLAGS="--all-features --release" 3 | 4 | WORKDIR /app 5 | COPY . ./ 6 | RUN cargo build ${CARGO_FLAGS} 7 | 8 | FROM gcr.io/distroless/cc 9 | COPY --from=build /app/target/release/stylua / 10 | CMD ["./stylua"] 11 | -------------------------------------------------------------------------------- /stylua-npm-bin/.gitignore: -------------------------------------------------------------------------------- 1 | node_modules/ 2 | bin/ 3 | -------------------------------------------------------------------------------- /stylua-npm-bin/install.js: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env node 2 | 3 | const { install } = require("./binary"); 4 | install(); 5 | -------------------------------------------------------------------------------- /stylua-npm-bin/run.js: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env node 2 | 3 | const { run } = require("./binary"); 4 | run(); 5 | -------------------------------------------------------------------------------- /stylua-npm-bin/uninstall.js: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env node 2 | 3 | const { uninstall } = require("./binary"); 4 | uninstall(); 5 | -------------------------------------------------------------------------------- /stylua-vscode/.editorconfig: -------------------------------------------------------------------------------- 1 | [*.{js,ts}] 2 | indent_style = space 3 | indent_size = 2 4 | 5 | [*.json] 6 | indent_style = space 7 | indent_size = 2 8 | -------------------------------------------------------------------------------- /stylua-vscode/.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | npm-debug.log 3 | Thumbs.db 4 | node_modules/ 5 | out/ 6 | dist/ 7 | .vscode-test/ 8 | -------------------------------------------------------------------------------- /stylua-vscode/.vscode-test.js: -------------------------------------------------------------------------------- 1 | // .vscode-test.js 2 | const { defineConfig } = require("@vscode/test-cli"); 3 | 4 | module.exports = defineConfig({ files: "out/test/**/*.test.js" }); 5 | -------------------------------------------------------------------------------- /stylua-vscode/.vscodeignore: -------------------------------------------------------------------------------- 1 | .vscode/** 2 | .vscode-test/** 3 | out/** 4 | node_modules/** 5 | src/** 6 | .gitignore 7 | .yarnrc 8 | webpack.config.js 9 | vsc-extension-quickstart.md 10 | **/tsconfig.json 11 | **/.eslintrc.json 12 | **/*.map 13 | **/*.ts 14 | -------------------------------------------------------------------------------- /stylua-vscode/assets/icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JohnnyMorganz/StyLua/145a7c3822754cccde80f9006e82ffc21650d02b/stylua-vscode/assets/icon.png -------------------------------------------------------------------------------- /test/example/test.luau: -------------------------------------------------------------------------------- 1 | local types = require("shared/types") 2 | 3 | local function Area() end 4 | 5 | local z = [==[testing]==] 6 | 7 | return { 8 | Area { 9 | act = {}, 10 | name = "", 11 | description = "", 12 | }, 13 | } 14 | -------------------------------------------------------------------------------- /tests/inputs-cfxlua/addition_assignment_operator.lua: -------------------------------------------------------------------------------- 1 | local index = 1 2 | 3 | index += 1 -------------------------------------------------------------------------------- /tests/inputs-cfxlua/ampersand_equal.lua: -------------------------------------------------------------------------------- 1 | local num = 6 2 | num &= 3 -------------------------------------------------------------------------------- /tests/inputs-cfxlua/bitwise_xor_assignment_operator.lua: -------------------------------------------------------------------------------- 1 | local num = 5 2 | num ^= 3 -------------------------------------------------------------------------------- /tests/inputs-cfxlua/c_style_comments.lua: -------------------------------------------------------------------------------- 1 | print("Hello, World!") /* Comment */ 2 | /* 3 | Multi 4 | Line 5 | Comment 6 | */ -------------------------------------------------------------------------------- /tests/inputs-cfxlua/compile_time_jenkins_hashes.lua: -------------------------------------------------------------------------------- 1 | print(`Hello, World!`) 2 | -------------------------------------------------------------------------------- /tests/inputs-cfxlua/division_assignment_operator.lua: -------------------------------------------------------------------------------- 1 | local num = 10 2 | num /= 2 -------------------------------------------------------------------------------- /tests/inputs-cfxlua/double_greater_than_equal.lua: -------------------------------------------------------------------------------- 1 | local num = 4 2 | num >>= 2 -------------------------------------------------------------------------------- /tests/inputs-cfxlua/double_less_than_equal.lua: -------------------------------------------------------------------------------- 1 | local num = 1 2 | num <<= 2 3 | -------------------------------------------------------------------------------- /tests/inputs-cfxlua/each_iteration.lua: -------------------------------------------------------------------------------- 1 | local t = { 1, 2, 3 } 2 | for k, v in each(t) do print(k, v) end 3 | -------------------------------------------------------------------------------- /tests/inputs-cfxlua/in_unpacking.lua: -------------------------------------------------------------------------------- 1 | local t = { 2 | a = 1, 3 | b = 2, 4 | c = 3 5 | } 6 | 7 | local a, b, c in t -------------------------------------------------------------------------------- /tests/inputs-cfxlua/multiplication_assignment_operator.lua: -------------------------------------------------------------------------------- 1 | local base = 10 2 | base *= 2 3 | -------------------------------------------------------------------------------- /tests/inputs-cfxlua/pipe_equal.lua: -------------------------------------------------------------------------------- 1 | local num = 4 2 | num |= 1 3 | -------------------------------------------------------------------------------- /tests/inputs-cfxlua/question_mark_dot.lua: -------------------------------------------------------------------------------- 1 | local a = { 2 | b = 1, 3 | c = 2, 4 | d = { 5 | e = 3 6 | } 7 | } 8 | 9 | local x = a?.b 10 | local y = a?.d?.e 11 | -------------------------------------------------------------------------------- /tests/inputs-cfxlua/set_constructor.lua: -------------------------------------------------------------------------------- 1 | t = { .a, b = false } 2 | -------------------------------------------------------------------------------- /tests/inputs-cfxlua/subtraction_assignment_operator.lua: -------------------------------------------------------------------------------- 1 | local ten = 10 2 | ten -= 5 3 | -------------------------------------------------------------------------------- /tests/inputs-collapse-single-statement/complex-conditional-1.lua: -------------------------------------------------------------------------------- 1 | if child == nil then 2 | child, index = index, #self + 1 3 | end 4 | -------------------------------------------------------------------------------- /tests/inputs-collapse-single-statement/complex-return-1.lua: -------------------------------------------------------------------------------- 1 | local x = function(body, opts) 2 | return { 3 | top = body.top - 1, 4 | bottom = body.bottom + 1, 5 | indent = math.max(H.get_line_indent(body.top - 1, opts), H.get_line_indent(body.bottom + 1, opts)), 6 | } 7 | end 8 | -------------------------------------------------------------------------------- /tests/inputs-collapse-single-statement/complex-return-2.lua: -------------------------------------------------------------------------------- 1 | function H.is_item(x) 2 | return type(x) == 'table' 3 | and H.is_fun_or_string(x['action'], false) 4 | and type(x['name']) == 'string' 5 | and type(x['section']) == 'string' 6 | end 7 | -------------------------------------------------------------------------------- /tests/inputs-collapse-single-statement/complex-return-3.lua: -------------------------------------------------------------------------------- 1 | function H.get_unsaved_listed_buffers() 2 | return vim.tbl_filter(function(buf_id) 3 | return vim.api.nvim_buf_get_option(buf_id, 'modified') and vim.api.nvim_buf_get_option(buf_id, 'buflisted') 4 | end, vim.api.nvim_list_bufs()) 5 | end 6 | -------------------------------------------------------------------------------- /tests/inputs-collapse-single-statement/complex-return-4.lua: -------------------------------------------------------------------------------- 1 | local erroring = function(x) 2 | return function() 3 | error(x, 0) 4 | end 5 | end 6 | -------------------------------------------------------------------------------- /tests/inputs-collapse-single-statement/conditional-with-function-1.lua: -------------------------------------------------------------------------------- 1 | -- https://github.com/JohnnyMorganz/StyLua/issues/898 2 | 3 | if bar then 4 | return function() 5 | foo() 6 | end 7 | end 8 | 9 | if bar then 10 | return Array.filter({}, function() 11 | return true 12 | end) 13 | end 14 | -------------------------------------------------------------------------------- /tests/inputs-collapse-single-statement/nested-functions.lua: -------------------------------------------------------------------------------- 1 | local get_match = function(hl_group) 2 | return vim.tbl_filter(function(x) 3 | return x.group == hl_group 4 | end, child.fn.getmatches()) 5 | end 6 | -------------------------------------------------------------------------------- /tests/inputs-collapse-single-statement/over-column-width-2.lua: -------------------------------------------------------------------------------- 1 | T['stat_summary()']['works'] = function() 2 | eq(stat_summary(10, 4, 3, 2, 1), { minimum = 1, mean = 4, median = 3, maximum = 10, n = 5, sd = math.sqrt(50 / 4) }) 3 | end 4 | -------------------------------------------------------------------------------- /tests/inputs-collapse-single-statement/over-column-width-3.lua: -------------------------------------------------------------------------------- 1 | -- https://github.com/JohnnyMorganz/StyLua/issues/619 2 | local a = { 3 | aa = function() return "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" end, 4 | } 5 | -------------------------------------------------------------------------------- /tests/inputs-collapse-single-statement/over-column-width-4.lua: -------------------------------------------------------------------------------- 1 | -- https://github.com/JohnnyMorganz/StyLua/issues/704 2 | vim.api.nvim_create_user_command('F', function(options) require('greeeeeeeeeeeeeeeeeeeeep').by_fixed(options.args) end, { 3 | nargs = '+', 4 | complete = 'file', 5 | }) 6 | -------------------------------------------------------------------------------- /tests/inputs-collapse-single-statement/over-column-width.lua: -------------------------------------------------------------------------------- 1 | function MiniCompletion.default_process_items(items, base) 2 | return H.default_config.lsp_completion.process_items(items, base) 3 | end 4 | -------------------------------------------------------------------------------- /tests/inputs-collapse-single-statement/simple-conditional-1.lua: -------------------------------------------------------------------------------- 1 | if x == true then 2 | return 3 | end 4 | -------------------------------------------------------------------------------- /tests/inputs-collapse-single-statement/simple-conditional-2.lua: -------------------------------------------------------------------------------- 1 | -- https://github.com/JohnnyMorganz/StyLua/issues/744 2 | 3 | if tabnr ~= finaltab then 4 | 5 | stack:push('%T') 6 | end 7 | -------------------------------------------------------------------------------- /tests/inputs-collapse-single-statement/simple-conditional-indentation.lua: -------------------------------------------------------------------------------- 1 | for i = 1, 10 do 2 | if true then 3 | return 4 | end 5 | end 6 | -------------------------------------------------------------------------------- /tests/inputs-collapse-single-statement/simple-conditional-over-width.lua: -------------------------------------------------------------------------------- 1 | if thisIsAVeryLongConditionthisIsAVeryLongConditionThisIsAVeryLongCondition then 2 | return thisIsAVeryLongReturnedExpression 3 | end 4 | -------------------------------------------------------------------------------- /tests/inputs-collapse-single-statement/simple-conditional-stmt-block-1.lua: -------------------------------------------------------------------------------- 1 | if true then 2 | call("hello") 3 | end 4 | -------------------------------------------------------------------------------- /tests/inputs-collapse-single-statement/simple-function-argument-1.lua: -------------------------------------------------------------------------------- 1 | local comment_parts = vim.tbl_filter(function(x) 2 | return x ~= '' 3 | end, vim.split(commentstring, '%s', true)) 4 | -------------------------------------------------------------------------------- /tests/inputs-collapse-single-statement/simple-function-argument-2.lua: -------------------------------------------------------------------------------- 1 | Helpers.expect.match = MiniTest.new_expectation('string matching', function(str, pattern) 2 | return str:find(pattern) ~= nil 3 | end, function(str, pattern) 4 | return string.format('Pattern: %s\nObserved string: %s', vim.inspect(pattern), str) 5 | end) 6 | -------------------------------------------------------------------------------- /tests/inputs-collapse-single-statement/simple-function-argument-3.lua: -------------------------------------------------------------------------------- 1 | local _, tag_section = toc_entry.parent:has_descendant(function(x) 2 | return type(x) == 'table' and x.type == 'section' and x.info.id == '@tag' 3 | end) 4 | -------------------------------------------------------------------------------- /tests/inputs-collapse-single-statement/simple-function-stmt-block-1.lua: -------------------------------------------------------------------------------- 1 | local x = function() 2 | call("testing") 3 | end 4 | -------------------------------------------------------------------------------- /tests/inputs-collapse-single-statement/simple-function-stmt-block-2.lua: -------------------------------------------------------------------------------- 1 | local x = function() 2 | x = 1 3 | end 4 | -------------------------------------------------------------------------------- /tests/inputs-collapse-single-statement/simple-function-stmt-block-3.lua: -------------------------------------------------------------------------------- 1 | local x = function() 2 | local x = 1 3 | end 4 | -------------------------------------------------------------------------------- /tests/inputs-collapse-single-statement/simple-function.lua: -------------------------------------------------------------------------------- 1 | function foo() 2 | return bar 3 | end 4 | 5 | -------------------------------------------------------------------------------- /tests/inputs-editorconfig/.editorconfig: -------------------------------------------------------------------------------- 1 | root = true 2 | 3 | [*] 4 | indent_style = space 5 | indent_size = 2 6 | 7 | [global/tab-single.lua] 8 | indent_style = tab 9 | quote_type = single 10 | -------------------------------------------------------------------------------- /tests/inputs-editorconfig/empty-root/.editorconfig: -------------------------------------------------------------------------------- 1 | root = true 2 | -------------------------------------------------------------------------------- /tests/inputs-editorconfig/empty-root/tab-double.lua: -------------------------------------------------------------------------------- 1 | local foo = { 2 | a = 1, 3 | } 4 | 5 | local bar = "" 6 | -------------------------------------------------------------------------------- /tests/inputs-editorconfig/global/tab-single.lua: -------------------------------------------------------------------------------- 1 | local foo = { 2 | a = 1, 3 | } 4 | 5 | local bar = "" 6 | -------------------------------------------------------------------------------- /tests/inputs-editorconfig/local/.editorconfig: -------------------------------------------------------------------------------- 1 | [*.lua] 2 | indent_style = Space 3 | indent_size = 4 4 | -------------------------------------------------------------------------------- /tests/inputs-editorconfig/local/space-4.lua: -------------------------------------------------------------------------------- 1 | local foo = { 2 | a = 1, 3 | } 4 | 5 | local bar = "" 6 | -------------------------------------------------------------------------------- /tests/inputs-editorconfig/space-2.lua: -------------------------------------------------------------------------------- 1 | local foo = { 2 | a = 1, 3 | } 4 | 5 | local bar = "" 6 | -------------------------------------------------------------------------------- /tests/inputs-editorconfig/stylua-toml/.editorconfig: -------------------------------------------------------------------------------- 1 | [*.lua] 2 | indent_style = tab 3 | quote_type = double 4 | -------------------------------------------------------------------------------- /tests/inputs-editorconfig/stylua-toml/single-space-8.lua: -------------------------------------------------------------------------------- 1 | local foo = { 2 | a = 1, 3 | } 4 | 5 | local bar = "" 6 | -------------------------------------------------------------------------------- /tests/inputs-editorconfig/stylua-toml/stylua.toml: -------------------------------------------------------------------------------- 1 | indent_type = "Spaces" 2 | indent_width = 8 3 | quote_style = "AutoPreferSingle" 4 | -------------------------------------------------------------------------------- /tests/inputs-full_moon/anonymous-functions-1.lua: -------------------------------------------------------------------------------- 1 | local x = function() 2 | call(1) 3 | end 4 | -------------------------------------------------------------------------------- /tests/inputs-full_moon/anonymous-functions-2.lua: -------------------------------------------------------------------------------- 1 | call(function() 2 | foo("bar") 3 | end) -------------------------------------------------------------------------------- /tests/inputs-full_moon/anonymous-functions-3.lua: -------------------------------------------------------------------------------- 1 | local x = function(...) end -------------------------------------------------------------------------------- /tests/inputs-full_moon/anonymous-functions-4.lua: -------------------------------------------------------------------------------- 1 | local x = function(a, b, ...) end -------------------------------------------------------------------------------- /tests/inputs-full_moon/assignment-1.lua: -------------------------------------------------------------------------------- 1 | x = 1 -------------------------------------------------------------------------------- /tests/inputs-full_moon/assignment-2.lua: -------------------------------------------------------------------------------- 1 | a, b = 1, true -------------------------------------------------------------------------------- /tests/inputs-full_moon/assignment-3.lua: -------------------------------------------------------------------------------- 1 | -- Crazy assignment code from AmaranthineCodices 2 | a, b, c.d.e[f][g][1], h:i().j[k]:l()[m] = true, false, 1, 4 -------------------------------------------------------------------------------- /tests/inputs-full_moon/assignment-4.lua: -------------------------------------------------------------------------------- 1 | a = 1 2 | b = 2 3 | -------------------------------------------------------------------------------- /tests/inputs-full_moon/assignment-5.lua: -------------------------------------------------------------------------------- 1 | gui.Label.Text = "LOADING DATA" .. ("."):rep(dotCount) 2 | -------------------------------------------------------------------------------- /tests/inputs-full_moon/binops.lua: -------------------------------------------------------------------------------- 1 | a = foo and bar 2 | b = foo and bar or baz 3 | c = 1 + 2 * 3 - 4 ^ 2 4 | d = a + i < b / 2 + 1 5 | e = 5 + x ^ 2 * 8 6 | f = a < y and y <= z 7 | g = -x ^ 2 8 | h = x ^ y ^ z -------------------------------------------------------------------------------- /tests/inputs-full_moon/body-with-spaces.lua: -------------------------------------------------------------------------------- 1 | do 2 | 3 | end -------------------------------------------------------------------------------- /tests/inputs-full_moon/call-1.lua: -------------------------------------------------------------------------------- 1 | call() 2 | call(1) 3 | call(1, 2) -------------------------------------------------------------------------------- /tests/inputs-full_moon/call-2.lua: -------------------------------------------------------------------------------- 1 | x.y("a") 2 | x:y("b") -------------------------------------------------------------------------------- /tests/inputs-full_moon/do.lua: -------------------------------------------------------------------------------- 1 | do 2 | call() 3 | end -------------------------------------------------------------------------------- /tests/inputs-full_moon/empty.lua: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JohnnyMorganz/StyLua/145a7c3822754cccde80f9006e82ffc21650d02b/tests/inputs-full_moon/empty.lua -------------------------------------------------------------------------------- /tests/inputs-full_moon/exponents.lua: -------------------------------------------------------------------------------- 1 | local num = 1e5 2 | local num2 = 1e-5 3 | local num3 = 1e+5 -------------------------------------------------------------------------------- /tests/inputs-full_moon/fractional-numbers.lua: -------------------------------------------------------------------------------- 1 | local num = 0.5 2 | local num2 = 0.5e5 3 | local num3 = .5 4 | local num4 = .5e5 5 | local num5 = 1. 6 | -------------------------------------------------------------------------------- /tests/inputs-full_moon/function-declaration-1.lua: -------------------------------------------------------------------------------- 1 | function x() 2 | call() 3 | end -------------------------------------------------------------------------------- /tests/inputs-full_moon/function-declaration-2.lua: -------------------------------------------------------------------------------- 1 | function x.y:z() end -------------------------------------------------------------------------------- /tests/inputs-full_moon/function-shortcuts.lua: -------------------------------------------------------------------------------- 1 | call { x = 1 } 2 | call "hello" -------------------------------------------------------------------------------- /tests/inputs-full_moon/generic-for-loop-1.lua: -------------------------------------------------------------------------------- 1 | for index, value in pairs(list) do 2 | call(index, value) 3 | end -------------------------------------------------------------------------------- /tests/inputs-full_moon/generic-for-loop-2.lua: -------------------------------------------------------------------------------- 1 | for index, value in next, list do 2 | call(index, value) 3 | end -------------------------------------------------------------------------------- /tests/inputs-full_moon/goto-as-identifier.lua: -------------------------------------------------------------------------------- 1 | -- goto as an identifier is permitted in lua 5.1 2 | self.goto("foo") -------------------------------------------------------------------------------- /tests/inputs-full_moon/gt-lt.lua: -------------------------------------------------------------------------------- 1 | call(1 < 2) 2 | call(1 <= 2) 3 | call(2 > 1) 4 | call(2 >= 1) 5 | call(x >= y) -------------------------------------------------------------------------------- /tests/inputs-full_moon/if-1.lua: -------------------------------------------------------------------------------- 1 | if x then 2 | call() 3 | end -------------------------------------------------------------------------------- /tests/inputs-full_moon/if-2.lua: -------------------------------------------------------------------------------- 1 | if x then 2 | foo() 3 | else 4 | bar() 5 | end -------------------------------------------------------------------------------- /tests/inputs-full_moon/if-3.lua: -------------------------------------------------------------------------------- 1 | if x then 2 | foo() 3 | elseif y then 4 | bar() 5 | end -------------------------------------------------------------------------------- /tests/inputs-full_moon/if-4.lua: -------------------------------------------------------------------------------- 1 | if x then 2 | foo() 3 | elseif y then 4 | bar() 5 | else 6 | baz() 7 | end -------------------------------------------------------------------------------- /tests/inputs-full_moon/index-1.lua: -------------------------------------------------------------------------------- 1 | local x = a.b.c -------------------------------------------------------------------------------- /tests/inputs-full_moon/index-2.lua: -------------------------------------------------------------------------------- 1 | local x = call("a").b -------------------------------------------------------------------------------- /tests/inputs-full_moon/local-assignment-1.lua: -------------------------------------------------------------------------------- 1 | local x -------------------------------------------------------------------------------- /tests/inputs-full_moon/local-assignment-2.lua: -------------------------------------------------------------------------------- 1 | local x = 1 -------------------------------------------------------------------------------- /tests/inputs-full_moon/local-assignment-3.lua: -------------------------------------------------------------------------------- 1 | local a, b = 1, 2 2 | local c, d = 3, 4 3 | local e, f = 5, 6 -------------------------------------------------------------------------------- /tests/inputs-full_moon/local-assignment-4.lua: -------------------------------------------------------------------------------- 1 | local x, y -------------------------------------------------------------------------------- /tests/inputs-full_moon/local-assignment-5.lua: -------------------------------------------------------------------------------- 1 | local x = 1 2 | -- Then a comment 3 | local y = 1 4 | -------------------------------------------------------------------------------- /tests/inputs-full_moon/local-function-1.lua: -------------------------------------------------------------------------------- 1 | local function x() 2 | call(1) 3 | end 4 | -------------------------------------------------------------------------------- /tests/inputs-full_moon/local-function-2.lua: -------------------------------------------------------------------------------- 1 | local function foo(a, b) end 2 | local function bar(...) end 3 | local function baz(a, b, ...) end -------------------------------------------------------------------------------- /tests/inputs-full_moon/mixed-indented-comments.lua: -------------------------------------------------------------------------------- 1 | -- Indented single line 2 | --[[ 3 | Indented multi line 4 | ]] -------------------------------------------------------------------------------- /tests/inputs-full_moon/multi-line-comments-1.lua: -------------------------------------------------------------------------------- 1 | --[[ 2 | such comments 3 | much lines 4 | wow 5 | ]] -------------------------------------------------------------------------------- /tests/inputs-full_moon/multi-line-comments-2.lua: -------------------------------------------------------------------------------- 1 | --[=[ 2 | never have i used these weird equals signs comments 3 | but im sure someone does 4 | ]=] -------------------------------------------------------------------------------- /tests/inputs-full_moon/multi-line-comments-3.lua: -------------------------------------------------------------------------------- 1 | --[=[ 2 | --[[ 3 | ]=] -------------------------------------------------------------------------------- /tests/inputs-full_moon/multi-line-comments-4.lua: -------------------------------------------------------------------------------- 1 | --[=====[ 2 | lua be like 3 | ]====] 4 | still going 5 | ]=====] -------------------------------------------------------------------------------- /tests/inputs-full_moon/multi-line-comments-5.lua: -------------------------------------------------------------------------------- 1 | --[[ 2 | local emotes = { 3 | [":thinking:"] = "http://www.roblox.com/asset/?id=643340245", 4 | [":bug:"] = "http://www.roblox.com/asset/?id=860037275" 5 | } 6 | ]] -------------------------------------------------------------------------------- /tests/inputs-full_moon/multi-line-comments-6.lua: -------------------------------------------------------------------------------- 1 | local function x(...--[[comment here]]) 2 | end -------------------------------------------------------------------------------- /tests/inputs-full_moon/multi-line-comments-7.lua: -------------------------------------------------------------------------------- 1 | --[=[ μέλλον ]=] 2 | 3 | -- some text here 4 | -------------------------------------------------------------------------------- /tests/inputs-full_moon/multi-line-comments-8.lua: -------------------------------------------------------------------------------- 1 | --[[👨🏾‍💻]] 2 | local more_code = here 3 | -------------------------------------------------------------------------------- /tests/inputs-full_moon/multi-line-comments-9.lua: -------------------------------------------------------------------------------- 1 | --[=[ 2 | 3 | This description starts one line down, 4 | 5 | And has a line in the middle, followed by trailing lines. 6 | 7 | ```lua 8 | function test() 9 | print("indentation") 10 | 11 | do 12 | print("more indented") 13 | end 14 | end 15 | ``` 16 | 17 | 18 | @class indentation 19 | 20 | 21 | ]=] -------------------------------------------------------------------------------- /tests/inputs-full_moon/multi-line-string-1.lua: -------------------------------------------------------------------------------- 1 | local x = [[Full Moon 2 | is a 3 | lossless 4 | Lua parser]] -------------------------------------------------------------------------------- /tests/inputs-full_moon/multi-line-string-2.lua: -------------------------------------------------------------------------------- 1 | local x = [=[This is 2 | several equal 3 | signs]=] -------------------------------------------------------------------------------- /tests/inputs-full_moon/multi-line-string-3.lua: -------------------------------------------------------------------------------- 1 | local x = [[ 2 | local emotes = { 3 | [":thinking:"] = "http://www.roblox.com/asset/?id=643340245", 4 | [":bug:"] = "http://www.roblox.com/asset/?id=860037275" 5 | } 6 | ]] -------------------------------------------------------------------------------- /tests/inputs-full_moon/multi-line-string-4.lua: -------------------------------------------------------------------------------- 1 | call([[doge]]) -------------------------------------------------------------------------------- /tests/inputs-full_moon/multi-line-string-5.lua: -------------------------------------------------------------------------------- 1 | local emoji = [[🧓🏽]] 2 | local more_code = here 3 | -------------------------------------------------------------------------------- /tests/inputs-full_moon/multi-line-string-6.lua: -------------------------------------------------------------------------------- 1 | local foo = "bar\ 2 | baz" 3 | -------------------------------------------------------------------------------- /tests/inputs-full_moon/multi-line-string-7.lua: -------------------------------------------------------------------------------- 1 | local a = [=[[%s]]=] -------------------------------------------------------------------------------- /tests/inputs-full_moon/multi-line-string-8.lua: -------------------------------------------------------------------------------- 1 | local x = [=[\v<((do|load)file|require)\s*\(?['"]\zs[^'"]+\ze['"]]=] -------------------------------------------------------------------------------- /tests/inputs-full_moon/negative-numbers.lua: -------------------------------------------------------------------------------- 1 | local foo = x-1 2 | local foo = x -1 3 | print(1+-3) 4 | local foo = -x+1 -------------------------------------------------------------------------------- /tests/inputs-full_moon/numbers-1.lua: -------------------------------------------------------------------------------- 1 | _ = 0x02 2 | -------------------------------------------------------------------------------- /tests/inputs-full_moon/numeric-for-loop.lua: -------------------------------------------------------------------------------- 1 | for index = 1, 10 do call(index) end 2 | for _ = start, final do end 3 | for _ = 1, 10, 2 do end -------------------------------------------------------------------------------- /tests/inputs-full_moon/paren-expressions.lua: -------------------------------------------------------------------------------- 1 | local x = 1 + (2 - 3) -------------------------------------------------------------------------------- /tests/inputs-full_moon/repeat-until.lua: -------------------------------------------------------------------------------- 1 | repeat 2 | call() 3 | until condition -------------------------------------------------------------------------------- /tests/inputs-full_moon/return-break.lua: -------------------------------------------------------------------------------- 1 | do 2 | return 1 3 | end 4 | 5 | do 6 | break 7 | end 8 | 9 | return call() 10 | -------------------------------------------------------------------------------- /tests/inputs-full_moon/semicolons-1.lua: -------------------------------------------------------------------------------- 1 | local x = 1; x = x + 1 -------------------------------------------------------------------------------- /tests/inputs-full_moon/semicolons-2.lua: -------------------------------------------------------------------------------- 1 | local x = 1 2 | return x; -------------------------------------------------------------------------------- /tests/inputs-full_moon/shebang.lua: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env lua 2 | 3 | print("Hello world"); 4 | -------------------------------------------------------------------------------- /tests/inputs-full_moon/single-line-comment-1.lua: -------------------------------------------------------------------------------- 1 | -- hello world 2 | -- and doge you too -------------------------------------------------------------------------------- /tests/inputs-full_moon/single-line-comment-2.lua: -------------------------------------------------------------------------------- 1 | call() -- This calls -------------------------------------------------------------------------------- /tests/inputs-full_moon/single-line-comment-3.lua: -------------------------------------------------------------------------------- 1 | -- tab in comment -------------------------------------------------------------------------------- /tests/inputs-full_moon/single-line-comment-4.lua: -------------------------------------------------------------------------------- 1 | --[comment 2 | --(comment) 3 | --[=comment 4 | -- 5 | -------------------------------------------------------------------------------- /tests/inputs-full_moon/single-line-comment-5.lua: -------------------------------------------------------------------------------- 1 | --`signatures` the value defaults to zero or is ignored if `signatures.length 2 | --=== 0`. Whenever possible implementors should make an active decision about -------------------------------------------------------------------------------- /tests/inputs-full_moon/single-line-comment-6.lua: -------------------------------------------------------------------------------- 1 | --随便写点中文 2 | -------------------------------------------------------------------------------- /tests/inputs-full_moon/single-line-comment-7.lua: -------------------------------------------------------------------------------- 1 | local a = 1 2 | 3 | --}}封装方便访问的接口========================================== -------------------------------------------------------------------------------- /tests/inputs-full_moon/strings-escape-newline.lua: -------------------------------------------------------------------------------- 1 | print("foo\ 2 | bar") 3 | -------------------------------------------------------------------------------- /tests/inputs-full_moon/strings-escape.lua: -------------------------------------------------------------------------------- 1 | call('\\') 2 | call("\\") 3 | call({ ["\\"] = "" }) -------------------------------------------------------------------------------- /tests/inputs-full_moon/strings.lua: -------------------------------------------------------------------------------- 1 | call("double") 2 | call('single') 3 | call("foo\nbar") 4 | call("") -------------------------------------------------------------------------------- /tests/inputs-full_moon/table-constructor-1.lua: -------------------------------------------------------------------------------- 1 | local x = { 2 | } -------------------------------------------------------------------------------- /tests/inputs-full_moon/table-constructor-2.lua: -------------------------------------------------------------------------------- 1 | local x = {1, 2, 3} -------------------------------------------------------------------------------- /tests/inputs-full_moon/table-constructor-3.lua: -------------------------------------------------------------------------------- 1 | local x = { 2 | a = 1, 3 | b = 2, 4 | c = 3 5 | } 6 | 7 | local y = { 8 | a = 1, 9 | b = 2, 10 | c = 3, 11 | } -------------------------------------------------------------------------------- /tests/inputs-full_moon/table-constructor-4.lua: -------------------------------------------------------------------------------- 1 | local x = { 2 | [call()] = 1, 3 | } -------------------------------------------------------------------------------- /tests/inputs-full_moon/table-constructor-5.lua: -------------------------------------------------------------------------------- 1 | local x = { 2 | [call()] = 1, 3 | 2, 4 | } -------------------------------------------------------------------------------- /tests/inputs-full_moon/table-constructor-6.lua: -------------------------------------------------------------------------------- 1 | local foo = { bar } -------------------------------------------------------------------------------- /tests/inputs-full_moon/table-constructors-7.lua: -------------------------------------------------------------------------------- 1 | local blacklist = { 2 | ["Audio file failed to load (18)."] = true; 3 | ["HTTP 0 (HTTP 429 (HTTP/1.1 429 ProvisionedThroughputExceeded))"] = true; 4 | ["LoadCharacter can only be called when Player is in the world"] = true; 5 | } -------------------------------------------------------------------------------- /tests/inputs-full_moon/table-constructors-8.lua: -------------------------------------------------------------------------------- 1 | return { 2 | ["Noob Attack: Periastron"] = "Noob Attack - Periastron"; 3 | ["Noob Attack꞉ Periastron"] = "Noob Attack - Periastron"; 4 | } 5 | -------------------------------------------------------------------------------- /tests/inputs-full_moon/table-constructors-9.lua: -------------------------------------------------------------------------------- 1 | -- comments separated by tab chars, should be parsed as trailing trivia of the tokens they are next to 2 | -- stylua: ignore 3 | local too = { 4 | x, -- string 5 | y, -- string 6 | } 7 | -------------------------------------------------------------------------------- /tests/inputs-full_moon/trivia-parsing.lua: -------------------------------------------------------------------------------- 1 | local foo = bar -- trailing comment 2 | 3 | -- leading comment 4 | local bar = baz 5 | local baz = foo 6 | 7 | do 8 | local foo = bar 9 | -- comment 10 | local bar = baz 11 | end -------------------------------------------------------------------------------- /tests/inputs-full_moon/unops.lua: -------------------------------------------------------------------------------- 1 | local negativeLiteral = -3 2 | local negativeVariable = -x 3 | local notLiteral = not true 4 | local notVariable = not x 5 | local length = #x -------------------------------------------------------------------------------- /tests/inputs-full_moon/utf-8.lua: -------------------------------------------------------------------------------- 1 | print("👚 " .. message) -------------------------------------------------------------------------------- /tests/inputs-full_moon/while.lua: -------------------------------------------------------------------------------- 1 | while condition do 2 | call() 3 | break 4 | end -------------------------------------------------------------------------------- /tests/inputs-ignore/ignore-table-field.lua: -------------------------------------------------------------------------------- 1 | local foo = { 2 | -- stylua: ignore 3 | x = 2, 4 | y = 3, 5 | z = " he " , 6 | } 7 | 8 | local bar = { 9 | x = 2, 10 | -- stylua: ignore 11 | y = 3, 12 | z = " he " , 13 | } 14 | 15 | local baz = { 16 | x = 2, 17 | y = 3, 18 | -- stylua: ignore 19 | z = " he " , 20 | } 21 | -------------------------------------------------------------------------------- /tests/inputs-ignore/multiline-block-ignore-1.lua: -------------------------------------------------------------------------------- 1 | local foo = bar 2 | -- stylua: ignore start 3 | local bar = baz 4 | -- stylua: ignore end 5 | local bar = baz 6 | -------------------------------------------------------------------------------- /tests/inputs-ignore/multiline-block-ignore-2.lua: -------------------------------------------------------------------------------- 1 | local foo = bar 2 | -- stylua: ignore start 3 | local bar = baz 4 | local bar = baz 5 | -- stylua: ignore end 6 | local bar = baz 7 | -------------------------------------------------------------------------------- /tests/inputs-ignore/multiline-block-ignore-multiple-comments-leading-trivia.lua: -------------------------------------------------------------------------------- 1 | --stylua: ignore start 2 | local a = 1 3 | --stylua: ignore end 4 | 5 | --stylua: ignore start 6 | local b = 2 7 | --stylua: ignore end 8 | 9 | --stylua: ignore start 10 | local c = 3 11 | --stylua: ignore end 12 | 13 | -- Some very large comment 14 | 15 | --stylua: ignore start 16 | local d = 4 17 | --stylua: ignore end 18 | -------------------------------------------------------------------------------- /tests/inputs-ignore/multiline-block-ignore-no-ending.lua: -------------------------------------------------------------------------------- 1 | local foo = bar 2 | -- stylua: ignore start 3 | local bar = baz 4 | local bar = baz 5 | local bar = baz 6 | -------------------------------------------------------------------------------- /tests/inputs-ignore/multiline-block-ignore-no-starting.lua: -------------------------------------------------------------------------------- 1 | local foo = bar 2 | local bar = baz 3 | local bar = baz 4 | -- stylua: ignore end 5 | local bar = baz 6 | -------------------------------------------------------------------------------- /tests/inputs-ignore/multiline-block-ignore-scope-no-ending.lua: -------------------------------------------------------------------------------- 1 | local foo = bar 2 | do 3 | -- stylua: ignore start 4 | local bar = baz 5 | local bar = baz 6 | end 7 | local bar = baz 8 | -------------------------------------------------------------------------------- /tests/inputs-ignore/multiline-block-ignore-scope.lua: -------------------------------------------------------------------------------- 1 | local foo = bar 2 | do 3 | -- stylua: ignore start 4 | local bar = baz 5 | -- stylua: ignore end 6 | local bar = baz 7 | end 8 | local bar = baz 9 | -------------------------------------------------------------------------------- /tests/inputs-ignore/multiline-ignore-table-field.lua: -------------------------------------------------------------------------------- 1 | -- https://github.com/JohnnyMorganz/StyLua/issues/705 2 | 3 | require("foo").bar { 4 | -- stylua: ignore start 5 | baz =0, 6 | foo = 2, 7 | -- stylua: ignore end 8 | bar = 1234 9 | } 10 | -------------------------------------------------------------------------------- /tests/inputs-ignore/singleline-ignore-1.lua: -------------------------------------------------------------------------------- 1 | local foo = bar 2 | -- stylua: ignore 3 | local bar = baz 4 | -------------------------------------------------------------------------------- /tests/inputs-ignore/singleline-ignore-2.lua: -------------------------------------------------------------------------------- 1 | local foo = bar 2 | -- stylua: ignore 3 | local bar = baz 4 | local bar = baz 5 | -------------------------------------------------------------------------------- /tests/inputs-ignore/singleline-ignore-last-stmt.lua: -------------------------------------------------------------------------------- 1 | -- stylua: ignore 2 | return "hi" 3 | -------------------------------------------------------------------------------- /tests/inputs-ignore/singleline-ignore-stmt-block.lua: -------------------------------------------------------------------------------- 1 | local x = 1 2 | -- stylua: ignore 3 | function foo () 4 | return x + 1 5 | end 6 | -------------------------------------------------------------------------------- /tests/inputs-lua52/goto-1.lua: -------------------------------------------------------------------------------- 1 | for i=1,10 do if i == 1 then goto skip end end 2 | ::skip:: -------------------------------------------------------------------------------- /tests/inputs-lua52/goto-2.lua: -------------------------------------------------------------------------------- 1 | -- http://lua-users.org/wiki/GotoStatement 2 | ::redo:: for x=1,10 do for y=1,10 do 3 | if not f(x,y) then goto continue end 4 | if not g(x,y) then goto skip end 5 | if not h(x,y) then goto redo end 6 | ::continue:: 7 | end end ::skip:: -------------------------------------------------------------------------------- /tests/inputs-lua53/binary-operators.lua: -------------------------------------------------------------------------------- 1 | local a = 1 & 2 2 | local b = 1 | 2 3 | local c = 1 << 2 4 | local d = 1 >> 2 5 | local e = 1 ~ 2 6 | local f = 1 // 2 7 | -------------------------------------------------------------------------------- /tests/inputs-lua53/unary-operators.lua: -------------------------------------------------------------------------------- 1 | local x = ~1 2 | -------------------------------------------------------------------------------- /tests/inputs-lua54/attributes-1.lua: -------------------------------------------------------------------------------- 1 | local a = 5 2 | local d 3 | local e , f = 1, 2 4 | local g , h 5 | local i , j, k 6 | -------------------------------------------------------------------------------- /tests/inputs-lua54/attributes-2.lua: -------------------------------------------------------------------------------- 1 | local a = 1 2 | -------------------------------------------------------------------------------- /tests/inputs-luau-full_moon/attributes.lua: -------------------------------------------------------------------------------- 1 | @example 2 | function foo() 3 | end 4 | 5 | @native 6 | local function bar() 7 | end 8 | 9 | local foo = @example function() end 10 | 11 | @example 12 | function foo:bar() 13 | end 14 | 15 | @attribute1 @attribute2 @attribute3 @attribute4 @attribute5 16 | local function many_attributes() 17 | end -------------------------------------------------------------------------------- /tests/inputs-luau-full_moon/compound_assignment.lua: -------------------------------------------------------------------------------- 1 | local x = 1 2 | local y = 2 3 | 4 | x += 5 5 | x -= 5 6 | x *= 5 7 | x /= 5 8 | x //= 5 9 | x %= 5 10 | x ^= 5 11 | 12 | x += y 13 | x -= y 14 | x *= y 15 | x /= y 16 | x //= y 17 | x %= y 18 | x ^= y 19 | 20 | local str1 = "Hello, " 21 | local str2 = "world!" 22 | 23 | str1 ..= "world!" 24 | str1 ..= str2 -------------------------------------------------------------------------------- /tests/inputs-luau-full_moon/continue.lua: -------------------------------------------------------------------------------- 1 | -- Very important loop here 2 | while true do 3 | continue 4 | end 5 | 6 | continue() 7 | local continue = 4 8 | -------------------------------------------------------------------------------- /tests/inputs-luau-full_moon/decimal_seperators.lua: -------------------------------------------------------------------------------- 1 | local num1 = 1_048_576 2 | local num2 = 0xFFFF_FFFF 3 | local num3 = 0b_0101_0101 4 | local num4 = 1_523_423.132_452_312 5 | local num5 = 1e512_412 6 | local num6 = 1e-512_412 -------------------------------------------------------------------------------- /tests/inputs-luau-full_moon/floor_division.lua: -------------------------------------------------------------------------------- 1 | local x = 1 // 2 2 | -------------------------------------------------------------------------------- /tests/inputs-luau-full_moon/multiline_typeof_regression.lua: -------------------------------------------------------------------------------- 1 | type TypeOf = 2 | typeof({}) 3 | -------------------------------------------------------------------------------- /tests/inputs-luau-full_moon/named_function_arg_types.lua: -------------------------------------------------------------------------------- 1 | type MyCallbackType = (cost: number, name: string) -> string 2 | 3 | local cb: (amount: number) -> number 4 | local function foo(cb: (name: string) -> ()) 5 | end 6 | 7 | local function bar(x: (number)?): (baz: string) -> string 8 | end 9 | 10 | local function bar(x: (number)?): (baz: string) -> ((names: Array) -> ...any) 11 | end -------------------------------------------------------------------------------- /tests/inputs-luau-full_moon/shorthand_array_type.lua: -------------------------------------------------------------------------------- 1 | type Array = { T } 2 | type Array = { [number]: T } -------------------------------------------------------------------------------- /tests/inputs-luau-full_moon/string_interpolation_base.lua: -------------------------------------------------------------------------------- 1 | x(`simple`) 2 | x(`hello {"world"}`) 3 | x(`1{2}3{"4"}5`) 4 | x(`1{`2{"3"}`}`) 5 | -------------------------------------------------------------------------------- /tests/inputs-luau-full_moon/string_interpolation_double_brace.lua: -------------------------------------------------------------------------------- 1 | local _ = `{ {}}` 2 | local _ = `{--[[]]{}}` 3 | local _ = `\{{true}` 4 | local _ = `{ {true}}` 5 | -- TODO: https://github.com/Roblox/luau/issues/1019 6 | -- local _ = `{ {hello}}` 7 | local _ = `\{{hello}}` -------------------------------------------------------------------------------- /tests/inputs-luau-full_moon/string_interpolation_regression.lua: -------------------------------------------------------------------------------- 1 | error( 2 | `a {b} c` 3 | ) 4 | -------------------------------------------------------------------------------- /tests/inputs-luau-full_moon/table_access_modifiers.lua: -------------------------------------------------------------------------------- 1 | type Foo = { 2 | read bar: number, 3 | write baz: number, 4 | } -------------------------------------------------------------------------------- /tests/inputs-luau-full_moon/types_chained_optionals.lua: -------------------------------------------------------------------------------- 1 | type Config = { 2 | option1: string??, -- you probably need it once in a while 3 | option2: string???, -- once a year 4 | option3: string?????? -- once in your life! 5 | } -------------------------------------------------------------------------------- /tests/inputs-luau-full_moon/types_compound_precedence.lua: -------------------------------------------------------------------------------- 1 | -- https://github.com/Kampfkarren/full-moon/issues/286 2 | 3 | -- should be parsed as a function returning a variable amount of values of type "string & T" 4 | type FnA = () -> ...string & T 5 | 6 | -- should be parsed as an intersection of a function returning U... values, and a value of type T 7 | type FnB = () -> U... & T 8 | -------------------------------------------------------------------------------- /tests/inputs-luau-full_moon/types_exported.lua: -------------------------------------------------------------------------------- 1 | type Foo = { bar: any } 2 | export type Baz = { foo: any } 3 | -------------------------------------------------------------------------------- /tests/inputs-luau-full_moon/types_function.lua: -------------------------------------------------------------------------------- 1 | type function f(...) 2 | -- implementation of the type function 3 | end 4 | 5 | export type function f(...) 6 | -- implementation of the type function 7 | end -------------------------------------------------------------------------------- /tests/inputs-luau-full_moon/types_generic.lua: -------------------------------------------------------------------------------- 1 | type Array = { T } 2 | local x: Array> 3 | -------------------------------------------------------------------------------- /tests/inputs-luau-full_moon/types_generic_declaration.lua: -------------------------------------------------------------------------------- 1 | --!strict 2 | type Foo = (U...) -> T... 3 | type Bar = nil 4 | type Function = (Args...) -> Return... 5 | type Baz = nil 6 | type Indexed = module.Indexed 7 | -------------------------------------------------------------------------------- /tests/inputs-luau-full_moon/types_generic_no_parameters.lua: -------------------------------------------------------------------------------- 1 | type Bar = Foo<> 2 | type Baz = module.Foo<> -------------------------------------------------------------------------------- /tests/inputs-luau-full_moon/types_indexable.lua: -------------------------------------------------------------------------------- 1 | local x: module.Foo = nil 2 | local x: module.Array = { "bar" } 3 | local x: module.Foo | string = "bar" 4 | local x: module.Foo? = nil 5 | local x: module.Foo<...string> = nil -------------------------------------------------------------------------------- /tests/inputs-luau-full_moon/types_loops.lua: -------------------------------------------------------------------------------- 1 | for i, v: string in pairs() do 2 | 3 | end 4 | 5 | for i: number = 1, 10, 2 do 6 | 7 | end -------------------------------------------------------------------------------- /tests/inputs-luau-full_moon/types_nested_array.lua: -------------------------------------------------------------------------------- 1 | type Foo = { { string } } 2 | type Foo = { {Name: string, Foo: number} } -------------------------------------------------------------------------------- /tests/inputs-luau-full_moon/types_semicolon_delimeter.lua: -------------------------------------------------------------------------------- 1 | type Foo = { 2 | bar: number; 3 | baz: number; 4 | } -------------------------------------------------------------------------------- /tests/inputs-luau-full_moon/z-escape-string.lua: -------------------------------------------------------------------------------- 1 | print("testing \z 2 | twelve") 3 | 4 | print("Hello \ 5 | World") 6 | 7 | print(`testing \z 8 | twelve`) 9 | 10 | print(`Hello \ 11 | World`) 12 | -------------------------------------------------------------------------------- /tests/inputs-luau/anonymous-function-types.lua: -------------------------------------------------------------------------------- 1 | local Object = {ClassName = "Object"} 2 | Object.__tostring = function(self) return self.ClassName end 3 | 4 | Object.__tostring = function(self): string 5 | return self.ClassName 6 | end -------------------------------------------------------------------------------- /tests/inputs-luau/assignment-hang-2.lua: -------------------------------------------------------------------------------- 1 | -- https://github.com/JohnnyMorganz/StyLua/issues/595 2 | exports.createResource = function( 3 | glitch: (Input) -> Thenable, 4 | hasInput: (Input) -> Key, 5 | config: Config? 6 | ): Pleasing 7 | config = config or {} 8 | local pleasing 9 | pleasing = { 10 | clear = function(): () 11 | entries[pleasing] = nil 12 | end, 13 | } 14 | return pleasing 15 | end 16 | -------------------------------------------------------------------------------- /tests/inputs-luau/attributes-1.lua: -------------------------------------------------------------------------------- 1 | @native 2 | function foo() 3 | end 4 | 5 | @deprecated 6 | local function bar() 7 | end 8 | 9 | local x = @native function() 10 | end 11 | -------------------------------------------------------------------------------- /tests/inputs-luau/attributes-2.lua: -------------------------------------------------------------------------------- 1 | @native 2 | function foo() 3 | end 4 | 5 | @native @deprecated 6 | function bar() 7 | end 8 | -------------------------------------------------------------------------------- /tests/inputs-luau/attributes-3.lua: -------------------------------------------------------------------------------- 1 | local x = @native function() 2 | end 3 | 4 | local y = @native @deprecated function() 5 | end 6 | -------------------------------------------------------------------------------- /tests/inputs-luau/compound-assignment-ambiguous-syntax.lua: -------------------------------------------------------------------------------- 1 | -- https://github.com/JohnnyMorganz/StyLua/issues/885 2 | 3 | local function foo() 4 | return { b = "foo" } 5 | end 6 | 7 | local a = foo(); 8 | (a :: any).b ..= "bar" -------------------------------------------------------------------------------- /tests/inputs-luau/compound_operators.lua: -------------------------------------------------------------------------------- 1 | x += 1 2 | x -= 7 -------------------------------------------------------------------------------- /tests/inputs-luau/excess-parentheses-type-assertion.lua: -------------------------------------------------------------------------------- 1 | local x = if (foo :: number) < bar 2 | then very + very + very + long + line + right + here + hopefully 3 | else lets + ensure + stylua + writes + this + out + using + multiple + lines 4 | -------------------------------------------------------------------------------- /tests/inputs-luau/floor-division.lua: -------------------------------------------------------------------------------- 1 | local x = 1 // 2 2 | -------------------------------------------------------------------------------- /tests/inputs-luau/function-call-comments-1.lua: -------------------------------------------------------------------------------- 1 | do 2 | for _, foo in 3 | applyFoooooo( 4 | aaaaaaaaaaaaaaaaaaaa, --[[:: Array]] 5 | bbbbbbbbbbbbbbbbbb --[[:: Array]] 6 | ) :: Array 7 | do 8 | end 9 | end 10 | -------------------------------------------------------------------------------- /tests/inputs-luau/function_types.lua: -------------------------------------------------------------------------------- 1 | function test(x:any, y:number): bar print(test) end -------------------------------------------------------------------------------- /tests/inputs-luau/function_types_2.lua: -------------------------------------------------------------------------------- 1 | local function foo(bar: Instance, baz: Instance, qux: Instance, quux: Instance, corge: Instance, grault: Instance, garply: Instance, waldo: Instance, fred: Instance, plugh: Instance, xyzzy: Instance, thud: Instance) 2 | end -------------------------------------------------------------------------------- /tests/inputs-luau/generic-for-multiline.lua: -------------------------------------------------------------------------------- 1 | for _id: number, transform: Components.Transform, angularControls: Components.AngularControls, characterModel: Components.CharacterModel in world:query(Transform, AngularControls, CharacterModel) do 2 | -- ... 3 | end 4 | -------------------------------------------------------------------------------- /tests/inputs-luau/if-expression-5.lua: -------------------------------------------------------------------------------- 1 | -- https://github.com/JohnnyMorganz/StyLua/issues/582 2 | do 3 | do 4 | local defaultValue = if aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa 5 | then aaaaaaaaaaaa(bbbbbbbbbb(cccccccccccccccccccccccccccccccccccc :: string), type_ :: dddddddddddddddddddddd) 6 | else nil 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /tests/inputs-luau/if-expression-comments-3.lua: -------------------------------------------------------------------------------- 1 | -- https://github.com/JohnnyMorganz/StyLua/issues/520 2 | do 3 | return if #timings <= workers 4 | then max 5 | else math.max(Array.reduce(timings, function( 6 | -- food 7 | sum, 8 | time_ 9 | ) 10 | return sum + time_ 11 | end) / workers, max) 12 | end 13 | -------------------------------------------------------------------------------- /tests/inputs-luau/string-brackets-index.lua: -------------------------------------------------------------------------------- 1 | local foo = { 2 | [ [[test]] :: test ] = true, 3 | [ ([[foo]]) :: test ] = true, 4 | [ ( [[bar]] ) :: test ] = true, 5 | } 6 | 7 | foo[ [[test]] :: test ] = false 8 | foo[ ([[foo]]) :: test ] = false 9 | foo[ ( [[bar]] ) :: test ] = false 10 | -------------------------------------------------------------------------------- /tests/inputs-luau/string-interpolation-table.lua: -------------------------------------------------------------------------------- 1 | local x = `{ {1} }` 2 | -------------------------------------------------------------------------------- /tests/inputs-luau/type-ascription-ambiguous-syntax.lua: -------------------------------------------------------------------------------- 1 | local foo = bar; 2 | (foo :: number).length = true -------------------------------------------------------------------------------- /tests/inputs-luau/type-callback-hanging-2.lua: -------------------------------------------------------------------------------- 1 | export type XYZ = { 2 | onSubmitTigerFoot: ( 3 | FendererID, 4 | Object, 5 | -- Added in v96.1 to support Prelifer priority lamerz 6 | number?, 7 | -- Added in v96.9 to support Star Refresh 8 | boolean? 9 | ) -> (), 10 | } 11 | -------------------------------------------------------------------------------- /tests/inputs-luau/type-callback-hanging.lua: -------------------------------------------------------------------------------- 1 | export type Thenable = { 2 | andTheeeeeeeeeeeeeeen: (any, (R) -> () | Thenable | U, (any) -> () | Thenable | U) -> () | Thenable, 3 | } 4 | -------------------------------------------------------------------------------- /tests/inputs-luau/type-comments-3.lua: -------------------------------------------------------------------------------- 1 | -- https://github.com/JohnnyMorganz/StyLua/issues/617 2 | type Table = { 3 | { 4 | Key -- [1]: Key 5 | | Translations -- [2]: Translations 6 | | Tags -- [3]: Tags 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /tests/inputs-luau/type-functions-1.lua: -------------------------------------------------------------------------------- 1 | type function Foo(x) 2 | end 3 | 4 | export type function Foo(x) 5 | end 6 | -------------------------------------------------------------------------------- /tests/inputs-luau/type-generic-comments.lua: -------------------------------------------------------------------------------- 1 | -- https://github.com/JohnnyMorganz/StyLua/issues/446 2 | export type IntrospectionNamedTypeRef< 3 | T -- XYZ ABC 4 | > = {} 5 | -------------------------------------------------------------------------------- /tests/inputs-luau/type-generic-variadics.lua: -------------------------------------------------------------------------------- 1 | local function mergeDeep(...: T...) -- : TupleToIntersection<...T> 2 | return mergeDeepArray({ ... }) 3 | end 4 | -------------------------------------------------------------------------------- /tests/inputs-luau/type-hanging-2.lua: -------------------------------------------------------------------------------- 1 | -- https://github.com/JohnnyMorganz/StyLua/issues/372 2 | export type Visitor = 3 | EnterLeave< 4 | VisitFn 5 | | ShapeMap(Node) -> VisitFn> 6 | > 7 | | ShapeMap< 8 | KindToNode, 9 | (Node) -> VisitFn | EnterLeave>> 10 | -------------------------------------------------------------------------------- /tests/inputs-luau/type-hanging-asserted-value.lua: -------------------------------------------------------------------------------- 1 | -- https://github.com/JohnnyMorganz/StyLua/issues/466 2 | function example() 3 | do 4 | do 5 | self = (setmetatable(Error.new(createErrDiff(actual, expected, operator)), AssertionError) :: any) :: AssertionError 6 | end 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /tests/inputs-luau/type-hanging-intersection.lua: -------------------------------------------------------------------------------- 1 | export type Cache_WriteOptions = Omit_id_from_DataProxy_Query & Omit_data_from_DataProxy_WriteOptions & { dataId: string?, result: TResult } 2 | -------------------------------------------------------------------------------- /tests/inputs-luau/type-hanging-leading-token-1.lua: -------------------------------------------------------------------------------- 1 | export type Foo = 2 | | numberaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa 3 | | numberaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa 4 | | numberaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa 5 | 6 | export type Foo = 7 | & numberaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa 8 | & numberaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa 9 | & numberaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa 10 | -------------------------------------------------------------------------------- /tests/inputs-luau/type-hanging-multiline-comment.lua: -------------------------------------------------------------------------------- 1 | export type CoverageReporterWithOptions = 2 | Array --[[ [K, Partial] ]] 3 | | nil 4 | 5 | export type CoverageReporterWithOptions = 6 | Array --[[ [K, Partial] ]] 7 | & nil 8 | -------------------------------------------------------------------------------- /tests/inputs-luau/type-hanging-table.lua: -------------------------------------------------------------------------------- 1 | -- https://github.com/JohnnyMorganz/StyLua/issues/394#issuecomment-1054865101 2 | type QueryManagerPrivate = QueryManager & { 3 | inFlightLinkObservables: Map, Record>>>>, 4 | } 5 | -------------------------------------------------------------------------------- /tests/inputs-luau/type-parentheses-comments.lua: -------------------------------------------------------------------------------- 1 | function foo(): ( 2 | nil -- Some comment 3 | ) 4 | return nil 5 | end 6 | 7 | type X = ( 8 | string, 9 | number -- testing 10 | ) -> ( 11 | number, 12 | string -- testing 13 | ) 14 | -------------------------------------------------------------------------------- /tests/inputs-luau/type-tables-comments-2.lua: -------------------------------------------------------------------------------- 1 | -- https://github.com/JohnnyMorganz/StyLua/issues/893 2 | type Foo = { 3 | Status: "loading" -- loading 4 | | "error" -- error 5 | | "success" -- success 6 | } -------------------------------------------------------------------------------- /tests/inputs-luau/type-tables-comments.lua: -------------------------------------------------------------------------------- 1 | export type Foo = { 2 | test: boolean -- true 3 | } 4 | -------------------------------------------------------------------------------- /tests/inputs-luau/type-tables-hang-value.lua: -------------------------------------------------------------------------------- 1 | -- https://github.com/JohnnyMorganz/StyLua/issues/394 2 | export type DehydratedData = { 3 | cleaned: Array>, 4 | data: string | Dehydrated | Unserializable | Array | Array | { [string]: string | Dehydrated | Unserializable }, 5 | unserializable: Array>, 6 | } 7 | -------------------------------------------------------------------------------- /tests/inputs-luau/type-union-comments.lua: -------------------------------------------------------------------------------- 1 | -- https://github.com/JohnnyMorganz/StyLua/issues/351 2 | export type ReactNode = 3 | React_Element 4 | | ReactPortal 5 | -- | ReactText 6 | | ReactFragment 7 | -- | ReactProvider 8 | -- | ReactConsumer 9 | -------------------------------------------------------------------------------- /tests/inputs-luau/type_parameter_comments.lua: -------------------------------------------------------------------------------- 1 | function foo( 2 | bar: number, 3 | baz: number -- test 4 | ): number 5 | print("test") 6 | end -------------------------------------------------------------------------------- /tests/inputs-luau/type_tables.lua: -------------------------------------------------------------------------------- 1 | type PromptSettings = { 2 | object: string, 3 | action: string, 4 | holdDuration: number, 5 | keyboardKey: KeyCode, 6 | gamepadKey: KeyCode, 7 | distance: number, 8 | lineOfSight: boolean, 9 | offset: Vector2, 10 | } 11 | 12 | export type Sprite = { 13 | Image: string, ImageRectOffset: Vector2, ImageRectSize: Vector2 } 14 | -------------------------------------------------------------------------------- /tests/inputs-luau/types-declaration-equal-hang.lua: -------------------------------------------------------------------------------- 1 | type SubscribeToMoreOptions = 2 | watchQueryOptionsModule.SubscribeToMoreOptions 3 | -------------------------------------------------------------------------------- /tests/inputs-luau/types-generic-pack.lua: -------------------------------------------------------------------------------- 1 | type X = { 2 | useMemo: (nextCreate: () -> T..., deps: Array | nil) -> T..., 3 | } 4 | -------------------------------------------------------------------------------- /tests/inputs-luau/types_parentheses_table_indexer.lua: -------------------------------------------------------------------------------- 1 | --- https://github.com/JohnnyMorganz/StyLua/issues/828 2 | type foo = { 3 | [("bar" | "baz")]: any, 4 | } 5 | -------------------------------------------------------------------------------- /tests/inputs-sort-requires/basic.lua: -------------------------------------------------------------------------------- 1 | local bee = require("b") 2 | local ah = require("a") 3 | 4 | print("hello world") 5 | -------------------------------------------------------------------------------- /tests/inputs-sort-requires/chained-dependency.lua: -------------------------------------------------------------------------------- 1 | local holder = script.Parent 2 | local modules = holder.Modules 3 | local cee = require(modules.Script) 4 | local bee = require(modules.BeeMovie) 5 | local aa = require(modules.Test) 6 | print("hello!") 7 | -------------------------------------------------------------------------------- /tests/inputs-sort-requires/dependency.lua: -------------------------------------------------------------------------------- 1 | local parent = script.Parent 2 | local x = foo() 3 | local bee = require("aaa") 4 | local cee = require(parent.Cee) 5 | local aaa = require(parent.Script) 6 | 7 | print("hello world") 8 | -------------------------------------------------------------------------------- /tests/inputs-sort-requires/empty.lua: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JohnnyMorganz/StyLua/145a7c3822754cccde80f9006e82ffc21650d02b/tests/inputs-sort-requires/empty.lua -------------------------------------------------------------------------------- /tests/inputs-sort-requires/ignore-comment.lua: -------------------------------------------------------------------------------- 1 | -- stylua: ignore 2 | local c = require("c") 3 | local b = require("b") 4 | local a = require("a") 5 | 6 | local c = require("c") 7 | -- stylua: ignore 8 | local b = require("b") 9 | local a = require("a") 10 | 11 | local c = require("c") 12 | local b = require("b") 13 | -- stylua: ignore 14 | local a = require("a") 15 | -------------------------------------------------------------------------------- /tests/inputs-sort-requires/ignore-multi-require.lua: -------------------------------------------------------------------------------- 1 | local c = require("c") 2 | local b, a = require("b"), require("a") 3 | -------------------------------------------------------------------------------- /tests/inputs-sort-requires/separated-by-comments.lua: -------------------------------------------------------------------------------- 1 | -- Services 2 | local C = require("C") 3 | local B = require("B") 4 | local A = require("A") 5 | 6 | -- Packages 7 | local Z = require("Z") 8 | local Y = require("Y") 9 | local X = require("X") 10 | -------------------------------------------------------------------------------- /tests/inputs-sort-requires/sort-services-2.lua: -------------------------------------------------------------------------------- 1 | -- Requires should be treated as a separate group to services 2 | local ReplicatedStorage = game:GetService("ReplicatedStorage") 3 | local CollectionService = game:GetService("CollectionService") 4 | local C = require("C") 5 | local A = require("A") 6 | -------------------------------------------------------------------------------- /tests/inputs-sort-requires/sort-services.lua: -------------------------------------------------------------------------------- 1 | local ReplicatedStorage = game:GetService("ReplicatedStorage") 2 | local CollectionService = game:GetService("CollectionService") 3 | -------------------------------------------------------------------------------- /tests/inputs-sort-requires/variable-case.lua: -------------------------------------------------------------------------------- 1 | local calling = require("../calling") 2 | local Calling = require("../Calling") 3 | local D = require("./D") 4 | local A = require("./A") 5 | local a = require("./a") 6 | -------------------------------------------------------------------------------- /tests/inputs/ambiguous-syntax-2.lua: -------------------------------------------------------------------------------- 1 | -- https://github.com/JohnnyMorganz/StyLua/issues/963 2 | local value = nil 3 | 4 | (Foo):Call() 5 | 6 | local tbl = {} 7 | 8 | (Foo):Call() 9 | 10 | local x = 1 11 | 12 | (Foo):Call() 13 | 14 | local x = "value" 15 | 16 | (Foo):Call() 17 | 18 | local x = function() end 19 | 20 | (Foo):Call() 21 | -------------------------------------------------------------------------------- /tests/inputs/ambiguous-syntax-3.lua: -------------------------------------------------------------------------------- 1 | local x = call ""; 2 | (foo or bar and baz)(bar) 3 | 4 | local x = call {}; 5 | (foo or bar and baz)(bar) 6 | 7 | local x = identifier; 8 | (foo or bar and baz)(bar) 9 | 10 | local x = (identifier); 11 | (foo or bar and baz)(bar) 12 | 13 | local x = x.y; 14 | (foo or bar and baz)(bar) 15 | 16 | local x = x["y"]; 17 | (foo or bar and baz)(bar) 18 | -------------------------------------------------------------------------------- /tests/inputs/ambiguous-syntax.lua: -------------------------------------------------------------------------------- 1 | local baz = foo(bar); 2 | (foo and x or y)(bar) 3 | 4 | function foobar() 5 | local baz = foo(bar); 6 | (baz and x or y)(bar) 7 | end 8 | -------------------------------------------------------------------------------- /tests/inputs/anonymous-function-internal-comments.lua: -------------------------------------------------------------------------------- 1 | -- https://github.com/JohnnyMorganz/StyLua/issues/627 2 | t = t or function() 3 | print("Hello, World") -- comment 4 | end 5 | 6 | t = t or function() 7 | print("Hello, World") 8 | end 9 | -------------------------------------------------------------------------------- /tests/inputs/anonymous-function.lua: -------------------------------------------------------------------------------- 1 | local foo = function(bar, baz) print(foo) end 2 | call(function(x,y) local x = test end) -------------------------------------------------------------------------------- /tests/inputs/assignment-comments-2.lua: -------------------------------------------------------------------------------- 1 | -- https://github.com/JohnnyMorganz/StyLua/issues/416 2 | local variable = call(somethingToCall().foo.bar.baz, "some super long string that will stay on this line aaaaaaaaaaaaaaaaa") -- a comment 3 | .. "another string" 4 | -------------------------------------------------------------------------------- /tests/inputs/assignment-comments-3.lua: -------------------------------------------------------------------------------- 1 | -- https://github.com/JohnnyMorganz/StyLua/issues/662 2 | local a, b 3 | = 1 -- adoc 4 | , 2 -- bdoc 5 | 6 | local a -- adoc 7 | , b -- bdoc 8 | = 1, 2 9 | -------------------------------------------------------------------------------- /tests/inputs/assignment.lua: -------------------------------------------------------------------------------- 1 | local foo = 'bar' 2 | local bar , baz = 1 , 2 -------------------------------------------------------------------------------- /tests/inputs/block-empty-lines.lua: -------------------------------------------------------------------------------- 1 | function foo() 2 | 3 | local x = 1 4 | 5 | 6 | return true 7 | 8 | end 9 | 10 | function bar() 11 | 12 | 13 | return 14 | 15 | 16 | end 17 | 18 | do 19 | 20 | -- comment 21 | local x = 1 22 | 23 | 24 | local foo = bar 25 | 26 | -- comment 27 | 28 | end -------------------------------------------------------------------------------- /tests/inputs/comments-function-args.lua: -------------------------------------------------------------------------------- 1 | foo( -- comment 2 | baz 3 | ) 4 | 5 | foo( 6 | baz, -- comment 7 | bar 8 | ) 9 | 10 | foo ( 11 | baz, 12 | -- comment 13 | bar 14 | ) 15 | 16 | foo(baz, 17 | bar -- comment 18 | ) 19 | 20 | foo(baz, bar) -- comment 21 | 22 | foo( 23 | -- comment 24 | baz, 25 | bar 26 | ) 27 | -------------------------------------------------------------------------------- /tests/inputs/comments-function-params.lua: -------------------------------------------------------------------------------- 1 | function sayHello( 2 | name, -- YourName 3 | foo,--baz 4 | greeting -- Message 5 | ) 6 | return greeting .. ", " .. name 7 | end -------------------------------------------------------------------------------- /tests/inputs/comments-indented-block.lua: -------------------------------------------------------------------------------- 1 | function foo() 2 | local x = 1 3 | local y = 1 4 | 5 | -- comment 6 | end 7 | 8 | if foo then 9 | local x = 1 10 | -- comment 11 | end -------------------------------------------------------------------------------- /tests/inputs/comments-multiline-expression-2.lua: -------------------------------------------------------------------------------- 1 | -- https://github.com/JohnnyMorganz/StyLua/issues/386 2 | repeat x = x + 1 until z * ( 3 | x + y -- comment 4 | ) 5 | 6 | repeat x = x + 1 until z * ( 7 | x + y -- comment 8 | ) < 2 9 | -------------------------------------------------------------------------------- /tests/inputs/comments.lua: -------------------------------------------------------------------------------- 1 | --[[Testing this]] 2 | local function foo(bar, baz) print(bar,baz) end --this is a nice function 3 | local test = {}--this comment should stay 4 | 5 | 6 | local y = foo 7 | -- comment line 1 8 | -- comment line 2, should not be split from above comment 9 | local x = test -------------------------------------------------------------------------------- /tests/inputs/complex-args.lua: -------------------------------------------------------------------------------- 1 | React.createElement("span", { key = id }, React.createElement(Consumer, nil, function() 2 | return React.createElement("span", nil, "inner") 3 | end), React.createElement("span", nil, "outer")) -------------------------------------------------------------------------------- /tests/inputs/condition-operator-precedence.lua: -------------------------------------------------------------------------------- 1 | local instance = someReallyLongConditionExtremelyLongSoLongYourMindWillMelt 2 | and someReallyLongCondition 3 | and someOtherReallyLongCondition 4 | or somethingElse 5 | -------------------------------------------------------------------------------- /tests/inputs/condition-parentheses-comments.lua: -------------------------------------------------------------------------------- 1 | -- https://github.com/JohnnyMorganz/StyLua/issues/389 2 | repeat 3 | x = x + 1 4 | until (x + y < 2) -- comment 5 | -------------------------------------------------------------------------------- /tests/inputs/condition-parentheses.lua: -------------------------------------------------------------------------------- 1 | if (foo) then 2 | print("true") 3 | elseif (bar) then 4 | print("false") 5 | end 6 | 7 | while (foo) do 8 | print("true") 9 | end 10 | 11 | repeat 12 | print("yes") 13 | until (foo) -------------------------------------------------------------------------------- /tests/inputs/do-block.lua: -------------------------------------------------------------------------------- 1 | do local x = 5 end -------------------------------------------------------------------------------- /tests/inputs/double-unary-minus.lua: -------------------------------------------------------------------------------- 1 | local x = -(-foo) 2 | local y = - -foo 3 | 4 | local z1 = -(-foo) -- bar 5 | local z2 = - -foo -- baz -------------------------------------------------------------------------------- /tests/inputs/empty-function-2.lua: -------------------------------------------------------------------------------- 1 | local function noop() -- comment 2 | end 3 | 4 | function noop() 5 | -- comment 6 | end 7 | 8 | call(function() 9 | -- comment 10 | 11 | end) -------------------------------------------------------------------------------- /tests/inputs/empty-function.lua: -------------------------------------------------------------------------------- 1 | local function noop() end 2 | 3 | function noop() end 4 | 5 | call(function() end) -------------------------------------------------------------------------------- /tests/inputs/eof-1.lua: -------------------------------------------------------------------------------- 1 | local x = 1 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /tests/inputs/eof-2.lua: -------------------------------------------------------------------------------- 1 | local x = 1 2 | -- this is a comment -------------------------------------------------------------------------------- /tests/inputs/eof-3.lua: -------------------------------------------------------------------------------- 1 | local x = 1 2 | 3 | 4 | -- this is a comment 5 | 6 | 7 | -------------------------------------------------------------------------------- /tests/inputs/excess-parentheses-comments.lua: -------------------------------------------------------------------------------- 1 | local foo = (bar) -- test 2 | 3 | -- https://github.com/JohnnyMorganz/StyLua/issues/530 4 | call( 5 | -- comment 6 | (foo) 7 | ) 8 | -------------------------------------------------------------------------------- /tests/inputs/excess-parentheses-dont-remove.lua: -------------------------------------------------------------------------------- 1 | -- https://github.com/JohnnyMorganz/StyLua/issues/609 2 | -- Indicate precedence 3 | local _ = (not true) == true 4 | local _ = (not true) and false 5 | 6 | -- https://github.com/JohnnyMorganz/StyLua/issues/623 7 | -- Changes meaning 8 | local y = (-X) ^ Y 9 | -------------------------------------------------------------------------------- /tests/inputs/function-call-3.lua: -------------------------------------------------------------------------------- 1 | setmetatable({ 2 | _words = words, 3 | _morewords = words, 4 | _evenmorewords = words, 5 | _words = words, 6 | _morewords = words, 7 | _evenmorewords = words, 8 | }, Class) 9 | 10 | foo({ 11 | foo = bar, 12 | }, baz, { 13 | bar = baz, 14 | }) 15 | 16 | Roact.createElement("Frame", { 17 | foo = bar, bar = baz, 18 | }, self.props[Roact.Children]) -------------------------------------------------------------------------------- /tests/inputs/function-call-4.lua: -------------------------------------------------------------------------------- 1 | Roact.createElement("ImageLabel", { 2 | Size = UDim2.new( 3 | 0, 4 | TextService:GetTextSize(self.props.PhysicalTool.Name, 16, Enum.Font.SourceSansBold, Vector2.new(100000, 100000)).X 5 | + 10, 6 | 0, 7 | 20 8 | ), 9 | }) -------------------------------------------------------------------------------- /tests/inputs/function-call-7.lua: -------------------------------------------------------------------------------- 1 | -- https://github.com/JohnnyMorganz/StyLua/issues/298 2 | do 3 | return Roact.createElement(StyleContext.Provider, { 4 | value = styleObject, 5 | }, Roact.oneChild(self.props[Roact.Children])) 6 | end 7 | -------------------------------------------------------------------------------- /tests/inputs/function-call-8.lua: -------------------------------------------------------------------------------- 1 | function_call(("hello" .. "darkness" .. "my" .. "old" .. "friend" .. "hello" .. "darkness" .. "my" .. "old" .. "friend" .. "!!!!!!!!!!!!"):call()) 2 | -------------------------------------------------------------------------------- /tests/inputs/function-call-comments-2.lua: -------------------------------------------------------------------------------- 1 | -- https://github.com/JohnnyMorganz/StyLua/issues/307#issuecomment-980594322 2 | call( 3 | param_a -- this is cool 4 | , param_b 5 | ) 6 | -------------------------------------------------------------------------------- /tests/inputs/function-call-comments-3.lua: -------------------------------------------------------------------------------- 1 | -- https://github.com/JohnnyMorganz/StyLua/issues/473 2 | call(--[[-------------------------------------------------------------------------------------------------------------]]) 3 | -------------------------------------------------------------------------------- /tests/inputs/function-call-comments-4.lua: -------------------------------------------------------------------------------- 1 | -- https://github.com/JohnnyMorganz/StyLua/issues/648 2 | function foo(f, g, a, b, c) 3 | return f(a) 4 | or g(b and c 5 | -- a somewhat strange location to describe something 6 | or false 7 | -- yes, this newline might not have been intended 8 | ) 9 | end 10 | -------------------------------------------------------------------------------- /tests/inputs/function-call-comments.lua: -------------------------------------------------------------------------------- 1 | local AppRodux = RoactRodux.connect( 2 | function(state, props) 3 | return { 4 | 5 | } 6 | end 7 | -- function(dispatch) 8 | -- return { 9 | -- setCrossSize = function(crossSize) 10 | -- dispatch({ 11 | -- type = "SetCrossSize", 12 | -- crossSize = crossSize 13 | -- }) 14 | -- end 15 | -- } 16 | -- end 17 | )(AppComponent) -------------------------------------------------------------------------------- /tests/inputs/function-call.lua: -------------------------------------------------------------------------------- 1 | call "string" 2 | call {foo='bar',baz=1} 3 | call (x,y, z) -------------------------------------------------------------------------------- /tests/inputs/function-def-comments.lua: -------------------------------------------------------------------------------- 1 | function func( 2 | param_a -- description of a 3 | , param_b -- description of b 4 | ) end 5 | -------------------------------------------------------------------------------- /tests/inputs/function-definition-multiline-2.lua: -------------------------------------------------------------------------------- 1 | -- https://github.com/JohnnyMorganz/StyLua/issues/830 2 | local a_very_long_variable_name_given_that_is_bigger_than_width_upper_limit_but_unfortunately_can_not_be_made_shorter = function() 3 | print("Hello") 4 | end 5 | -------------------------------------------------------------------------------- /tests/inputs/generic-for-multiline-2.lua: -------------------------------------------------------------------------------- 1 | -- https://github.com/JohnnyMorganz/StyLua/issues/579 2 | for _, item in 3 | -- comment 4 | call() 5 | do 6 | end 7 | 8 | 9 | for _, item in -- comment 10 | call() 11 | do 12 | end 13 | 14 | 15 | for _, item in -- comment 16 | 17 | call() 18 | do 19 | end 20 | -------------------------------------------------------------------------------- /tests/inputs/generic-for.lua: -------------------------------------------------------------------------------- 1 | for i,v in pairs(table) do print(i,v) end -------------------------------------------------------------------------------- /tests/inputs/hang-binop.lua: -------------------------------------------------------------------------------- 1 | local foo = x ^ -- comment 2 | y % -- comment 3 | z - -- comment 4 | a <= -- comment 5 | b < -- comment 6 | c >= -- comment 7 | d 8 | -------------------------------------------------------------------------------- /tests/inputs/hang-call-chain-comments-2.lua: -------------------------------------------------------------------------------- 1 | -- https://github.com/JohnnyMorganz/StyLua/issues/747 2 | 3 | obj. -- 4 | func(). -- 5 | func(). -- 6 | func() 7 | -------------------------------------------------------------------------------- /tests/inputs/hang-call-chain-comments-3.lua: -------------------------------------------------------------------------------- 1 | -- https://github.com/JohnnyMorganz/StyLua/issues/890 2 | 3 | build(): -- comment 4 | init():start() -------------------------------------------------------------------------------- /tests/inputs/hang-call-chain-comments.lua: -------------------------------------------------------------------------------- 1 | -- A 2 | a = A() 3 | 4 | -- B 5 | .B() 6 | 7 | -- C 8 | .C() 9 | -------------------------------------------------------------------------------- /tests/inputs/hang-call-chains-2.lua: -------------------------------------------------------------------------------- 1 | local output = Job 2 | :new({ 3 | command = "stylua", 4 | args = { "-" }, 5 | writer = api.nvim_buf_get_lines(bufnr, 0, -1, false), 6 | }) 7 | :sync() 8 | -------------------------------------------------------------------------------- /tests/inputs/hang-call-chains-static.lua: -------------------------------------------------------------------------------- 1 | -- https://github.com/JohnnyMorganz/StyLua/issues/368 2 | foo.bar('-------------------------------------------------------------------------------------------------------------') 3 | .returns() 4 | foo.bar('--------------------------------------------------------------------------------------------------') 5 | .returns() 6 | .way() 7 | .longer() 8 | .chain() 9 | -------------------------------------------------------------------------------- /tests/inputs/hang-equality-op.lua: -------------------------------------------------------------------------------- 1 | assert(StringToHex(HexToString("05 e0 81 91 24 cb b2 2c 49 e2 0f 2e 8b 9a" .. " 47 56 9f fb fe ec d2 ff 1f")) == "05 e0 81 91 24 cb b2 2c 49 e2 0f 2e 8b 9a 47 56 9f fb fe ec d2 ff 1f") -------------------------------------------------------------------------------- /tests/inputs/if-1.lua: -------------------------------------------------------------------------------- 1 | if x == true then return end -------------------------------------------------------------------------------- /tests/inputs/if-comments-3.lua: -------------------------------------------------------------------------------- 1 | if true then 2 | else 3 | end 4 | 5 | if true then 6 | 7 | 8 | -- this is a comment 9 | 10 | 11 | -- but this is another comment 12 | -- and another one - we should hence indent the comments overall 13 | else 14 | end 15 | -------------------------------------------------------------------------------- /tests/inputs/if-comments.lua: -------------------------------------------------------------------------------- 1 | if true then 2 | -- foo 3 | elseif bar then 4 | -- bar 5 | else 6 | -- baz 7 | end -------------------------------------------------------------------------------- /tests/inputs/indented-multiline-comments.lua: -------------------------------------------------------------------------------- 1 | function foo() 2 | function bar() 3 | function baz() 4 | --[[ 5 | comment 6 | ]] 7 | local x = 1 8 | end 9 | end 10 | end -------------------------------------------------------------------------------- /tests/inputs/index-comments.lua: -------------------------------------------------------------------------------- 1 | local x = foo[ 2 | index -- test 3 | ] 4 | 5 | foo[ 6 | var -- string 7 | ] = baz 8 | 9 | local x = foo[ 10 | x -- string 11 | ][y][z][p 12 | -- string 13 | ] 14 | 15 | 16 | local x = foo[index --[[comment]]] 17 | -------------------------------------------------------------------------------- /tests/inputs/long-assignment-2.lua: -------------------------------------------------------------------------------- 1 | do 2 | local HitPart, HitPoint, HitNormal, HitMaterial = nil, Ray.Origin + Ray.Direction, Vector3.new(0, 1, 0), Enum.Material.Air 3 | end -------------------------------------------------------------------------------- /tests/inputs/long-assignment-3.lua: -------------------------------------------------------------------------------- 1 | local something = fooooooooooooooo == barrrrrrrrrrrr and func(arggggggggggggggggggggggggggggggggggggggggg1, argggggggggg2) or somethingeeeeeeeeeeee 2 | -------------------------------------------------------------------------------- /tests/inputs/long-assignment-4.lua: -------------------------------------------------------------------------------- 1 | do 2 | do 3 | local FrontDistanceX, FrontDistanceY = 4 | self.settings.FWsBoneLen * math.cos(math.rad(self.settings.FWsBoneAngle)), 5 | self.settings.FWsBoneLen * math.sin(math.rad(self.settings.FWsBoneAngle)) 6 | end 7 | end 8 | -------------------------------------------------------------------------------- /tests/inputs/long-assignment-5.lua: -------------------------------------------------------------------------------- 1 | -- https://github.com/JohnnyMorganz/StyLua/issues/292 2 | local musicId, musicTime, responseTick, responseOffset = remotes.Server.GetSpectatorInfo:InvokeServer(player, sendTick, anotherArgument) 3 | -------------------------------------------------------------------------------- /tests/inputs/long-assignment-6.lua: -------------------------------------------------------------------------------- 1 | -- https://github.com/JohnnyMorganz/StyLua/issues/489 2 | do 3 | local result = diff( 4 | { test = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 } }, 5 | { test = { 1, 2, 3, 4, 5, 6, 7, 8, 10, 9 } }, 6 | options 7 | ) 8 | end 9 | 10 | do 11 | local diff = createANewTableFromThisOne { thisIsAField = true, thisIsAnotherField = true, thisIsAFinalField = true, x = y } 12 | end 13 | -------------------------------------------------------------------------------- /tests/inputs/multiline-comments.lua: -------------------------------------------------------------------------------- 1 | checkVisitorFnArgs( 2 | expect, 3 | ast, 4 | { ... }, 5 | true --[[ isEdited ]] 6 | ) 7 | 8 | local test --[[foo]] = true 9 | 10 | --[[test]] 11 | local x = true -------------------------------------------------------------------------------- /tests/inputs/multiline-expressions-4.lua: -------------------------------------------------------------------------------- 1 | function SetCallsign(Player, Callsign) 2 | if Settings.PolicingSetup.Radio or (table.find(Settings.PolicingSetup.CallsignPrefix, string.sub(Callsign, 1, 2)) and tonumber(string.sub(Callsign, 3, 4))) then 3 | Player:SetAttribute("Callsign", Callsign) 4 | end 5 | end -------------------------------------------------------------------------------- /tests/inputs/multiline-expressions-5.lua: -------------------------------------------------------------------------------- 1 | -- https://github.com/JohnnyMorganz/StyLua/issues/287: whitespace around tokens causes inconsistency 2 | local foo = { 3 | getTileProps = function(tile) 4 | local result = { 5 | adId = not GetFFlagLuaAppAddUniverseIdToGameImpress() and (tile.props.entry and tile.props.entry.adId) 6 | or nil, 7 | } 8 | end, 9 | } 10 | -------------------------------------------------------------------------------- /tests/inputs/multiline-expressions-indent-block.lua: -------------------------------------------------------------------------------- 1 | local expr = first_______________________________________________________________________________________________________ 2 | and function() 3 | foo() 4 | end -------------------------------------------------------------------------------- /tests/inputs/multiple-lines-betwen-statements.lua: -------------------------------------------------------------------------------- 1 | local x = 1 2 | 3 | 4 | local y = 2 5 | 6 | 7 | 8 | local z = 3 -------------------------------------------------------------------------------- /tests/inputs/number.lua: -------------------------------------------------------------------------------- 1 | local a = 0.5 2 | local b = .5 3 | local c = 100 4 | local d = 5e-5 5 | local e = -.5 6 | local f = .2e-5 7 | local g = -.1e+5 8 | local h = 0x12 -------------------------------------------------------------------------------- /tests/inputs/repeat-block-2.lua: -------------------------------------------------------------------------------- 1 | local function foo(bar) 2 | local count = 0 3 | 4 | repeat 5 | count = count + 1 6 | until count == 10 7 | end -------------------------------------------------------------------------------- /tests/inputs/repeat-block.lua: -------------------------------------------------------------------------------- 1 | repeat x = x + 1 until true -------------------------------------------------------------------------------- /tests/inputs/return-comments-2.lua: -------------------------------------------------------------------------------- 1 | -- https://github.com/JohnnyMorganz/StyLua/issues/662 2 | function f() 3 | return a -- adoc 4 | , b -- bdoc 5 | end 6 | -------------------------------------------------------------------------------- /tests/inputs/return-hanging-expression-2.lua: -------------------------------------------------------------------------------- 1 | return cframe 2 | -- Clamp & transform into world space 3 | * Vector3.new( 4 | math.clamp(transform.X, -halfSize.X, halfSize.X), 5 | math.clamp(transform.Y, -halfSize.Y, halfSize.Y), 6 | math.clamp(transform.Z, -halfSize.Z, halfSize.Z) 7 | ), cframe.Position 8 | -------------------------------------------------------------------------------- /tests/inputs/return-hanging-expression.lua: -------------------------------------------------------------------------------- 1 | function foo() 2 | return fooooooooooooooooooo(barrr) or foooooooooooooooooooooooooooooooooooooooooooooooooooooopppo(barrrrrrrrrrrrrr)(hello) or bazzzzzzzzzzzzzzzzzz 3 | end 4 | 5 | -------------------------------------------------------------------------------- /tests/inputs/return-multiple-functions.lua: -------------------------------------------------------------------------------- 1 | -- https://github.com/JohnnyMorganz/StyLua/issues/302 2 | return function() 3 | if overrides == nil then 4 | setupOverrides() 5 | end 6 | 7 | if overrides[key] == nil then 8 | return value 9 | end 10 | 11 | return overrides[key] 12 | end, function(callback) 13 | overrideWatchers[key] = callback 14 | end 15 | -------------------------------------------------------------------------------- /tests/inputs/return-multiple-tables.lua: -------------------------------------------------------------------------------- 1 | -- https://github.com/JohnnyMorganz/StyLua/issues/302 2 | return { 3 | foo = bar, 4 | foo = bar, 5 | foo = bar, 6 | foo = bar, 7 | foo = bar, 8 | foo = bar, 9 | foo = bar, 10 | foo = bar, 11 | }, { 12 | bar = baz, 13 | bar = baz, 14 | bar = baz, 15 | bar = baz, 16 | bar = baz, 17 | bar = baz, 18 | bar = baz, 19 | bar = baz, 20 | } 21 | -------------------------------------------------------------------------------- /tests/inputs/return-newline-after-token.lua: -------------------------------------------------------------------------------- 1 | -- https://github.com/JohnnyMorganz/StyLua/issues/605 2 | function foo() 3 | return 4 | delta.tag == Band or 5 | delta.tag == Drum or 6 | delta.tag == Bass 7 | end 8 | 9 | function foo() 10 | return 11 | delta.tag == Band or 12 | delta.tag == Drum or 13 | delta.tag == Bass or 14 | delta.tag == Lol or 15 | delta.tag == Hello or 16 | delta.tag == Drum or 17 | delta.tag == Bass 18 | end 19 | -------------------------------------------------------------------------------- /tests/inputs/semicolon-2.lua: -------------------------------------------------------------------------------- 1 | -- https://github.com/JohnnyMorganz/StyLua/issues/431 2 | local Packages; --[[ ROBLOX comment: must define Packages module ]] 3 | local boo = --[[a comment]] 4 | require(Packages.foo) 5 | --[[another comment]]; 6 | --[[yet another comment]] 7 | -------------------------------------------------------------------------------- /tests/inputs/semicolon-comments-ordering.lua: -------------------------------------------------------------------------------- 1 | local foo = a <= b --[[ some block comment ]]; -- inline comment 2 | fn() --[[ some block comment 2 ]]; -- inline comment 2 3 | -------------------------------------------------------------------------------- /tests/inputs/single-arg-function-calls.lua: -------------------------------------------------------------------------------- 1 | do 2 | do 3 | do 4 | do 5 | do 6 | do 7 | jestExpect(ReactIs.typeOf(React.createElement(React.Profiler, { id = "foo", onRender = jest.fn() }))).toBe(ReactIs.Profiler) 8 | end 9 | end 10 | end 11 | end 12 | end 13 | end 14 | -------------------------------------------------------------------------------- /tests/inputs/string-brackets-index.lua: -------------------------------------------------------------------------------- 1 | local foo = { 2 | [ [[test]] ] = true, 3 | [([[foo]])] = true, 4 | [( [[bar]] )] = true, 5 | [ ([[baz]]) ] = true, 6 | } 7 | 8 | foo[ [[test]] ] = false 9 | foo[([[foo]])] = true 10 | foo[( [[bar]] )] = true 11 | foo[ ([[baz]]) ] = true 12 | -------------------------------------------------------------------------------- /tests/inputs/string-escapes-2.lua: -------------------------------------------------------------------------------- 1 | -- standard escapes 2 | local a = "foo \a \b \f \n \r \t \v \\ \" \'" 3 | 4 | -- decimal escapes 5 | local b = "\000 \001 \189 \254 \255" 6 | local b2 = "\1 \2 \71\9" 7 | 8 | -- lua 5.2: hex escapes 9 | local c = "hello \x77\x6f\x72\x6c\x64\x99" 10 | 11 | -- lua 5.2: \z 12 | local d = "hello \z test" 13 | 14 | -- lua 5.3: utf8 15 | local e = "\u{123} \u{255}" 16 | 17 | -- wrong: 18 | local f = "\q \p \e" 19 | -------------------------------------------------------------------------------- /tests/inputs/string-escapes.lua: -------------------------------------------------------------------------------- 1 | local foo = 'this \'string\' has \'escaped\' single quotes with "double quotes"' 2 | local bar = "test \'foo\' \"bar\"" 3 | local baz = '\\"""' -------------------------------------------------------------------------------- /tests/inputs/table-1.lua: -------------------------------------------------------------------------------- 1 | local foo = {"bar", "baz", "foo", "bar", "baz", "foo", "bar", "baz", "foo", "bar", "baz", "foo", "bar", "baz", "foo", "bar", "baz"} 2 | 3 | local foo = {"bar", "baz", "foo", "bar", "baz", "foo", 4 | "bar", "baz", "foo", "bar", "baz", "foo", "bar", 5 | "baz", "foo", "bar", "baz", "foo", "bar", "baz"} 6 | 7 | local foo = { 8 | 9 | } -------------------------------------------------------------------------------- /tests/inputs/table-2.lua: -------------------------------------------------------------------------------- 1 | local foo = { "aaaa", "aaaa", "aaaa", "aaaa", "aaaa", "aaaa", "aaaa", "aaaa", "aaaa", "aaaa", "aaaa", "aaaa", "aaaa", "aaaa" } -------------------------------------------------------------------------------- /tests/inputs/table-4.lua: -------------------------------------------------------------------------------- 1 | local thisisathing = {this_is_one = "one", this_is_two = "two", this_is_three = "three", this_is_four = "four", f = "b"} 2 | -------------------------------------------------------------------------------- /tests/inputs/table-5.lua: -------------------------------------------------------------------------------- 1 | a = { 2 | key1 = string.format("test", "test", "test", "test", "test", "test", "test", "test", "test", "test", variable_names), 3 | key2 = string.format("test", "test", "test", "test", "test", "test", "test", "test", "test", "test", variable_names), 4 | } 5 | -------------------------------------------------------------------------------- /tests/inputs/table-6.lua: -------------------------------------------------------------------------------- 1 | -- https://github.com/JohnnyMorganz/StyLua/issues/296 2 | aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa({ aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa = false}) 3 | aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa({ aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa = false }) 4 | -------------------------------------------------------------------------------- /tests/inputs/table-7.lua: -------------------------------------------------------------------------------- 1 | -- https://github.com/JohnnyMorganz/StyLua/issues/436 2 | local OffsetEnum = {aValue = 10, anotherValue = 11, yetAnotherValue = 12, reset = 0, postReset = 1, aaaaaaaaaaa = true} 3 | 4 | local OffsetEnum = { aValue = 10, anotherValue = 11, yetAnotherValue = 12, reset = 0, postReset = 1, aaaaaaaaa = true } 5 | -------------------------------------------------------------------------------- /tests/inputs/table-8.lua: -------------------------------------------------------------------------------- 1 | -- https://github.com/JohnnyMorganz/StyLua/issues/551 2 | local test = { 3 | { "http://example.com/b//c//d;p?q#blarg", "http://u:p@h.com/p/a/t/h?s#hash2", "http://u:p@h.com/p/a/t/h?s#hash2" }, 4 | } 5 | -------------------------------------------------------------------------------- /tests/inputs/table-field-comments-2.lua: -------------------------------------------------------------------------------- 1 | -- https://github.com/JohnnyMorganz/StyLua/issues/942 2 | local t = { 3 | plus_one = 4 | ---@param n number 5 | ---@return number 6 | function(n) 7 | return n + 1 8 | end , 9 | } 10 | -------------------------------------------------------------------------------- /tests/inputs/table-field-comments-3.lua: -------------------------------------------------------------------------------- 1 | -- https://github.com/JohnnyMorganz/StyLua/issues/942 2 | local mixed = { 3 | --- identity 4 | ---@param n number 5 | ---@return number 6 | function(n) 7 | return n 8 | end, 9 | plus_one = 10 | ---@param n number 11 | ---@return number 12 | function(n) 13 | return n + 1 14 | end, 15 | } 16 | -------------------------------------------------------------------------------- /tests/inputs/table-field-comments.lua: -------------------------------------------------------------------------------- 1 | -- https://github.com/JohnnyMorganz/StyLua/issues/471 2 | local foo = { 3 | x = props.Item.Type == "Crystal" 4 | and utf8.char(0x221e) -- Infinite symbol 5 | or nil, 6 | } 7 | -------------------------------------------------------------------------------- /tests/inputs/table-field-hanging-1.lua: -------------------------------------------------------------------------------- 1 | -- https://github.com/JohnnyMorganz/StyLua/issues/542 2 | -- https://github.com/JohnnyMorganz/StyLua/issues/541 3 | local thisIsATable = { 4 | CreateAnElementFromThisTable = SomethingIsSelected and getTheSelectedThing(TheSelectedItem) or getTheSelectedThing(NoItemSelected) 5 | } 6 | -------------------------------------------------------------------------------- /tests/inputs/table-functions.lua: -------------------------------------------------------------------------------- 1 | local foo = {} function foo.bar(baz) print(x,y) end -------------------------------------------------------------------------------- /tests/inputs/table-trailing-comma-comments.lua: -------------------------------------------------------------------------------- 1 | -- https://github.com/JohnnyMorganz/StyLua/issues/547 2 | local too = { 3 | x, -- string 4 | y -- string 5 | } 6 | -------------------------------------------------------------------------------- /tests/inputs/table-wrapping.lua: -------------------------------------------------------------------------------- 1 | local foo = { 2 | {"foobarbazfoobarbaz", "foobarbazfoobarbaz"}, 3 | {"foobarbazfoobarbaz", "foobarbazfoobarbaz"}, 4 | {"foobarbazfoobarbaz", "foobarbazfoobarbaz"}, 5 | {"foobarbazfoobarbaz", "foobarbazfoobarbaz"} 6 | } -------------------------------------------------------------------------------- /tests/inputs/var-expression-comments-2.lua: -------------------------------------------------------------------------------- 1 | -- https://github.com/JohnnyMorganz/StyLua/issues/509 2 | local foo = bar -- comment after bar 3 | .fizz -- comment after fizz 4 | -------------------------------------------------------------------------------- /tests/inputs/var-expression-comments.lua: -------------------------------------------------------------------------------- 1 | -- https://github.com/JohnnyMorganz/StyLua/issues/500 2 | local foo = bar 3 | -- comment 1 4 | .fizz 5 | -- comment 2 6 | .buzz 7 | -------------------------------------------------------------------------------- /tests/inputs/while-1.lua: -------------------------------------------------------------------------------- 1 | while true do 2 | print("foo") 3 | end -------------------------------------------------------------------------------- /tests/inputs/while-2.lua: -------------------------------------------------------------------------------- 1 | function foo() 2 | while NextFreq.Access ~= true and not Llama.List.find(NextFreq.Access, Players.LocalPlayer.Team.Name) and NextIndex > #Constants.RADIO_CHANNEL_ORDER do 3 | print("test") 4 | end 5 | end -------------------------------------------------------------------------------- /tests/snapshots/test_editorconfig__empty_root.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: tests/test_editorconfig.rs 3 | expression: "format(&contents, path.to_str().unwrap())" 4 | input_file: tests/inputs-editorconfig/empty-root/tab-double.lua 5 | --- 6 | local foo = { 7 | a = 1, 8 | } 9 | 10 | local bar = "" 11 | 12 | -------------------------------------------------------------------------------- /tests/snapshots/test_editorconfig__global.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: tests/test_editorconfig.rs 3 | expression: "format(&contents, path.to_str().unwrap())" 4 | input_file: tests/inputs-editorconfig/global/tab-single.lua 5 | --- 6 | local foo = { 7 | a = 1, 8 | } 9 | 10 | local bar = '' 11 | 12 | -------------------------------------------------------------------------------- /tests/snapshots/test_editorconfig__local.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: tests/test_editorconfig.rs 3 | expression: "format(&contents, path.to_str().unwrap())" 4 | input_file: tests/inputs-editorconfig/local/space-4.lua 5 | --- 6 | local foo = { 7 | a = 1, 8 | } 9 | 10 | local bar = "" 11 | 12 | -------------------------------------------------------------------------------- /tests/snapshots/test_editorconfig__root.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: tests/test_editorconfig.rs 3 | expression: "format(&contents, path.to_str().unwrap())" 4 | input_file: tests/inputs-editorconfig/space-2.lua 5 | --- 6 | local foo = { 7 | a = 1, 8 | } 9 | 10 | local bar = "" 11 | 12 | -------------------------------------------------------------------------------- /tests/snapshots/test_editorconfig__stylua_toml.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: tests/test_editorconfig.rs 3 | expression: "&contents" 4 | input_file: tests/inputs-editorconfig/stylua-toml/single-space-8.lua 5 | --- 6 | local foo = { 7 | a = 1, 8 | } 9 | 10 | local bar = '' 11 | 12 | -------------------------------------------------------------------------------- /tests/snapshots/tests__cfxlua@addition_assignment_operator.lua.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: tests/tests.rs 3 | expression: "format(&contents, LuaVersion::CfxLua)" 4 | input_file: tests/inputs-cfxlua/addition_assignment_operator.lua 5 | snapshot_kind: text 6 | --- 7 | local index = 1 8 | 9 | index += 1 10 | -------------------------------------------------------------------------------- /tests/snapshots/tests__cfxlua@ampersand_equal.lua.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: tests/tests.rs 3 | expression: "format(&contents, LuaVersion::CfxLua)" 4 | input_file: tests/inputs-cfxlua/ampersand_equal.lua 5 | snapshot_kind: text 6 | --- 7 | local num = 6 8 | num &= 3 9 | -------------------------------------------------------------------------------- /tests/snapshots/tests__cfxlua@bitwise_xor_assignment_operator.lua.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: tests/tests.rs 3 | expression: "format(&contents, LuaVersion::CfxLua)" 4 | input_file: tests/inputs-cfxlua/bitwise_xor_assignment_operator.lua 5 | snapshot_kind: text 6 | --- 7 | local num = 5 8 | num ^= 3 9 | -------------------------------------------------------------------------------- /tests/snapshots/tests__cfxlua@c_style_comments.lua.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: tests/tests.rs 3 | expression: "format(&contents, LuaVersion::CfxLua)" 4 | input_file: tests/inputs-cfxlua/c_style_comments.lua 5 | snapshot_kind: text 6 | --- 7 | print("Hello, World!") 8 | /* Comment */ 9 | /* 10 | Multi 11 | Line 12 | Comment 13 | */ 14 | -------------------------------------------------------------------------------- /tests/snapshots/tests__cfxlua@compile_time_jenkins_hashes.lua.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: tests/tests.rs 3 | expression: "format(&contents, LuaVersion::CfxLua)" 4 | input_file: tests/inputs-cfxlua/compile_time_jenkins_hashes.lua 5 | snapshot_kind: text 6 | --- 7 | print(`Hello, World!`) 8 | -------------------------------------------------------------------------------- /tests/snapshots/tests__cfxlua@division_assignment_operator.lua.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: tests/tests.rs 3 | expression: "format(&contents, LuaVersion::CfxLua)" 4 | input_file: tests/inputs-cfxlua/division_assignment_operator.lua 5 | snapshot_kind: text 6 | --- 7 | local num = 10 8 | num /= 2 9 | -------------------------------------------------------------------------------- /tests/snapshots/tests__cfxlua@double_greater_than_equal.lua.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: tests/tests.rs 3 | expression: "format(&contents, LuaVersion::CfxLua)" 4 | input_file: tests/inputs-cfxlua/double_greater_than_equal.lua 5 | snapshot_kind: text 6 | --- 7 | local num = 4 8 | num >>= 2 9 | -------------------------------------------------------------------------------- /tests/snapshots/tests__cfxlua@double_less_than_equal.lua.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: tests/tests.rs 3 | expression: "format(&contents, LuaVersion::CfxLua)" 4 | input_file: tests/inputs-cfxlua/double_less_than_equal.lua 5 | snapshot_kind: text 6 | --- 7 | local num = 1 8 | num <<= 2 9 | -------------------------------------------------------------------------------- /tests/snapshots/tests__cfxlua@each_iteration.lua.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: tests/tests.rs 3 | expression: "format(&contents, LuaVersion::CfxLua)" 4 | input_file: tests/inputs-cfxlua/each_iteration.lua 5 | snapshot_kind: text 6 | --- 7 | local t = { 1, 2, 3 } 8 | for k, v in each(t) do 9 | print(k, v) 10 | end 11 | -------------------------------------------------------------------------------- /tests/snapshots/tests__cfxlua@in_unpacking.lua.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: tests/tests.rs 3 | expression: "format(&contents, LuaVersion::CfxLua)" 4 | input_file: tests/inputs-cfxlua/in_unpacking.lua 5 | snapshot_kind: text 6 | --- 7 | local t = { 8 | a = 1, 9 | b = 2, 10 | c = 3, 11 | } 12 | 13 | local a, b, c in t 14 | -------------------------------------------------------------------------------- /tests/snapshots/tests__cfxlua@multiplication_assignment_operator.lua.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: tests/tests.rs 3 | expression: "format(&contents, LuaVersion::CfxLua)" 4 | input_file: tests/inputs-cfxlua/multiplication_assignment_operator.lua 5 | snapshot_kind: text 6 | --- 7 | local base = 10 8 | base *= 2 9 | -------------------------------------------------------------------------------- /tests/snapshots/tests__cfxlua@pipe_equal.lua.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: tests/tests.rs 3 | expression: "format(&contents, LuaVersion::CfxLua)" 4 | input_file: tests/inputs-cfxlua/pipe_equal.lua 5 | snapshot_kind: text 6 | --- 7 | local num = 4 8 | num |= 1 9 | -------------------------------------------------------------------------------- /tests/snapshots/tests__cfxlua@question_mark_dot.lua.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: tests/tests.rs 3 | expression: "format(&contents, LuaVersion::CfxLua)" 4 | input_file: tests/inputs-cfxlua/question_mark_dot.lua 5 | snapshot_kind: text 6 | --- 7 | local a = { 8 | b = 1, 9 | c = 2, 10 | d = { 11 | e = 3, 12 | }, 13 | } 14 | 15 | local x = a?.b 16 | local y = a?.d?.e 17 | -------------------------------------------------------------------------------- /tests/snapshots/tests__cfxlua@set_constructor.lua.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: tests/tests.rs 3 | expression: "format(&contents, LuaVersion::CfxLua)" 4 | input_file: tests/inputs-cfxlua/set_constructor.lua 5 | snapshot_kind: text 6 | --- 7 | t = { .a, b = false } 8 | -------------------------------------------------------------------------------- /tests/snapshots/tests__cfxlua@subtraction_assignment_operator.lua.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: tests/tests.rs 3 | expression: "format(&contents, LuaVersion::CfxLua)" 4 | input_file: tests/inputs-cfxlua/subtraction_assignment_operator.lua 5 | snapshot_kind: text 6 | --- 7 | local ten = 10 8 | ten -= 5 9 | -------------------------------------------------------------------------------- /tests/snapshots/tests__collapse_single_statement@complex-conditional-1.lua.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: tests/tests.rs 3 | expression: "format_code(&contents,\n Config::default().with_collapse_simple_statement(CollapseSimpleStatement::Always),\n None, OutputVerification::None).unwrap()" 4 | --- 5 | if child == nil then 6 | child, index = index, #self + 1 7 | end 8 | 9 | -------------------------------------------------------------------------------- /tests/snapshots/tests__collapse_single_statement@complex-return-4.lua.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: tests/tests.rs 3 | expression: "format_code(&contents,\n Config::default().with_collapse_simple_statement(CollapseSimpleStatement::Always),\n None, OutputVerification::None).unwrap()" 4 | --- 5 | local erroring = function(x) 6 | return function() error(x, 0) end 7 | end 8 | 9 | -------------------------------------------------------------------------------- /tests/snapshots/tests__collapse_single_statement@nested-functions.lua.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: tests/tests.rs 3 | expression: "format_code(&contents,\n Config::default().with_collapse_simple_statement(CollapseSimpleStatement::Always),\n None, OutputVerification::None).unwrap()" 4 | --- 5 | local get_match = function(hl_group) 6 | return vim.tbl_filter(function(x) return x.group == hl_group end, child.fn.getmatches()) 7 | end 8 | 9 | -------------------------------------------------------------------------------- /tests/snapshots/tests__collapse_single_statement@over-column-width.lua.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: tests/tests.rs 3 | expression: "format_code(&contents,\n Config::default().with_collapse_simple_statement(CollapseSimpleStatement::Always),\n None, OutputVerification::None).unwrap()" 4 | --- 5 | function MiniCompletion.default_process_items(items, base) 6 | return H.default_config.lsp_completion.process_items(items, base) 7 | end 8 | 9 | -------------------------------------------------------------------------------- /tests/snapshots/tests__collapse_single_statement@simple-conditional-1.lua.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: tests/tests.rs 3 | expression: "format_code(&contents,\n Config::default().with_collapse_simple_statement(CollapseSimpleStatement::Always),\n None, OutputVerification::None).unwrap()" 4 | --- 5 | if x == true then return end 6 | 7 | -------------------------------------------------------------------------------- /tests/snapshots/tests__collapse_single_statement@simple-conditional-2.lua.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: tests/tests.rs 3 | expression: "format_code(&contents,\n Config::default().with_collapse_simple_statement(CollapseSimpleStatement::Always),\n None, OutputVerification::None).unwrap()" 4 | --- 5 | -- https://github.com/JohnnyMorganz/StyLua/issues/744 6 | 7 | if tabnr ~= finaltab then stack:push("%T") end 8 | 9 | -------------------------------------------------------------------------------- /tests/snapshots/tests__collapse_single_statement@simple-conditional-indentation.lua.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: tests/tests.rs 3 | expression: "format_code(&contents,\n Config::default().with_collapse_simple_statement(CollapseSimpleStatement::Always),\n None, OutputVerification::None).unwrap()" 4 | --- 5 | for i = 1, 10 do 6 | if true then return end 7 | end 8 | 9 | -------------------------------------------------------------------------------- /tests/snapshots/tests__collapse_single_statement@simple-conditional-over-width.lua.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: tests/tests.rs 3 | expression: "format_code(&contents,\n Config::default().with_collapse_simple_statement(CollapseSimpleStatement::Always),\n None, OutputVerification::None).unwrap()" 4 | --- 5 | if thisIsAVeryLongConditionthisIsAVeryLongConditionThisIsAVeryLongCondition then 6 | return thisIsAVeryLongReturnedExpression 7 | end 8 | 9 | -------------------------------------------------------------------------------- /tests/snapshots/tests__collapse_single_statement@simple-conditional-stmt-block-1.lua.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: tests/tests.rs 3 | expression: "format_code(&contents,\n Config::default().with_collapse_simple_statement(CollapseSimpleStatement::Always),\n None, OutputVerification::None).unwrap()" 4 | --- 5 | if true then call("hello") end 6 | 7 | -------------------------------------------------------------------------------- /tests/snapshots/tests__collapse_single_statement@simple-function-argument-1.lua.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: tests/tests.rs 3 | expression: "format_code(&contents,\n Config::default().with_collapse_simple_statement(CollapseSimpleStatement::Always),\n None, OutputVerification::None).unwrap()" 4 | --- 5 | local comment_parts = vim.tbl_filter(function(x) return x ~= "" end, vim.split(commentstring, "%s", true)) 6 | 7 | -------------------------------------------------------------------------------- /tests/snapshots/tests__collapse_single_statement@simple-function-stmt-block-1.lua.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: tests/tests.rs 3 | expression: "format_code(&contents,\n Config::default().with_collapse_simple_statement(CollapseSimpleStatement::Always),\n None, OutputVerification::None).unwrap()" 4 | --- 5 | local x = function() call("testing") end 6 | 7 | -------------------------------------------------------------------------------- /tests/snapshots/tests__collapse_single_statement@simple-function-stmt-block-2.lua.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: tests/tests.rs 3 | expression: "format_code(&contents,\n Config::default().with_collapse_simple_statement(CollapseSimpleStatement::Always),\n None, OutputVerification::None).unwrap()" 4 | --- 5 | local x = function() x = 1 end 6 | 7 | -------------------------------------------------------------------------------- /tests/snapshots/tests__collapse_single_statement@simple-function-stmt-block-3.lua.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: tests/tests.rs 3 | expression: "format_code(&contents,\n Config::default().with_collapse_simple_statement(CollapseSimpleStatement::Always),\n None, OutputVerification::None).unwrap()" 4 | --- 5 | local x = function() local x = 1 end 6 | 7 | -------------------------------------------------------------------------------- /tests/snapshots/tests__collapse_single_statement@simple-function.lua.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: tests/tests.rs 3 | expression: "format_code(&contents,\n Config::default().with_collapse_simple_statement(CollapseSimpleStatement::Always),\n None, OutputVerification::None).unwrap()" 4 | --- 5 | function foo() return bar end 6 | 7 | -------------------------------------------------------------------------------- /tests/snapshots/tests__full_moon_test_suite@anonymous-functions-1.lua.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: tests/tests.rs 3 | expression: format(&contents) 4 | --- 5 | local x = function() 6 | call(1) 7 | end 8 | 9 | -------------------------------------------------------------------------------- /tests/snapshots/tests__full_moon_test_suite@anonymous-functions-2.lua.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: tests/tests.rs 3 | expression: format(&contents) 4 | --- 5 | call(function() 6 | foo("bar") 7 | end) 8 | 9 | -------------------------------------------------------------------------------- /tests/snapshots/tests__full_moon_test_suite@anonymous-functions-3.lua.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: tests/tests.rs 3 | expression: format(&contents) 4 | --- 5 | local x = function(...) end 6 | 7 | -------------------------------------------------------------------------------- /tests/snapshots/tests__full_moon_test_suite@anonymous-functions-4.lua.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: tests/tests.rs 3 | expression: format(&contents) 4 | --- 5 | local x = function(a, b, ...) end 6 | 7 | -------------------------------------------------------------------------------- /tests/snapshots/tests__full_moon_test_suite@assignment-1.lua.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: tests/tests.rs 3 | expression: format(&contents) 4 | --- 5 | x = 1 6 | 7 | -------------------------------------------------------------------------------- /tests/snapshots/tests__full_moon_test_suite@assignment-2.lua.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: tests/tests.rs 3 | expression: format(&contents) 4 | --- 5 | a, b = 1, true 6 | 7 | -------------------------------------------------------------------------------- /tests/snapshots/tests__full_moon_test_suite@assignment-3.lua.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: tests/tests.rs 3 | expression: format(&contents) 4 | --- 5 | -- Crazy assignment code from AmaranthineCodices 6 | a, b, c.d.e[f][g][1], h:i().j[k]:l()[m] = true, false, 1, 4 7 | 8 | -------------------------------------------------------------------------------- /tests/snapshots/tests__full_moon_test_suite@assignment-4.lua.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: tests/tests.rs 3 | expression: "format(&contents, LuaVersion::Lua51)" 4 | input_file: tests/inputs-full_moon/assignment-4.lua 5 | --- 6 | a = 1 7 | b = 2 8 | 9 | -------------------------------------------------------------------------------- /tests/snapshots/tests__full_moon_test_suite@assignment-5.lua.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: tests/tests.rs 3 | expression: "format(&contents, LuaVersion::Lua51)" 4 | input_file: tests/inputs-full_moon/assignment-5.lua 5 | --- 6 | gui.Label.Text = "LOADING DATA" .. ("."):rep(dotCount) 7 | 8 | -------------------------------------------------------------------------------- /tests/snapshots/tests__full_moon_test_suite@binops.lua.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: tests/tests.rs 3 | expression: format(&contents) 4 | --- 5 | a = foo and bar 6 | b = foo and bar or baz 7 | c = 1 + 2 * 3 - 4 ^ 2 8 | d = a + i < b / 2 + 1 9 | e = 5 + x ^ 2 * 8 10 | f = a < y and y <= z 11 | g = -x ^ 2 12 | h = x ^ y ^ z 13 | 14 | -------------------------------------------------------------------------------- /tests/snapshots/tests__full_moon_test_suite@body-with-spaces.lua.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: tests/tests.rs 3 | expression: "format(&contents, LuaVersion::Lua51)" 4 | input_file: tests/inputs-full_moon/body-with-spaces.lua 5 | --- 6 | do 7 | end 8 | 9 | -------------------------------------------------------------------------------- /tests/snapshots/tests__full_moon_test_suite@call-1.lua.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: tests/tests.rs 3 | expression: format(&contents) 4 | --- 5 | call() 6 | call(1) 7 | call(1, 2) 8 | 9 | -------------------------------------------------------------------------------- /tests/snapshots/tests__full_moon_test_suite@call-2.lua.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: tests/tests.rs 3 | expression: format(&contents) 4 | --- 5 | x.y("a") 6 | x:y("b") 7 | 8 | -------------------------------------------------------------------------------- /tests/snapshots/tests__full_moon_test_suite@do.lua.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: tests/tests.rs 3 | expression: format(&contents) 4 | --- 5 | do 6 | call() 7 | end 8 | 9 | -------------------------------------------------------------------------------- /tests/snapshots/tests__full_moon_test_suite@empty.lua.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: tests/tests.rs 3 | expression: format(&contents) 4 | --- 5 | 6 | -------------------------------------------------------------------------------- /tests/snapshots/tests__full_moon_test_suite@exponents.lua.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: tests/tests.rs 3 | expression: format(&contents) 4 | --- 5 | local num = 1e5 6 | local num2 = 1e-5 7 | local num3 = 1e+5 8 | 9 | -------------------------------------------------------------------------------- /tests/snapshots/tests__full_moon_test_suite@fractional-numbers.lua.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: tests/tests.rs 3 | expression: format(&contents) 4 | --- 5 | local num = 0.5 6 | local num2 = 0.5e5 7 | local num3 = 0.5 8 | local num4 = 0.5e5 9 | local num5 = 1. 10 | 11 | -------------------------------------------------------------------------------- /tests/snapshots/tests__full_moon_test_suite@function-declaration-1.lua.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: tests/tests.rs 3 | expression: format(&contents) 4 | --- 5 | function x() 6 | call() 7 | end 8 | 9 | -------------------------------------------------------------------------------- /tests/snapshots/tests__full_moon_test_suite@function-declaration-2.lua.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: tests/tests.rs 3 | expression: format(&contents) 4 | --- 5 | function x.y:z() end 6 | 7 | -------------------------------------------------------------------------------- /tests/snapshots/tests__full_moon_test_suite@function-shortcuts.lua.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: tests/tests.rs 3 | expression: format(&contents) 4 | --- 5 | call({ x = 1 }) 6 | call("hello") 7 | 8 | -------------------------------------------------------------------------------- /tests/snapshots/tests__full_moon_test_suite@generic-for-loop-1.lua.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: tests/tests.rs 3 | expression: format(&contents) 4 | --- 5 | for index, value in pairs(list) do 6 | call(index, value) 7 | end 8 | 9 | -------------------------------------------------------------------------------- /tests/snapshots/tests__full_moon_test_suite@generic-for-loop-2.lua.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: tests/tests.rs 3 | expression: format(&contents) 4 | --- 5 | for index, value in next, list do 6 | call(index, value) 7 | end 8 | 9 | -------------------------------------------------------------------------------- /tests/snapshots/tests__full_moon_test_suite@goto-as-identifier.lua.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: tests/tests.rs 3 | expression: format(&contents) 4 | --- 5 | -- goto as an identifier is permitted in lua 5.1 6 | self.goto("foo") 7 | 8 | -------------------------------------------------------------------------------- /tests/snapshots/tests__full_moon_test_suite@gt-lt.lua.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: tests/tests.rs 3 | expression: format(&contents) 4 | --- 5 | call(1 < 2) 6 | call(1 <= 2) 7 | call(2 > 1) 8 | call(2 >= 1) 9 | call(x >= y) 10 | 11 | -------------------------------------------------------------------------------- /tests/snapshots/tests__full_moon_test_suite@if-1.lua.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: tests/tests.rs 3 | expression: format(&contents) 4 | --- 5 | if x then 6 | call() 7 | end 8 | 9 | -------------------------------------------------------------------------------- /tests/snapshots/tests__full_moon_test_suite@if-2.lua.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: tests/tests.rs 3 | expression: format(&contents) 4 | --- 5 | if x then 6 | foo() 7 | else 8 | bar() 9 | end 10 | 11 | -------------------------------------------------------------------------------- /tests/snapshots/tests__full_moon_test_suite@if-3.lua.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: tests/tests.rs 3 | expression: format(&contents) 4 | --- 5 | if x then 6 | foo() 7 | elseif y then 8 | bar() 9 | end 10 | 11 | -------------------------------------------------------------------------------- /tests/snapshots/tests__full_moon_test_suite@if-4.lua.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: tests/tests.rs 3 | expression: format(&contents) 4 | --- 5 | if x then 6 | foo() 7 | elseif y then 8 | bar() 9 | else 10 | baz() 11 | end 12 | 13 | -------------------------------------------------------------------------------- /tests/snapshots/tests__full_moon_test_suite@index-1.lua.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: tests/tests.rs 3 | expression: format(&contents) 4 | --- 5 | local x = a.b.c 6 | 7 | -------------------------------------------------------------------------------- /tests/snapshots/tests__full_moon_test_suite@index-2.lua.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: tests/tests.rs 3 | expression: format(&contents) 4 | --- 5 | local x = call("a").b 6 | 7 | -------------------------------------------------------------------------------- /tests/snapshots/tests__full_moon_test_suite@local-assignment-1.lua.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: tests/tests.rs 3 | expression: format(&contents) 4 | --- 5 | local x 6 | 7 | -------------------------------------------------------------------------------- /tests/snapshots/tests__full_moon_test_suite@local-assignment-2.lua.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: tests/tests.rs 3 | expression: format(&contents) 4 | --- 5 | local x = 1 6 | 7 | -------------------------------------------------------------------------------- /tests/snapshots/tests__full_moon_test_suite@local-assignment-3.lua.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: tests/tests.rs 3 | expression: format(&contents) 4 | --- 5 | local a, b = 1, 2 6 | local c, d = 3, 4 7 | local e, f = 5, 6 8 | 9 | -------------------------------------------------------------------------------- /tests/snapshots/tests__full_moon_test_suite@local-assignment-4.lua.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: tests/tests.rs 3 | expression: format(&contents) 4 | --- 5 | local x, y 6 | 7 | -------------------------------------------------------------------------------- /tests/snapshots/tests__full_moon_test_suite@local-assignment-5.lua.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: tests/tests.rs 3 | expression: format(&contents) 4 | --- 5 | local x = 1 6 | -- Then a comment 7 | local y = 1 8 | 9 | -------------------------------------------------------------------------------- /tests/snapshots/tests__full_moon_test_suite@local-function-1.lua.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: tests/tests.rs 3 | expression: format(&contents) 4 | --- 5 | local function x() 6 | call(1) 7 | end 8 | 9 | -------------------------------------------------------------------------------- /tests/snapshots/tests__full_moon_test_suite@local-function-2.lua.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: tests/tests.rs 3 | expression: format(&contents) 4 | --- 5 | local function foo(a, b) end 6 | local function bar(...) end 7 | local function baz(a, b, ...) end 8 | 9 | -------------------------------------------------------------------------------- /tests/snapshots/tests__full_moon_test_suite@mixed-indented-comments.lua.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: tests/tests.rs 3 | expression: format(&contents) 4 | --- 5 | -- Indented single line 6 | --[[ 7 | Indented multi line 8 | ]] 9 | 10 | -------------------------------------------------------------------------------- /tests/snapshots/tests__full_moon_test_suite@multi-line-comments-1.lua.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: tests/tests.rs 3 | expression: format(&contents) 4 | --- 5 | --[[ 6 | such comments 7 | much lines 8 | wow 9 | ]] 10 | 11 | -------------------------------------------------------------------------------- /tests/snapshots/tests__full_moon_test_suite@multi-line-comments-2.lua.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: tests/tests.rs 3 | expression: format(&contents) 4 | --- 5 | --[=[ 6 | never have i used these weird equals signs comments 7 | but im sure someone does 8 | ]=] 9 | 10 | -------------------------------------------------------------------------------- /tests/snapshots/tests__full_moon_test_suite@multi-line-comments-3.lua.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: tests/tests.rs 3 | expression: format(&contents) 4 | --- 5 | --[=[ 6 | --[[ 7 | ]=] 8 | 9 | -------------------------------------------------------------------------------- /tests/snapshots/tests__full_moon_test_suite@multi-line-comments-4.lua.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: tests/tests.rs 3 | expression: format(&contents) 4 | --- 5 | --[=====[ 6 | lua be like 7 | ]====] 8 | still going 9 | ]=====] 10 | 11 | -------------------------------------------------------------------------------- /tests/snapshots/tests__full_moon_test_suite@multi-line-comments-5.lua.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: tests/tests.rs 3 | expression: format(&contents) 4 | --- 5 | --[[ 6 | local emotes = { 7 | [":thinking:"] = "http://www.roblox.com/asset/?id=643340245", 8 | [":bug:"] = "http://www.roblox.com/asset/?id=860037275" 9 | } 10 | ]] 11 | 12 | -------------------------------------------------------------------------------- /tests/snapshots/tests__full_moon_test_suite@multi-line-comments-6.lua.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: tests/tests.rs 3 | expression: format(&contents) 4 | --- 5 | local function x( 6 | ... --[[comment here]] 7 | ) 8 | end 9 | 10 | -------------------------------------------------------------------------------- /tests/snapshots/tests__full_moon_test_suite@multi-line-comments-7.lua.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: tests/tests.rs 3 | expression: format(&contents) 4 | --- 5 | --[=[ μέλλον ]=] 6 | 7 | -- some text here 8 | 9 | -------------------------------------------------------------------------------- /tests/snapshots/tests__full_moon_test_suite@multi-line-comments-8.lua.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: tests/tests.rs 3 | expression: format(&contents) 4 | --- 5 | --[[👨🏾‍💻]] 6 | local more_code = here 7 | 8 | -------------------------------------------------------------------------------- /tests/snapshots/tests__full_moon_test_suite@multi-line-string-1.lua.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: tests/tests.rs 3 | expression: format(&contents) 4 | --- 5 | local x = [[Full Moon 6 | is a 7 | lossless 8 | Lua parser]] 9 | 10 | -------------------------------------------------------------------------------- /tests/snapshots/tests__full_moon_test_suite@multi-line-string-2.lua.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: tests/tests.rs 3 | expression: format(&contents) 4 | --- 5 | local x = [=[This is 6 | several equal 7 | signs]=] 8 | 9 | -------------------------------------------------------------------------------- /tests/snapshots/tests__full_moon_test_suite@multi-line-string-3.lua.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: tests/tests.rs 3 | expression: format(&contents) 4 | --- 5 | local x = [[ 6 | local emotes = { 7 | [":thinking:"] = "http://www.roblox.com/asset/?id=643340245", 8 | [":bug:"] = "http://www.roblox.com/asset/?id=860037275" 9 | } 10 | ]] 11 | 12 | -------------------------------------------------------------------------------- /tests/snapshots/tests__full_moon_test_suite@multi-line-string-4.lua.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: tests/tests.rs 3 | expression: format(&contents) 4 | --- 5 | call([[doge]]) 6 | 7 | -------------------------------------------------------------------------------- /tests/snapshots/tests__full_moon_test_suite@multi-line-string-5.lua.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: tests/tests.rs 3 | expression: format(&contents) 4 | --- 5 | local emoji = [[🧓🏽]] 6 | local more_code = here 7 | 8 | -------------------------------------------------------------------------------- /tests/snapshots/tests__full_moon_test_suite@multi-line-string-6.lua.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: tests/tests.rs 3 | expression: format(&contents) 4 | --- 5 | local foo = "bar\ 6 | baz" 7 | 8 | -------------------------------------------------------------------------------- /tests/snapshots/tests__full_moon_test_suite@multi-line-string-7.lua.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: tests/tests.rs 3 | expression: format(&contents) 4 | --- 5 | local a = [=[[%s]]=] 6 | 7 | -------------------------------------------------------------------------------- /tests/snapshots/tests__full_moon_test_suite@multi-line-string-8.lua.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: tests/tests.rs 3 | expression: format(&contents) 4 | --- 5 | local x = [=[\v<((do|load)file|require)\s*\(?['"]\zs[^'"]+\ze['"]]=] 6 | 7 | -------------------------------------------------------------------------------- /tests/snapshots/tests__full_moon_test_suite@negative-numbers.lua.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: tests/tests.rs 3 | expression: "format(&contents, LuaVersion::Lua51)" 4 | input_file: tests/inputs-full_moon/negative-numbers.lua 5 | --- 6 | local foo = x - 1 7 | local foo = x - 1 8 | print(1 + -3) 9 | local foo = -x + 1 10 | 11 | -------------------------------------------------------------------------------- /tests/snapshots/tests__full_moon_test_suite@numbers-1.lua.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: tests/tests.rs 3 | expression: "format(&contents, LuaVersion::Lua51)" 4 | input_file: tests/inputs-full_moon/numbers-1.lua 5 | --- 6 | _ = 0x02 7 | 8 | -------------------------------------------------------------------------------- /tests/snapshots/tests__full_moon_test_suite@numeric-for-loop.lua.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: tests/tests.rs 3 | expression: format(&contents) 4 | --- 5 | for index = 1, 10 do 6 | call(index) 7 | end 8 | for _ = start, final do 9 | end 10 | for _ = 1, 10, 2 do 11 | end 12 | 13 | -------------------------------------------------------------------------------- /tests/snapshots/tests__full_moon_test_suite@paren-expressions.lua.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: tests/tests.rs 3 | expression: format(&contents) 4 | --- 5 | local x = 1 + (2 - 3) 6 | 7 | -------------------------------------------------------------------------------- /tests/snapshots/tests__full_moon_test_suite@repeat-until.lua.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: tests/tests.rs 3 | expression: format(&contents) 4 | --- 5 | repeat 6 | call() 7 | until condition 8 | 9 | -------------------------------------------------------------------------------- /tests/snapshots/tests__full_moon_test_suite@return-break.lua.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: tests/tests.rs 3 | expression: format(&contents) 4 | --- 5 | do 6 | return 1 7 | end 8 | 9 | do 10 | break 11 | end 12 | 13 | return call() 14 | 15 | -------------------------------------------------------------------------------- /tests/snapshots/tests__full_moon_test_suite@semicolons-1.lua.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: tests/tests.rs 3 | expression: format(&contents) 4 | --- 5 | local x = 1 6 | x = x + 1 7 | 8 | -------------------------------------------------------------------------------- /tests/snapshots/tests__full_moon_test_suite@semicolons-2.lua.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: tests/tests.rs 3 | expression: format(&contents) 4 | --- 5 | local x = 1 6 | return x 7 | 8 | -------------------------------------------------------------------------------- /tests/snapshots/tests__full_moon_test_suite@shebang.lua.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: tests/tests.rs 3 | expression: format(&contents) 4 | --- 5 | #!/usr/bin/env lua 6 | 7 | print("Hello world") 8 | 9 | -------------------------------------------------------------------------------- /tests/snapshots/tests__full_moon_test_suite@single-line-comment-1.lua.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: tests/tests.rs 3 | expression: format(&contents) 4 | --- 5 | -- hello world 6 | -- and doge you too 7 | 8 | -------------------------------------------------------------------------------- /tests/snapshots/tests__full_moon_test_suite@single-line-comment-2.lua.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: tests/tests.rs 3 | expression: format(&contents) 4 | --- 5 | call() -- This calls 6 | 7 | -------------------------------------------------------------------------------- /tests/snapshots/tests__full_moon_test_suite@single-line-comment-3.lua.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: tests/tests.rs 3 | expression: format(&contents) 4 | --- 5 | -- tab in comment 6 | 7 | -------------------------------------------------------------------------------- /tests/snapshots/tests__full_moon_test_suite@single-line-comment-4.lua.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: tests/tests.rs 3 | expression: format(&contents) 4 | --- 5 | --[comment 6 | --(comment) 7 | --[=comment 8 | -- 9 | 10 | -------------------------------------------------------------------------------- /tests/snapshots/tests__full_moon_test_suite@single-line-comment-5.lua.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: tests/tests.rs 3 | expression: format(&contents) 4 | --- 5 | --`signatures` the value defaults to zero or is ignored if `signatures.length 6 | --=== 0`. Whenever possible implementors should make an active decision about 7 | 8 | -------------------------------------------------------------------------------- /tests/snapshots/tests__full_moon_test_suite@single-line-comment-6.lua.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: tests/tests.rs 3 | expression: format(&contents) 4 | input_file: tests/inputs-full_moon/single-line-comment-6.lua 5 | --- 6 | --随便写点中文 7 | 8 | -------------------------------------------------------------------------------- /tests/snapshots/tests__full_moon_test_suite@single-line-comment-7.lua.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: tests/tests.rs 3 | expression: format(&contents) 4 | input_file: tests/inputs-full_moon/single-line-comment-7.lua 5 | --- 6 | local a = 1 7 | 8 | --}}封装方便访问的接口========================================== 9 | 10 | -------------------------------------------------------------------------------- /tests/snapshots/tests__full_moon_test_suite@strings-escape-newline.lua.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: tests/tests.rs 3 | expression: format(&contents) 4 | --- 5 | print("foo\ 6 | bar") 7 | 8 | -------------------------------------------------------------------------------- /tests/snapshots/tests__full_moon_test_suite@strings-escape.lua.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: tests/tests.rs 3 | expression: format(&contents) 4 | --- 5 | call("\\") 6 | call("\\") 7 | call({ ["\\"] = "" }) 8 | 9 | -------------------------------------------------------------------------------- /tests/snapshots/tests__full_moon_test_suite@strings.lua.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: tests/tests.rs 3 | expression: format(&contents) 4 | --- 5 | call("double") 6 | call("single") 7 | call("foo\nbar") 8 | call("") 9 | 10 | -------------------------------------------------------------------------------- /tests/snapshots/tests__full_moon_test_suite@table-constructor-1.lua.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: tests/tests.rs 3 | expression: format(&contents) 4 | --- 5 | local x = {} 6 | 7 | -------------------------------------------------------------------------------- /tests/snapshots/tests__full_moon_test_suite@table-constructor-2.lua.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: tests/tests.rs 3 | expression: format(&contents) 4 | --- 5 | local x = { 1, 2, 3 } 6 | 7 | -------------------------------------------------------------------------------- /tests/snapshots/tests__full_moon_test_suite@table-constructor-3.lua.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: tests/tests.rs 3 | expression: format(&contents) 4 | --- 5 | local x = { 6 | a = 1, 7 | b = 2, 8 | c = 3, 9 | } 10 | 11 | local y = { 12 | a = 1, 13 | b = 2, 14 | c = 3, 15 | } 16 | 17 | -------------------------------------------------------------------------------- /tests/snapshots/tests__full_moon_test_suite@table-constructor-4.lua.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: tests/tests.rs 3 | expression: format(&contents) 4 | --- 5 | local x = { 6 | [call()] = 1, 7 | } 8 | 9 | -------------------------------------------------------------------------------- /tests/snapshots/tests__full_moon_test_suite@table-constructor-5.lua.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: tests/tests.rs 3 | expression: format(&contents) 4 | --- 5 | local x = { 6 | [call()] = 1, 7 | 2, 8 | } 9 | 10 | -------------------------------------------------------------------------------- /tests/snapshots/tests__full_moon_test_suite@table-constructor-6.lua.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: tests/tests.rs 3 | expression: format(&contents) 4 | --- 5 | local foo = { bar } 6 | 7 | -------------------------------------------------------------------------------- /tests/snapshots/tests__full_moon_test_suite@table-constructors-7.lua.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: tests/tests.rs 3 | expression: format(&contents) 4 | --- 5 | local blacklist = { 6 | ["Audio file failed to load (18)."] = true, 7 | ["HTTP 0 (HTTP 429 (HTTP/1.1 429 ProvisionedThroughputExceeded))"] = true, 8 | ["LoadCharacter can only be called when Player is in the world"] = true, 9 | } 10 | 11 | -------------------------------------------------------------------------------- /tests/snapshots/tests__full_moon_test_suite@table-constructors-8.lua.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: tests/tests.rs 3 | expression: format(&contents) 4 | --- 5 | return { 6 | ["Noob Attack: Periastron"] = "Noob Attack - Periastron", 7 | ["Noob Attack꞉ Periastron"] = "Noob Attack - Periastron", 8 | } 9 | 10 | -------------------------------------------------------------------------------- /tests/snapshots/tests__full_moon_test_suite@table-constructors-9.lua.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: tests/tests.rs 3 | expression: "format(&contents, LuaVersion::Lua51)" 4 | input_file: tests/inputs-full_moon/table-constructors-9.lua 5 | --- 6 | -- comments separated by tab chars, should be parsed as trailing trivia of the tokens they are next to 7 | -- stylua: ignore 8 | local too = { 9 | x, -- string 10 | y, -- string 11 | } 12 | 13 | -------------------------------------------------------------------------------- /tests/snapshots/tests__full_moon_test_suite@trivia-parsing.lua.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: tests/tests.rs 3 | expression: format(&contents) 4 | --- 5 | local foo = bar -- trailing comment 6 | 7 | -- leading comment 8 | local bar = baz 9 | local baz = foo 10 | 11 | do 12 | local foo = bar 13 | -- comment 14 | local bar = baz 15 | end 16 | 17 | -------------------------------------------------------------------------------- /tests/snapshots/tests__full_moon_test_suite@unops.lua.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: tests/tests.rs 3 | expression: format(&contents) 4 | --- 5 | local negativeLiteral = -3 6 | local negativeVariable = -x 7 | local notLiteral = not true 8 | local notVariable = not x 9 | local length = #x 10 | 11 | -------------------------------------------------------------------------------- /tests/snapshots/tests__full_moon_test_suite@utf-8.lua.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: tests/tests.rs 3 | expression: format(&contents) 4 | --- 5 | print("👚 " .. message) 6 | 7 | -------------------------------------------------------------------------------- /tests/snapshots/tests__full_moon_test_suite@while.lua.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: tests/tests.rs 3 | expression: format(&contents) 4 | --- 5 | while condition do 6 | call() 7 | break 8 | end 9 | 10 | -------------------------------------------------------------------------------- /tests/snapshots/tests__ignores@ignore-table-field.lua.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: tests/tests.rs 3 | expression: format(&contents) 4 | --- 5 | local foo = { 6 | -- stylua: ignore 7 | x = 2, 8 | y = 3, 9 | z = " he ", 10 | } 11 | 12 | local bar = { 13 | x = 2, 14 | -- stylua: ignore 15 | y = 3, 16 | z = " he ", 17 | } 18 | 19 | local baz = { 20 | x = 2, 21 | y = 3, 22 | -- stylua: ignore 23 | z = " he " , 24 | } 25 | 26 | -------------------------------------------------------------------------------- /tests/snapshots/tests__ignores@multiline-block-ignore-1.lua.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: tests/tests.rs 3 | expression: format(&contents) 4 | --- 5 | local foo = bar 6 | -- stylua: ignore start 7 | local bar = baz 8 | -- stylua: ignore end 9 | local bar = baz 10 | 11 | -------------------------------------------------------------------------------- /tests/snapshots/tests__ignores@multiline-block-ignore-2.lua.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: tests/tests.rs 3 | expression: format(&contents) 4 | --- 5 | local foo = bar 6 | -- stylua: ignore start 7 | local bar = baz 8 | local bar = baz 9 | -- stylua: ignore end 10 | local bar = baz 11 | 12 | -------------------------------------------------------------------------------- /tests/snapshots/tests__ignores@multiline-block-ignore-no-ending.lua.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: tests/tests.rs 3 | expression: format(&contents) 4 | --- 5 | local foo = bar 6 | -- stylua: ignore start 7 | local bar = baz 8 | local bar = baz 9 | local bar = baz 10 | 11 | -------------------------------------------------------------------------------- /tests/snapshots/tests__ignores@multiline-block-ignore-no-starting.lua.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: tests/tests.rs 3 | expression: format(&contents) 4 | --- 5 | local foo = bar 6 | local bar = baz 7 | local bar = baz 8 | -- stylua: ignore end 9 | local bar = baz 10 | 11 | -------------------------------------------------------------------------------- /tests/snapshots/tests__ignores@multiline-block-ignore-scope-no-ending.lua.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: tests/tests.rs 3 | expression: format(&contents) 4 | --- 5 | local foo = bar 6 | do 7 | -- stylua: ignore start 8 | local bar = baz 9 | local bar = baz 10 | end 11 | local bar = baz 12 | 13 | -------------------------------------------------------------------------------- /tests/snapshots/tests__ignores@multiline-block-ignore-scope.lua.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: tests/tests.rs 3 | expression: format(&contents) 4 | --- 5 | local foo = bar 6 | do 7 | -- stylua: ignore start 8 | local bar = baz 9 | -- stylua: ignore end 10 | local bar = baz 11 | end 12 | local bar = baz 13 | 14 | -------------------------------------------------------------------------------- /tests/snapshots/tests__ignores@multiline-ignore-table-field.lua.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: tests/tests.rs 3 | expression: format(&contents) 4 | --- 5 | -- https://github.com/JohnnyMorganz/StyLua/issues/705 6 | 7 | require("foo").bar({ 8 | -- stylua: ignore start 9 | baz =0, 10 | foo = 2, 11 | -- stylua: ignore end 12 | bar = 1234, 13 | }) 14 | 15 | -------------------------------------------------------------------------------- /tests/snapshots/tests__ignores@singleline-ignore-1.lua.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: tests/tests.rs 3 | expression: format(&contents) 4 | --- 5 | local foo = bar 6 | -- stylua: ignore 7 | local bar = baz 8 | 9 | -------------------------------------------------------------------------------- /tests/snapshots/tests__ignores@singleline-ignore-2.lua.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: tests/tests.rs 3 | expression: format(&contents) 4 | --- 5 | local foo = bar 6 | -- stylua: ignore 7 | local bar = baz 8 | local bar = baz 9 | 10 | -------------------------------------------------------------------------------- /tests/snapshots/tests__ignores@singleline-ignore-last-stmt.lua.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: tests/tests.rs 3 | expression: format(&contents) 4 | --- 5 | -- stylua: ignore 6 | return "hi" 7 | 8 | -------------------------------------------------------------------------------- /tests/snapshots/tests__ignores@singleline-ignore-stmt-block.lua.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: tests/tests.rs 3 | expression: format(&contents) 4 | --- 5 | local x = 1 6 | -- stylua: ignore 7 | function foo () 8 | return x + 1 9 | end 10 | 11 | -------------------------------------------------------------------------------- /tests/snapshots/tests__lua52@goto-1.lua.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: tests/tests.rs 3 | expression: format(&contents) 4 | --- 5 | for i = 1, 10 do 6 | if i == 1 then 7 | goto skip 8 | end 9 | end 10 | ::skip:: 11 | 12 | -------------------------------------------------------------------------------- /tests/snapshots/tests__lua52@goto-2.lua.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: tests/tests.rs 3 | expression: format(&contents) 4 | --- 5 | -- http://lua-users.org/wiki/GotoStatement 6 | ::redo:: 7 | for x = 1, 10 do 8 | for y = 1, 10 do 9 | if not f(x, y) then 10 | goto continue 11 | end 12 | if not g(x, y) then 13 | goto skip 14 | end 15 | if not h(x, y) then 16 | goto redo 17 | end 18 | ::continue:: 19 | end 20 | end 21 | ::skip:: 22 | 23 | -------------------------------------------------------------------------------- /tests/snapshots/tests__lua53@binary-operators.lua.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: tests/tests.rs 3 | expression: format(&contents) 4 | --- 5 | local a = 1 & 2 6 | local b = 1 | 2 7 | local c = 1 << 2 8 | local d = 1 >> 2 9 | local e = 1 ~ 2 10 | local f = 1 // 2 11 | 12 | -------------------------------------------------------------------------------- /tests/snapshots/tests__lua53@unary-operators.lua.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: tests/tests.rs 3 | expression: format(&contents) 4 | --- 5 | local x = ~1 6 | 7 | -------------------------------------------------------------------------------- /tests/snapshots/tests__lua54@attributes-1.lua.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: tests/tests.rs 3 | expression: format(&contents) 4 | --- 5 | local a = 5 6 | local d 7 | local e , f = 1, 2 8 | local g , h 9 | local i , j, k 10 | 11 | -------------------------------------------------------------------------------- /tests/snapshots/tests__lua54@attributes-2.lua.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: tests/tests.rs 3 | expression: format(&contents) 4 | input_file: tests/inputs-lua54/attributes-2.lua 5 | --- 6 | local a = 1 7 | 8 | -------------------------------------------------------------------------------- /tests/snapshots/tests__luau@anonymous-function-types.lua.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: tests/tests.rs 3 | expression: format(&contents) 4 | --- 5 | local Object = { ClassName = "Object" } 6 | Object.__tostring = function(self) 7 | return self.ClassName 8 | end 9 | 10 | Object.__tostring = function(self): string 11 | return self.ClassName 12 | end 13 | 14 | -------------------------------------------------------------------------------- /tests/snapshots/tests__luau@attributes-1.lua.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: tests/tests.rs 3 | expression: "format(&contents, LuaVersion::Luau)" 4 | input_file: tests/inputs-luau/attributes-1.lua 5 | snapshot_kind: text 6 | --- 7 | @native 8 | function foo() end 9 | 10 | @deprecated 11 | local function bar() end 12 | 13 | local x = @native function() end 14 | -------------------------------------------------------------------------------- /tests/snapshots/tests__luau@attributes-2.lua.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: tests/tests.rs 3 | expression: "format(&contents, LuaVersion::Luau)" 4 | input_file: tests/inputs-luau/attributes-2.lua 5 | snapshot_kind: text 6 | --- 7 | @native 8 | function foo() end 9 | 10 | @native 11 | @deprecated 12 | function bar() end 13 | -------------------------------------------------------------------------------- /tests/snapshots/tests__luau@attributes-3.lua.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: tests/tests.rs 3 | expression: "format(&contents, LuaVersion::Luau)" 4 | input_file: tests/inputs-luau/attributes-3.lua 5 | snapshot_kind: text 6 | --- 7 | local x = @native function() end 8 | 9 | local y = @native @deprecated function() end 10 | -------------------------------------------------------------------------------- /tests/snapshots/tests__luau@compound-assignment-ambiguous-syntax.lua.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: tests/tests.rs 3 | expression: format(&contents) 4 | input_file: tests/inputs-luau/compound-assignment-ambiguous-syntax.lua 5 | --- 6 | -- https://github.com/JohnnyMorganz/StyLua/issues/885 7 | 8 | local function foo() 9 | return { b = "foo" } 10 | end 11 | 12 | local a = foo(); 13 | (a :: any).b ..= "bar" 14 | -------------------------------------------------------------------------------- /tests/snapshots/tests__luau@compound_operators.lua.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: tests/tests.rs 3 | expression: format(&contents) 4 | --- 5 | x += 1 6 | x -= 7 7 | 8 | -------------------------------------------------------------------------------- /tests/snapshots/tests__luau@excess-parentheses-type-assertion.lua.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: tests/tests.rs 3 | expression: "format(&contents, LuaVersion::Luau)" 4 | input_file: tests/inputs-luau/excess-parentheses-type-assertion.lua 5 | snapshot_kind: text 6 | --- 7 | local x = if (foo :: number) < bar 8 | then very + very + very + long + line + right + here + hopefully 9 | else lets + ensure + stylua + writes + this + out + using + multiple + lines 10 | -------------------------------------------------------------------------------- /tests/snapshots/tests__luau@floor-division.lua.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: tests/tests.rs 3 | expression: format(&contents) 4 | input_file: tests/inputs-luau/floor-division.lua 5 | --- 6 | local x = 1 // 2 7 | 8 | -------------------------------------------------------------------------------- /tests/snapshots/tests__luau@function-call-comments-1.lua.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: tests/tests.rs 3 | expression: format(&contents) 4 | --- 5 | do 6 | for _, foo in 7 | applyFoooooo( 8 | aaaaaaaaaaaaaaaaaaaa, --[[:: Array]] 9 | bbbbbbbbbbbbbbbbbb --[[:: Array]] 10 | ) :: Array 11 | do 12 | end 13 | end 14 | 15 | -------------------------------------------------------------------------------- /tests/snapshots/tests__luau@function_types.lua.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: tests/tests.rs 3 | expression: format(&contents) 4 | --- 5 | function test(x: any, y: number): bar 6 | print(test) 7 | end 8 | 9 | -------------------------------------------------------------------------------- /tests/snapshots/tests__luau@function_types_2.lua.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: tests/tests.rs 3 | expression: format(&contents) 4 | --- 5 | local function foo( 6 | bar: Instance, 7 | baz: Instance, 8 | qux: Instance, 9 | quux: Instance, 10 | corge: Instance, 11 | grault: Instance, 12 | garply: Instance, 13 | waldo: Instance, 14 | fred: Instance, 15 | plugh: Instance, 16 | xyzzy: Instance, 17 | thud: Instance 18 | ) 19 | end 20 | 21 | -------------------------------------------------------------------------------- /tests/snapshots/tests__luau@generic-for-multiline.lua.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: tests/tests.rs 3 | expression: format(&contents) 4 | --- 5 | for 6 | _id: number, 7 | transform: Components.Transform, 8 | angularControls: Components.AngularControls, 9 | characterModel: Components.CharacterModel 10 | in world:query(Transform, AngularControls, CharacterModel) do 11 | -- ... 12 | end 13 | 14 | -------------------------------------------------------------------------------- /tests/snapshots/tests__luau@if-expression-comments-3.lua.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: tests/tests.rs 3 | expression: format(&contents) 4 | --- 5 | -- https://github.com/JohnnyMorganz/StyLua/issues/520 6 | do 7 | return if #timings <= workers 8 | then max 9 | else math.max(Array.reduce(timings, function( 10 | -- food 11 | sum, 12 | time_ 13 | ) 14 | return sum + time_ 15 | end) / workers, max) 16 | end 17 | 18 | -------------------------------------------------------------------------------- /tests/snapshots/tests__luau@string-brackets-index.lua.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: tests/tests.rs 3 | expression: format(&contents) 4 | input_file: tests/inputs-luau/string-brackets-index.lua 5 | --- 6 | local foo = { 7 | [ [[test]] :: test ] = true, 8 | [ ([[foo]]) :: test ] = true, 9 | [ ([[bar]]) :: test ] = true, 10 | } 11 | 12 | foo[ [[test]] :: test ] = false 13 | foo[ ([[foo]]) :: test ] = false 14 | foo[ ([[bar]]) :: test ] = false 15 | 16 | -------------------------------------------------------------------------------- /tests/snapshots/tests__luau@string-interpolation-table.lua.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: tests/tests.rs 3 | expression: format(&contents) 4 | input_file: tests/inputs-luau/string-interpolation-table.lua 5 | --- 6 | local x = `{ { 1 }}` 7 | 8 | -------------------------------------------------------------------------------- /tests/snapshots/tests__luau@type-ascription-ambiguous-syntax.lua.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: tests/tests.rs 3 | expression: format(&contents) 4 | --- 5 | local foo = bar; 6 | (foo :: number).length = true 7 | 8 | -------------------------------------------------------------------------------- /tests/snapshots/tests__luau@type-callback-hanging-2.lua.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: tests/tests.rs 3 | expression: format(&contents) 4 | --- 5 | export type XYZ = { 6 | onSubmitTigerFoot: ( 7 | FendererID, 8 | Object, 9 | -- Added in v96.1 to support Prelifer priority lamerz 10 | number?, 11 | -- Added in v96.9 to support Star Refresh 12 | boolean? 13 | ) -> (), 14 | } 15 | 16 | -------------------------------------------------------------------------------- /tests/snapshots/tests__luau@type-callback-hanging.lua.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: tests/tests.rs 3 | expression: "format(&contents, LuaVersion::Luau)" 4 | input_file: tests/inputs-luau/type-callback-hanging.lua 5 | --- 6 | export type Thenable = { 7 | andTheeeeeeeeeeeeeeen: (any, (R) -> () | Thenable | U, (any) -> () | Thenable | U) -> () 8 | | Thenable, 9 | } 10 | 11 | -------------------------------------------------------------------------------- /tests/snapshots/tests__luau@type-comments-3.lua.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: tests/tests.rs 3 | expression: format(&contents) 4 | --- 5 | -- https://github.com/JohnnyMorganz/StyLua/issues/617 6 | type Table = { 7 | { 8 | Key -- [1]: Key 9 | | Translations -- [2]: Translations 10 | | Tags -- [3]: Tags 11 | } 12 | } 13 | 14 | -------------------------------------------------------------------------------- /tests/snapshots/tests__luau@type-functions-1.lua.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: tests/tests.rs 3 | expression: "format(&contents, LuaVersion::Luau)" 4 | input_file: tests/inputs-luau/type-functions-1.lua 5 | snapshot_kind: text 6 | --- 7 | type function Foo(x) end 8 | 9 | export type function Foo(x) end 10 | -------------------------------------------------------------------------------- /tests/snapshots/tests__luau@type-generic-comments.lua.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: tests/tests.rs 3 | expression: format(&contents) 4 | --- 5 | -- https://github.com/JohnnyMorganz/StyLua/issues/446 6 | export type IntrospectionNamedTypeRef< 7 | T -- XYZ ABC 8 | > = {} 9 | 10 | -------------------------------------------------------------------------------- /tests/snapshots/tests__luau@type-generic-variadics.lua.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: tests/tests.rs 3 | expression: format(&contents) 4 | --- 5 | local function mergeDeep(...: T...) -- : TupleToIntersection<...T> 6 | return mergeDeepArray({ ... }) 7 | end 8 | 9 | -------------------------------------------------------------------------------- /tests/snapshots/tests__luau@type-hanging-2.lua.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: tests/tests.rs 3 | expression: format(&contents) 4 | --- 5 | -- https://github.com/JohnnyMorganz/StyLua/issues/372 6 | export type Visitor = 7 | EnterLeave | ShapeMap(Node) -> VisitFn>> 8 | | ShapeMap(Node) -> VisitFn | EnterLeave>> 9 | 10 | -------------------------------------------------------------------------------- /tests/snapshots/tests__luau@type-hanging-asserted-value.lua.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: tests/tests.rs 3 | expression: format(&contents) 4 | --- 5 | -- https://github.com/JohnnyMorganz/StyLua/issues/466 6 | function example() 7 | do 8 | do 9 | self = ( 10 | setmetatable(Error.new(createErrDiff(actual, expected, operator)), AssertionError) :: any 11 | ) :: AssertionError 12 | end 13 | end 14 | end 15 | 16 | -------------------------------------------------------------------------------- /tests/snapshots/tests__luau@type-hanging-intersection.lua.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: tests/tests.rs 3 | expression: format(&contents) 4 | --- 5 | export type Cache_WriteOptions = 6 | Omit_id_from_DataProxy_Query 7 | & Omit_data_from_DataProxy_WriteOptions 8 | & { dataId: string?, result: TResult } 9 | 10 | -------------------------------------------------------------------------------- /tests/snapshots/tests__luau@type-hanging-multiline-comment.lua.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: tests/tests.rs 3 | expression: format(&contents) 4 | --- 5 | export type CoverageReporterWithOptions = 6 | Array --[[ [K, Partial] ]] 7 | | nil 8 | 9 | export type CoverageReporterWithOptions = 10 | Array --[[ [K, Partial] ]] 11 | & nil 12 | 13 | -------------------------------------------------------------------------------- /tests/snapshots/tests__luau@type-parentheses-comments.lua.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: tests/tests.rs 3 | expression: format(&contents) 4 | --- 5 | function foo(): ( 6 | nil -- Some comment 7 | ) 8 | return nil 9 | end 10 | 11 | type X = ( 12 | string, 13 | number -- testing 14 | ) -> ( 15 | number, 16 | string -- testing 17 | ) 18 | 19 | -------------------------------------------------------------------------------- /tests/snapshots/tests__luau@type-tables-comments-2.lua.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: tests/tests.rs 3 | expression: format(&contents) 4 | input_file: tests/inputs-luau/type-tables-comments-2.lua 5 | --- 6 | -- https://github.com/JohnnyMorganz/StyLua/issues/893 7 | type Foo = { 8 | Status: "loading" -- loading 9 | | "error" -- error 10 | | "success", -- success 11 | } 12 | -------------------------------------------------------------------------------- /tests/snapshots/tests__luau@type-tables-comments.lua.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: tests/tests.rs 3 | expression: format(&contents) 4 | --- 5 | export type Foo = { 6 | test: boolean, -- true 7 | } 8 | 9 | -------------------------------------------------------------------------------- /tests/snapshots/tests__luau@type-union-comments.lua.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: tests/tests.rs 3 | expression: format(&contents) 4 | --- 5 | -- https://github.com/JohnnyMorganz/StyLua/issues/351 6 | export type ReactNode = 7 | React_Element 8 | | ReactPortal 9 | -- | ReactText 10 | | ReactFragment 11 | -- | ReactProvider 12 | -- | ReactConsumer 13 | 14 | -------------------------------------------------------------------------------- /tests/snapshots/tests__luau@type_parameter_comments.lua.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: tests/tests.rs 3 | expression: format(&contents) 4 | --- 5 | function foo( 6 | bar: number, 7 | baz: number -- test 8 | ): number 9 | print("test") 10 | end 11 | 12 | -------------------------------------------------------------------------------- /tests/snapshots/tests__luau@types-declaration-equal-hang.lua.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: tests/tests.rs 3 | expression: format(&contents) 4 | --- 5 | type SubscribeToMoreOptions = 6 | watchQueryOptionsModule.SubscribeToMoreOptions 7 | 8 | -------------------------------------------------------------------------------- /tests/snapshots/tests__luau@types-generic-pack.lua.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: tests/tests.rs 3 | expression: format(&contents) 4 | --- 5 | type X = { 6 | useMemo: (nextCreate: () -> T..., deps: Array | nil) -> T..., 7 | } 8 | 9 | -------------------------------------------------------------------------------- /tests/snapshots/tests__luau@types_parentheses_table_indexer.lua.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: tests/tests.rs 3 | expression: format(&contents) 4 | input_file: tests/inputs-luau/types_parentheses_table_indexer.lua 5 | --- 6 | --- https://github.com/JohnnyMorganz/StyLua/issues/828 7 | type foo = { 8 | [("bar" | "baz")]: any, 9 | } 10 | 11 | -------------------------------------------------------------------------------- /tests/snapshots/tests__luau_full_moon@continue.lua.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: tests/tests.rs 3 | expression: format(&contents) 4 | --- 5 | -- Very important loop here 6 | while true do 7 | continue 8 | end 9 | 10 | continue() 11 | local continue = 4 12 | 13 | -------------------------------------------------------------------------------- /tests/snapshots/tests__luau_full_moon@decimal_seperators.lua.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: tests/tests.rs 3 | expression: format(&contents) 4 | --- 5 | local num1 = 1_048_576 6 | local num2 = 0xFFFF_FFFF 7 | local num3 = 0b_0101_0101 8 | local num4 = 1_523_423.132_452_312 9 | local num5 = 1e512_412 10 | local num6 = 1e-512_412 11 | 12 | -------------------------------------------------------------------------------- /tests/snapshots/tests__luau_full_moon@floor_division.lua.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: tests/tests.rs 3 | expression: format(&contents) 4 | input_file: tests/inputs-luau-full_moon/floor_division.lua 5 | --- 6 | local x = 1 // 2 7 | 8 | -------------------------------------------------------------------------------- /tests/snapshots/tests__luau_full_moon@multiline_typeof_regression.lua.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: tests/tests.rs 3 | expression: "format(&contents, LuaVersion::Luau)" 4 | input_file: tests/inputs-luau-full_moon/multiline_typeof_regression.lua 5 | --- 6 | type TypeOf = typeof({}) 7 | 8 | -------------------------------------------------------------------------------- /tests/snapshots/tests__luau_full_moon@shorthand_array_type.lua.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: tests/tests.rs 3 | expression: format(&contents) 4 | --- 5 | type Array = { T } 6 | type Array = { [number]: T } 7 | 8 | -------------------------------------------------------------------------------- /tests/snapshots/tests__luau_full_moon@string_interpolation_base.lua.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: tests/tests.rs 3 | assertion_line: 40 4 | expression: format(&contents) 5 | input_file: tests/inputs-luau-full_moon/string_interpolation_base.lua 6 | 7 | --- 8 | x(`simple`) 9 | x(`hello {"world"}`) 10 | x(`1{2}3{"4"}5`) 11 | x(`1{`2{"3"}`}`) 12 | 13 | -------------------------------------------------------------------------------- /tests/snapshots/tests__luau_full_moon@string_interpolation_regression.lua.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: tests/tests.rs 3 | expression: "format(&contents, LuaVersion::Luau)" 4 | input_file: tests/inputs-luau-full_moon/string_interpolation_regression.lua 5 | --- 6 | error(`a {b} c`) 7 | 8 | -------------------------------------------------------------------------------- /tests/snapshots/tests__luau_full_moon@table_access_modifiers.lua.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: tests/tests.rs 3 | expression: "format(&contents, LuaVersion::Luau)" 4 | input_file: tests/inputs-luau-full_moon/table_access_modifiers.lua 5 | --- 6 | type Foo = { 7 | read bar: number, 8 | write baz: number, 9 | } 10 | 11 | -------------------------------------------------------------------------------- /tests/snapshots/tests__luau_full_moon@types_chained_optionals.lua.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: tests/tests.rs 3 | expression: "format(&contents, LuaVersion::Luau)" 4 | input_file: tests/inputs-luau-full_moon/types_chained_optionals.lua 5 | --- 6 | type Config = { 7 | option1: string??, -- you probably need it once in a while 8 | option2: string???, -- once a year 9 | option3: string??????, -- once in your life! 10 | } 11 | 12 | -------------------------------------------------------------------------------- /tests/snapshots/tests__luau_full_moon@types_exported.lua.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: tests/tests.rs 3 | expression: format(&contents) 4 | --- 5 | type Foo = { bar: any } 6 | export type Baz = { foo: any } 7 | 8 | -------------------------------------------------------------------------------- /tests/snapshots/tests__luau_full_moon@types_function.lua.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: tests/tests.rs 3 | expression: "format(&contents, LuaVersion::Luau)" 4 | input_file: tests/inputs-luau-full_moon/types_function.lua 5 | --- 6 | type function f(...) 7 | -- implementation of the type function 8 | end 9 | 10 | export type function f(...) 11 | -- implementation of the type function 12 | end 13 | -------------------------------------------------------------------------------- /tests/snapshots/tests__luau_full_moon@types_generic.lua.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: tests/tests.rs 3 | expression: format(&contents) 4 | --- 5 | type Array = { T } 6 | local x: Array> 7 | 8 | -------------------------------------------------------------------------------- /tests/snapshots/tests__luau_full_moon@types_generic_declaration.lua.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: tests/tests.rs 3 | expression: format(&contents) 4 | --- 5 | --!strict 6 | type Foo = (U...) -> T... 7 | type Bar = nil 8 | type Function = (Args...) -> Return... 9 | type Baz = nil 10 | type Indexed = module.Indexed 11 | 12 | -------------------------------------------------------------------------------- /tests/snapshots/tests__luau_full_moon@types_generic_no_parameters.lua.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: tests/tests.rs 3 | expression: "format(&contents, LuaVersion::Luau)" 4 | input_file: tests/inputs-luau-full_moon/types_generic_no_parameters.lua 5 | --- 6 | type Bar = Foo<> 7 | type Baz = module.Foo<> 8 | 9 | -------------------------------------------------------------------------------- /tests/snapshots/tests__luau_full_moon@types_indexable.lua.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: tests/tests.rs 3 | expression: format(&contents) 4 | --- 5 | local x: module.Foo = nil 6 | local x: module.Array = { "bar" } 7 | local x: module.Foo | string = "bar" 8 | local x: module.Foo? = nil 9 | local x: module.Foo<...string> = nil 10 | 11 | -------------------------------------------------------------------------------- /tests/snapshots/tests__luau_full_moon@types_loops.lua.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: tests/tests.rs 3 | expression: format(&contents) 4 | --- 5 | for i, v: string in pairs() do 6 | end 7 | 8 | for i: number = 1, 10, 2 do 9 | end 10 | 11 | -------------------------------------------------------------------------------- /tests/snapshots/tests__luau_full_moon@types_nested_array.lua.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: tests/tests.rs 3 | expression: format(&contents) 4 | --- 5 | type Foo = { { string } } 6 | type Foo = { { Name: string, Foo: number } } 7 | 8 | -------------------------------------------------------------------------------- /tests/snapshots/tests__luau_full_moon@types_semicolon_delimeter.lua.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: tests/tests.rs 3 | expression: format(&contents) 4 | --- 5 | type Foo = { 6 | bar: number, 7 | baz: number, 8 | } 9 | 10 | -------------------------------------------------------------------------------- /tests/snapshots/tests__luau_full_moon@z-escape-string.lua.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: tests/tests.rs 3 | expression: "format(&contents, LuaVersion::Luau)" 4 | input_file: tests/inputs-luau-full_moon/z-escape-string.lua 5 | snapshot_kind: text 6 | --- 7 | print("testing \z 8 | twelve") 9 | 10 | print("Hello \ 11 | World") 12 | 13 | print(`testing \z 14 | twelve`) 15 | 16 | print(`Hello \ 17 | World`) 18 | -------------------------------------------------------------------------------- /tests/snapshots/tests__sort_requires@basic.lua.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: tests/tests.rs 3 | expression: "format_code(&contents,\n Config::default().with_sort_requires(SortRequiresConfig::default().set_enabled(true)),\n None, OutputVerification::None).unwrap()" 4 | --- 5 | local ah = require("a") 6 | local bee = require("b") 7 | 8 | print("hello world") 9 | 10 | -------------------------------------------------------------------------------- /tests/snapshots/tests__sort_requires@empty.lua.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: tests/tests.rs 3 | expression: "format_code(&contents,\n Config::default().with_sort_requires(SortRequiresConfig::default().set_enabled(true)),\n None, OutputVerification::None).unwrap()" 4 | --- 5 | 6 | -------------------------------------------------------------------------------- /tests/snapshots/tests__sort_requires@ignore-multi-require.lua.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: tests/tests.rs 3 | expression: "format_code(&contents,\n Config::default().with_sort_requires(SortRequiresConfig::default().set_enabled(true)),\n None, OutputVerification::None).unwrap()" 4 | --- 5 | local c = require("c") 6 | local b, a = require("b"), require("a") 7 | 8 | -------------------------------------------------------------------------------- /tests/snapshots/tests__sort_requires@sort-services.lua.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: tests/tests.rs 3 | expression: "format_code(&contents,\n Config::default().with_sort_requires(SortRequiresConfig::default().set_enabled(true)),\n None, OutputVerification::None).unwrap()" 4 | --- 5 | local CollectionService = game:GetService("CollectionService") 6 | local ReplicatedStorage = game:GetService("ReplicatedStorage") 7 | 8 | -------------------------------------------------------------------------------- /tests/snapshots/tests__standard@ambiguous-syntax.lua.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: tests/tests.rs 3 | expression: format(&contents) 4 | --- 5 | local baz = foo(bar); 6 | (foo and x or y)(bar) 7 | 8 | function foobar() 9 | local baz = foo(bar); 10 | (baz and x or y)(bar) 11 | end 12 | 13 | -------------------------------------------------------------------------------- /tests/snapshots/tests__standard@anonymous-function-internal-comments.lua.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: tests/tests.rs 3 | expression: format(&contents) 4 | --- 5 | -- https://github.com/JohnnyMorganz/StyLua/issues/627 6 | t = t or function() 7 | print("Hello, World") -- comment 8 | end 9 | 10 | t = t or function() 11 | print("Hello, World") 12 | end 13 | 14 | -------------------------------------------------------------------------------- /tests/snapshots/tests__standard@anonymous-function.lua.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: tests/tests.rs 3 | expression: format(&contents) 4 | --- 5 | local foo = function(bar, baz) 6 | print(foo) 7 | end 8 | call(function(x, y) 9 | local x = test 10 | end) 11 | 12 | -------------------------------------------------------------------------------- /tests/snapshots/tests__standard@assignment-comments-2.lua.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: tests/tests.rs 3 | expression: format(&contents) 4 | --- 5 | -- https://github.com/JohnnyMorganz/StyLua/issues/416 6 | local variable = call( 7 | somethingToCall().foo.bar.baz, 8 | "some super long string that will stay on this line aaaaaaaaaaaaaaaaa" 9 | ) -- a comment 10 | .. "another string" 11 | 12 | -------------------------------------------------------------------------------- /tests/snapshots/tests__standard@assignment-comments-3.lua.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: tests/tests.rs 3 | expression: format(&contents) 4 | --- 5 | -- https://github.com/JohnnyMorganz/StyLua/issues/662 6 | local a, b = 7 | 1, -- adoc 8 | 2 -- bdoc 9 | 10 | local a, -- adoc 11 | b -- bdoc 12 | = 1, 2 13 | 14 | -------------------------------------------------------------------------------- /tests/snapshots/tests__standard@assignment.lua.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: tests/tests.rs 3 | expression: format(&contents) 4 | --- 5 | local foo = "bar" 6 | local bar, baz = 1, 2 7 | 8 | -------------------------------------------------------------------------------- /tests/snapshots/tests__standard@block-empty-lines.lua.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: tests/tests.rs 3 | expression: format(&contents) 4 | --- 5 | function foo() 6 | local x = 1 7 | 8 | return true 9 | end 10 | 11 | function bar() 12 | return 13 | end 14 | 15 | do 16 | -- comment 17 | local x = 1 18 | 19 | local foo = bar 20 | 21 | -- comment 22 | end 23 | 24 | -------------------------------------------------------------------------------- /tests/snapshots/tests__standard@comments-function-args.lua.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: tests/tests.rs 3 | expression: format(&contents) 4 | --- 5 | foo( -- comment 6 | baz 7 | ) 8 | 9 | foo( 10 | baz, -- comment 11 | bar 12 | ) 13 | 14 | foo( 15 | baz, 16 | -- comment 17 | bar 18 | ) 19 | 20 | foo( 21 | baz, 22 | bar -- comment 23 | ) 24 | 25 | foo(baz, bar) -- comment 26 | 27 | foo( 28 | -- comment 29 | baz, 30 | bar 31 | ) 32 | 33 | -------------------------------------------------------------------------------- /tests/snapshots/tests__standard@comments-function-params.lua.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: tests/tests.rs 3 | expression: format(&contents) 4 | --- 5 | function sayHello( 6 | name, -- YourName 7 | foo, --baz 8 | greeting -- Message 9 | ) 10 | return greeting .. ", " .. name 11 | end 12 | 13 | -------------------------------------------------------------------------------- /tests/snapshots/tests__standard@comments-indented-block.lua.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: tests/tests.rs 3 | expression: format(&contents) 4 | --- 5 | function foo() 6 | local x = 1 7 | local y = 1 8 | 9 | -- comment 10 | end 11 | 12 | if foo then 13 | local x = 1 14 | -- comment 15 | end 16 | 17 | -------------------------------------------------------------------------------- /tests/snapshots/tests__standard@comments-multiline-expression-2.lua.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: tests/tests.rs 3 | expression: format(&contents) 4 | --- 5 | -- https://github.com/JohnnyMorganz/StyLua/issues/386 6 | repeat 7 | x = x + 1 8 | until z * ( 9 | x + y -- comment 10 | ) 11 | 12 | repeat 13 | x = x + 1 14 | until z * ( 15 | x + y -- comment 16 | ) < 2 17 | 18 | -------------------------------------------------------------------------------- /tests/snapshots/tests__standard@comments.lua.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: tests/tests.rs 3 | expression: format(&contents) 4 | --- 5 | --[[Testing this]] 6 | local function foo(bar, baz) 7 | print(bar, baz) 8 | end --this is a nice function 9 | local test = {} --this comment should stay 10 | 11 | local y = foo 12 | -- comment line 1 13 | -- comment line 2, should not be split from above comment 14 | local x = test 15 | 16 | -------------------------------------------------------------------------------- /tests/snapshots/tests__standard@complex-args.lua.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: tests/tests.rs 3 | expression: format(&contents) 4 | --- 5 | React.createElement( 6 | "span", 7 | { key = id }, 8 | React.createElement(Consumer, nil, function() 9 | return React.createElement("span", nil, "inner") 10 | end), 11 | React.createElement("span", nil, "outer") 12 | ) 13 | 14 | -------------------------------------------------------------------------------- /tests/snapshots/tests__standard@condition-operator-precedence.lua.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: tests/tests.rs 3 | expression: format(&contents) 4 | --- 5 | local instance = someReallyLongConditionExtremelyLongSoLongYourMindWillMelt 6 | and someReallyLongCondition 7 | and someOtherReallyLongCondition 8 | or somethingElse 9 | 10 | -------------------------------------------------------------------------------- /tests/snapshots/tests__standard@condition-parentheses-comments.lua.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: tests/tests.rs 3 | expression: format(&contents) 4 | --- 5 | -- https://github.com/JohnnyMorganz/StyLua/issues/389 6 | repeat 7 | x = x + 1 8 | until x + y < 2 -- comment 9 | 10 | -------------------------------------------------------------------------------- /tests/snapshots/tests__standard@condition-parentheses.lua.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: tests/tests.rs 3 | expression: format(&contents) 4 | --- 5 | if foo then 6 | print("true") 7 | elseif bar then 8 | print("false") 9 | end 10 | 11 | while foo do 12 | print("true") 13 | end 14 | 15 | repeat 16 | print("yes") 17 | until foo 18 | 19 | -------------------------------------------------------------------------------- /tests/snapshots/tests__standard@do-block.lua.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: tests/tests.rs 3 | expression: format(&contents) 4 | --- 5 | do 6 | local x = 5 7 | end 8 | 9 | -------------------------------------------------------------------------------- /tests/snapshots/tests__standard@double-unary-minus.lua.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: tests/tests.rs 3 | expression: format(&contents) 4 | --- 5 | local x = -(-foo) 6 | local y = -(-foo) 7 | 8 | local z1 = -(-foo) -- bar 9 | local z2 = -(-foo) -- baz 10 | 11 | -------------------------------------------------------------------------------- /tests/snapshots/tests__standard@empty-function-2.lua.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: tests/tests.rs 3 | expression: format(&contents) 4 | --- 5 | local function noop() -- comment 6 | end 7 | 8 | function noop() 9 | -- comment 10 | end 11 | 12 | call(function() 13 | -- comment 14 | end) 15 | 16 | -------------------------------------------------------------------------------- /tests/snapshots/tests__standard@empty-function.lua.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: tests/tests.rs 3 | expression: format(&contents) 4 | --- 5 | local function noop() end 6 | 7 | function noop() end 8 | 9 | call(function() end) 10 | 11 | -------------------------------------------------------------------------------- /tests/snapshots/tests__standard@eof-1.lua.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: tests/tests.rs 3 | expression: format(&contents) 4 | --- 5 | local x = 1 6 | 7 | -------------------------------------------------------------------------------- /tests/snapshots/tests__standard@eof-2.lua.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: tests/tests.rs 3 | expression: format(&contents) 4 | --- 5 | local x = 1 6 | -- this is a comment 7 | 8 | -------------------------------------------------------------------------------- /tests/snapshots/tests__standard@eof-3.lua.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: tests/tests.rs 3 | expression: format(&contents) 4 | --- 5 | local x = 1 6 | 7 | -- this is a comment 8 | 9 | -------------------------------------------------------------------------------- /tests/snapshots/tests__standard@excess-parentheses-comments.lua.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: tests/tests.rs 3 | expression: format(&contents) 4 | --- 5 | local foo = bar -- test 6 | 7 | -- https://github.com/JohnnyMorganz/StyLua/issues/530 8 | call( 9 | -- comment 10 | foo 11 | ) 12 | 13 | -------------------------------------------------------------------------------- /tests/snapshots/tests__standard@excess-parentheses-dont-remove.lua.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: tests/tests.rs 3 | expression: format(&contents) 4 | --- 5 | -- https://github.com/JohnnyMorganz/StyLua/issues/609 6 | -- Indicate precedence 7 | local _ = (not true) == true 8 | local _ = (not true) and false 9 | 10 | -- https://github.com/JohnnyMorganz/StyLua/issues/623 11 | -- Changes meaning 12 | local y = (-X) ^ Y 13 | 14 | -------------------------------------------------------------------------------- /tests/snapshots/tests__standard@function-call-4.lua.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: tests/tests.rs 3 | expression: format(&contents) 4 | --- 5 | Roact.createElement("ImageLabel", { 6 | Size = UDim2.new( 7 | 0, 8 | TextService:GetTextSize(self.props.PhysicalTool.Name, 16, Enum.Font.SourceSansBold, Vector2.new(100000, 100000)).X 9 | + 10, 10 | 0, 11 | 20 12 | ), 13 | }) 14 | 15 | -------------------------------------------------------------------------------- /tests/snapshots/tests__standard@function-call-7.lua.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: tests/tests.rs 3 | expression: format(&contents) 4 | --- 5 | -- https://github.com/JohnnyMorganz/StyLua/issues/298 6 | do 7 | return Roact.createElement(StyleContext.Provider, { 8 | value = styleObject, 9 | }, Roact.oneChild(self.props[Roact.Children])) 10 | end 11 | 12 | -------------------------------------------------------------------------------- /tests/snapshots/tests__standard@function-call-8.lua.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: tests/tests.rs 3 | expression: format(&contents) 4 | --- 5 | function_call( 6 | ( 7 | "hello" 8 | .. "darkness" 9 | .. "my" 10 | .. "old" 11 | .. "friend" 12 | .. "hello" 13 | .. "darkness" 14 | .. "my" 15 | .. "old" 16 | .. "friend" 17 | .. "!!!!!!!!!!!!" 18 | ):call() 19 | ) 20 | 21 | -------------------------------------------------------------------------------- /tests/snapshots/tests__standard@function-call-comments-2.lua.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: tests/tests.rs 3 | expression: format(&contents) 4 | --- 5 | -- https://github.com/JohnnyMorganz/StyLua/issues/307#issuecomment-980594322 6 | call( 7 | param_a, -- this is cool 8 | param_b 9 | ) 10 | 11 | -------------------------------------------------------------------------------- /tests/snapshots/tests__standard@function-call-comments-3.lua.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: tests/tests.rs 3 | expression: format(&contents) 4 | --- 5 | -- https://github.com/JohnnyMorganz/StyLua/issues/473 6 | call(--[[-------------------------------------------------------------------------------------------------------------]]) 7 | 8 | -------------------------------------------------------------------------------- /tests/snapshots/tests__standard@function-call-comments-4.lua.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: tests/tests.rs 3 | expression: format(&contents) 4 | --- 5 | -- https://github.com/JohnnyMorganz/StyLua/issues/648 6 | function foo(f, g, a, b, c) 7 | return f(a) 8 | or g( 9 | b and c 10 | -- a somewhat strange location to describe something 11 | or false 12 | -- yes, this newline might not have been intended 13 | ) 14 | end 15 | 16 | -------------------------------------------------------------------------------- /tests/snapshots/tests__standard@function-call.lua.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: tests/tests.rs 3 | expression: format(&contents) 4 | --- 5 | call("string") 6 | call({ foo = "bar", baz = 1 }) 7 | call(x, y, z) 8 | 9 | -------------------------------------------------------------------------------- /tests/snapshots/tests__standard@function-def-comments.lua.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: tests/tests.rs 3 | expression: format(&contents) 4 | --- 5 | function func( 6 | param_a, -- description of a 7 | param_b -- description of b 8 | ) 9 | end 10 | 11 | -------------------------------------------------------------------------------- /tests/snapshots/tests__standard@function-definition-multiline-2.lua.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: tests/tests.rs 3 | expression: format(&contents) 4 | input_file: tests/inputs/function-definition-multiline-2.lua 5 | --- 6 | -- https://github.com/JohnnyMorganz/StyLua/issues/830 7 | local a_very_long_variable_name_given_that_is_bigger_than_width_upper_limit_but_unfortunately_can_not_be_made_shorter = function() 8 | print("Hello") 9 | end 10 | 11 | -------------------------------------------------------------------------------- /tests/snapshots/tests__standard@generic-for-multiline-2.lua.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: tests/tests.rs 3 | expression: format(&contents) 4 | --- 5 | -- https://github.com/JohnnyMorganz/StyLua/issues/579 6 | for _, item in 7 | -- comment 8 | call() 9 | do 10 | end 11 | 12 | for _, item in -- comment 13 | call() 14 | do 15 | end 16 | 17 | for _, item in -- comment 18 | call() 19 | do 20 | end 21 | 22 | -------------------------------------------------------------------------------- /tests/snapshots/tests__standard@generic-for.lua.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: tests/tests.rs 3 | expression: format(&contents) 4 | --- 5 | for i, v in pairs(table) do 6 | print(i, v) 7 | end 8 | 9 | -------------------------------------------------------------------------------- /tests/snapshots/tests__standard@hang-binop.lua.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: tests/tests.rs 3 | expression: format(&contents) 4 | --- 5 | local foo = x -- comment 6 | ^ y -- comment 7 | % z -- comment 8 | - a -- comment 9 | <= b -- comment 10 | < c -- comment 11 | >= d 12 | 13 | -------------------------------------------------------------------------------- /tests/snapshots/tests__standard@hang-call-chain-comments-2.lua.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: tests/tests.rs 3 | expression: format(&contents) 4 | --- 5 | -- https://github.com/JohnnyMorganz/StyLua/issues/747 6 | 7 | obj 8 | -- 9 | .func() 10 | -- 11 | .func() 12 | -- 13 | .func() 14 | 15 | -------------------------------------------------------------------------------- /tests/snapshots/tests__standard@hang-call-chain-comments-3.lua.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: tests/tests.rs 3 | expression: format(&contents) 4 | input_file: tests/inputs/hang-call-chain-comments-3.lua 5 | --- 6 | -- https://github.com/JohnnyMorganz/StyLua/issues/890 7 | 8 | build() 9 | -- comment 10 | :init() 11 | :start() 12 | -------------------------------------------------------------------------------- /tests/snapshots/tests__standard@hang-call-chain-comments.lua.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: tests/tests.rs 3 | expression: format(&contents) 4 | --- 5 | -- A 6 | a = A() 7 | -- B 8 | .B() 9 | -- C 10 | .C() 11 | 12 | -------------------------------------------------------------------------------- /tests/snapshots/tests__standard@hang-call-chains-2.lua.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: tests/tests.rs 3 | expression: format(&contents) 4 | --- 5 | local output = Job:new({ 6 | command = "stylua", 7 | args = { "-" }, 8 | writer = api.nvim_buf_get_lines(bufnr, 0, -1, false), 9 | }):sync() 10 | 11 | -------------------------------------------------------------------------------- /tests/snapshots/tests__standard@hang-equality-op.lua.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: tests/tests.rs 3 | expression: format(&contents) 4 | --- 5 | assert( 6 | StringToHex(HexToString("05 e0 81 91 24 cb b2 2c 49 e2 0f 2e 8b 9a" .. " 47 56 9f fb fe ec d2 ff 1f")) 7 | == "05 e0 81 91 24 cb b2 2c 49 e2 0f 2e 8b 9a 47 56 9f fb fe ec d2 ff 1f" 8 | ) 9 | 10 | -------------------------------------------------------------------------------- /tests/snapshots/tests__standard@if-1.lua.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: tests/tests.rs 3 | expression: format(&contents) 4 | --- 5 | if x == true then 6 | return 7 | end 8 | 9 | -------------------------------------------------------------------------------- /tests/snapshots/tests__standard@if-comments-3.lua.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: tests/tests.rs 3 | expression: format(&contents) 4 | --- 5 | if true then 6 | else 7 | end 8 | 9 | if true then 10 | 11 | -- this is a comment 12 | 13 | -- but this is another comment 14 | -- and another one - we should hence indent the comments overall 15 | else 16 | end 17 | 18 | -------------------------------------------------------------------------------- /tests/snapshots/tests__standard@if-comments.lua.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: tests/tests.rs 3 | expression: format(&contents) 4 | --- 5 | if true then 6 | -- foo 7 | elseif bar then 8 | -- bar 9 | else 10 | -- baz 11 | end 12 | 13 | -------------------------------------------------------------------------------- /tests/snapshots/tests__standard@indented-multiline-comments.lua.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: tests/tests.rs 3 | expression: format(&contents) 4 | --- 5 | function foo() 6 | function bar() 7 | function baz() 8 | --[[ 9 | comment 10 | ]] 11 | local x = 1 12 | end 13 | end 14 | end 15 | 16 | -------------------------------------------------------------------------------- /tests/snapshots/tests__standard@index-comments.lua.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: tests/tests.rs 3 | expression: format(&contents) 4 | --- 5 | local x = foo[ 6 | index -- test 7 | ] 8 | 9 | foo[ 10 | var -- string 11 | ] = baz 12 | 13 | local x = foo[ 14 | x -- string 15 | ][y][z][ 16 | p 17 | -- string 18 | ] 19 | 20 | local x = foo[ 21 | index --[[comment]] 22 | ] 23 | 24 | -------------------------------------------------------------------------------- /tests/snapshots/tests__standard@long-assignment-2.lua.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: tests/tests.rs 3 | expression: format(&contents) 4 | --- 5 | do 6 | local HitPart, HitPoint, HitNormal, HitMaterial = 7 | nil, Ray.Origin + Ray.Direction, Vector3.new(0, 1, 0), Enum.Material.Air 8 | end 9 | 10 | -------------------------------------------------------------------------------- /tests/snapshots/tests__standard@long-assignment-3.lua.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: tests/tests.rs 3 | expression: format(&contents) 4 | --- 5 | local something = fooooooooooooooo == barrrrrrrrrrrr 6 | and func(arggggggggggggggggggggggggggggggggggggggggg1, argggggggggg2) 7 | or somethingeeeeeeeeeeee 8 | 9 | -------------------------------------------------------------------------------- /tests/snapshots/tests__standard@long-assignment-4.lua.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: tests/tests.rs 3 | expression: format(&contents) 4 | --- 5 | do 6 | do 7 | local FrontDistanceX, FrontDistanceY = 8 | self.settings.FWsBoneLen * math.cos(math.rad(self.settings.FWsBoneAngle)), 9 | self.settings.FWsBoneLen * math.sin(math.rad(self.settings.FWsBoneAngle)) 10 | end 11 | end 12 | 13 | -------------------------------------------------------------------------------- /tests/snapshots/tests__standard@long-assignment-5.lua.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: tests/tests.rs 3 | expression: format(&contents) 4 | --- 5 | -- https://github.com/JohnnyMorganz/StyLua/issues/292 6 | local musicId, musicTime, responseTick, responseOffset = 7 | remotes.Server.GetSpectatorInfo:InvokeServer(player, sendTick, anotherArgument) 8 | 9 | -------------------------------------------------------------------------------- /tests/snapshots/tests__standard@multiline-comments.lua.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: tests/tests.rs 3 | expression: format(&contents) 4 | --- 5 | checkVisitorFnArgs(expect, ast, { ... }, true --[[ isEdited ]]) 6 | 7 | local test --[[foo]] = true 8 | 9 | --[[test]] 10 | local x = true 11 | 12 | -------------------------------------------------------------------------------- /tests/snapshots/tests__standard@multiline-expressions-indent-block.lua.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: tests/tests.rs 3 | expression: format(&contents) 4 | --- 5 | local expr = first_______________________________________________________________________________________________________ 6 | and function() 7 | foo() 8 | end 9 | 10 | -------------------------------------------------------------------------------- /tests/snapshots/tests__standard@multiple-lines-betwen-statements.lua.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: tests/tests.rs 3 | expression: format(&contents) 4 | --- 5 | local x = 1 6 | 7 | local y = 2 8 | 9 | local z = 3 10 | 11 | -------------------------------------------------------------------------------- /tests/snapshots/tests__standard@number.lua.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: tests/tests.rs 3 | expression: format(&contents) 4 | --- 5 | local a = 0.5 6 | local b = 0.5 7 | local c = 100 8 | local d = 5e-5 9 | local e = -0.5 10 | local f = 0.2e-5 11 | local g = -0.1e+5 12 | local h = 0x12 13 | 14 | -------------------------------------------------------------------------------- /tests/snapshots/tests__standard@repeat-block-2.lua.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: tests/tests.rs 3 | expression: format(&contents) 4 | --- 5 | local function foo(bar) 6 | local count = 0 7 | 8 | repeat 9 | count = count + 1 10 | until count == 10 11 | end 12 | 13 | -------------------------------------------------------------------------------- /tests/snapshots/tests__standard@repeat-block.lua.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: tests/tests.rs 3 | expression: format(&contents) 4 | --- 5 | repeat 6 | x = x + 1 7 | until true 8 | 9 | -------------------------------------------------------------------------------- /tests/snapshots/tests__standard@return-comments-2.lua.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: tests/tests.rs 3 | expression: format(&contents) 4 | --- 5 | -- https://github.com/JohnnyMorganz/StyLua/issues/662 6 | function f() 7 | return a, -- adoc 8 | b -- bdoc 9 | end 10 | 11 | -------------------------------------------------------------------------------- /tests/snapshots/tests__standard@return-hanging-expression-2.lua.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: tests/tests.rs 3 | expression: format(&contents) 4 | --- 5 | return cframe 6 | -- Clamp & transform into world space 7 | * Vector3.new( 8 | math.clamp(transform.X, -halfSize.X, halfSize.X), 9 | math.clamp(transform.Y, -halfSize.Y, halfSize.Y), 10 | math.clamp(transform.Z, -halfSize.Z, halfSize.Z) 11 | ), 12 | cframe.Position 13 | 14 | -------------------------------------------------------------------------------- /tests/snapshots/tests__standard@return-hanging-expression.lua.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: tests/tests.rs 3 | expression: format(&contents) 4 | --- 5 | function foo() 6 | return fooooooooooooooooooo(barrr) 7 | or foooooooooooooooooooooooooooooooooooooooooooooooooooooopppo(barrrrrrrrrrrrrr)(hello) 8 | or bazzzzzzzzzzzzzzzzzz 9 | end 10 | 11 | -------------------------------------------------------------------------------- /tests/snapshots/tests__standard@semicolon-2.lua.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: tests/tests.rs 3 | expression: format(&contents) 4 | --- 5 | -- https://github.com/JohnnyMorganz/StyLua/issues/431 6 | local Packages --[[ ROBLOX comment: must define Packages module ]] 7 | local boo = --[[a comment]] 8 | require(Packages.foo) --[[another comment]] 9 | --[[yet another comment]] 10 | 11 | -------------------------------------------------------------------------------- /tests/snapshots/tests__standard@semicolon-comments-ordering.lua.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: tests/tests.rs 3 | expression: format(&contents) 4 | --- 5 | local foo = a <= b --[[ some block comment ]] -- inline comment 6 | fn() --[[ some block comment 2 ]] -- inline comment 2 7 | 8 | -------------------------------------------------------------------------------- /tests/snapshots/tests__standard@single-arg-function-calls.lua.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: tests/tests.rs 3 | expression: format(&contents) 4 | --- 5 | do 6 | do 7 | do 8 | do 9 | do 10 | do 11 | jestExpect( 12 | ReactIs.typeOf(React.createElement(React.Profiler, { id = "foo", onRender = jest.fn() })) 13 | ).toBe(ReactIs.Profiler) 14 | end 15 | end 16 | end 17 | end 18 | end 19 | end 20 | 21 | -------------------------------------------------------------------------------- /tests/snapshots/tests__standard@string-brackets-index.lua.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: tests/tests.rs 3 | expression: format(&contents) 4 | --- 5 | local foo = { 6 | [ [[test]] ] = true, 7 | [ [[foo]] ] = true, 8 | [ [[bar]] ] = true, 9 | [ [[baz]] ] = true, 10 | } 11 | 12 | foo[ [[test]] ] = false 13 | foo[ [[foo]] ] = true 14 | foo[ [[bar]] ] = true 15 | foo[ [[baz]] ] = true 16 | 17 | -------------------------------------------------------------------------------- /tests/snapshots/tests__standard@string-escapes.lua.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: tests/tests.rs 3 | expression: format(&contents) 4 | --- 5 | local foo = "this 'string' has 'escaped' single quotes with \"double quotes\"" 6 | local bar = "test 'foo' \"bar\"" 7 | local baz = '\\"""' 8 | 9 | -------------------------------------------------------------------------------- /tests/snapshots/tests__standard@table-2.lua.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: tests/tests.rs 3 | expression: format(&contents) 4 | --- 5 | local foo = 6 | { "aaaa", "aaaa", "aaaa", "aaaa", "aaaa", "aaaa", "aaaa", "aaaa", "aaaa", "aaaa", "aaaa", "aaaa", "aaaa", "aaaa" } 7 | 8 | -------------------------------------------------------------------------------- /tests/snapshots/tests__standard@table-4.lua.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: tests/tests.rs 3 | expression: format(&contents) 4 | --- 5 | local thisisathing = 6 | { this_is_one = "one", this_is_two = "two", this_is_three = "three", this_is_four = "four", f = "b" } 7 | 8 | -------------------------------------------------------------------------------- /tests/snapshots/tests__standard@table-6.lua.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: tests/tests.rs 3 | expression: format(&contents) 4 | --- 5 | -- https://github.com/JohnnyMorganz/StyLua/issues/296 6 | aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa({ aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa = false }) 7 | aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa({ aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa = false }) 8 | 9 | -------------------------------------------------------------------------------- /tests/snapshots/tests__standard@table-7.lua.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: tests/tests.rs 3 | expression: format(&contents) 4 | --- 5 | -- https://github.com/JohnnyMorganz/StyLua/issues/436 6 | local OffsetEnum = 7 | { aValue = 10, anotherValue = 11, yetAnotherValue = 12, reset = 0, postReset = 1, aaaaaaaaaaa = true } 8 | 9 | local OffsetEnum = { aValue = 10, anotherValue = 11, yetAnotherValue = 12, reset = 0, postReset = 1, aaaaaaaaa = true } 10 | 11 | -------------------------------------------------------------------------------- /tests/snapshots/tests__standard@table-8.lua.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: tests/tests.rs 3 | expression: format(&contents) 4 | --- 5 | -- https://github.com/JohnnyMorganz/StyLua/issues/551 6 | local test = { 7 | { "http://example.com/b//c//d;p?q#blarg", "http://u:p@h.com/p/a/t/h?s#hash2", "http://u:p@h.com/p/a/t/h?s#hash2" }, 8 | } 9 | 10 | -------------------------------------------------------------------------------- /tests/snapshots/tests__standard@table-field-comments-2.lua.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: tests/tests.rs 3 | expression: "format(&contents, LuaVersion::Lua51)" 4 | input_file: tests/inputs/table-field-comments-2.lua 5 | snapshot_kind: text 6 | --- 7 | -- https://github.com/JohnnyMorganz/StyLua/issues/942 8 | local t = { 9 | plus_one = 10 | ---@param n number 11 | ---@return number 12 | function(n) 13 | return n + 1 14 | end, 15 | } 16 | -------------------------------------------------------------------------------- /tests/snapshots/tests__standard@table-field-comments.lua.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: tests/tests.rs 3 | expression: format(&contents) 4 | --- 5 | -- https://github.com/JohnnyMorganz/StyLua/issues/471 6 | local foo = { 7 | x = props.Item.Type == "Crystal" and utf8.char(0x221e) -- Infinite symbol 8 | or nil, 9 | } 10 | 11 | -------------------------------------------------------------------------------- /tests/snapshots/tests__standard@table-field-hanging-1.lua.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: tests/tests.rs 3 | expression: format(&contents) 4 | --- 5 | -- https://github.com/JohnnyMorganz/StyLua/issues/542 6 | -- https://github.com/JohnnyMorganz/StyLua/issues/541 7 | local thisIsATable = { 8 | CreateAnElementFromThisTable = SomethingIsSelected and getTheSelectedThing(TheSelectedItem) 9 | or getTheSelectedThing(NoItemSelected), 10 | } 11 | 12 | -------------------------------------------------------------------------------- /tests/snapshots/tests__standard@table-functions.lua.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: tests/tests.rs 3 | expression: format(&contents) 4 | --- 5 | local foo = {} 6 | function foo.bar(baz) 7 | print(x, y) 8 | end 9 | 10 | -------------------------------------------------------------------------------- /tests/snapshots/tests__standard@table-trailing-comma-comments.lua.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: tests/tests.rs 3 | expression: format(&contents) 4 | --- 5 | -- https://github.com/JohnnyMorganz/StyLua/issues/547 6 | local too = { 7 | x, -- string 8 | y, -- string 9 | } 10 | 11 | -------------------------------------------------------------------------------- /tests/snapshots/tests__standard@table-wrapping.lua.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: tests/tests.rs 3 | expression: format(&contents) 4 | --- 5 | local foo = { 6 | { "foobarbazfoobarbaz", "foobarbazfoobarbaz" }, 7 | { "foobarbazfoobarbaz", "foobarbazfoobarbaz" }, 8 | { "foobarbazfoobarbaz", "foobarbazfoobarbaz" }, 9 | { "foobarbazfoobarbaz", "foobarbazfoobarbaz" }, 10 | } 11 | 12 | -------------------------------------------------------------------------------- /tests/snapshots/tests__standard@var-expression-comments-2.lua.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: tests/tests.rs 3 | expression: format(&contents) 4 | --- 5 | -- https://github.com/JohnnyMorganz/StyLua/issues/509 6 | local foo = bar -- comment after bar 7 | .fizz -- comment after fizz 8 | 9 | -------------------------------------------------------------------------------- /tests/snapshots/tests__standard@var-expression-comments.lua.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: tests/tests.rs 3 | expression: format(&contents) 4 | --- 5 | -- https://github.com/JohnnyMorganz/StyLua/issues/500 6 | local foo = bar 7 | -- comment 1 8 | .fizz 9 | -- comment 2 10 | .buzz 11 | 12 | -------------------------------------------------------------------------------- /tests/snapshots/tests__standard@while-1.lua.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: tests/tests.rs 3 | expression: format(&contents) 4 | --- 5 | while true do 6 | print("foo") 7 | end 8 | 9 | -------------------------------------------------------------------------------- /tests/snapshots/tests__standard@while-2.lua.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: tests/tests.rs 3 | expression: format(&contents) 4 | --- 5 | function foo() 6 | while 7 | NextFreq.Access ~= true 8 | and not Llama.List.find(NextFreq.Access, Players.LocalPlayer.Team.Name) 9 | and NextIndex > #Constants.RADIO_CHANNEL_ORDER 10 | do 11 | print("test") 12 | end 13 | end 14 | 15 | -------------------------------------------------------------------------------- /wasm/.gitignore: -------------------------------------------------------------------------------- 1 | stylua.web/ 2 | stylua_lib.cjs 3 | LICENSE.md 4 | README.md 5 | *.tgz 6 | -------------------------------------------------------------------------------- /wasm/src/stylua_lib_node.cjs: -------------------------------------------------------------------------------- 1 | export * from "../stylua.web/stylua_lib.js"; 2 | import { initSync } from "../stylua.web/stylua_lib.js"; 3 | 4 | const path = require("path").join(__dirname, "stylua.web/stylua_lib_bg.wasm"); 5 | const bytes = require("fs").readFileSync(path); 6 | 7 | initSync(bytes); 8 | -------------------------------------------------------------------------------- /wasm/stylua_lib.d.cts: -------------------------------------------------------------------------------- 1 | export type * from "./stylua.web/stylua_lib"; 2 | export declare const initSync: never; 3 | -------------------------------------------------------------------------------- /wasm/stylua_lib.d.mts: -------------------------------------------------------------------------------- 1 | export type * from "./stylua.web/stylua_lib"; 2 | export declare const initSync: never; 3 | -------------------------------------------------------------------------------- /wasm/stylua_lib.mjs: -------------------------------------------------------------------------------- 1 | import fs from "node:fs"; 2 | import { initSync } from "./stylua.web/stylua_lib.js"; 3 | 4 | const wasm = new URL("./stylua.web/stylua_lib_bg.wasm", import.meta.url); 5 | initSync(fs.readFileSync(wasm)); 6 | 7 | export * from "./stylua.web/stylua_lib.js"; 8 | -------------------------------------------------------------------------------- /wasm/stylua_lib_bundler.d.ts: -------------------------------------------------------------------------------- 1 | export type * from "./stylua.web/stylua_lib"; 2 | export declare const initSync: never; 3 | -------------------------------------------------------------------------------- /wasm/stylua_lib_bundler.js: -------------------------------------------------------------------------------- 1 | import * as wasm from "./stylua.web/stylua_lib_bg.wasm"; 2 | 3 | import { __finalizeInit } from "./stylua.web/stylua_lib.js"; 4 | 5 | __finalizeInit({ exports: wasm }); 6 | 7 | export * from "./stylua.web/stylua_lib.js"; 8 | -------------------------------------------------------------------------------- /wasm/stylua_lib_bundler_wbg.cjs: -------------------------------------------------------------------------------- 1 | module.exports = require("./stylua.web/stylua_lib.js").__getImports().wbg; 2 | --------------------------------------------------------------------------------