forked from editor-rs/vscode-rust
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
bb8a07e
commit db51d15
Showing
14 changed files
with
545 additions
and
71 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,199 @@ | ||
# Cargo Command Execution Page | ||
|
||
The extension allows a developer to execute any of built-in cargo commands. | ||
|
||
These commands are: | ||
|
||
* bench | ||
* build | ||
* check | ||
* clean | ||
* clippy | ||
* doc | ||
* new | ||
* run | ||
* test | ||
* update | ||
|
||
These commands available through the command palette (CTRL+P). | ||
|
||
These commands have prefix `"Cargo: "`. | ||
|
||
## Execute Command On Save | ||
|
||
The extension supports executing a command after saving the document opened in the active text document. | ||
|
||
The `"rust.actionOnSave"` configuration parameter specifies a command to execute. | ||
|
||
The possible values: | ||
|
||
* `"build"` - the extension executes `"Cargo: Build"` | ||
* `"check"` - the extension executes `"Cargo: Check"` | ||
* `"clippy"` - the extension executes `"Cargo: Clippy"` | ||
* `"run"` - the extension executes `"Cargo: Run"` | ||
* `"test"` - the extension executes `"Cargo: Test"` | ||
* `null` - the extension does nothing | ||
|
||
By default, it is `null`. | ||
|
||
## Current Working Directory Determination | ||
|
||
The extension executes a cargo command in some directory. To find out which directory the extension should use, the extension uses the following algorithm: | ||
|
||
* Try making out the current working directory from the active text editor | ||
|
||
If all of the conditions are met: | ||
|
||
* There is an active text editor | ||
* A file opened in the editor is in the workspace (the opened directory) | ||
* There is a `Cargo.toml` file near the file or in the parent directories within the workspace | ||
|
||
Then use the directory containing the `Cargo.toml` file. | ||
|
||
* Try using the previous current working directory | ||
* Try using the workspace | ||
|
||
## Configuration Parameters | ||
|
||
### Cargo Path | ||
|
||
The `"rust.cargoPath"` configuration parameter specifies a path to the cargo's executable. | ||
|
||
The possible values: | ||
|
||
* `"Some path"` - the extension would try to use the path | ||
* `null` - the extension would try to use cargo from the `PATH` variable of the environment. | ||
|
||
If cargo isn't available the extension can't execute a cargo command. | ||
|
||
### Cargo Environment | ||
|
||
The `"rust.cargoEnv"` configuration parameter specifies an environment which would be added to the general environment for executing a cargo command. | ||
|
||
The possible values: | ||
|
||
* Some object (`{ "RUST_BACKTRACE": 1 }`) | ||
* `null` | ||
|
||
### Passing Arguments | ||
|
||
The extension supports several configuration parameters: | ||
|
||
* `"rust.buildArgs"` | ||
* `"rust.checkArgs"` | ||
* `"rust.clippyArgs"` | ||
* `"rust.runArgs"` | ||
* `"rust.testArgs"` | ||
|
||
The type of these configuration parameters is an array of strings. | ||
|
||
These configuration parameters specify arguments which are passed to an appropriate command. | ||
|
||
It is useful when you want the extension to execute `cargo build --features some_feature`. | ||
|
||
These configuration parameters are used when one of the following commands is invoked: | ||
|
||
* `"Cargo: Build"` | ||
* `"Cargo: Check"` | ||
* `"Cargo: Clippy"` | ||
* `"Cargo: Run"` | ||
* `"Cargo: Test"` | ||
|
||
#### Examples | ||
|
||
```json | ||
"rust.buildArgs": ["--features", "some_feature"] | ||
``` | ||
|
||
### Custom Configurations | ||
|
||
The extension supports several configuration parameters: | ||
|
||
* `"rust.customBuildConfigurations"` | ||
* `"rust.customCheckConfigurations"` | ||
* `"rust.customClippyConfigurations"` | ||
* `"rust.customRunConfigurations"` | ||
* `"rust.customTestConfigurations"` | ||
|
||
The type of these configuration parameters is an array of objects. | ||
The object must have the following fields: | ||
|
||
* `"title"` - a string. It is shown as the label of a quick pick item if a cargo command has several custom configurations | ||
* `"args"` - an array of strings. If a custom configuration is chosen, a cargo command is executed with the arguments from the custom configuration | ||
|
||
These configuration parameters are used when one of the following commands is invoked: | ||
|
||
* `"Cargo: Build using custom configuration"` | ||
* `"Cargo: Check using custom configuration"` | ||
* `"Cargo: Clippy using custom configuration"` | ||
* `"Cargo: Run using custom configuration"` | ||
* `"Cargo: Test using custom configuration"` | ||
|
||
If any of the following commands is invoked, the extension decides what to do. | ||
|
||
If none of the custom configurations for the command is defined the extension shows an error message. | ||
|
||
If only one custom configuration for the command is defined the extension executes the command with the arguments from the custom configuration. | ||
|
||
If many custom configurations for the command are defined the extension shows a quick pick with titles of the custom configurations to let a developer decide. | ||
|
||
If a developer cancels the quick pick the extension does nothing. | ||
|
||
If a developer chooses an item the extension executes the command with the arguments from the chosen configuration. | ||
|
||
#### Examples | ||
|
||
##### Build Example | ||
|
||
```json | ||
"rust.customBuildConfigurations": [ | ||
{ | ||
"title": "Example: my_example", | ||
"args": ["--example", "my_example"] | ||
} | ||
] | ||
``` | ||
|
||
##### Check With Features | ||
|
||
```json | ||
"rust.customCheckConfigurations": [ | ||
{ | ||
"title": "With Features", | ||
"args": ["--features", "feature1", "feature2"] | ||
} | ||
] | ||
``` | ||
|
||
##### Clippy With Features | ||
|
||
```json | ||
"rust.customClippyConfigurations": [ | ||
{ | ||
"title": "With Features", | ||
"args": ["--features", "feature1", "feature2"] | ||
} | ||
] | ||
``` | ||
|
||
##### Run With Arguments | ||
|
||
```json | ||
"rust.customRunConfigurations": [ | ||
{ | ||
"title": "With Arguments", | ||
"args": ["--", "arg1", "arg2"] | ||
} | ||
] | ||
``` | ||
|
||
##### Test No Run | ||
|
||
```json | ||
"rust.customTestConfigurations": [ | ||
{ | ||
"title": "No Run", | ||
"args": ["--no-run"] | ||
} | ||
] | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
# Format Page | ||
|
||
The extension supports formatting the document opened in the active text editor on saving. | ||
|
||
If the extension is runnning in [RLS Mode](rls_mode.md), formatting is performed via `rustfmt` integrated into RLS. | ||
|
||
If the extension is running in [Legacy Mode](legacy_mode/main.md), formatting is performed via separate `rustfmt`. | ||
|
||
Read more about [rustfmt configuration](legacy_mode/rustfmt_configuration.md) for Legacy Mode. | ||
|
||
In order to format the document, make a right click and choose `"Format Document"`. | ||
|
||
## Format On Save | ||
|
||
The extension supports formatting the document opened in the active text editor on saving. | ||
|
||
The `"rust.formatOnSave"` specifies whether the extension should format the active document on save. | ||
|
||
By default, it is `false`. |
Oops, something went wrong.