版本发布 8
## [2.2.0] - 2025-09-14 ### Added - Added option `block_newline_gaps` to determine whether newline gaps at the start / end of blocks should be preserved. Defaults to `Never`, which is the original behaviour. ([#857](https://github.com/JohnnyMorganz/StyLua/pull/857)) - StyLua can now run in a language server mode. Start StyLua with `stylua --lsp` and connect with a language client. ([#936](https://github.com/JohnnyMorganz/StyLua/issues/936)) ### Changed - Luau: Improved union of tables formatting to hang the union type rather than attempt to hug all the tables together ([#958](https://github.com/JohnnyMorganz/StyLua/issues/958)) ### Fixed - Fixed formatting of index containing brackets string in parentheses ([#992](https://github.com/JohnnyMorganz/StyLua/pull/992)) - Fixed goto not being recognised for LuaJIT ([#986](https://github.com/JohnnyMorganz/StyLua/issues/986)) - Fixed semicolon removed after a statement ending with an if-expression leading to ambiguous syntax when the next line begins with parentheses ([#1010](https://github.com/JohnnyMorganz/StyLua/issues/1010)) - Luau: Fixed malformed formatting when there is a comment after a type specifier in a local assignment ([#995](https://github.com/JohnnyMorganz/StyLua/issues/995)) - Luau: Fixed long type union formatted onto a single line if there is a comment in between the equals sign and the type union in a type declaration ([#1007](https://github.com/JohnnyMorganz/StyLua/issues/1007)) - Fixed StyLua installation via pip / uv for Windows ([#1018](https://github.com/JohnnyMorganz/StyLua/pull/1018)) --- ## External Contributions * Fix formatting of index containing brackets string in parentheses by @phanen in https://github.com/JohnnyMorganz/StyLua/pull/992 * Fix goto not being recognised for LuaJIT by @Sainan in https://github.com/JohnnyMorganz/StyLua/pull/998 * Add option to preserve newline gaps for blocks by @InoUno in https://github.com/JohnnyMorganz/StyLua/pull/857 * feat: Stylua LSP server by @PolyMeilex in https://github.com/JohnnyMorganz/StyLua/pull/970 * fix(release-gitter): correct Windows asset name for pip build by @izzalDev in https://github.com/JohnnyMorganz/StyLua/pull/1018 ## New Contributors * @Sainan made their first contribution in https://github.com/JohnnyMorganz/StyLua/pull/998 * @InoUno made their first contribution in https://github.com/JohnnyMorganz/StyLua/pull/857 * @PolyMeilex made their first contribution in https://github.com/JohnnyMorganz/StyLua/pull/970 * @izzalDev made their first contribution in https://github.com/JohnnyMorganz/StyLua/pull/1018 **Full Changelog**: https://github.com/JohnnyMorganz/StyLua/compare/v2.1.0...v2.2.0
## [2.1.0] - 2025-04-21 ### Added - Luau: Added support for parsing user-defined type functions ([#938](https://github.com/JohnnyMorganz/StyLua/issues/938)) - Luau: Added support for parsing attributes (`@native` / `@deprecated`) on functions - Added support for CfxLua (FiveM) syntax formatting. This is available with `syntax = "cfxlua"` ([#855](https://github.com/JohnnyMorganz/StyLua/issues/855)) - Added a pre-built binary release for `stylua-linux-aarch64-musl.zip` - Added error hints on parse failurse when a potential Lua syntax conflict is noticed (e.g., Lua 5.2 vs Luau syntax for labels `::` and generics `>>`) ([#960](https://github.com/JohnnyMorganz/StyLua/issues/960) / [#962](https://github.com/JohnnyMorganz/StyLua/issues/962)) ### Changed - Updated StyLua release GitHub action to `ubuntu-22.04` workers due to GitHub's deprecation of `ubuntu-20.04`. This may mean the pre-built release artifacts published to GitHub no longer work on `ubuntu-20.04` and require a manual build. ### Fixed - Luau: fixed parentheses incorrectly removed in `(expr :: assertion) < foo` when multilining the expression, leading to a syntax error ([#940](https://github.com/JohnnyMorganz/StyLua/issues/940)) - Fixed panic when attempting to format a file outside of the current working directory when `--respect-ignores` is enabled ([#969](https://github.com/JohnnyMorganz/StyLua/pull/969)) - Fixed unnecessary semicolons being introduced at the end of statements when incorrectly determined as ambiguous ([#963](https://github.com/JohnnyMorganz/StyLua/issues/963)) - Fixed malformed formatting of function calls where parentheses are removed but there are comments in between the parentheses and the expression. Now, we will keep the parentheses in these cases, except for trailing comments ([#964](https://github.com/JohnnyMorganz/StyLua/issues/964)) - Fixed malformed formatting of table field expression when there are comments in between the equals and the value ([#942](https://github.com/JohnnyMorganz/StyLua/issues/942)) --- ## External Contributions * Bump fullmoon to 1.2.0 by @Ukendio in https://github.com/JohnnyMorganz/StyLua/pull/945 * fix: use "summary" for the missing `--check` error message by @eitamal in https://github.com/JohnnyMorganz/StyLua/pull/949 * Document --stdin-filepath in README.md by @notpeter in https://github.com/JohnnyMorganz/StyLua/pull/954 * Fix panic when `--respect-ignores --stdin-filepath` on external path to cwd by @phanen in https://github.com/JohnnyMorganz/StyLua/pull/969 * Support Cfx Lua Syntax by @Kuuzoo in https://github.com/JohnnyMorganz/StyLua/pull/972 ## New Contributors * @Ukendio made their first contribution in https://github.com/JohnnyMorganz/StyLua/pull/945 * @eitamal made their first contribution in https://github.com/JohnnyMorganz/StyLua/pull/949 * @notpeter made their first contribution in https://github.com/JohnnyMorganz/StyLua/pull/954 * @phanen made their first contribution in https://github.com/JohnnyMorganz/StyLua/pull/969 * @Kuuzoo made their first contribution in https://github.com/JohnnyMorganz/StyLua/pull/972 **Full Changelog**: https://github.com/JohnnyMorganz/StyLua/compare/v2.0.2...v2.1.0
## [2.0.2] - 2024-12-07 ### Fixed - Fixed regression where configuration present in current working directory not used when formatting from stdin and no `--stdin-filepath` is provided ([#928](https://github.com/JohnnyMorganz/StyLua/issues/928)) - Luau: fixed incorrect indentation for leading token in union / intersection when hanging ([#932](https://github.com/JohnnyMorganz/StyLua/issues/932))
## [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](https://github.com/JohnnyMorganz/StyLua/issues/925)) --- **Full Changelog**: https://github.com/JohnnyMorganz/StyLua/compare/v2.0.0...v2.0.1
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: https://github.com/JohnnyMorganz/StyLua/issues/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: ```toml 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: https://github.com/JohnnyMorganz/StyLua/issues/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: https://github.com/JohnnyMorganz/StyLua/pull/916 --- ## [2.0.0] - 2024-11-17 ### Breaking Changes - For automated downloaders: the legacy release artifacts `stylua-win64.zip`, `stylua-linux.zip` and `stylua-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` and `stylua-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 if `foo.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](https://github.com/JohnnyMorganz/StyLua/issues/407)) - Added configuration option `space_after_function_names` to specify whether to include a space between a function name and parentheses ([#839](https://github.com/JohnnyMorganz/StyLua/issues/839)) ### Changed - Update internal Lua parser version (full-moon) to v1.1.0. This includes parser performance improvements. ([#854](https://github.com/JohnnyMorganz/StyLua/issues/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`, executing `stylua 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](https://github.com/JohnnyMorganz/StyLua/issues/898)) ### Fixed - Fixed formatting of method call chain when there is a comment between the colon token `:` and the function name ([#890](https://github.com/JohnnyMorganz/StyLua/issues/890)) - Removed accidental random print to stdout when formatting a return statement across multiple lines ([#879](https://github.com/JohnnyMorganz/StyLua/issues/879)) - Luau: Fixed incorrect removal of semicolon before compound assignment with parentheses leading to ambiguous syntax error ([#885](https://github.com/JohnnyMorganz/StyLua/issues/885)) - Luau: Fixed incorrect collapsing of union/intersection type value with comments in a type table leading to a syntax error ([#893](https://github.com/JohnnyMorganz/StyLua/issues/893)) - Fixed `--verify` panicing due to overflow for very large Hex numbers ([#875](https://github.com/JohnnyMorganz/StyLua/issues/875), [#889](https://github.com/JohnnyMorganz/StyLua/issues/889))
## [0.20.0] - 2024-01-20 ### Added - Introduced a new release artifact `stylua-linux-x86_64-musl` ([#834](https://github.com/JohnnyMorganz/StyLua/issues/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](https://github.com/JohnnyMorganz/StyLua/issues/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](https://github.com/JohnnyMorganz/StyLua/issues/827)) - Fixed function body parentheses being placed on multiple lines unnecessarily when there are no parameters ([#830](https://github.com/JohnnyMorganz/StyLua/issues/830)) - Fixed directory paths w/o globs in `.styluaignore` not matching when using `--respect-ignores` ([#845](https://github.com/JohnnyMorganz/StyLua/issues/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](https://github.com/JohnnyMorganz/StyLua/issues/828)) ## New Contributors * @andros21 made their first contribution in https://github.com/JohnnyMorganz/StyLua/pull/834 * @dundargoc made their first contribution in https://github.com/JohnnyMorganz/StyLua/pull/840 * @DervexHero made their first contribution in https://github.com/JohnnyMorganz/StyLua/pull/826 **Full Changelog**: https://github.com/JohnnyMorganz/StyLua/compare/v0.19.1...v0.20.0
## [0.19.1] - 2023-11-15 This release has no changes. It resolves an issue in our test suite that may affect downstream package management tooling failing tests ([#824](https://github.com/JohnnyMorganz/StyLua/issues/824))
## [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](https://github.com/JohnnyMorganz/StyLua/issues/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 - 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. - 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](https://github.com/JohnnyMorganz/StyLua/issues/778)) ### Fixed - Wasm build now correctly supports configuring sort requires ([#818](https://github.com/JohnnyMorganz/StyLua/issues/818))