Skip to content

Commit

Permalink
update VS Code configuration docs
Browse files Browse the repository at this point in the history
  • Loading branch information
Techatrix committed Dec 11, 2024
1 parent 302a18c commit 75c6292
Showing 1 changed file with 35 additions and 4 deletions.
39 changes: 35 additions & 4 deletions content/zls/editors/vscode.smd
Original file line number Diff line number Diff line change
Expand Up @@ -18,21 +18,24 @@ Using ZLS in VS Code is as simple as installing the [official Zig Language exten

## Configuration

The VS Code extension can automatically install Zig and ZLS. The extension is intended to provide the best possible experience Out-of-the-Box without extra configuration.
The VS Code extension will automatically install Zig and ZLS. The extension is intended to provide the best possible experience Out-of-the-Box without extra configuration.

With that being said, there are some Zig specific settings that you may wish to apply:

```json
// settings.json (open with `Preferences: Open User Settings (JSON)`)
{
"zig.zls.enabled": "on",
// You can more more Zig and ZLS options here

// All nested settings will only affect Zig files.
"[zig]": {
// Formatting with ZLS matches `zig fmt`.
// The Zig FAQ answers some questions about `zig fmt`:
// https://github.com/ziglang/zig/wiki/FAQ
//
// disable format-on-save
// "editor.formatOnSave": false,

// disable inlay hints
// "editor.inlayHints.enabled": "off",

// overwrite words when accepting completions
Expand All @@ -48,6 +51,34 @@ With that being said, there are some Zig specific settings that you may wish to
// "source.organizeImports": "explicit",
}
},
"editor.semanticTokenColorCustomizations": {
"rules": {
"*.deprecated": {
// highlight semantic tokens that are marked as "deprecated"
"strikethrough": true
}
}
}
}
```

### Additional Config Options

The available config options in the VS Code extension match those that are offered by the latest nightly build of ZLS. (sometimes they are out of sync)

To set config options that are offered by older ZLS version (e.g. `enable_autofix` for ZLS `0.13.0`) you can use the `zig.zls.additionalOptions` property:

```json
// settings.json (open with `Preferences: Open User Settings (JSON)`)
{
"zig.zls.additionalOptions": {
// Here are some examples of config options that have been removed:
"zig.zls.enableAutofix": true, // Will set the "enable_autofix" config option
"zig.zls.buildOnSaveStep": "foo", // Will set the "build_on_save_step" config option

// All values have to be converted to camelCase and get prefixed with `zig.zls`.
},
}
```

Add it to your `settings.json` (open with `Preferences: Open User Settings (JSON)`)
You can check the [ZLS logs](zls/guides/view-logs) to see if the additional options have been set. Unknown config options will be silently ignored.

0 comments on commit 75c6292

Please sign in to comment.