8
8
It is possible to change the foreground/background color and font
9
9
family/size of inlay hints. Just add this to your ` settings.json ` :
10
10
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
+ }
26
26
}
27
+ }
28
+ ```
27
29
28
30
### Semantic style customizations
29
31
@@ -32,46 +34,52 @@ code. For example, mutable bindings are underlined by default and you
32
34
can override this behavior by adding the following section to your
33
35
` settings.json ` :
34
36
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
+ },
43
44
}
45
+ },
46
+ }
47
+ ```
44
48
45
49
Most themes doesn’t support styling unsafe operations differently yet.
46
50
You can fix this by adding overrides for the rules ` operator.unsafe ` ,
47
51
` function.unsafe ` , and ` method.unsafe ` :
48
52
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
+ ```
58
64
59
65
In addition to the top-level rules you can specify overrides for
60
66
specific themes. For example, if you wanted to use a darker text color
61
67
on a specific light theme, you might write:
62
68
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
+ ```
75
83
76
84
Make sure you include the brackets around the theme name. For example,
77
85
use ` "[Ayu Light]" ` to customize the theme Ayu Light.
@@ -81,11 +89,13 @@ use `"[Ayu Light]"` to customize the theme Ayu Light.
81
89
You may use ` inRustProject ` context to configure keybindings for rust
82
90
projects only. For example:
83
91
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
+ ```
89
99
90
100
More about ` when ` clause contexts
91
101
[ 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
96
106
runnable environment-specific substitution variables. The simplest way
97
107
for all runnables in a bunch:
98
108
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
+ ```
102
114
103
115
Or it is possible to specify vars more granularly:
104
116
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
118
130
}
119
- ]
131
+ }
132
+ ]
133
+ ```
120
134
121
135
You can use any valid regular expression as a mask. Also note that a
122
136
full runnable name is something like ** run bin\_ or\_ example\_ name** ,
@@ -127,25 +141,27 @@ this masks: `"^run"`, `"^test "` (the trailing space matters!), and
127
141
128
142
If needed, you can set different values for different platforms:
129
143
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" ,
147
156
}
148
- ]
157
+ },
158
+ { // for all platforms
159
+ "env" : {
160
+ "APP_COMMON_DATA" : " xxx" ,
161
+ }
162
+ }
163
+ ]
164
+ ```
149
165
150
166
### Compiler feedback from external commands
151
167
@@ -161,14 +177,16 @@ For example, if you want to run
161
177
[ ` cargo watch ` ] ( https://crates.io/crates/cargo-watch ) instead, you might
162
178
add the following to ` .vscode/tasks.json ` :
163
179
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
+ ```
172
190
173
191
### Live Share
174
192
0 commit comments