Skip to content

vaticle/bazel-intellij-rust-example

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Bazel + IntelliJ + Rust Example

Working example of Bazel + IntelliJ + Rust integration, allowing for all of IntelliJ's Rust code completion, navigation and refactoring features to work in a Bazel project.

Please note: This video was taken from a previous version of the integration, where Cargo.toml generation worked differently, but the end result remains unchanged.

bazel-intellij-rust-demo.mov

Architecture

This integration is achieved using a fork of the Rust IntelliJ plugin:

As well as a Cargo project generator that converts Bazel to Cargo:

Detecting project structure

The Rust plugin is built to work with Cargo projects, so to make it work with Bazel projects, we need to generate the Cargo manifest files using Bazel, which we do in our Cargo project generator.

External crates from https://crates.io are supported using cargo-raze - see https://github.com/vaticle/bazel-intellij-rust-example/tree/master/dependencies/crates for a usage example.

Loading the Rust toolchain

The modified Rust plugin is able to detect the Rust toolchain in the Bazel sandbox, as well as the standard library sources.

Current limitations

Currently the plugins have only been tested against IntelliJ IDEA 2021.3 UE, IntelliJ IDEA 2022.2 UE and CLion 2022.2. Further changes may be needed to ensure compatibility with other environments. It is unlikely that the Cargo project generator runs on Windows.

The Rust toolchain paths are largely hardcoded - it would be preferable to load them via Bazel commands run in the Rust plugin.

The overall architecture of the Bazel support in intellij-rust is suboptimal, and warrants a proper discussion.

Contributing

We need support to bring these plugins to production quality, via any of the following means:

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages