Skip to content

Commit

Permalink
docs: Add lua-language-server formatter example (#24105)
Browse files Browse the repository at this point in the history
  • Loading branch information
notpeter authored Feb 2, 2025
1 parent 4885ace commit 1dd2bbe
Showing 1 changed file with 21 additions and 4 deletions.
25 changes: 21 additions & 4 deletions docs/src/languages/lua.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`:
Expand Down

0 comments on commit 1dd2bbe

Please sign in to comment.