Skip to content

Commit cddea9d

Browse files
committed
Some better codeblocks
1 parent db7b339 commit cddea9d

File tree

3 files changed

+227
-205
lines changed

3 files changed

+227
-205
lines changed

docs/book/src/editor_features/README.md

+110-92
Original file line numberDiff line numberDiff line change
@@ -8,22 +8,24 @@
88
It is possible to change the foreground/background color and font
99
family/size of inlay hints. Just add this to your `settings.json`:
1010

11-
{
12-
"editor.inlayHints.fontFamily": "Courier New",
13-
"editor.inlayHints.fontSize": 11,
14-
15-
"workbench.colorCustomizations": {
16-
// Name of the theme you are currently using
17-
"[Default Dark+]": {
18-
"editorInlayHint.foreground": "#868686f0",
19-
"editorInlayHint.background": "#3d3d3d48",
20-
21-
// Overrides for specific kinds of inlay hints
22-
"editorInlayHint.typeForeground": "#fdb6fdf0",
23-
"editorInlayHint.parameterForeground": "#fdb6fdf0",
24-
}
25-
}
11+
```json
12+
{
13+
"editor.inlayHints.fontFamily": "Courier New",
14+
"editor.inlayHints.fontSize": 11,
15+
16+
"workbench.colorCustomizations": {
17+
// Name of the theme you are currently using
18+
"[Default Dark+]": {
19+
"editorInlayHint.foreground": "#868686f0",
20+
"editorInlayHint.background": "#3d3d3d48",
21+
22+
// Overrides for specific kinds of inlay hints
23+
"editorInlayHint.typeForeground": "#fdb6fdf0",
24+
"editorInlayHint.parameterForeground": "#fdb6fdf0",
25+
}
2626
}
27+
}
28+
```
2729

2830
### Semantic style customizations
2931

@@ -32,46 +34,52 @@ code. For example, mutable bindings are underlined by default and you
3234
can override this behavior by adding the following section to your
3335
`settings.json`:
3436

35-
{
36-
"editor.semanticTokenColorCustomizations": {
37-
"rules": {
38-
"*.mutable": {
39-
"fontStyle": "", // underline is the default
40-
},
41-
}
42-
},
37+
```json
38+
{
39+
"editor.semanticTokenColorCustomizations": {
40+
"rules": {
41+
"*.mutable": {
42+
"fontStyle": "", // underline is the default
43+
},
4344
}
45+
},
46+
}
47+
```
4448

4549
Most themes doesn’t support styling unsafe operations differently yet.
4650
You can fix this by adding overrides for the rules `operator.unsafe`,
4751
`function.unsafe`, and `method.unsafe`:
4852

49-
{
50-
"editor.semanticTokenColorCustomizations": {
51-
"rules": {
52-
"operator.unsafe": "#ff6600",
53-
"function.unsafe": "#ff6600",
54-
"method.unsafe": "#ff6600"
55-
}
56-
},
57-
}
53+
```json
54+
{
55+
"editor.semanticTokenColorCustomizations": {
56+
"rules": {
57+
"operator.unsafe": "#ff6600",
58+
"function.unsafe": "#ff6600",
59+
"method.unsafe": "#ff6600"
60+
}
61+
},
62+
}
63+
```
5864

5965
In addition to the top-level rules you can specify overrides for
6066
specific themes. For example, if you wanted to use a darker text color
6167
on a specific light theme, you might write:
6268

63-
{
64-
"editor.semanticTokenColorCustomizations": {
65-
"rules": {
66-
"operator.unsafe": "#ff6600"
67-
},
68-
"[Ayu Light]": {
69-
"rules": {
70-
"operator.unsafe": "#572300"
71-
}
72-
}
73-
},
74-
}
69+
```json
70+
{
71+
"editor.semanticTokenColorCustomizations": {
72+
"rules": {
73+
"operator.unsafe": "#ff6600"
74+
},
75+
"[Ayu Light]": {
76+
"rules": {
77+
"operator.unsafe": "#572300"
78+
}
79+
}
80+
},
81+
}
82+
```
7583

7684
Make sure you include the brackets around the theme name. For example,
7785
use `"[Ayu Light]"` to customize the theme Ayu Light.
@@ -81,11 +89,13 @@ use `"[Ayu Light]"` to customize the theme Ayu Light.
8189
You may use `inRustProject` context to configure keybindings for rust
8290
projects only. For example:
8391

84-
{
85-
"key": "ctrl+alt+d",
86-
"command": "rust-analyzer.openDocs",
87-
"when": "inRustProject"
88-
}
92+
```json
93+
{
94+
"key": "ctrl+alt+d",
95+
"command": "rust-analyzer.openDocs",
96+
"when": "inRustProject"
97+
}
98+
```
8999

90100
More about `when` clause contexts
91101
[here](https://code.visualstudio.com/docs/getstarted/keybindings#_when-clause-contexts).
@@ -96,27 +106,31 @@ You can use "rust-analyzer.runnables.extraEnv" setting to define
96106
runnable environment-specific substitution variables. The simplest way
97107
for all runnables in a bunch:
98108

99-
"rust-analyzer.runnables.extraEnv": {
100-
"RUN_SLOW_TESTS": "1"
101-
}
109+
```json
110+
"rust-analyzer.runnables.extraEnv": {
111+
"RUN_SLOW_TESTS": "1"
112+
}
113+
```
102114

103115
Or it is possible to specify vars more granularly:
104116

105-
"rust-analyzer.runnables.extraEnv": [
106-
{
107-
// "mask": null, // null mask means that this rule will be applied for all runnables
108-
env: {
109-
"APP_ID": "1",
110-
"APP_DATA": "asdf"
111-
}
112-
},
113-
{
114-
"mask": "test_name",
115-
"env": {
116-
"APP_ID": "2", // overwrites only APP_ID
117-
}
117+
```json
118+
"rust-analyzer.runnables.extraEnv": [
119+
{
120+
// "mask": null, // null mask means that this rule will be applied for all runnables
121+
env: {
122+
"APP_ID": "1",
123+
"APP_DATA": "asdf"
124+
}
125+
},
126+
{
127+
"mask": "test_name",
128+
"env": {
129+
"APP_ID": "2", // overwrites only APP_ID
118130
}
119-
]
131+
}
132+
]
133+
```
120134

121135
You can use any valid regular expression as a mask. Also note that a
122136
full runnable name is something like **run bin\_or\_example\_name**,
@@ -127,25 +141,27 @@ this masks: `"^run"`, `"^test "` (the trailing space matters!), and
127141

128142
If needed, you can set different values for different platforms:
129143

130-
"rust-analyzer.runnables.extraEnv": [
131-
{
132-
"platform": "win32", // windows only
133-
env: {
134-
"APP_DATA": "windows specific data"
135-
}
136-
},
137-
{
138-
"platform": ["linux"],
139-
"env": {
140-
"APP_DATA": "linux data",
141-
}
142-
},
143-
{ // for all platforms
144-
"env": {
145-
"APP_COMMON_DATA": "xxx",
146-
}
144+
```json
145+
"rust-analyzer.runnables.extraEnv": [
146+
{
147+
"platform": "win32", // windows only
148+
env: {
149+
"APP_DATA": "windows specific data"
150+
}
151+
},
152+
{
153+
"platform": ["linux"],
154+
"env": {
155+
"APP_DATA": "linux data",
147156
}
148-
]
157+
},
158+
{ // for all platforms
159+
"env": {
160+
"APP_COMMON_DATA": "xxx",
161+
}
162+
}
163+
]
164+
```
149165

150166
### Compiler feedback from external commands
151167

@@ -161,14 +177,16 @@ For example, if you want to run
161177
[`cargo watch`](https://crates.io/crates/cargo-watch) instead, you might
162178
add the following to `.vscode/tasks.json`:
163179

164-
{
165-
"label": "Watch",
166-
"group": "build",
167-
"type": "shell",
168-
"command": "cargo watch",
169-
"problemMatcher": "$rustc-watch",
170-
"isBackground": true
171-
}
180+
```json
181+
{
182+
"label": "Watch",
183+
"group": "build",
184+
"type": "shell",
185+
"command": "cargo watch",
186+
"problemMatcher": "$rustc-watch",
187+
"isBackground": true
188+
}
189+
```
172190

173191
### Live Share
174192

0 commit comments

Comments
 (0)