diff --git a/README.md b/README.md index 080d9a4..9f0dbb4 100644 --- a/README.md +++ b/README.md @@ -139,13 +139,8 @@ also be set via lspconfig. ### Kate -Kate doesn't seem to include the typical cargo home (`/.cargo/bin`) directory -on the `PATH` it passes to rust-analyzer, so you'll need to pass the cargo home path to -`cargo-subspace` directly and provide an absolute path to the `cargo-subspace` binary itself. -In the example below, `` should be substituted for an absolute path to the directory -in which your cargo binaries reside (usually, this is `/.cargo/bin`). - -These settings should be specified in `Settings --> LSP Client --> User Server Settings`: +These settings should be specified in `Settings --> LSP Client --> User Server Settings`. Note the +`"useWorkspace": false` line; this is required! ```json { @@ -154,10 +149,8 @@ These settings should be specified in `Settings --> LSP Client --> User Server S "useWorkspace": false, "initializationOptions": { "check": { - "allFeatures": true, "overrideCommand": [ - "/cargo-subspace", - "--cargo-home=", + "cargo-subspace", "clippy", "$saved_file" ] @@ -165,8 +158,7 @@ These settings should be specified in `Settings --> LSP Client --> User Server S "workspace": { "discoverConfig": { "command": [ - "/cargo-subspace", - "--cargo-home=", + "cargo-subspace", "discover", "{arg}" ], @@ -182,8 +174,6 @@ These settings should be specified in `Settings --> LSP Client --> User Server S } ``` -Note the `"useWorkspace": false` line; this is required! - ## Troubleshooting/Debugging If you run into trouble, please feel free to open an issue with the following: diff --git a/src/cli.rs b/src/cli.rs index 1c2bbc3..1d0eac6 100644 --- a/src/cli.rs +++ b/src/cli.rs @@ -14,8 +14,8 @@ pub struct CargoSubspace { #[arg(long, short)] pub verbose: bool, - /// The explicit path to the directory containing your cargo binaries. By default, - /// `cargo-subspace` will use the binaries on your `PATH`. + /// The explicit path to your cargo home. Typically, this is `$HOME/.cargo`. If this flag is not + /// included, `cargo-subspace` will use the binaries on your `PATH`. #[arg(long, env = "CARGO_HOME")] pub cargo_home: Option, diff --git a/src/main.rs b/src/main.rs index 9ea3b2c..4adb0b0 100644 --- a/src/main.rs +++ b/src/main.rs @@ -81,13 +81,11 @@ impl Context { } fn toolchain_command(&self, command: &str) -> Command { - let mut cmd = Command::new(command); - if let Some(cargo_home) = self.cargo_home.as_ref() { - cmd.env("PATH", cargo_home); + Command::new(cargo_home.join("bin").join(command)) + } else { + Command::new(command) } - - cmd } } @@ -189,7 +187,7 @@ fn discover(ctx: &Context, discover_args: DiscoverArgs, manifest_path: FilePath< cmd.manifest_path(manifest_path); if let Some(cargo_home) = ctx.cargo_home.as_ref() { - cmd.cargo_path(cargo_home.join("cargo")); + cmd.cargo_path(cargo_home.join("bin/cargo")); } if let Some(target_triple) = target_triple {