Skip to content

Commit 00fdbe5

Browse files
committed
Tweaks to readme documentation
1 parent 6049849 commit 00fdbe5

File tree

1 file changed

+29
-30
lines changed

1 file changed

+29
-30
lines changed

README.md

Lines changed: 29 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ Alternatively, see [installing from crates.io](#from-cratesio) on how to install
2929

3030
If you have [Rust](https://www.rust-lang.org/) installed, you can install StyLua using cargo.
3131
By default, this builds for just Lua 5.1.
32-
You can pass the `--features <flag>` argument to build for Lua 5.2 (`lua52`), Lua 5.3 (`lua53`), Lua 5.4 (`lua54`), LuaJIT (`luajit`) or Luau (`luau`)
32+
You can pass the `--features <flag>` argument to add extra syntax variants:
3333

3434
```sh
3535
cargo install stylua
@@ -40,12 +40,12 @@ cargo install stylua --features luajit
4040
cargo install stylua --features luau
4141
```
4242

43-
You can specify multiple features in a single installation, and then use [configuration in a `.stylua.toml` file](#configuring-runtime-syntax-selection) to defer syntax selection to runtime.
43+
You can specify multiple features at once, and then use [configuration in a `.stylua.toml` file](#configuring-runtime-syntax-selection) to defer syntax selection to runtime.
4444

4545
### GitHub Actions
4646

47-
You can use the [stylua-action](https://github.com/marketplace/actions/stylua) GitHub Action in your CI to install and run StyLua.
48-
This action uses the prebuilt GitHub release binaries, instead of running cargo install, for faster CI times.
47+
The [stylua-action](https://github.com/marketplace/actions/stylua) GitHub Action can install and run StyLua.
48+
This action uses the prebuilt GitHub release binaries, instead of running cargo install, for faster CI startup times.
4949

5050
### pre-commit
5151

@@ -68,7 +68,7 @@ Add the following to your `.pre-commit-config.yaml` file:
6868
### npm
6969
7070
StyLua is available as a binary [published to npm](https://www.npmjs.com/package/@johnnymorganz/stylua-bin) as `@johnnymorganz/stylua-bin`.
71-
This is a thin wrapper which installs the binary and allows it to be run through npm.
71+
This is a thin wrapper that installs the binary and makes it available through npm / npx.
7272

7373
```sh
7474
npx @johnnymorganz/stylua-bin --help
@@ -136,16 +136,16 @@ stylua --glob '**/*.luau' -- src # format all files in src matching **/*.luau
136136
stylua -g '*.lua' -g '!*.spec.lua' -- . # format all Lua files except test files ending with `.spec.lua`
137137
```
138138

139-
Note, if you are using the glob argument, it can take in multiple strings, so `--` is required to break between the glob pattern and the files to format.
139+
Note that the `-g/--glob` argument can take multiple strings at once, so `--` is required to separate between the glob patterns and the files to format.
140140

141-
By default, glob filtering (and `.styluaignore` files) are only applied for directory traversal and searching.
141+
By default, glob filtering (and `.styluaignore` files) are only applied during directory traversal and searching.
142142
Files passed directly (e.g. `stylua foo.txt`) will override the glob / ignore and always be formatted.
143143
To disable this behaviour, pass the `--respect-ignores` flag (`stylua --respect-ignores foo.txt`).
144144

145145
### Filtering using `.styluaignore`
146146

147147
You can create a `.styluaignore` file, with a format similar to `.gitignore`.
148-
Any files matching the globs in the ignore file will be ignored by StyLua.
148+
Any files matching the globs in the ignore file are ignored by StyLua.
149149
For example, for a `.styluaignore` file with the following contents:
150150

151151
```
@@ -156,31 +156,30 @@ running `stylua .` will ignore the `vendor/` directory.
156156

157157
### `--check`: Checking files for formatting
158158

159-
To check whether files have been formatted (but not write directly to them), use the `--check` flag.
159+
To check whether files require formatting (but not write directly to them), use the `--check` flag.
160160
It will take files as input, and output a diff to stdout instead of rewriting the file contents.
161-
If there are files which haven't been fully formatted, StyLua will exit with status code 1.
161+
If there are any files that require formatting, StyLua will exit with status code 1.
162162

163-
There are different styles of output that are available:
163+
There are different styles of output available:
164164

165-
- `--output-format=standard`: output a custom pretty diff (default)
166-
- `--output-format=unified`: output a unified diff, which can be consumed by tools like `patch` or `delta`
167-
- `--output-format=json`: output JSON representing the changes, useful for machine-readable output (usable in non-check mode as well)
165+
- `--output-format=standard`: output a custom diff (default)
166+
- `--output-format=unified`: output a unified diff, consumable by tools like `patch` or `delta`
167+
- `--output-format=json`: output JSON representing the changes, useful for machine-readable output
168168
- `--output-format=summary`: output a summary list of file paths that are incorrectly formatted
169169

170170
### `--verify`: Verifying formatting output
171171

172-
As a safety measure, the `--verify` flag can be passed to StyLua, and StyLua will verify the output of all formatting
173-
before saving it to a file.
172+
As a safety measure, you can use the `--verify` flag to verify the output of all formatting before saving the file.
174173

175174
If enabled, the tool will re-parse the formatted output to verify if the AST is still valid (no syntax errors) and is similar to the input (possible semantic changes).
176175

177-
Useful when adopting StyLua in a large codebase, where it is difficult to verify all formatting is correct.
176+
This is useful when adopting StyLua in a large codebase, where it is difficult to manually check all formatting is correct.
178177
Note that this may produce false positives and negatives - we recommend manual verification as well as running tests to confirm.
179178

180179
### Ignoring parts of a file
181180

182181
To skip formatting a particular part of a file, you can add `-- stylua: ignore` before it.
183-
This may be useful if there is a particular style you want to preseve for readability, e.g.:
182+
This is useful if there is a particular style you want to preseve for readability, e.g.:
184183

185184
```lua
186185
-- stylua: ignore
@@ -191,7 +190,7 @@ local matrix = {
191190
}
192191
```
193192

194-
Formatting can also be skipped over a block of code using `-- stylua: ignore start` and `-- stylua: ignore end`:
193+
To skip a block of code, use `-- stylua: ignore start` and `-- stylua: ignore end`:
195194

196195
```lua
197196
local foo = true
@@ -202,15 +201,15 @@ local baz = 0
202201
local foobar = false
203202
```
204203

205-
Note that ignoring cannot cross scope boundaries - once a block is exited, formatting will be re-enabled.
204+
Note that ignoring cannot cross scope boundaries - once a block is exited, formatting is re-enabled.
206205

207206
### Formatting Ranges
208207

209208
To format a specific range within a file, use `--range-start <num>` and/or `--range-end <num>`.
210-
Both arguments are inclusive and optional - if an argument is not provided, the start/end of the file will be used respectively.
209+
Both arguments are inclusive and optional - if an argument is not provided, the start/end of the file is used respectively.
211210

212-
Only whole statements lying within the range will be formatted.
213-
If part of a statement falls outside the range, the statement will be ignored.
211+
Only whole statements lying within the range are formatted.
212+
If part of a statement falls outside the range, the statement is ignored.
214213

215214
In editors, `Format Selection` is supported.
216215

@@ -219,8 +218,8 @@ In editors, `Format Selection` is supported.
219218
StyLua has built-in support for sorting require statements. We group consecutive require statements into a single "block",
220219
and then requires are sorted only within that block. Blocks of requires do not move around the file.
221220

222-
We only include requires of the form `local NAME = require(EXPR)`, and sort lexicographically based on `NAME`.
223-
(We also sort Roblox services of the form `local NAME = game:GetService(EXPR)`)
221+
StyLua only considers requires of the form `local NAME = require(EXPR)`, and sorts lexicographically based on `NAME`.
222+
(StyLua can also sort Roblox services of the form `local NAME = game:GetService(EXPR)`)
224223

225224
Requires sorting is off by default. To enable it, add the following to your `stylua.toml`:
226225

@@ -241,12 +240,12 @@ If not found, we search for an `.editorconfig` file, otherwise fall back to the
241240
This feature can be disabled using `--no-editorconfig`.
242241
See [EditorConfig](https://editorconfig.org/) for more details.
243242

244-
A custom path can be provided using `--config-path <path>`.
245-
If the path provided is not found/malformed, StyLua will exit with an error.
243+
Use `--config-path <path>` to provide a custom path to the configuration.
244+
If the file provided is not found/malformed, StyLua will exit with an error.
246245

247-
By default, the tool does not search further than the current directory.
248-
Recursively searching parent directories can be enabled using `--search-parent-directories`.
249-
This will keep searching ancestors. If not found, it will then look in `$XDG_CONFIG_HOME` / `$XDG_CONFIG_HOME/stylua`.
246+
By default, StyLua does not search further than the current directory.
247+
Use `--search-parent-directories` to recursively search parent directories.
248+
This will keep searching ancestors and, if not found, will then look in `$XDG_CONFIG_HOME` / `$XDG_CONFIG_HOME/stylua` / `$HOME/.config` and `$HOME/.config/stylua`.
250249

251250
**Note: enabling searching outside of the current directory is NOT recommended due to possibilities of conflicting formatting:**
252251

0 commit comments

Comments
 (0)