Fix --wsl option (#404)

* use wsl nvim

* use piped stderr for release build
macos-click-through
Calvin Kosmatka 4 years ago committed by GitHub
parent a864e7b596
commit 9f26e50f06
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -29,16 +29,14 @@ fn set_windows_creation_flags(cmd: &mut Command) {
#[cfg(windows)]
fn platform_build_nvim_cmd(bin: &str) -> Option<Command> {
if !Path::new(&bin).exists() {
return None;
}
if env::args().any(|arg| arg == "--wsl") {
let mut cmd = Command::new("wsl");
cmd.arg(bin);
Some(cmd)
} else {
} else if Path::new(&bin).exists() {
Some(Command::new(bin))
} else {
None
}
}
@ -59,6 +57,23 @@ fn build_nvim_cmd() -> Command {
warn!("NEOVIM_BIN is invalid falling back to first bin in PATH");
}
}
#[cfg(windows)]
if env::args().any(|arg| arg == "--wsl") {
if let Ok(output) = std::process::Command::new("wsl").arg("which").arg("nvim").output() {
if output.status.success() {
let path = String::from_utf8(output.stdout).unwrap();
let mut cmd = Command::new("wsl");
cmd.arg(path.trim());
return cmd;
} else {
error!("nvim not found in WSL path");
std::process::exit(1);
}
} else {
error!("wsl which nvim failed");
std::process::exit(1);
}
}
if let Ok(path) = which::which("nvim") {
if let Some(cmd) = platform_build_nvim_cmd(path.to_str().unwrap()) {
cmd
@ -95,8 +110,13 @@ pub fn create_nvim_command() -> Command {
let mut cmd = build_nvim_cmd();
cmd.arg("--embed")
.args(SETTINGS.neovim_arguments.iter().skip(1))
.stderr(Stdio::inherit());
.args(SETTINGS.neovim_arguments.iter().skip(1));
#[cfg(not(debug_assertions))]
cmd.stderr(Stdio::piped());
#[cfg(debug_assertions)]
cmd.stderr(Stdio::inherit());
#[cfg(windows)]
set_windows_creation_flags(&mut cmd);

Loading…
Cancel
Save