VSCode Rust 环境配置
先安装插件
rust-analyzer
在此,再推荐大家几个好用的插件:
- Even Better TOML,支持 .toml 文件完整特性
- Error Lens, 更好的获得错误展示
- One Dark Pro, 非常好看的 VSCode 主题
- CodeLLDB, Debugger 程序
配置完可以做到
- 代码提示补全
- F5调试
- 代码自动格式化
配置VSCode
json launch.json
内容如下:
{
// 使用 IntelliSense 了解相关属性。
// 悬停以查看现有属性的描述。
// 欲了解更多信息,请访问: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "rust",
"type": "lldb",
"request": "launch",
"program": "${workspaceRoot}/target/debug/${workspaceFolderBasename}",
"args": [],
"cwd": "${workspaceRoot}",
"preLaunchTask":"build"
}
]
}
json settings.json
内容如下:
{
"[rust]":{
"editor.defaultFormatter":"rust-lang.rust-analyzer",
"editor.formatOnSave": true,// Makes the magiceditor.formatOnSave":true
"rust-analyzer.checkOnSave.command": "clippy"
},
}
json tasks.json
内容如下:
{
"version": "2.0.0",
"tasks": [
{
"type": "cargo",
"command": "build",
"problemMatcher": [
"$rustc"
],
"group": "build",
"label": "build"
}
]
}
Enjoy~~~

浙公网安备 33010602011771号