Overview
GLuaLS includes an opinionated Lua formatter. Format the current file withShift+Alt+F (or right-click → Format Document).
Built-in presets
GLuaLS includes three presets for common GMod style choices:| Preset | Description |
|---|---|
default | Standard, no specific style |
cfc | Follows CFC-Servers style guidelines |
custom | Use only styleOverrides |
.gluarc.json:
.gluarc.json
Style overrides
UsestyleOverrides to change individual rules within a preset:
.gluarc.json
Key style options
| Option | Values | Description |
|---|---|---|
indent_style | "tab", "space" | Indentation mode |
indent_size | 1–8 | Number of spaces per indent level (when using spaces) |
tab_width | 1–8 | Visual width of tabs |
quote_style | "none", "single", "double" | Preferred quote style for string literals |
call_arg_parentheses | "keep", "remove", "remove_table_only", "remove_string_only", "always" | How to handle parentheses around single-string/table call args |
max_line_length | integer | Line wrap threshold |
trailing_table_separator | "keep", "never", "always", "smart" | Trailing separator in table constructors |
External formatter
Use an external formatting tool, such asstylua or GLuaFixer, instead of the built-in formatter:
.gluarc.json
EditorConfig
GLuaLS can read.editorconfig indent settings. Those values can override matching styleOverrides entries based on your priority setting between .editorconfig and .gluarc.json.
Format on save
Enable format-on-save in VS Code:VS Code settings