Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rust: with Clion/IntelliJ IDEA Community/Vscode #390

Open
hhstore opened this issue Sep 14, 2022 · 7 comments
Open

Rust: with Clion/IntelliJ IDEA Community/Vscode #390

hhstore opened this issue Sep 14, 2022 · 7 comments
Labels
Clion Rust vscode Visual Studio Code

Comments

@hhstore
Copy link
Owner Author

hhstore commented Sep 14, 2022

Rust 开发环境搭建:

  • ✅ 首选推荐使用 Clion/IntelliJ IDEA Community 社区版, 比 vscode + ra 代码索引+跳转+补全能力更强.
  • vscode+ra 目前无法跳转宏动态导模块 的代码, Clion 可以.

基本步骤:

PS:

安装 IntelliJ IDEA Community 社区版 + intellij-rust 插件,
然后 action 开启 `org.rust.cargo.evaluate.build.scripts` 选项。 
也是支持宏代码跳转的。亲测有效。依然比 vscode + ra 强大。

使用 rustup 安装 rust:

curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh

查看安装 rust 版本:

 rustup show
Default host: aarch64-apple-darwin
rustup home:  /Users/dev/.rustup

installed toolchains
--------------------

stable-aarch64-apple-darwin
nightly-2022-07-31-aarch64-apple-darwin
nightly-aarch64-apple-darwin (default)
1.61.0-aarch64-apple-darwin

active toolchain
----------------

nightly-aarch64-apple-darwin (default)
rustc 1.63.0-nightly (12cd71f4d 2022-06-01)




 cargo version
cargo 1.63.0-nightly (38472bc19 2022-05-31)

验证 IDE 宏补全 - 示例项目:

image

Rust LSP - rust-analyzer: for Vscode

pb 生成代码补全:

intellij-rust 代码补全 - 核心设置: for Clion

org.rust.cargo.evaluate.build.scripts = true

@hhstore
Copy link
Owner Author

hhstore commented Sep 14, 2022

Rust 配置 Clion 开发环境:

基本设置:

  • ✅ 配置 cargo 等:

image

项目主动激活索引:

  • ✅ 新项目, 主动激活索引的方法:
  • ✅ 项目中如果有多个 workspace, 需要手动指定 Cargo.toml 文件, 来激活IDE 创建索引.

image

激活宏生成的代码补全:

org.rust.cargo.evaluate.build.scripts

说明:

  • ✅ JB IDE 快捷键 双 shift, 然后输入: experimental , 切换到 Action, 选择打开 "实验特性".
  • ✅ 激活后, IDE 宏跳转代码, 可能并不会立即生效.
    • 需要手动清除 IDE 当前项目的索引 cache.
    • 关闭IDE, 重新打开项目. (后面有详细截图)

具体步骤:

  • ✅ 找到 action Tab: 快捷键 双 shift, 然后输入: experimental , 切换到 Action,

image

  • ✅ 激活 action 实验选项:

image

  • ✅ 如果IDE 没有立即生效, 手动清除cache, 重建项目索引, 重新打开工程:

image

配置成功的效果:

  • ✅ 感受 clion 的强大:

rx2IKRCVlN

  • ✅ 对比 vscode 的支持能力差距:

xsmQSWuYLt

@hhstore
Copy link
Owner Author

hhstore commented Sep 14, 2022

@hhstore
Copy link
Owner Author

hhstore commented Sep 14, 2022

clion 的宏补全能力:

NECmKRXQXw

@hhstore
Copy link
Owner Author

hhstore commented Sep 14, 2022

Clion index 炸机修复:

# clion功能不行的时候,用这个命令:
cargo metadata --verbose --format-version 1 --all-features

@hhstore
Copy link
Owner Author

hhstore commented Sep 14, 2022

1

1 similar comment
@hhstore
Copy link
Owner Author

hhstore commented Sep 14, 2022

1

@hhstore hhstore added vscode Visual Studio Code Rust Clion labels Sep 14, 2022
@hhstore hhstore changed the title Rust: with Clion/Vscode Rust: with Clion/IntelliJ IDEA Community/Vscode Sep 21, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Clion Rust vscode Visual Studio Code
Projects
None yet
Development

No branches or pull requests

1 participant