From 703b7bbe5bd25d6009c0162702b494405f45ed8c Mon Sep 17 00:00:00 2001 From: Nicholas Jarretta Date: Fri, 27 Mar 2020 10:16:47 -0300 Subject: [PATCH] Add WSL arg and code to use the Windows WSL --- src/bridge/mod.rs | 21 ++++++++++++++++++++- src/settings.rs | 2 ++ 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/src/bridge/mod.rs b/src/bridge/mod.rs index e3e438c..a74b067 100644 --- a/src/bridge/mod.rs +++ b/src/bridge/mod.rs @@ -32,8 +32,27 @@ fn set_windows_creation_flags(cmd: &mut Command) { cmd.creation_flags(0x08000000); // CREATE_NO_WINDOW } +#[cfg(target_os = "windows")] +fn build_cmd() -> Command { + if std::env::args() + .collect::>() + .contains(&String::from("--wsl")) + { + let mut cmd = Command::new("wsl"); + cmd.arg("nvim"); + cmd + } else { + Command::new("nvim") + } +} + +#[cfg(not(target_os = "windows"))] +fn build_cmd() -> Command { + Command::new("nvim") +} + fn create_nvim_command() -> Command { - let mut cmd = Command::new("nvim"); + let mut cmd = build_cmd(); cmd.arg("--embed") .args(SETTINGS.neovim_arguments.iter().skip(1)) diff --git a/src/settings.rs b/src/settings.rs index 552cb75..cb7616c 100644 --- a/src/settings.rs +++ b/src/settings.rs @@ -140,6 +140,8 @@ impl Settings { false } else if arg.starts_with("--geometry=") { false + } else if arg == "--wsl" { + false } else { true }