Skip to content

Commit e3135ff

Browse files
committed
document how to setup per-project configuration for each editor
1 parent e6fe4a5 commit e3135ff

File tree

9 files changed

+74
-21
lines changed

9 files changed

+74
-21
lines changed

content/zls/configure/in-editor.smd

Lines changed: 23 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -7,26 +7,32 @@
77
}
88
---
99

10-
In-Editor Config (or Workspace Config) will integrate with the config system of your editor to configure ZLS on a per-editor basis.
11-
12-
Some editors (like VS Code) also allow workspace-specific configuration. If you want to share the same configuration across multiple editors, please refer to the [zls.json]($link.page('zls/configure/zls-json')) alternative.
10+
In-Editor Config (a.k.a workspace configuration) will integrate with the config system of your editor to configure ZLS on a per-editor basis. Most editors also support per-project configuration.
1311

1412
## Supported Editors
1513

16-
| Editor | in-editor config support |
17-
| ------------------------------------------------------------- | ------------------------- |
18-
| [VS Code](/zls/editors/vscode) | Yes |
19-
| [Sublime Text](/zls/editors/sublime-text) | Yes |
20-
| [ZigBrains for JetBrains](/zls/editors/jetbrains) | Limited\* |
21-
| [Helix](/zls/editors/helix) | Yes |
22-
| [Zed](/zls/editors/zed) | Yes |
23-
| [Neovim with nvim-lspconfig](/zls/editors/vim/nvim-lspconfig) | Yes |
24-
| [Vim/Neovim with CoC](/zls/editors/vim/coc) | Yes |
25-
| [Vim/Neovim with YCM](/zls/editors/vim/ycm) | Yes\*\* |
26-
| [Emacs with eglot](/zls/editors/emacs) | Yes |
27-
| [Emacs with lsp-mode](/zls/editors/emacs) | Yes |
28-
| [Kate](/zls/editors/kate) | Yes |
14+
| Editor | supported? |
15+
| ------------------------------------------------------------- | ---------- |
16+
| [VS Code](/zls/editors/vscode) | Yes |
17+
| [Sublime Text](/zls/editors/sublime-text) | Yes |
18+
| [ZigBrains for JetBrains](/zls/editors/jetbrains) | Limited\* |
19+
| [Helix](/zls/editors/helix) | Yes |
20+
| [Zed](/zls/editors/zed) | Yes |
21+
| [Neovim with nvim-lspconfig](/zls/editors/vim/nvim-lspconfig) | Yes |
22+
| [Vim/Neovim with CoC](/zls/editors/vim/coc) | Yes |
23+
| [Vim/Neovim with YCM](/zls/editors/vim/ycm) | Yes |
24+
| [Emacs with eglot](/zls/editors/emacs) | Yes |
25+
| [Emacs with lsp-mode](/zls/editors/emacs) | Yes |
26+
| [Kate](/zls/editors/kate) | Yes |
2927

3028
\* Only a subset of config options are available.
3129

32-
\*\* In-Editor configuration is somewhat tedious to setup for this Editor. You may favor the [zls.json]($link.page('zls/configure/zls-json')) alternative.
30+
## Available Config Options
31+
32+
Most editors do not know which config options are available for a language server like ZLS. ZLS provides a [JSON Schema](https://github.com/zigtools/zls/blob/master/schema.json) that can be used to find all available config options.
33+
34+
Be aware that configuration options change over time. The linked schema file above assumes that you are using ZLS nightly/master. When using a tagged release of ZLS, use the JSON Schema file corresponding to that version, like so:
35+
36+
```
37+
https://raw.githubusercontent.com/zigtools/zls/refs/tags/<ZLS_VERSION_HERE>/schema.json
38+
```

content/zls/editors/emacs/gnu-emacs.smd

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,6 @@ To apply [in-editor-configuration](/zls/configure/in-editor) or manually specify
4444
)))))
4545
```
4646

47-
Eglot also supports Project-specific or User-specific [server configuration](https://www.gnu.org/software/emacs/manual/html_node/eglot/Advanced-server-configuration.html).
48-
4947
Use `M-x eglot` in a zig-mode buffer to start the server or add a hook:
5048

5149
```
@@ -70,5 +68,6 @@ Add the following to run `source.fixAll` code action on save:
7068

7169
Use `M-x eglot-code-action-organize-imports` to manually execute the code action.
7270

73-
# lsp-mode
71+
### Per-project config
7472

