on master help sign in
Use which to resolve lsp/dap binaries
9712bbbBlaž Hrastnik
Cargo.lock+2
@@ -393,6 +393,7 @@ dependencies = [
393 "serde_json",
393 "serde_json",
394 "thiserror",
394 "thiserror",
395 "tokio",
395 "tokio",
396+ "which",
396]
397]
397
398
398[[package]]
399[[package]]
@@ -411,6 +412,7 @@ dependencies = [
411 "thiserror",
412 "thiserror",
412 "tokio",
413 "tokio",
413 "tokio-stream",
414 "tokio-stream",
415+ "which",
414]
416]
415
417
416[[package]]
418[[package]]
helix-dap/Cargo.toml+1
@@ -19,6 +19,7 @@ serde = { version = "1.0", features = ["derive"] }
19serde_json = "1.0"
19serde_json = "1.0"
20thiserror = "1.0"
20thiserror = "1.0"
21tokio = { version = "1", features = ["rt", "rt-multi-thread", "io-util", "io-std", "time", "process", "macros", "fs", "parking_lot", "net", "sync"] }
21tokio = { version = "1", features = ["rt", "rt-multi-thread", "io-util", "io-std", "time", "process", "macros", "fs", "parking_lot", "net", "sync"] }
22+which = "4.2"
22
23
23[dev-dependencies]
24[dev-dependencies]
24fern = "0.6"
25fern = "0.6"
helix-dap/src/client.rs+3
@@ -105,6 +105,9 @@ impl Client {
105 args: Vec<&str>,
105 args: Vec<&str>,
106 id: usize,
106 id: usize,
107 ) -> Result<(Self, UnboundedReceiver<Payload>)> {
107 ) -> Result<(Self, UnboundedReceiver<Payload>)> {
108+ // Resolve path to the binary
109+ let cmd = which::which(cmd).map_err(|err| anyhow::anyhow!(err))?;
110+
108 let process = Command::new(cmd)
111 let process = Command::new(cmd)
109 .args(args)
112 .args(args)
110 .stdin(Stdio::piped())
113 .stdin(Stdio::piped())
helix-lsp/Cargo.toml+1
@@ -25,3 +25,4 @@ serde_json = "1.0"
25thiserror = "1.0"
25thiserror = "1.0"
26tokio = { version = "1.17", features = ["rt", "rt-multi-thread", "io-util", "io-std", "time", "process", "macros", "fs", "parking_lot", "sync"] }
26tokio = { version = "1.17", features = ["rt", "rt-multi-thread", "io-util", "io-std", "time", "process", "macros", "fs", "parking_lot", "sync"] }
27tokio-stream = "0.1.8"
27tokio-stream = "0.1.8"
28+which = "4.2"
helix-lsp/src/client.rs+3
@@ -43,6 +43,9 @@ impl Client {
43 root_markers: Vec<String>,
43 root_markers: Vec<String>,
44 id: usize,
44 id: usize,
45 ) -> Result<(Self, UnboundedReceiver<(usize, Call)>, Arc<Notify>)> {
45 ) -> Result<(Self, UnboundedReceiver<(usize, Call)>, Arc<Notify>)> {
46+ // Resolve path to the binary
47+ let cmd = which::which(cmd).map_err(|err| anyhow::anyhow!(err))?;
48+
46 let process = Command::new(cmd)
49 let process = Command::new(cmd)
47 .args(args)
50 .args(args)
48 .stdin(Stdio::piped())
51 .stdin(Stdio::piped())
helix-term/src/application.rs+2−21
@@ -479,32 +479,13 @@ impl Application {
479 Payload::Response(_) => unreachable!(),
479 Payload::Response(_) => unreachable!(),
480 Payload::Request(request) => match request.command.as_str() {
480 Payload::Request(request) => match request.command.as_str() {
481 RunInTerminal::COMMAND => {
481 RunInTerminal::COMMAND => {
482− let mut arguments: dap::requests::RunInTerminalArguments =
482+ let arguments: dap::requests::RunInTerminalArguments =
483 serde_json::from_value(request.arguments.unwrap_or_default()).unwrap();
483 serde_json::from_value(request.arguments.unwrap_or_default()).unwrap();
484 // TODO: no unwrap
484 // TODO: no unwrap
485
485
486− log::error!("run_in_terminal {:?}", arguments);
487−
488− // HAXX: lldb-vscode uses $CWD/lldb-vscode which is wrong
489− let program = arguments.args[0]
490− .strip_prefix(
491− std::env::current_dir()
492− .expect("Couldn't get current working directory")
493− .as_path()
494− .to_str()
495− .unwrap(),
496− )
497− .and_then(|arg| arg.strip_prefix('/'))
498− .map(|arg| arg.to_owned())
499− .unwrap_or_else(|| arguments.args[0].clone());
500− arguments.args[0] = program;
501−
502− log::error!("{}", arguments.args.join(" "));
503−
504− // TODO: handle cwd
505 let process = std::process::Command::new("tmux")
486 let process = std::process::Command::new("tmux")
506 .arg("split-window")
487 .arg("split-window")
507− .arg(arguments.args.join(" ")) // TODO: first arg is wrong, it uses current dir
488+ .arg(arguments.args.join(" "))
508 .spawn()
489 .spawn()
509 .unwrap();
490 .unwrap();
510
491