docs: Add lua-language-server formatter example (#24105)
Some checks are pending
CI / Check Postgres and Protobuf migrations, mergability (push) Waiting to run
CI / Check formatting and spelling (push) Waiting to run
CI / (macOS) Run Clippy and tests (push) Waiting to run
CI / (Linux) Run Clippy and tests (push) Waiting to run
CI / (Linux) Build Remote Server (push) Waiting to run
CI / (Windows) Run Clippy and tests (push) Waiting to run
CI / Create a macOS bundle (push) Blocked by required conditions
CI / Linux x86_x64 release bundle (push) Blocked by required conditions
CI / Linux arm64 release bundle (push) Blocked by required conditions
CI / Auto release preview (push) Blocked by required conditions
Deploy Docs / Deploy Docs (push) Waiting to run
Docs / Check formatting (push) Waiting to run
Script / ShellCheck Scripts (push) Waiting to run

This commit is contained in:
Peter Tripp 2025-02-02 15:15:50 -05:00 committed by GitHub
parent 4885ace107
commit 1dd2bbe2ba
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -16,22 +16,39 @@ See [LuaLS Settings Documentation](https://luals.github.io/wiki/settings/) for a
"$schema": "https://raw.githubusercontent.com/LuaLS/vscode-lua/master/setting/schema.json",
"runtime.version": "Lua 5.4",
"diagnostics.severity": {
// "duplicate-set-field": "Hint"
"duplicate-set-field": "Hint"
},
"format.enable": true,
"format.defaultConfig": {
"indent_style": "space",
"indent_size": "4"
},
// Location(s) of any LuaCATS / EmmyLua annotation stubs
"workspace.library": [
// "path/to/library/directory"
"../soemdir/library"
]
}
```
## Formatting
Zed can enable auto-formatting of code with formatters like [StyLua](https://github.com/JohnnyMorganz/StyLua).
### LuaLS
To enable auto-formatting with your LuaLS, make sure you have `"format.enable": true,` in your .luarc.json add the following to your Zed `settings.json`:
```json
{
"languages": {
"Lua": {
"format_on_save": "on",
"formatter": "language_server"
}
}
}
```
### StyLua
Alternative you can use [StyLua](https://github.com/JohnnyMorganz/StyLua):
1. Install [StyLua](https://github.com/JohnnyMorganz/StyLua): `brew install stylua` or `cargo install stylua --features lua52,lua53,lua54,luau,luajit` (feel free to remove any Lua versions you don't need).
2. Add the following to your `settings.json`: