Below you will find pages that utilize the taxonomy term “Visual-Studio-Code”
Visual Studio workspace-specific settings and proto path
I use Pbkit for Protobuf support. There are other extensions available.
I’d experienced problems with the tool when (correctly) import‘ing protobufs under a proto_path and learned that there’s a solution and also learned that it’s possible to use workspace-specific settings.
With a ${workspaceFolder}/protos folder containing:
protos
└── greet
├── v1
│ └── greet.proto
└── v2
└── greet.proto
And, in which protos/greet/v2/greet.proto contains:
import "greet/v1/greet.proto";
I had been receiving import and reference errors until I read the Stack overflow answer.
rust-analyzer and tonic
Solution: https://github.com/rust-analyzer/rust-analyzer/issues/5799
References: https://jen20.dev/post/completion-of-generated-code-in-intellij-rust/
build.rs:
fn main() -> Result<(), Box<dyn std::error::Error>> {
// gRPC Healthcheck
tonic_build::compile_protos("proto/grpc_health_v1.proto")?;
Ok(())
}
But, because this compiles the proto(s) at build time, the imports aren’t available to Visual Studio Code and rust-analyzer
pub mod grpc_health_v1 {
tonic::include_proto!("grpc.health.v1");
}
// These imports would be unavailable and error
use grpc_health_v1::{
health_check_response::ServingStatus,
health_server::{Health, HealthServer},
HealthCheckRequest, HealthCheckResponse,
};
However,
"rust-analyzer.cargo.loadOutDirsFromCheck": true,