Add rust LSP utilities
Added the rust analyzer rules needed to generate a rust-project.json.
Once generated, this will be picked up by the rust analyzer server to
provide better language server features.
To generate it you can `bazel run //tools:gen_rust_project`
Change-Id: I5b05fa6f891ac3710b6f60d98e8be792db740a47
Signed-off-by: Adam Snaider <adsnaider@gmail.com>
diff --git a/WORKSPACE b/WORKSPACE
index 51f9c8f..f65e4ee 100644
--- a/WORKSPACE
+++ b/WORKSPACE
@@ -1089,7 +1089,9 @@
path = "third_party/rules_rust",
)
-load("@rules_rust//rust:repositories.bzl", "rust_repository_set")
+load("@rules_rust//rust:repositories.bzl", "rust_analyzer_toolchain_repository", "rust_repository_set")
+
+RUST_VERSION = "1.70.0"
rust_repository_set(
name = "rust",
@@ -1102,8 +1104,8 @@
"aarch64-unknown-linux-gnu",
],
register_toolchain = False,
- rustfmt_version = "1.70.0",
- versions = ["1.70.0"],
+ rustfmt_version = RUST_VERSION,
+ versions = [RUST_VERSION],
)
load("@rules_rust//crate_universe:repositories.bzl", "crate_universe_dependencies")
@@ -1157,7 +1159,7 @@
],
rust_toolchain_cargo_template = "@rust__{triple}__{channel}_tools//:bin/{tool}",
rust_toolchain_rustc_template = "@rust__{triple}__{channel}_tools//:bin/{tool}",
- rust_version = "1.70.0",
+ rust_version = RUST_VERSION,
supported_platform_triples = [
"x86_64-unknown-linux-gnu",
"arm-unknown-linux-gnueabi",
@@ -1170,6 +1172,15 @@
crate_repositories()
+load("@rules_rust//tools/rust_analyzer:deps.bzl", "rust_analyzer_dependencies")
+
+rust_analyzer_dependencies()
+
+register_toolchains(rust_analyzer_toolchain_repository(
+ name = "rust_analyzer_toolchain",
+ version = RUST_VERSION,
+))
+
http_archive(
name = "cxxbridge-cmd",
build_file = "//third_party/cargo:cxxbridge-cmd/include.BUILD.bazel",