id = "stylua"
name = "StyLua"
homepage = "https://github.com/JohnnyMorganz/StyLua"
description = "An opinionated Lua code formatter."
executables = ["stylua"]
[dotfiles]
paths = ["[configHome]/stylua/stylua.toml"]
secret = []
side_effect = false
[commands]
format = 1
label = "Format Lua files"
description = "Format or check Lua/Luau files and directories with StyLua. Range formatting, stdin, glob filters and per-style overrides other than indentation and column width are left out."
quality = "ai-draft"
parser = { end_of_options = "--", interleave = "permute", long_equals = true, short_attached = true, short_bundles = false }
[[commands.source]]
id = "readme"
kind = "help"
url = "https://raw.githubusercontent.com/JohnnyMorganz/StyLua/main/README.md"
revision = "2026-10-27"
evidence = """
To check whether files require formatting (but not write directly to them), use the `--check` flag.
- `--output-format=standard`: output a custom diff (default)
- `--output-format=unified`: output a unified diff, consumable by tools like `patch` or `delta`
- `--output-format=json`: output JSON representing the changes, useful for machine-readable output
- `--output-format=summary`: output a summary list of file paths that are incorrectly formatted
you can optionally provide the filename via `--stdin-filepath`.
Use `--config-path <path>` to provide a custom path to the configuration.
Use `--search-parent-directories` to recursively search parent directories.
Alternatively, you can specify it on the command line, with `stylua --syntax lua52 ...`
When specifying the option on the command line, replace the underscore with a dash, e.g., `indent_type` becomes `--indent-type`.
| `column_width` | `120` | Approximate line length for printing.
| `indent_type` | `Tabs` | Indent type. Possible options: `Tabs` or `Spaces`
| `indent_width` | `4` | Character size of single indentation.
you can use the `--verify` flag to verify the output of all formatting before saving the file.
"""
[[commands.field]]
id = "check"
label = "Check only"
description = "Do not rewrite files; print a diff and exit with status 1 if any file needs formatting."
type = "boolean"
option = ["--check"]
sources = ["readme"]
[[commands.field]]
id = "output_format"
label = "Check output format"
type = "enum"
option = ["--output-format"]
choices = [{ value = "standard", label = "Standard diff" }, { value = "unified", label = "Unified diff" }, { value = "json", label = "JSON" }, { value = "summary", label = "Summary of files" }]
sources = ["readme"]
[[commands.field]]
id = "verify"
label = "Verify output"
description = "Verify the formatted output before saving each file."
type = "boolean"
option = ["--verify"]
sources = ["readme"]
[[commands.field]]
id = "config_path"
label = "Config file"
type = "path"
option = ["--config-path"]
path = { kind = "file", role = "input", must_exist = true }
sources = ["readme"]
[[commands.field]]
id = "search_parents"
label = "Search parent directories for config"
type = "boolean"
option = ["--search-parent-directories"]
sources = ["readme"]
[[commands.field]]
id = "indent_type"
label = "Indent type"
type = "enum"
option = ["--indent-type"]
choices = [{ value = "Tabs", label = "Tabs" }, { value = "Spaces", label = "Spaces" }]
sources = ["readme"]
[[commands.field]]
id = "files"
label = "Files or directories"
type = "path"
position = 0
multiple = true
path = { kind = "any", role = "input", must_exist = true }
sources = ["readme"]
[[commands.task]]
id = "format"
label = "Format in place"
fields = ["files", "verify"]
required = ["files"]
[[commands.task]]
id = "check"
label = "Check formatting"
fields = ["files", "check", "output_format"]
required = ["files", "check"]
set = { check = [true] }
[[commands.group]]
id = "basic"
label = "Basic"
fields = ["files", "check", "output_format", "verify"]
[[commands.group]]
id = "advanced"
label = "Style and config"
fields = ["config_path", "search_parents", "indent_type"]