73+
Eglot supports per-project configuration which is documented in the [Advanced server configuration](https://www.gnu.org/software/emacs/manual/html_node/eglot/Advanced-server-configuration.html) docs.

content/zls/editors/helix.smd

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,3 +49,9 @@ For more information on the health check results refer to [Health check](https:/
4949
## Code Actions on save
5050

5151
Helix does not yet support running code actions on save. See [helix-editor/helix#1565](https://github.com/helix-editor/helix/issues/1565).
52+
53+
## Per-project config
54+
55+
Helix allows setting LSP settings per project via a `./helix/config.toml` file. For more information, check the Helix [configuration docs](https://docs.helix-editor.com/configuration.html).
56+
57+
If the use case for per-project config is to set the path to the Zig or ZLS executable, consider using [direnv](https://direnv.net/) to add it to your `$PATH` or use a version manager for Zig and ZLS.

content/zls/editors/kate.smd

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,3 +51,21 @@ To apply [in-editor-configuration](/zls/configure/in-editor) or manually specify
5151
## Code Actions on save
5252

5353
Kate does not support code actions on save.
54+
55+
## Per-project config
56+
57+
Kate's [LSP Client Plugin](https://docs.kde.org/stable5/en/kate/kate/kate-application-plugin-lspclient.html) allows setting LSP settings per project via a `.kateproject` file. Here is an example of how this could look like:
58+
59+
```json
60+
{
61+
"lspclient": {
62+
"servers": {
63+
"zig": {
64+
"settings": {
65+
"enable_build_on_save": true
66+
}
67+
}
68+
}
69+
}
70+
}
71+
```

content/zls/editors/sublime-text.smd

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,3 +94,7 @@
9494
}
9595
}
9696
```
97+
98+
## Per-project config
99+
100+
The Sublime Text LSP plugin allows setting LSP settings per project via a `.sublime-project` file. See [per-project-overrides](https://lsp.sublimetext.io/client_configuration/#per-project-overrides).

content/zls/editors/vim/coc.smd

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
// Show inlay hints in the editor. Inlay hints are short annotations within the code,
3333
// which show variable types or parameter names.
3434
// "inlayHint.enable": true,
35-
35+
3636
// Use the language server to perform code highlighting
3737
"semanticTokens.enable": true
3838
},
@@ -110,3 +110,9 @@ vim.api.nvim_create_autocmd('BufWritePre',{
110110
```vim
111111
autocmd BufWritePre *.zig,*.zon call CocActionAsync('organizeImport')
112112
```
113+
114+
## Per-project config
115+
116+
Coc allows setting LSP settings per project via a `.vim/coc-settings.json` file. Use the `:CocLocalConfig` to create and open the settings file in your workspace folder. Run `:h coc-configuration` for more information.
117+
118+
If the use case for per-project config is to set the path to the Zig or ZLS executable, consider using [direnv](https://direnv.net/) to add it to your `$PATH` or use a version manager for Zig and ZLS.

content/zls/editors/vim/nvim-lspconfig.smd

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,3 +178,9 @@ autocmd BufWritePre *.zig,*.zon lua vim.lsp.buf.code_action({
178178
apply = true,
179179
})
180180
```
181+
182+
## Per-project config
183+
184+
Neovim allows setting LSP settings per project via [exrc](https://neovim.io/doc/user/options.html#'exrc').
185+
186+
If the use case for per-project config is to set the path to the Zig or ZLS executable, consider using [direnv](https://direnv.net/) to add it to your `$PATH` or use a version manager for Zig and ZLS.

content/zls/editors/vscode.smd

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,8 @@ With that being said, there are some Zig specific settings that you may wish to
6464
}
6565
```
6666

67+
For more information, checkout the VS Code docs about [Settings](https://code.visualstudio.com/docs/configure/settings).
68+
6769
### Additional Config Options
6870

6971
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)

content/zls/editors/zed.smd

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,3 +61,9 @@ Add the following to your `settings.json`:
6161
}
6262
}
6363
```
64+
65+
## Per-project config
66+
67+
Zed supports per-project configuration by creating a `.zed/settings.json` inside a project. For more information, check the Zed about [configuration docs](https://zed.dev/docs/configuring-zed#configuring-zed).
68+
69+
If the use case for per-project config is to set the path to the Zig executable, consider using [direnv](https://zed.dev/docs/configuring-zed#direnv-integration) to add it to your `$PATH`.

0 commit comments

Comments
 (0)