You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: CHANGELOG.md
+1Lines changed: 1 addition & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -10,6 +10,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
10
10
### Added
11
11
12
12
- 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))
13
+
- 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))
Copy file name to clipboardExpand all lines: README.md
+15-1Lines changed: 15 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -238,6 +238,20 @@ Requires sorting is off by default. To enable it, add the following to your `sty
238
238
enabled = true
239
239
```
240
240
241
+
### Language Server Mode
242
+
243
+
StyLua can run as a language server, connecting with language clients that follow the [Language Server Protocol](https://microsoft.github.io/language-server-protocol/).
244
+
It will then respond to `textDocument/formatting` and `textDocument/rangeFormatting` requests.
245
+
Formatting is only performed on files with a `lua` or `luau` language ID.
246
+
247
+
You can start the language server by running:
248
+
249
+
```sh
250
+
stylua --lsp
251
+
```
252
+
253
+
StyLua will listen to LSP messages on stdin and respond on stdout.
254
+
241
255
## Configuration
242
256
243
257
StyLua has opinionated defaults, but also provides a few options that can be set per project.
@@ -293,7 +307,7 @@ StyLua only offers the following options:
293
307
|`quote_style`|`AutoPreferDouble`| Quote style for string literals. Possible options: `AutoPreferDouble`, `AutoPreferSingle`, `ForceDouble`, `ForceSingle`. `AutoPrefer` styles will prefer the specified quote style, but fall back to the alternative if it has fewer string escapes. `Force` styles always use the specified style regardless of escapes. |
294
308
|`call_parentheses`|`Always`| Whether parentheses should be applied on function calls with a single string/table argument. Possible options: `Always`, `NoSingleString`, `NoSingleTable`, `None`, `Input`. `Always` applies parentheses in all cases. `NoSingleString` omits parentheses on calls with a single string argument. Similarly, `NoSingleTable` omits parentheses on calls with a single table argument. `None` omits parentheses in both cases. Note: parentheses are still kept in situations where removal can lead to obscurity (e.g. `foo "bar".setup -> foo("bar").setup`, since the index is on the call result, not the string). `Input` removes all automation and preserves parentheses only if they were present in input code: consistency is not enforced. |
295
309
|`space_after_function_names`|`Never`| Specify whether to add a space between the function name and parentheses. Possible options: `Never`, `Definitions`, `Calls`, or `Always`|
296
-
|`block_newline_gaps`|`Never`| Specify whether to preserve leading and trailing newline gaps for blocks. Possible options: `Never`, `Preserve`|
310
+
|`block_newline_gaps`|`Never`| Specify whether to preserve leading and trailing newline gaps for blocks. Possible options: `Never`, `Preserve`|
297
311
|`collapse_simple_statement`|`Never`| Specify whether to collapse simple statements. Possible options: `Never`, `FunctionOnly`, `ConditionalOnly`, or `Always`|
298
312
299
313
Default `stylua.toml`, note you do not need to explicitly specify each option if you want to use the defaults:
0 commit comments