Skip to content

Commit 7858ecb

Browse files
authored
Update editor settings reference with new format (#944)
## Summary This PR updates the documentation to reflect the changes made in astral-sh/ruff#19614 and astral-sh/ty-vscode#106. ## Test Plan <details><summary>Screenshot of the new editor settings reference page:</summary> <p> <img width="4992" height="3702" alt="image" src="https://github.com/user-attachments/assets/e3afd5a3-8b5b-43c3-addd-e1d6636ab1b7" /> </p> </details>
1 parent 1712284 commit 7858ecb

File tree

2 files changed

+257
-58
lines changed

2 files changed

+257
-58
lines changed

docs/editors.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ For Neovim 0.10 or earlier (with [`nvim-lspconfig`](https://github.com/neovim/nv
1616

1717
```lua
1818
require('lspconfig').ty.setup({
19-
init_options = {
20-
settings = {
19+
settings = {
20+
ty = {
2121
-- ty language server settings go here
2222
}
2323
}
@@ -29,8 +29,8 @@ For Neovim 0.11+ (with [`vim.lsp.config`](<https://neovim.io/doc/user/lsp.html#v
2929
```lua
3030
-- Optional: Only required if you need to update the language server settings
3131
vim.lsp.config('ty', {
32-
init_options = {
33-
settings = {
32+
settings = {
33+
ty = {
3434
-- ty language server settings go here
3535
}
3636
}

docs/reference/editor-settings.md

Lines changed: 253 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
# Editor settings
22

3-
The editor settings supported by ty's language server, as well as the settings specific to [ty's VS Code extension](https://github.com/astral-sh/ty-vscode/).
3+
The editor settings supported by ty's language server, as well as the settings specific to [ty's VS
4+
Code extension][ty-vscode].
45

5-
## `python.ty.disableLanguageServices`
6+
## `disableLanguageServices`
67

78
Whether to disable the language services for the ty language server like code completion, hover,
89
go to definition, etc.
@@ -16,84 +17,142 @@ server for features like code completion, hover, go to definition, etc.
1617

1718
**Example usage**:
1819

19-
```json
20-
{
21-
"python.ty.disableLanguageServices": true
22-
}
23-
```
24-
25-
## `diagnosticMode`
26-
27-
Determines the scope of the diagnostics reported by the language server.
28-
29-
- `openFilesOnly`: Diagnostics are reported only for files that are currently open in the editor.
30-
- `workspace`: Diagnostics are reported for all files in the workspace.
31-
32-
**Default value**: `"openFilesOnly"`
20+
=== "VS Code"
21+
22+
```json
23+
{
24+
"ty.disableLanguageServices": true
25+
}
26+
```
27+
28+
=== "Neovim"
29+
30+
```lua
31+
require('lspconfig').ty.setup({
32+
settings = {
33+
ty = {
34+
disableLanguageServices = true,
35+
},
36+
},
37+
})
38+
39+
-- For Neovim 0.11.0 and later:
40+
vim.lsp.config('ty', {
41+
settings = {
42+
ty = {
43+
disableLanguageServices = true,
44+
},
45+
},
46+
})
47+
```
48+
49+
=== "Zed"
50+
51+
```json
52+
{
53+
"lsp": {
54+
"ty": {
55+
"settings": {
56+
"ty": {
57+
"disableLanguageServices": true
58+
}
59+
}
60+
}
61+
}
62+
}
63+
```
64+
65+
______________________________________________________________________
3366

34-
**Type**: `"workspace" | "openFilesOnly"`
67+
## `python.ty.disableLanguageServices`
3568

36-
**Example usage**:
69+
!!! warning "Deprecated"
3770

38-
```json
39-
{
40-
"ty.diagnosticMode": "workspace"
41-
}
42-
```
71+
This option has been deprecated. Use [`ty.disableLanguageServices`](#disablelanguageservices) instead.
4372

44-
## `logFile`
73+
Whether to disable the language services that ty provides like code completion, hover, go to
74+
definition, etc.
4575

46-
Path to the file to which the language server writes its log messages. By default, ty writes log messages to stderr.
76+
This is useful if you want to use ty exclusively for type checking in combination with another
77+
language server for features like code completion, hover, go to definition, etc.
4778

48-
**Default value**: `null`
79+
**Default value**: `false`
4980

50-
**Type**: `string`
81+
**Type**: `boolean`
5182

5283
**Example usage**:
5384

5485
```json
5586
{
56-
"ty.logFile": "~/path/to/ty.log"
87+
"python.ty.disableLanguageServices": true
5788
}
5889
```
5990

60-
## `logLevel`
61-
62-
The log level to use for the language server.
63-
64-
**Default value**: `"info"`
65-
66-
**Type**: `"trace" | "debug" | "info" | "warn" | "error"`
67-
68-
**Example usage**:
91+
______________________________________________________________________
6992

70-
```json
71-
{
72-
"ty.logLevel": "debug"
73-
}
74-
```
93+
## `diagnosticMode`
7594

76-
## `trace.server`
95+
Determines the scope of the diagnostics reported by the language server.
7796

78-
The detail level at which messages between the language server and the editor (client) are logged. Refer to the [LSP
79-
specification](https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#traceValue)
80-
for more information.
97+
- `openFilesOnly`: Diagnostics are reported only for files that are currently open in the editor.
98+
- `workspace`: Diagnostics are reported for all files in the workspace.
8199

82-
**Default value**: `"off"`
100+
**Default value**: `"openFilesOnly"`
83101

84-
**Type**: `"off" | "messages" | "verbose"`
102+
**Type**: `"workspace" | "openFilesOnly"`
85103

86104
**Example usage**:
87105

88-
```json
89-
{
90-
"ty.trace.server": "messages"
91-
}
92-
```
106+
=== "VS Code"
107+
108+
```json
109+
{
110+
"ty.diagnosticMode": "workspace"
111+
}
112+
```
113+
114+
=== "Neovim"
115+
116+
```lua
117+
require('lspconfig').ty.setup({
118+
settings = {
119+
ty = {
120+
diagnosticMode = 'workspace',
121+
},
122+
},
123+
})
124+
125+
-- For Neovim 0.11.0 and later:
126+
vim.lsp.config('ty', {
127+
settings = {
128+
ty = {
129+
diagnosticMode = 'workspace',
130+
},
131+
},
132+
})
133+
```
134+
135+
=== "Zed"
136+
137+
```json
138+
{
139+
"lsp": {
140+
"ty": {
141+
"settings": {
142+
"ty": {
143+
"diagnosticMode": "workspace"
144+
}
145+
}
146+
}
147+
}
148+
}
149+
```
150+
151+
______________________________________________________________________
93152

94153
## VS Code specific
95154

96-
The following settings are specific to ty's VS Code extension.
155+
The following settings are specific to [ty's VS Code extension][ty-vscode].
97156

98157
### `importStrategy`
99158

@@ -114,6 +173,8 @@ Strategy for loading the `ty` executable.
114173
}
115174
```
116175

176+
______________________________________________________________________
177+
117178
### `interpreter`
118179

119180
A list of paths to Python interpreters. Even though this is a list, only the first interpreter is
@@ -134,6 +195,8 @@ The interpreter path is used to find the `ty` executable when
134195
}
135196
```
136197

198+
______________________________________________________________________
199+
137200
### `path`
138201

139202
A list of path to `ty` executables.
@@ -152,3 +215,139 @@ The extension uses the first executable that exists. This setting takes preceden
152215
"ty.path": ["/home/user/.local/bin/ty"]
153216
}
154217
```
218+
219+
______________________________________________________________________
220+
221+
### `trace.server`
222+
223+
The detail level at which messages between the language server and the editor (client) are logged.
224+
225+
This setting is useful for debugging issues with the language server. Refer to the [troubleshooting
226+
guide](https://github.com/astral-sh/ty-vscode/blob/6cf16b4e87342a49f2bec1310a730cde8229e1d9/TROUBLESHOOTING.md)
227+
in [ty's VS Code extension][ty-vscode] for more information.
228+
229+
**Default value**: `"off"`
230+
231+
**Type**: `"off" | "messages" | "verbose"`
232+
233+
**Example usage**:
234+
235+
```json
236+
{
237+
"ty.trace.server": "messages"
238+
}
239+
```
240+
241+
______________________________________________________________________
242+
243+
## Initialization options
244+
245+
The following settings are required when ty is initialized in an editor. These settings are
246+
static so changing them requires restarting the editor to take effect.
247+
248+
For VS Code users, these settings are defined in the `ty.*` namespace as usual, but for other
249+
editors, they would need to be provided in a separate field of the configuration that corresponds to
250+
the initialization options. Refer to the examples below for how to set these options in different
251+
editors.
252+
253+
### `logFile`
254+
255+
Path to the file to which the language server writes its log messages. By default, ty writes log messages to stderr.
256+
257+
**Default value**: `null`
258+
259+
**Type**: `string`
260+
261+
**Example usage**:
262+
263+
=== "VS Code"
264+
265+
```json
266+
{
267+
"ty.logFile": "/path/to/ty.log"
268+
}
269+
```
270+
271+
=== "Neovim"
272+
273+
```lua
274+
require('lspconfig').ty.setup({
275+
init_options = {
276+
logFile = '/path/to/ty.log',
277+
},
278+
})
279+
280+
-- For Neovim 0.11.0 and later:
281+
vim.lsp.config('ty', {
282+
init_options = {
283+
logFile = '/path/to/ty.log',
284+
},
285+
})
286+
```
287+
288+
=== "Zed"
289+
290+
```json
291+
{
292+
"lsp": {
293+
"ty": {
294+
"initialization_options": {
295+
"logFile": "/path/to/ty.log"
296+
}
297+
}
298+
}
299+
}
300+
```
301+
302+
______________________________________________________________________
303+
304+
### `logLevel`
305+
306+
The log level to use for the language server.
307+
308+
**Default value**: `"info"`
309+
310+
**Type**: `"trace" | "debug" | "info" | "warn" | "error"`
311+
312+
**Example usage**:
313+
314+
=== "VS Code"
315+
316+
```json
317+
{
318+
"ty.logLevel": "debug"
319+
}
320+
```
321+
322+
=== "Neovim"
323+
324+
```lua
325+
require('lspconfig').ty.setup({
326+
init_options = {
327+
logLevel = 'debug',
328+
},
329+
})
330+
331+
-- For Neovim 0.11.0 and later:
332+
vim.lsp.config('ty', {
333+
init_options = {
334+
logLevel = 'debug',
335+
},
336+
})
337+
```
338+
339+
=== "Zed"
340+
341+
```json
342+
{
343+
"lsp": {
344+
"ty": {
345+
"initialization_options": {
346+
"logLevel": "debug"
347+
}
348+
}
349+
}
350+
}
351+
```
352+
353+
[ty-vscode]: https://marketplace.visualstudio.com/items?itemName=astral-sh.ty

0 commit comments

Comments
 (0)