Rust Code Pro is a comprehensive Visual Studio Code (VS Code) extension designed to enhance your Rust development experience. It provides a suite of tools to format, lint, test, check, and fix Rust code using cargo fmt
, cargo clippy
, cargo test
, cargo check
, and cargo fix
.
- Code Formatting: Automatically format your Rust code using
cargo fmt
. - Linting: Lint your Rust code using
cargo clippy
, including support for pedantic lints. - Testing: Run tests for your Rust projects using
cargo test
. - Code Checking: Check your Rust code for errors using
cargo check
. - Building: Build your Rust projects using
cargo build
. - Documentation: Generate and open documentation for your Rust code using
cargo doc
. - Clean Projects: Clean your Rust projects using
cargo clean
. - Run Projects: Run your Rust projects using
cargo run
. - Benchmarking: Benchmark your Rust code using
cargo bench
. - Real-time Linting: Enable real-time linting feedback as you type.
- Workspace Diagnostics Summary: Run diagnostics across the entire workspace and display a summary.
- Refactor Suggestions: Run
cargo fix
to apply suggested refactorings. - Toolchain Management: Install, update, and switch between Rust toolchains using
rustup
. - Cargo Features Management: Enable or disable specific Cargo features.
- Send to Playground: Send your Rust code to Rust Playground for easy sharing.
- Profile Management: Create, edit, switch, and delete configuration profiles.
- Install Visual Studio Code.
- Open the Extensions view by clicking on the Extensions icon in the Activity Bar on the side of the window.
- Search for "Rust Code Pro".
- Click the Install button.
The extension provides several configuration options that can be customized in your VS Code settings. You can access the settings by navigating to File > Preferences > Settings
and searching for Rust Code Pro
.
rustCodePro.realTimeLinting
: Enable or disable real-time linting feedback (default:true
).rustCodePro.formatOnSave
: Enable or disable formatting on save (default:true
).rustCodePro.testOnSave
: Enable or disable running tests on save (default:false
).rustCodePro.checkOnSave
: Enable or disable checking code on save (default:false
).rustCodePro.buildOnSave
: Enable or disable building code on save (default:false
).rustCodePro.formatArgs
: Additional arguments forcargo fmt
(default:[]
).rustCodePro.lintArgs
: Additional arguments forcargo clippy
(default:[]
).rustCodePro.outputChannelName
: Name of the output channel (default:Rust Code Pro
).rustCodePro.autoClearOutput
: Automatically clear the output channel before each command (default:false
).rustCodePro.diagnosticsCommand
: Command to use for workspace diagnostics (default:cargo check
).rustCodePro.enableClippyPedantic
: Enable Clippy pedantic lints for stricter code checks (default:false
).rustCodePro.profiles
: Configuration profiles for different workflows (default: see below).rustCodePro.activeProfile
: The currently active configuration profile (default:default
).rustCodePro.diagnosticsCategories
: Enable/disable specific categories in the diagnostics report (default:{ errors: true, warnings: true, performance: true, pitfalls: true }
).
{
"default": {
"enableClippyPedantic": false,
"autoClearOutput": true,
"realTimeLinting": true,
"formatOnSave": true,
"testOnSave": false,
"checkOnSave": false,
"buildOnSave": false,
"outputChannelName": "Rust Code Pro"
}
}
The extension provides various commands that can be executed from the Command Palette (Ctrl+Shift+P
or Cmd+Shift+P
on macOS) or by configuring keybindings. Below is a list of available commands:
rustcodepro.rustFmt
: Runcargo fmt
to format code.rustcodepro.rustClippy
: Runcargo clippy
to lint code.rustcodepro.rustTest
: Runcargo test
to run tests.rustcodepro.rustCheck
: Runcargo check
to check code.rustcodepro.rustBuild
: Runcargo build
to build code.rustcodepro.rustDoc
: Runcargo doc
to generate documentation.rustcodepro.rustClean
: Runcargo clean
to clean the project.rustcodepro.rustRun
: Runcargo run
to run the project.rustcodepro.rustBench
: Runcargo bench
to benchmark code.rustcodepro.rustFmtFile
: Format the current file withcargo fmt
.rustcodepro.rustClippyFile
: Lint the current file withcargo clippy
.rustcodepro.editRustfmtConfig
: Edit therustfmt.toml
configuration file.rustcodepro.editClippyConfig
: Edit theclippy.toml
configuration file.rustcodepro.rustFix
: Runcargo fix
to apply suggested refactorings.rustcodepro.rustAnalyzer
: Runrust-analyzer diagnostics
.rustcodepro.showQuickPick
: Show a quick pick menu to select and run commands.rustcodepro.workspaceDiagnosticsSummary
: Show a summary of workspace diagnostics.rustcodepro.installToolchain
: Install a Rust toolchain usingrustup
.rustcodepro.updateToolchain
: Update Rust toolchains usingrustup
.rustcodepro.switchToolchain
: Switch to a different Rust toolchain usingrustup
.rustcodepro.cargoGenerate
: Runcargo-generate
to scaffold new projects.rustcodepro.manageCargoFeatures
: Enable or disable specific Cargo features.rustcodepro.sendToPlayground
: Send the current code to Rust Playground.rustcodepro.manageProfiles
: Manage configuration profiles.rustcodepro.createProfile
: Create a new configuration profile.rustcodepro.editProfile
: Edit an existing configuration profile.rustcodepro.deleteProfile
: Delete an existing configuration profile.rustcodepro.switchProfile
: Switch to a different configuration profile.
To develop and test this extension, clone the repository and run the following commands:
git clone https://github.com/genc-murat/rust-formatter-linter-plus.git
cd rust-formatter-linter-plus
npm install
npm run watch
Open the project in VS Code and press F5
to start a new VS Code window with the extension loaded.
vscode:prepublish
: Compiles the extension.compile
: Compiles the TypeScript source files.watch
: Watches for changes and recompiles the extension.pretest
: Compiles and lints the extension before running tests.lint
: Lints the TypeScript source files using ESLint.test
: Runs the tests for the extension.
Run the tests using the following command:
npm test
Contributions are welcome! If you have suggestions for new features or improvements, please open an issue or submit a pull request on GitHub.
This project is licensed under the MIT License. See the LICENSE file for details.
For any questions or suggestions, please open an issue on the GitHub repository.
Thank you for using Rust Code Pro! We hope it enhances your Rust development experience. Happy coding!