rust-analyzer VScode配置

rust-analyzer 是目前rust语言广泛在用的Language Server Protocol, 通过后台进程与VSCode等进行通信,实现代码补全和跳转等功能。

下面介绍其在VsCode setting.json中的配置项:

rust-analyzer.cargo.features

rust-analyzer.cargo.features 这个配置项默认为空,rust-analyzer默认不识别Cargo.toml设置为features模块
tower 仓库为例,在其

tower
|_lib.rs 

这个文件中通过宏有条件的导入

这时候Vscode这些代码是灰色的,并且提示

为了让这些模块也能够使用rust-analyzer代码提示功能,则可以在Vscode的setting.json配置文件中将rust-analyzer.cargo.features 配置为

  "rust-analyzer.cargo.features": [
      "full"
  ]

这样子所有的feature模块就能使用代码补全了。

posted @ 2023-01-08 00:59  yihailin  阅读(1267)  评论(0编辑  收藏  举报