Solved the pathing issue with a bit less hacking [OSX] (#309)

* solved the pathing issue with a bit less hacking

* only source paths if not using terminal
macos-click-through
j4qfrost 5 years ago committed by GitHub
parent b4abe370b2
commit 4643464571
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

73
Cargo.lock generated

@ -129,28 +129,6 @@ version = "1.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f8aac770f1885fd7e387acedd76065302551364496e46b3dd00860b2f8359b9d"
[[package]]
name = "backtrace"
version = "0.3.46"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b1e692897359247cc6bb902933361652380af0f1b7651ae5c5013407f30e109e"
dependencies = [
"backtrace-sys",
"cfg-if",
"libc",
"rustc-demangle",
]
[[package]]
name = "backtrace-sys"
version = "0.1.37"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "18fbebbe1c9d1f383a9cc7e8ccdb471b91c8d024ee9c2ca5b5346121fe8b4399"
dependencies = [
"cc",
"libc",
]
[[package]]
name = "base64"
version = "0.11.0"
@ -178,7 +156,7 @@ dependencies = [
"regex",
"rustc-hash",
"shlex",
"which",
"which 3.1.1",
]
[[package]]
@ -680,15 +658,6 @@ dependencies = [
"pkg-config",
]
[[package]]
name = "failure"
version = "0.1.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d32e9bd16cc02eae7db7ef620b392808b89f6a5e16bb3497d159c6b92a0f4f86"
dependencies = [
"backtrace",
]
[[package]]
name = "filetime"
version = "0.2.9"
@ -1329,6 +1298,7 @@ dependencies = [
"cargo-husky",
"cfg-if",
"derive-new",
"dirs",
"euclid",
"flexi_logger",
"font-kit",
@ -1347,7 +1317,7 @@ dependencies = [
"skulpin",
"tokio",
"unicode-segmentation",
"which",
"which 4.0.0",
"winapi 0.3.8",
"winres",
]
@ -1882,12 +1852,6 @@ dependencies = [
"walkdir",
]
[[package]]
name = "rustc-demangle"
version = "0.1.16"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4c691c0e608126e00913e33f0ccf3727d5fc84573623b8d65b2df340b5201783"
[[package]]
name = "rustc-hash"
version = "1.1.0"
@ -2271,6 +2235,26 @@ dependencies = [
"unicode-width",
]
[[package]]
name = "thiserror"
version = "1.0.19"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b13f926965ad00595dd129fa12823b04bbf866e9085ab0a5f2b05b850fbfc344"
dependencies = [
"thiserror-impl",
]
[[package]]
name = "thiserror-impl"
version = "1.0.19"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "893582086c2f98cde18f906265a65b5030a074b1046c674ae898be6519a7f479"
dependencies = [
"proc-macro2 1.0.12",
"quote 1.0.4",
"syn 1.0.19",
]
[[package]]
name = "thread_local"
version = "1.0.1"
@ -2513,10 +2497,19 @@ version = "3.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d011071ae14a2f6671d0b74080ae0cd8ebf3a6f8c9589a2cd45f23126fe29724"
dependencies = [
"failure",
"libc",
]
[[package]]
name = "which"
version = "4.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bd3edc3cf5458851a4d6a2329232bd5f42c7f9bbe4c4782c4ef9ce37e5d101b2"
dependencies = [
"libc",
"thiserror",
]
[[package]]
name = "winapi"
version = "0.2.8"

@ -30,7 +30,8 @@ flexi_logger = { version = "0.14.6", default-features = false }
anyhow = "1.0.26"
parking_lot="0.10.0"
cfg-if = "0.1.10"
which = "3.1"
which = "4"
dirs = "2"
[dev-dependencies]
mockall = "0.7.0"

@ -22,25 +22,26 @@ use crate::window::window_geometry_or_default;
pub use events::*;
use handler::NeovimHandler;
pub use layouts::*;
use std::env;
use std::path::Path;
pub use ui_commands::UiCommand;
lazy_static! {
pub static ref BRIDGE: Bridge = Bridge::new();
}
#[cfg(target_os = "windows")]
#[cfg(windows)]
fn set_windows_creation_flags(cmd: &mut Command) {
cmd.creation_flags(0x08000000); // CREATE_NO_WINDOW
}
#[cfg(target_os = "windows")]
#[cfg(windows)]
fn platform_build_nvim_cmd(bin: &str) -> Option<Command> {
use std::path::Path;
if !Path::new(&bin).exists() {
return None;
}
if std::env::args()
if env::args()
.collect::<Vec<String>>()
.contains(&String::from("--wsl"))
{
@ -52,9 +53,8 @@ fn platform_build_nvim_cmd(bin: &str) -> Option<Command> {
}
}
#[cfg(not(target_os = "windows"))]
#[cfg(unix)]
fn platform_build_nvim_cmd(bin: &str) -> Option<Command> {
use std::path::Path;
if Path::new(&bin).exists() {
Some(Command::new(bin))
} else {
@ -63,26 +63,20 @@ fn platform_build_nvim_cmd(bin: &str) -> Option<Command> {
}
fn build_nvim_cmd() -> Command {
if let Some(path) = std::env::var_os("NEOVIM_BIN") {
if let Some(cmd) = platform_build_nvim_cmd(&path.to_string_lossy()) {
if let Ok(path) = env::var("NEOVIM_BIN") {
if let Some(cmd) = platform_build_nvim_cmd(&path) {
return cmd;
} else {
warn!("NEOVIM_BIN is invalid falling back to first bin in PATH");
}
}
#[cfg(not(target_os = "macos"))]
{
if let Ok(path) = which::which("nvim") {
if let Some(cmd) = platform_build_nvim_cmd(path.to_str().unwrap()) {
return cmd;
}
}
}
let default_path = "/usr/local/bin/nvim";
if let Some(cmd) = platform_build_nvim_cmd(default_path) {
cmd
} else {
error!("nvim does not have proper permissions!");
std::process::exit(1);
}
} else {
error!("nvim not found!");
std::process::exit(1);
@ -96,7 +90,7 @@ pub fn create_nvim_command() -> Command {
.args(SETTINGS.neovim_arguments.iter().skip(1))
.stderr(Stdio::inherit());
#[cfg(target_os = "windows")]
#[cfg(windows)]
set_windows_creation_flags(&mut cmd);
cmd

@ -31,6 +31,24 @@ fn main() {
eprintln!("{}", err);
process::exit(1);
};
#[cfg(target_os = "macos")]
{
use std::env;
if env::var_os("TERM").is_none() {
let mut profile_path = dirs::home_dir().unwrap();
profile_path.push(".profile");
let shell = env::var("SHELL").unwrap();
let cmd = format!(
"(source /etc/profile && source {} && echo $PATH)",
profile_path.to_str().unwrap()
);
if let Ok(path) = process::Command::new(shell).arg("-c").arg(cmd).output() {
env::set_var("PATH", std::str::from_utf8(&path.stdout).unwrap());
}
}
}
window::initialize_settings();
redraw_scheduler::initialize_settings();
renderer::cursor_renderer::initialize_settings();

Loading…
Cancel
Save