I’m trying to develop a Rust application, however, when I develop from within the Nix shell for my project (via. nix develop), my LSP within Neovim appears to sort-of break:
Am I supposed to declare rust-analyzer as a build input explicitly when using oxalica/rust-overlay? I was assuming the toolchain would include it and it seems that manually declaring rust-analyzer doesn’t change the outcome. If this helps:
# ...
overlays = [(import rust-overlay)];
pkgs = import nixpkgs {
inherit system overlays;
};
# Toolchain for development use
toolchain = pkgs.rust-bin.stable.latest.default;
naersk' = naersk.lib.${system}.override {
cargo = toolchain;
rustc = toolchain;
};
# ...
How can I enable rust-analyzer for my toolchain then? Using complete is obviously a bad idea, and the oxalica/rust-overlay docs don’t specifically mention it.
# ...
# Toolchain for development use
toolchain = pkgs.rust-bin.stable.latest.default.override {
extensions = ["rust-analyzer"];
};
# ...
And confirmed via. :checkhealth vim.lsp that it is using /nix/store/vb0iyfnnjg4npvlib0yxvi9d5rvq8mss-rust-default-1.93.0/bin/rust-analyzer and not my system one. However, the problem persists.
Edit: Checked the rust-analyzer logs, turns out it was missing the rust-src component. This configuration works:
# ...
# Toolchain for development use
toolchain = pkgs.rust-bin.stable.latest.default.override {
extensions = ["rust-analyzer" "rust-src"];
};
# ...