-
Notifications
You must be signed in to change notification settings - Fork 102
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
Enable rust-analyzer optional cargo features #529
Comments
I also tried setting the same variables, but I still can't get error lints for code behind features. |
If you would have to configure rust-analyzer, that should be done via lsp-mode. Eg: emacs-lsp/lsp-mode#4257 |
This is my config for (after! rustic
(setq lsp-rust-all-features t
lsp-rust-features "all")) I based it on https://emacs-lsp.github.io/lsp-mode/page/lsp-rust-rls/#lsp-rust-all-features and https://emacs-lsp.github.io/lsp-mode/page/lsp-rust-rls/#lsp-rust-features. fn main() {
#[cfg(feature = "foobar")]
{
let foo = 42;
println!("{}", bar);
}
} The problem is that no matter what I do in my config, I don't get lsp hints for the code behind features. For example, in the snippet above, there should be a hint that |
When something like this happens, I try to check it's behavior with VSCode and see the language server logs and try to compare it with the lsp-mode interaction to see what is missing in lsp-mode. |
That would help. Is there a way I can actually see the communication between lsp-mode and rust-analyzer? |
I am playing around with Leptos which lets you write isomorphic Rust code that runs both on the server and in the web-browser. It uses code blocks like this to run code that needs to execute only in one environment or the other:
The problem is that rust-analyzer does not consider any of the code nested inside the "ssr" feature check, and it does not report on any coding mistakes or warnings inside the block.
According to rust-lang/rust-analyzer#14045 rust-analyzer can only support ONE path through this block, but thats better than nothing. So the ssr feature can be enabled by setting the
rust-analyzer.cargo.features
setting by the lsp client, and this should enable rust-anaylzer to properly check the code inside the ssr block (at least).So how do I set the
rust-analyzer.cargo.features
setting via rustic in Emacs? I found these likely variables and set them accordingly, but to no avail:Environment
rustic version: 3.4
The text was updated successfully, but these errors were encountered: