Skip to content

Commit

Permalink
Some better codeblocks
Browse files Browse the repository at this point in the history
  • Loading branch information
Veykril committed Jun 11, 2024
1 parent db7b339 commit cddea9d
Show file tree
Hide file tree
Showing 3 changed files with 227 additions and 205 deletions.
202 changes: 110 additions & 92 deletions docs/book/src/editor_features/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,22 +8,24 @@
It is possible to change the foreground/background color and font
family/size of inlay hints. Just add this to your `settings.json`:

{
"editor.inlayHints.fontFamily": "Courier New",
"editor.inlayHints.fontSize": 11,

"workbench.colorCustomizations": {
// Name of the theme you are currently using
"[Default Dark+]": {
"editorInlayHint.foreground": "#868686f0",
"editorInlayHint.background": "#3d3d3d48",

// Overrides for specific kinds of inlay hints
"editorInlayHint.typeForeground": "#fdb6fdf0",
"editorInlayHint.parameterForeground": "#fdb6fdf0",
}
}
```json
{
"editor.inlayHints.fontFamily": "Courier New",
"editor.inlayHints.fontSize": 11,

"workbench.colorCustomizations": {
// Name of the theme you are currently using
"[Default Dark+]": {
"editorInlayHint.foreground": "#868686f0",
"editorInlayHint.background": "#3d3d3d48",

// Overrides for specific kinds of inlay hints
"editorInlayHint.typeForeground": "#fdb6fdf0",
"editorInlayHint.parameterForeground": "#fdb6fdf0",
}
}
}
```

### Semantic style customizations

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

{
"editor.semanticTokenColorCustomizations": {
"rules": {
"*.mutable": {
"fontStyle": "", // underline is the default
},
}
},
```json
{
"editor.semanticTokenColorCustomizations": {
"rules": {
"*.mutable": {
"fontStyle": "", // underline is the default
},
}
},
}
```

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

{
"editor.semanticTokenColorCustomizations": {
"rules": {
"operator.unsafe": "#ff6600",
"function.unsafe": "#ff6600",
"method.unsafe": "#ff6600"
}
},
}
```json
{
"editor.semanticTokenColorCustomizations": {
"rules": {
"operator.unsafe": "#ff6600",
"function.unsafe": "#ff6600",
"method.unsafe": "#ff6600"
}
},
}
```

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

{
"editor.semanticTokenColorCustomizations": {
"rules": {
"operator.unsafe": "#ff6600"
},
"[Ayu Light]": {
"rules": {
"operator.unsafe": "#572300"
}
}
},
}
```json
{
"editor.semanticTokenColorCustomizations": {
"rules": {
"operator.unsafe": "#ff6600"
},
"[Ayu Light]": {
"rules": {
"operator.unsafe": "#572300"
}
}
},
}
```

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

{
"key": "ctrl+alt+d",
"command": "rust-analyzer.openDocs",
"when": "inRustProject"
}
```json
{
"key": "ctrl+alt+d",
"command": "rust-analyzer.openDocs",
"when": "inRustProject"
}
```

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

"rust-analyzer.runnables.extraEnv": {
"RUN_SLOW_TESTS": "1"
}
```json
"rust-analyzer.runnables.extraEnv": {
"RUN_SLOW_TESTS": "1"
}
```

Or it is possible to specify vars more granularly:

"rust-analyzer.runnables.extraEnv": [
{
// "mask": null, // null mask means that this rule will be applied for all runnables
env: {
"APP_ID": "1",
"APP_DATA": "asdf"
}
},
{
"mask": "test_name",
"env": {
"APP_ID": "2", // overwrites only APP_ID
}
```json
"rust-analyzer.runnables.extraEnv": [
{
// "mask": null, // null mask means that this rule will be applied for all runnables
env: {
"APP_ID": "1",
"APP_DATA": "asdf"
}
},
{
"mask": "test_name",
"env": {
"APP_ID": "2", // overwrites only APP_ID
}
]
}
]
```

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

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

"rust-analyzer.runnables.extraEnv": [
{
"platform": "win32", // windows only
env: {
"APP_DATA": "windows specific data"
}
},
{
"platform": ["linux"],
"env": {
"APP_DATA": "linux data",
}
},
{ // for all platforms
"env": {
"APP_COMMON_DATA": "xxx",
}
```json
"rust-analyzer.runnables.extraEnv": [
{
"platform": "win32", // windows only
env: {
"APP_DATA": "windows specific data"
}
},
{
"platform": ["linux"],
"env": {
"APP_DATA": "linux data",
}
]
},
{ // for all platforms
"env": {
"APP_COMMON_DATA": "xxx",
}
}
]
```

### Compiler feedback from external commands

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

{
"label": "Watch",
"group": "build",
"type": "shell",
"command": "cargo watch",
"problemMatcher": "$rustc-watch",
"isBackground": true
}
```json
{
"label": "Watch",
"group": "build",
"type": "shell",
"command": "cargo watch",
"problemMatcher": "$rustc-watch",
"isBackground": true
}
```

### Live Share

Expand Down
Loading

0 comments on commit cddea9d

Please sign in to comment.