-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Support tools other than Cargo for rust-analyzer.check.overrideCommand
#18460
Comments
Could you maybe share the output ( if it has a reasonable size) that you want to see in the editor? To do what you are looking for is not very straightforward. We first need to implement a reader that can make sense of the said output and turn it into something that resembles |
I haven't really deeply looked into the issue. We are rewriting our Did you read this ? |
Yes I have read into that, but it doesn't explain which command to run to get the right JSON output for Rust analyzer. The output that I would like to see is red underlined text beneath symbols that do not exist. Right now, the editor experience in Bazel is very bad because Rust analyzer does not cooperate with Bazel. Missing identifers are not marked. I have to run the compiler to see mistakes in my code. I cannot find any documentation online about how to obtain the output that comes from cargo clippy without using cargo clippy. I have searched for special options to the clippy tool offered by https://bazelbuild.github.io/rules_rust/rust_clippy.html#rust_clippy. I managed to get some output from
Compared to
this contains clearly less information |
@rustbot claim |
I don't think there's anything for rust-analyzer to do here besides commit to and document the schema expected by |
@darichey Okay, do you think it is possible to convert the first JSON output into an output format like the second without cargo? It seems like there are some cargo specific fields in that JSON such as manifest which I don't have. More precisely, the part
|
You don't need those, just the Diagnostic fields, so the first JSON output already matches the schema |
@darichey I have tried using that output for rust analyser but it doesn't work. Are you sure I don't have to wrap the output in something else so it becomes more like the second JSON schema? |
This works for me. Obviously you may want to replace rust-analyzer/docs/user/generated_config.adoc Lines 241 to 244 in d1fbfc6
or maybe with something that just builds the whole "workspace". I'm not familiar enough with Bazel to say what that might look like. |
I think your So it would look like this:
Another issue I found with Rust analyzer, is that there is no way to see whether the |
It seems like there should be a way to go from the output of
to the output of
|
@darichey i have written a conversion script to match the output from cargo but that doesn't show anything in the log of the rust analyser language server. When I change override command to a non existing command I get an error when running flycheck. Running it with the output of Bazel converted to JSON format expected does not show anything. The schema I am using is the one you mentioned. |
For some reason the cargo output contains $message_type":"diagnostic" but this is not present in the serialization by Serde of a diagnostics message. It has to be added manually after building a Message as in the crate you mentioned @darichey. It means rust analyzer accepts a different schema. |
No, it's not needed. Did you try the command I gave? It works for me. |
No your command doesn't work. I ran it. Why does it work for you?The Bazel output I get is JSON that does not contain a particular field that the output of Cargo Clippy contains, see my earlier message. After manually adding this field, it works. It would really be helpful if Rust analyzer gave some feedback on whether the output of the command could be parsed or not. Without its just guessing how it should look by comparing with Cargo Clippy output. |
@darichey Which version of VS Code, Rust Analyzer and Bazel are you using? For me, no command output is printed when a command is provided that produces JSON in the wrong format. It just silently fails and ignores it. |
I would like to use Rust Analyzer to show hints in my editor of choice.
I know that I can override the command used to feed data to Rust Analyzer.
The problem is that I am working in a Bazel repository where there is no Cargo. The command that comes close is
but it produces no JSON output.
I have created a minimal example in https://github.com/otiv-willem-vanhulle/bazel-rust-check
The bazel rules_rust project https://github.com/bazelbuild/rules_rust does not offer a solution either.
The text was updated successfully, but these errors were encountered: