Releases: JohnnyMorganz/StyLua
v2.0.2
v2.0.1
[2.0.1] - 2024-11-18
Added
- Verbose mode will now show resolved options
Fixed
- Fixed CLI overrides not applying on top of a resolved
stylua.toml
file (#925)
Full Changelog: v2.0.0...v2.0.1
v2.0.0
StyLua has officially stabilised to v2.0.0. With this, we make a commitment that the formatting output is fairly stable across minor version bumps. More details: #459
Key Changes
This release updates the internal Lua parser, bringing performance improvements and new Luau syntax features.
LuaJIT is now separate from Lua5.2, with its own feature flag.
Runtime syntax selection
By default, StyLua runs with a parser that is able to handle a variety of different Lua syntaxes at once, with a goal of being easily usable on different codebases. However, there are times where 2 different syntax definitions conflict, introducing ambiguity. For example, Lua 5.2 label syntax (::label::
) conflicts with Luau's type assertion syntax (x :: number
), and the latter ends up taking priority.
Now, you can select a particular style of syntax at runtime to deal with these ambiguities.
In your stylua.toml
file, add:
syntax = "Lua52" # Possible values: All, Lua51, Lua52, Lua53, Lua54, LuaJIT, Luau
Or, specify --syntax lua52
on the command line.
The default remains "All" to handle all syntaxes as much as possible.
More details: #407
Updated Configuration Resolution
Previously, StyLua would only search for a stylua.toml
(or .stylua.toml
) file in the directory where the binary was executed - the current working directory (or its ancestors, if --search-parent-directories
is enabled). This means that any configuration files present in subdirectories are not taken into account.
This release changes config resolution to pick up stylua.toml
files in subdirectories. Now, a file will format based on the stylua.toml
configuration closest to its location. StyLua will search backwards from the file location to the current working directory for a configuration file. By default, searching will stop at the current working directory, however it will continue if --search-parent-directories
is enabled.
More details: #916
[2.0.0] - 2024-11-17
Breaking Changes
- For automated downloaders: the legacy release artifacts
stylua-win64.zip
,stylua-linux.zip
andstylua-macos.zip
are no longer produced in GitHub releases, in favour of more specific names (e.g.,stylua-windows-x86_64
,stylua-linux-x86_64
andstylua-macos-x86_64
). --stdin-filepath
no longer respects ignore files by default, in line with passing files directly to the command line. Now,stylua --stdin-filepath foo.lua -
will still format the stdin even iffoo.lua
was in a.styluaignore
file. Use--respect-ignores
to preserve the original behaviour.- Removed deprecated access patterns on
Config
struct in stylua Rust library
Added
- Added runtime syntax configuration option
syntax
to help handle ambiguous syntax. By default, StyLua builds and runs with a parser to handle all Lua versions. However, the syntax of some Lua versions conflict with eachother: most notably, Lua 5.2+ goto label syntax::label::
and Luau type assertion operator::
. This option allows choosing what syntax to parse, to handle these conflicts. (#407) - Added configuration option
space_after_function_names
to specify whether to include a space between a function name and parentheses (#839)
Changed
- Update internal Lua parser version (full-moon) to v1.1.0. This includes parser performance improvements. (#854)
- LuaJIT is now separated from Lua52, and is available in its own feature and syntax flag
.stylua.toml
config resolution now supports looking up config files next to files being formatted, recursively going
upwards until reaching the current working directory, then stopping (unless--search-parent-directories
was specified).
For example, for a file./src/test.lua
, executingstylua src/
will look for./src/stylua.toml
and then./stylua.toml
.- When
collapse_simple_statement
is enabled, if the enclosing block is a return, we will check if the return expression is "simple" (currently, not containing a function definition) (#898)
Fixed
- Fixed formatting of method call chain when there is a comment between the colon token
:
and the function name (#890) - Removed accidental random print to stdout when formatting a return statement across multiple lines (#879)
- Luau: Fixed incorrect removal of semicolon before compound assignment with parentheses leading to ambiguous syntax error (#885)
- Luau: Fixed incorrect collapsing of union/intersection type value with comments in a type table leading to a syntax error (#893)
- Fixed
--verify
panicing due to overflow for very large Hex numbers (#875, #889)
What's Changed
- feat(wasm): Support more targets by @magic-akari in #848
- fix(stylua-npm-bin): adjust axios config to work with proxy env variables by @antoineauger in #868
- Apply clippy suggestions by @alerque in #870
- deps: bump libc from 0.2.148 to 0.2.155 by @huajingyun01 in #862
- Add option for formatting with spaces between function names and arguments by @alerque in #839
- Fix method call chain formatting with inline comments by @JohnnyMorganz in #904
- Fix incorrect removal of semicolon before compound assignment causing ambiguous syntax error by @JohnnyMorganz in #905
- Don't collapse compound type field if it contains comments by @JohnnyMorganz in #906
- Remove accidental print when formatting hanging returns by @JohnnyMorganz in #907
- Update documentation of 'opinionated' to reflect project goals by @alerque in #909
- Update to new full-moon version v1.1.1 by @JohnnyMorganz in #854
- Remove legacy release artifacts from GitHub releases by @JohnnyMorganz in #911
- Don't ignore by default with
--stdin-filepath
, use--respect-ignores
by @JohnnyMorganz in #912 - Update VSCode extension to use stdin-filepath and respect-ignores by @JohnnyMorganz in #913
- Update to full-moon 1.1.2 by @JohnnyMorganz in #920
- Improve error reporting on full moon errors by @JohnnyMorganz in #921
- Switch to closest file configuration resolution by @JohnnyMorganz in #916
- Remove deprecated access patterns on
Config
struct by @JohnnyMorganz in #922 - collapse_simple_stmt: check if return expressions are "simple" by @JohnnyMorganz in #923
- Update contents of readme about syntax selection by @JohnnyMorganz in #914
New Contributors
- @magic-akari made their first contribution in #848
- @antoineauger made their first contribution in #868
- @alerque made their first contribution in #870
- @huajingyun01 made their first contribution in #862
Full Changelog: v0.20.0...v2.0.0
v0.20.0
[0.20.0] - 2024-01-20
Added
- Introduced a new release artifact
stylua-linux-x86_64-musl
(#834)
Changed
- Files excluded by git (via
.gitignore
or global git configuration), as well as in an.ignore
file (used by ripgrep and The Silver Searcher)
will now also be ignored by StyLua (as if they were all.styluaignore
files). (#833)
Fixed
General
- The CLI tool will now only write files if the contents differ, and not modify the file if there is no change after formatting (#827)
- Fixed function body parentheses being placed on multiple lines unnecessarily when there are no parameters (#830)
- Fixed directory paths w/o globs in
.styluaignore
not matching when using--respect-ignores
(#845)
Luau
- Fixed handling of floor division (
//
) syntax when only Luau command line flag is enabled - Fixed missing space when table is inside of Luau interpolated string expression (
{{
is invalid syntax) - Fixed parentheses around a Luau compound type inside of a type table indexer being removed causing a syntax error (#828)
New Contributors
- @andros21 made their first contribution in #834
- @dundargoc made their first contribution in #840
- @DervexHero made their first contribution in #826
Full Changelog: v0.19.1...v0.20.0
v0.19.1
v0.19.0
[0.19.0] - 2023-11-12
Added
- Added flag
--respect-ignores
. By default, files explicitly passed to stylua (e.g.stylua foo.lua
) will always be formatted, regardless of whether the file is ignored. Enabling this flag will consider.styluaignore
or glob matches before formatting the file. (#765)- Note: for backwards compatibility reasons, formatting via stdin always respects ignores. This behaviour will change in the next major release
Changed
-
Updated parser crate with following changes:
- Support Luau floor division (
//
) - Fix Luau string interpolation parsing
- Fix Luau
\z
escape parsing
- Support Luau floor division (
-
Simplified access and modification patterns for StyLua configuration. You can now access the properties directly
- Deprecated: the old access patterns of
.property()
and.with_property()
are now deprecated - Breaking Change (WASM): due to JS/TS lack of differentiation between
.property
/.property()
implementation, the.property()
functions were removed from WASM output.
- Deprecated: the old access patterns of
-
Multiline comments before commas will now remain in place and not move to after the comma. This is to support type-assertions-via-comments that is commonly used by some language servers. (#778)
Fixed
- Wasm build now correctly supports configuring sort requires (#818)
v0.18.2
[0.18.2] - 2023-09-10
Fixed
- Fixed LuaJIT suffixes
LL
/ULL
causing a panic when running in--verify
mode (#750) - Fixed incorrect formatting of conditionals when
collapse_simple_statement
is enabled and the block begins with an empty line (#744) - Fixed formatting of dot function call chains with comment between dot and names (#747)
Full Changelog: v0.18.1...v0.18.2
v0.18.1
v0.18.0
[0.18.0] - 2023-06-14
Added
- Multiline ignores (
-- stylua: ignore start
/-- stylua: ignore end
) will now work within table fields:
require("foo").bar {
-- stylua: ignore start
baz =0, -- < not formatted
foo = 2, -- < not formatted
-- stylua: ignore end
bar = 1234 -- < formatted
}
- Added option
"Input"
tocall_parentheses
setting, where call parentheses are retained based on their presence in the original input code.
Note: this setting removes all automation in determining call parentheses, and consistency is not enforced.
Changed
- Improved heuristics around Luau type excess parentheses removal, so unnecessary parentheses around types are removed in more locations
Fixed
- Function calls are now formatted onto multiple lines if the opening brace
{
of a multiline table forces one of the lines over width - Fixed missing option
--sort-requires
to enable sort requires on the command line
$ stylua --sort-requires test.lua
- Fixed parentheses removed around Luau optional type
(B?)
causing syntax errors when present in an intersectionA & (B?)
- Fixed comments lost when parentheses removed around Luau types
- Fixed race condition where if a file is passed more than once as an argument to format, then it could potentially be wiped completely (for example, if an ancestor directory is passed and recursively searched, as well as the file itself)
v0.17.1
[0.17.1] - 2023-03-30
Fixed
- Bumped internal parser dependency which should fix parsing problems for comments with Chinese characters, and multiline string escapes
- Fixed comments in punctuated lists for return statements or assignments being incorrectly formatted leading to syntax errors (#662)
- Fixed line endings not being correctly formatted in multiline string literals and comments (#665)
What's Changed
- Adding Homebrew instructions by @benfrain in #661
- Fix comments in punctuated list for returns and assignments by @JohnnyMorganz in #663
- Cleanup trivia code by @JohnnyMorganz in #664
- Format line endings in multiline strings and comments by @JohnnyMorganz in #666
New Contributors
Full Changelog: v0.17.0...v0.17.1