github JohnnyMorganz/StyLua v0.6.0

latest releases: v0.20.0, v0.19.1, v0.19.0...
3 years ago

[0.6.0] - 2021-03-27

Added

  • Added support for creating new Config structs when using StyLua as a library
  • Added configuration for quote style. There are four quote style options - AutoPreferDouble, AutoPreferSingle, ForceDouble and ForceSingle.
    For the auto styles, we will prefer the quote type specified, but fall back to the opposite if it means there are fewer escapes. For the
    force styles, we will always use the quote type specified.
  • StyLua will now error when unknown fields are found in the configuration stylua.toml file
  • Long lines of assignments, where the expressions aren't hangable, will now be put onto a newline, where a newline is created after the equal sign, and the expressions indented.
  • Added initial support for Lua 5.2 syntax. StyLua can now format code containing gotos and labels. See #87 to track further support for Lua 5.2 syntax.

Changed

  • Function call heuristic have been further improve to decide when to expand the function call arguments onto multiple lines.
  • StyLua now allows some arguments after a multiline table before forcing expansion. This makes sense for something like setmetatable({ ... }, class), where
    { ... } is a multiline table, but we don't want to expand onto multiple lines. StyLua will not allow a mixture of multiline tables and small identifiers in between
    (e.g. call({ ... }, foo, { ... })), in order to improve readability.
  • Empty newlines at the start and end of a block will now be removed as they are unnecessary
  • Changed the default quote style from ForceDouble to AutoPreferDouble. We will now default to swapping quote type if it will reduce the number of escapes.

Fixed

  • Fixed tables with internal comments (and no fields) incorrectly collapsing to a single line
  • Fixed parentheses being incorrectly removed around a BinOp where first value was a UnOp
  • Fixed indentation of leading comments bound to the end brace of a multiline table
  • Fixed LastStmt (return/break etc.) still being formatted when it wasn't defined inside the range
  • Fixed hanging expressions which are inside function calls being indented unnecessarily by one extra level
  • Fixed parentheses being incorrectly removed around a function definition, which may be called like (function() ... end)()
  • Fixed some string escapes being incorrectly deemed as unnecessary
  • Fixed trailing comments after semicolons at the end of statements being lost when formatting
  • Fixed formatting issues in relation to newline and whitespace when using range formatting.
  • Fixed empty tables taking 2 formatting passes to format properly

Don't miss a new StyLua release

NewReleases is sending notifications on new releases.