LinuxCommandLibrary
GitHubF-DroidGoogle Play Store

stylua

Opinionated Lua code formatter

TLDR

Format file
$ stylua [script.lua]
copy
Format multiple files
$ stylua [file1.lua] [file2.lua]
copy
Format directory
$ stylua [src/]
copy
Check formatting (don't modify)
$ stylua --check [script.lua]
copy
Show diff (don't modify)
$ stylua --diff [script.lua]
copy
Format from stdin
$ cat [script.lua] | stylua -
copy
Use specific config
$ stylua --config [stylua.toml] [script.lua]
copy

SYNOPSIS

stylua [--check] [--diff] [--config file] [options] [files]

DESCRIPTION

stylua formats Lua code according to configurable style rules. It enforces consistent formatting automatically.Configuration in stylua.toml or .stylua.toml sets project preferences. Options include indentation, line width, quote style, and more. If no config file is found, StyLua also checks for an .editorconfig file.Check mode verifies formatting without changes. It returns non-zero exit code if files would be reformatted, suitable for CI.Diff mode shows what would change. This helps review formatting before applying it.The formatter handles various Lua versions and can be configured for game-specific variants like Roblox Luau via the --syntax flag or syntax option in the config file.Integration with editors enables format-on-save. CI integration ensures consistent style across contributions. A .styluaignore file (with .gitignore-like syntax) can be used to exclude files from formatting.

PARAMETERS

--check

Check without formatting.
--diff
Show diff without formatting.
--config FILE
Configuration file.
--search-parent-directories
Search for config in parents.
--stdin-filepath PATH
Path for stdin input.
--column-width N
Line width.
--indent-type TYPE
Tabs or spaces.
--indent-width N
Indent width.
--line-endings TYPE
Unix or windows.
--quote-style STYLE
String quote style.
--call-parentheses STYLE
Call parentheses style.
-g, --glob PATTERN
Glob pattern for filtering files. Use -- to separate glob patterns from file arguments.
--verify
Verify output by re-parsing formatted code to ensure no syntax errors were introduced.
--syntax SYNTAX
Lua syntax version: All (default), Lua51, Lua52, Lua53, Lua54, LuaJIT, Luau, CfxLua.
--respect-ignores
Respect .styluaignore rules even for files passed directly on the command line.
-v, --verbose
Verbose output.

CONFIGURATION

stylua.toml or .stylua.toml

Project configuration file specifying formatting rules such as column width, indent type, quote style, and call parentheses behavior.
.styluaignore
Ignore file with .gitignore-like syntax for excluding files from formatting.

INSTALL

sudo pacman -S stylua
copy
sudo apk add stylua
copy
brew install stylua
copy
nix profile install nixpkgs#stylua
copy

CAVEATS

Some style preferences can't be configured. Complex expressions may format unexpectedly. Column width is a guide for line wrapping, not a hard limit.

HISTORY

StyLua was created by JohnnyMorganz around 2020. Written in Rust, it provides fast, opinionated Lua formatting similar to Prettier for JavaScript.

SEE ALSO

lua(1), luacheck(1), selene(1)

Braincup
Open source brain training for math, memory and focus
Braincup mini-games
41 mini-games · Apache-2.0
No ads · No tracking
Play in browser
Download Braincup on the App StoreGet Braincup on Google PlayGet Braincup on F-Droid
276 stars
From the maker of Linux Command Library
Copied to clipboard
Braincup
Open source brain training for math, memory and focus. 41 mini-games, from mental arithmetic to Sudoku, N-Back and Solo Chess.
Apache-2.0 licensed · No ads · No tracking · No account
From the maker of Linux Command Library
Download Braincup on the App StoreGet Braincup on Google PlayGet Braincup on F-Droid