StyLua

An opinionated Lua code formatter

MPL-2.0 License

Downloads
8.2K
Stars
1.6K
Committers
38

Bot releases are visible (Hide)

StyLua - v0.12.5

Published by github-actions[bot] over 2 years ago

This release only affects users of the luau feature flag

[0.12.5] - 2022-03-08

Fixed

Luau

  • Fixed crashed due to unhandled generic type packs under the luau feature flag. (#403)

Full Changelog: https://github.com/JohnnyMorganz/StyLua/compare/v0.12.4...v0.12.5

StyLua - v0.12.4

Published by github-actions[bot] over 2 years ago

[0.12.4] - 2022-03-02

Fixed

General

  • Fixed comments being lost around a condition when unnecessary parentheses are removed. (#389)
  • Fixed multiline expression with comments inside parentheses being collapsed leading to a syntax error. (#386)
  • Fixed ignore comments not respected in child blocks of ignored statements. (#387)

Luau

  • Fixed long comments forcing unnecessary hanging of type declarations. (#384)
  • Fixed long intersection types not hanging. (#382)
  • Fixed values in type tables not hanging when over width. (#394)
  • Fixed type info generics not hanging when over width. (#394)
  • Fixed callback types with binop type parameters / return types not hanging leading to a syntax error when comments are present. (#396)
  • Fixed type declarations not hanging properly causing them to go over width. This includes hanging at the equals token and hanging union/intersection types.
StyLua - v0.12.3

Published by github-actions[bot] over 2 years ago

[0.12.3] - 2022-02-17

Fixed

General

  • Fixed call chains not hanging when comments were present in between calls, leading to a syntax error. (#367)

Luau

  • Fixed if-expression syntax getting unnecessarily expanded further due to trailing comments. (#375)
  • Fixed formatting of leading comments of a keyword in if-expression syntax. (#374)
  • Fixed formatting of long type declarations which go over the line width to hang if possible. (#372)
  • Fixed mistransformation of comments within a type union leading to a syntax error. (#378)

What's Changed

Full Changelog: https://github.com/JohnnyMorganz/StyLua/compare/v0.12.2...v0.12.3

StyLua - v0.12.2

Published by github-actions[bot] over 2 years ago

This release only affects users of the luau feature flag.

Fixed

  • Fixed crash due to unhandled singleton type formatting under the luau feature flag. (#358)
  • Includes types in shape calculation for causing a generic for to go multiline under the luau feature flag. (#360)

What's Changed

Full Changelog: https://github.com/JohnnyMorganz/StyLua/compare/v0.12.1...v0.12.2

StyLua - v0.12.1

Published by github-actions[bot] over 2 years ago

[0.12.1] - 2022-02-01

Fixed

  • Fixed misformatting of conditions in if-expression syntax leading to spurious whitespace under the luau feature flag. (#349)
  • Fixed incorrect shape calculation in if-expression syntax: if-expression will now go multiline when only slightly over column width (luau feature flag).
  • Fixed incorrect handling of comments at the end of a callback type's arguments under the luau feature flag. (#352)
  • Fixed mistransformation of type declaration when the type info is a union which must be multiline due to comments under the luau feature flag. (#351)
  • Fixed leading comments on a | symbol in a type info being lost when hanging the type under the luau feature flag.
  • Fixed trailing comments of a function call being lost as parentheses are removed around a single argument when call_parentheses is set to not Always. (#356)

What's Changed

Full Changelog: https://github.com/JohnnyMorganz/StyLua/compare/v0.12.0...v0.12.1

StyLua - v0.12.0

Published by github-actions[bot] over 2 years ago

[0.12.0] - 2022-01-31

Added

  • Added option call_parentheses:
    Specify whether to apply parentheses on function calls with single string or table arg. Possible options: Always (default), NoSingleString, NoSingleTable, None. (#329)
  • Added proper multiline hanging of generic for syntax. (#322)
  • Added proper formatting for if-expression syntax under the luau feature flag. (#289)
  • Updated parser to add support for generic/variadic type packs, singleton types and default types under the luau feature flag.

Fixed

  • Fixed generic variadics not being handled under the luau feature flag. (#333)
  • Fixed issue with comments within an assignment not being correctly handled, leading to a syntax error. (#340)
  • Fixed parentheses around an IfExpression being removed, leading to incorrect semantics, under the luau feature flag. (#345)

Deprecated

  • Option no_call_parentheses has been deprecated. Use call_parentheses = "None" instead.

What's Changed

New Contributors

Full Changelog: https://github.com/JohnnyMorganz/StyLua/compare/v0.11.3...v0.12.0

StyLua - v0.11.3

Published by github-actions[bot] almost 3 years ago

[0.11.3] - 2022-01-01

Fixed

  • Fixed comments preceding a comma within a function call or parameter list for a function definition being mistransformed leading to a syntax error. (#307)
  • Fixed IfExpression having abnormal leading whitespace under the luau feature flag. (#315)
  • Fixed incorrect handling of comments in unusual places within a table causing mistransformations leading to syntax errors. (#318)

What's Changed

New Contributors

Full Changelog: https://github.com/JohnnyMorganz/StyLua/compare/v0.11.2...v0.11.3

StyLua - v0.11.2

Published by github-actions[bot] almost 3 years ago

[0.11.2] - 2021-11-15

Fixed

  • Fixed spaces around brackets string ([[string]]) used as an index or table key (i.e. [ [[string]] ]) being removed, leading to a syntax error. (#293)
  • Fixed incorrect shape calculation leading to arguments incorrectly expanding when under column width. (#298)
  • Fixed incorrect shape calculation for singleline table at the column width boundary. (#296)
  • Fixed IfExpression syntax containing extra/abnormal trailing whitespace when currently formatting as-is under the luau feature flag. (#297)
  • Fixed newlines before arguments in a function call which is later formatted on a single line being preserved, leading to inconsistent formatting. (#290)
  • Fixed odd formatting when returning multiple tables or functions only. (#302)
  • Fixed comments within an index expression (foo[index]) incorrectly handled leading to malformed formatting. (#304)
StyLua - v0.11.1

Published by github-actions[bot] almost 3 years ago

[0.11.1] - 2021-11-08

Changed

  • Updated internal parser to fix parsing issues and update luau parsing. (#229, #231)
  • Default glob now matches **/*.luau (as well as **/*.lua) when the luau flag is enabled. (#291)

Fixed

  • Fixed indentation of type callback specifier parameters when parameters have leading comment trivia. (#278)
  • Fixed trailing comma not being taken into account when determining the width of a field in a multiline table. (#282)
  • Fixed --num-threads 1 causing a deadlock. (#281)
  • Fixed whitespace around parts of a binary expression causing it to over-hang in first pass, leading to unstable formatting. (#287)
StyLua - v0.11.0

Published by github-actions[bot] about 3 years ago

[0.11.0] - 2021-09-16

Changed

  • In Luau type tables, a newline after the opening brace will now force the type table multiline. This is the same procedure as standard tables. (#226)
  • In Luau, type specifiers for function parameters will now force the parameters to be formatted multiline if a specifier is multiline (and there is more than one parameter).
  • Improved error messages to make them easier to understand.

Fixed

  • Fixed range formatting no longer working when setting the range to statements inside nested blocks. (#239)
  • Fixed ignore file present in cwd not taken into account if cwd not included in file paths to format. (#249)
  • Fixed config locations ($XDG_CONFIG_HOME and $HOME/.config) not being looked into correctly on macOS when --search-parent-directories is used. (#260)
  • Fixed incorrect indentation of multiline type specifiers for function parameters under the luau feature flag. (#256)
  • Fixed unstable formatting caused by a singleline table which just reaches the column width. (#261)
  • Fixed misformatting of a binop expression as precedence of the RHS expression was not taken into account. (#257, #261)
StyLua - v0.10.1

Published by github-actions[bot] about 3 years ago

[0.10.1] - 2021-08-08

Fixed

  • Fixed an incorrect trailing comma being added to function args as part of a multiline expression list leading to a syntax error. (#227)
  • Fixed the first expression in a multiple assignment prematurely hanging even if its below the column width. (#233)
  • Updated internal parser to fix parsing issues for Luau code under the luau feature flag.
StyLua - v0.10.0

Published by github-actions[bot] over 3 years ago

[0.10.0] - 2021-07-11

Added

  • Added flag --verify which, when enabled, attempts to verify the generated output AST with the input AST to detect any changes to code correctness. Useful for adopting StyLua into a large codebase, at the cost of slower processing. (#199)
  • Added optional command line options --column-width, --indent-type, --indent-width, --line-endings and --quote-style, which, when provided, will override any configuration setting inferred from the default or a stylua.toml. (#213)
  • Added multithreaded support for formatting file in the CLI. Now each file will be formatted in its own thread. The number of threads used defaults to the number of cores on your computer, but can be set using --num-threads
  • Added support for disabling formatting over specific ranges. Use -- stylua: ignore start to disable formatting and -- stylua: ignore end to re-enable it. The comment must be preceding a statement and disabling formatting cannot cross block scope boundaries. (#198)

Changed

  • Luau type tables (luau feature flag) now use the same formatting strategy as normal expression tables, so that their formatting is more aligned.
  • Luau typings now have improved checking against the current shape width to determine how to format if over column width.
  • Luau callback types will now format multiline if they become over width under the luau feature flag.
  • Improved the formatting of return expressions, they are now more in line with assignment expressions. (#194)
  • Changed buffering of error messages in the CLI. Originally, they would be buffered till the end, but now they are output immediately when seen.
  • Allowed the use of --check when taking input from stdin.
  • An error when parsing provided globs will cause the program to immediately exit rather than continuing with the incorrect glob.
  • Only diff errors will exit with a status code of 1. Other errors (e.g. parse errors or internal errors) will now exit with status code of 2.

Fixed

  • Fixed comments inside Luau type tables leading to malformed formatting under the luau feature flag. (#219)
  • Fixed multiple assignment where an expression was originally hung due to comments being collapsed leading to malformed formatting. (#222)
  • Fixed an issue where a function call with a single table argument being hugged with the parentheses which contain comments leading to a syntax error. (#224)
StyLua - v0.9.3

Published by github-actions[bot] over 3 years ago

[0.9.3] - 2021-06-26

Added

  • Added --verbose to print debug information, including finding config files and time taken to format files.

Fixed

  • Fixed severe performance regression due to a change in table formatting leading to exponential blowup for nested tables. (#205)
  • Fixed long binop chains with a comment deep inside not being hung, leading to a syntax error. (#210)
StyLua - v0.9.2

Published by github-actions[bot] over 3 years ago

[0.9.2] - 2021-06-20

Changed

  • Bumped full-moon to 0.12.1 to fix parsing bugs

Fixed

  • Fixed parentheses around type assertions being classed as unnecessary and removed under the luau feature flag.
  • Fixed mistransformation of function type where arguments have comments under the luau feature flag. (#201)
  • Fixed comments in an assignment in between the equals token and the expression leading to a mistransformation. (#200)
StyLua - v0.9.1

Published by github-actions[bot] over 3 years ago

[0.9.1] - 2021-06-17

Added

  • Added --stdin-filepath option to specify location of file being taken in from stdin. This is optional and is only used to determine where to find the configuration file. If not provided, we default to searching from current working directory. (#192)

Fixed

  • Fixed empty functions with comments being incorrectly collapsed leading to syntax error. (#195)
StyLua - v0.9.0

Published by github-actions[bot] over 3 years ago

[0.9.0] - 2021-06-15

Added

  • CLI will now look for stylua.toml and its hidden counterpart, .stylua.toml. (#145)
  • Added CLI flag --search-parent-directories. If enabled, we will look in parent directories for a configuration file, or look in $XDG_CONFIG_HOME or $XDG_CONFIG_HOME/stylua. (#127, #146)
  • Updated full-moon: Added support for typed variadics, named function type args, and generic functions under the Luau feature flag
  • Will now hang on equality operators within binary expressions, if over width.
  • If a file path is explicitly provided to the CLI which doesn't end with .lua ending, the *.lua glob check is skipped. (#170)
  • Long type unions will now hang under the luau feature flag. (#165)
  • Added option no_call_parentheses. Enabling this config will remove parentheses around function calls taking a single string/table as an argument. This config was added for adoption purposes. (#133)

Changed

  • Long prefix expressions which are hangable and go over the line limit (e.g. ("foooo" .. "barrrrrrr" .. "bazzzzzz"):format(...)) will now hang multiline (#139)
  • Changed formatting for assignments. We will now try all tactics then determine the best one. Multiple assignments will now no longer attempt to hang a single expression first - we will hang the whole punctuated list. (#157)
  • Function calls with single arguments are now possible to be expanded. This will allow the call to be expanded if the line goes over budget. (#156)
  • StyLua will now firstly prefer hanging long arguments to function calls to try and fit under the width, before expanding them multiline. (#159)
  • When hanging a binary expression, previously, we would always hang the "root" node of AST BinExp tree. Now we will check to see if is necessary (we are over width) before hanging (#163)
  • StyLua will hug together table braces with function call parentheses when formatting a function call taking a single table as an argument. (#182)
  • Function calls with more than one argument, where an argument is "complex", will now expand multiline. "complex" is an argument spanning multiple lines, but excludes a table or anonymous function, as we handle them explicitly. (#183)
  • StyLua will always hang at the equals token for a multi-variable assignment. (#185)
  • Tables with multiline fields (such as an anonymous function expression) should always expand if previously on single line. (#187)
  • Function definitions (both normal and anonymous) with an empty body will now be kept on a single line. This is common for noop functions local function noop() end. (#188)

Fixed

  • Fixed 1 or 2 digit numerical escapes being incorrectly removed
  • Fixed whitespace being lost before a multiline comment. We will now preserve a single space (e.g. local test --[[foo]] = true -> local test --[[foo]] = true) (#136)
  • Fixed the double formatting of a hanging call chain when it was being assigned to a variable causing it to be incorrectly formatted (#151)
  • Fixed leading comments to a binop in a hanging expression being lost (#154)
  • Fixed mistransformation of comments leading the RHS of a hanging binop. They are now moved to before the binop (#154)
  • Fixed comments trailing unnecessary parentheses around expressions that were later removed not being preserved (#176)
  • Fixed a double unary minus (- -foo/-(-foo)) being formatted as --foo leading to a comment syntax error. Parentheses are now enforced: -(-foo) (#171)
  • Fixed semicolon being removed leading to function call x new statement ambiguity when next statement is an assignment with the first variable being a parentheses var expression (#173)
  • Fixed mistransformation of comments in if condition then or while condition do lines - improved assurance that they will hang multiline (#164)
  • Fixed indentation of comments leading a then or do token when if ... then or while ... do are multiline.
  • Fixed mistransformation of comments in a generic declaration under the luau feature flag (#166)
  • Fixed trailing comma being added after comments in multiline type table under the luau feature flag (#166)
StyLua - v0.8.1

Published by JohnnyMorganz over 3 years ago

[0.8.1] - 2021-04-30

Fixed

  • Fixed bug where a hanging expression inside of parentheses would lead to function arguments being incorrectly formatted with a trailing comma - leading to a syntax error
StyLua - v0.8.0

Published by JohnnyMorganz over 3 years ago

[0.8.0] - 2021-04-30

Added

  • Parentheses around conditions are now removed, as they are not required in Lua. if (foo and (not bar or baz)) then ... end turns to if foo and (not bar or baz) then ... end
  • Long multi-variable assignments which surpass the column width, even when hanging on the equals token, will now hang on multiple lines.

Changed

  • Changed the heursitics for when parentheses are removed around expressions. Parentheses will now never be removed around a function call prefix (e.g. ("hello"):len())
  • Changed formatting for comma-separated lists. Previously, we would buffer the comments to the end of the list, but now we keep the comments next to where they original were.
  • Improved contextual formatting informattion when formatting deep in the AST. We can now better determine how much space is left on the current line, before we need to change formatting
  • Improved formatting of function declarations. It will now properly take into account the amount of space left on the column width.
  • Improve formatting for assignments with expressions such as function calls. The whole assignment is now taken into account, so we can better determine whether to split the expression.

Fixed

  • Fixed trailing whitespace remaining on the last item of a multiline table (which was expanded from a singleline one)
StyLua - v0.7.1

Published by JohnnyMorganz over 3 years ago

[0.7.1] - 2021-04-19

Fixed

  • Fixed parentheses around a table being incorrectly removed leading to a syntax error, such as in ({}):foo()
StyLua - v0.7.0

Published by JohnnyMorganz over 3 years ago

[0.7.0] - 2021-04-13

Added

  • Added hanging for chained function calls. See #109
  • Long function definitions (normally with parameters containing types and a return type) will now be split across multiple lines if they surpass the column limit

Changed

  • Further improvements to the way binary expressions are hung on new lines

Fixed

  • Fixed trailing comments at the end of multiline tables being lost
  • Fixed panic "stmt trailing comments not implemented" occuring due to incomplete function
  • Fixed trailing comments after semicolons at the end of last statements being lost when formatting
  • Fixed function parameters collapsing when there is a comments at the end of function parameters, where the last parameter has a type specifier
  • Fixed comments at the end of tables being indented one extra level
  • Fixed trailing comments within if-elseif-else blocks not being correctly indented.
  • Fixed do in a while ... do statement not correctly indented when the condition spans multiple lines
  • Fixed multiline parameters for a function definition inside of an indent block (e.g. a table) not being correctly indented
Package Rankings
Top 5.92% on Alpine-v3.18
Top 8.43% on Npmjs.org
Top 9.08% on Crates.io
Top 7.56% on Proxy.golang.org
Top 12.68% on Alpine-v3.17
Top 10.54% on Alpine-edge
Top 15.0% on Formulae.brew.sh
Badges
Extracted from project README
Community Packages