diff --git a/Cargo.lock b/Cargo.lock index abebfb5..be7f29a 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -400,27 +400,6 @@ dependencies = [ "cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", ] -[[package]] -name = "crossbeam" -version = "0.7.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", - "crossbeam-channel 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", - "crossbeam-deque 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)", - "crossbeam-epoch 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", - "crossbeam-queue 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", - "crossbeam-utils 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "crossbeam-channel" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "crossbeam-utils 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", -] - [[package]] name = "crossbeam-deque" version = "0.7.2" @@ -1143,7 +1122,6 @@ version = "0.4.0" dependencies = [ "anyhow 1.0.26 (registry+https://github.com/rust-lang/crates.io-index)", "async-trait 0.1.24 (registry+https://github.com/rust-lang/crates.io-index)", - "crossbeam 0.7.3 (registry+https://github.com/rust-lang/crates.io-index)", "derive-new 0.5.8 (registry+https://github.com/rust-lang/crates.io-index)", "euclid 0.20.7 (registry+https://github.com/rust-lang/crates.io-index)", "flexi_logger 0.14.7 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2221,8 +2199,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum core-text 15.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "131b3fd1f8bd5db9f2b398fa4fdb6008c64afc04d447c306ac2c7e98fba2a61d" "checksum core-video-sys 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "8dc065219542086f72d1e9f7aadbbab0989e980263695d129d502082d063a9d0" "checksum crc32fast 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ba125de2af0df55319f41944744ad91c71113bf74a4646efff39afe1f6842db1" -"checksum crossbeam 0.7.3 (registry+https://github.com/rust-lang/crates.io-index)" = "69323bff1fb41c635347b8ead484a5ca6c3f11914d784170b158d8449ab07f8e" -"checksum crossbeam-channel 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "acec9a3b0b3559f15aee4f90746c4e5e293b701c0f7d3925d24e01645267b68c" "checksum crossbeam-deque 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)" = "c3aa945d63861bfe624b55d153a39684da1e8c0bc8fba932f7ee3a3c16cea3ca" "checksum crossbeam-epoch 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "5064ebdbf05ce3cb95e45c8b086f72263f4166b29b97f6baff7ef7fe047b55ac" "checksum crossbeam-queue 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "c695eeca1e7173472a32221542ae469b3e9aac3a4fc81f7696bcad82029493db" diff --git a/Cargo.toml b/Cargo.toml index 9b8fe8c..e090af8 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -24,7 +24,6 @@ unicode-segmentation = "1.6.0" log = "0.4.8" flexi_logger = { version = "0.14.6", default-features = false } anyhow = "1.0.26" -crossbeam = "0.7" parking_lot="0.10.0" [build-dependencies] diff --git a/src/bridge/mod.rs b/src/bridge/mod.rs index 5c7800e..16a08d7 100644 --- a/src/bridge/mod.rs +++ b/src/bridge/mod.rs @@ -8,7 +8,7 @@ use std::process::Stdio; use rmpv::Value; use nvim_rs::{create::tokio as create, UiAttachOptions}; -use tokio::runtime::{Runtime}; +use tokio::runtime::Runtime; use tokio::process::Command; use tokio::sync::mpsc::{unbounded_channel, UnboundedReceiver, UnboundedSender}; use log::{info, error, trace}; @@ -34,10 +34,8 @@ fn set_windows_creation_flags(cmd: &mut Command) { fn create_nvim_command() -> Command { let mut cmd = Command::new("nvim"); - let args = SETTINGS.neovim_arguments.swap(None).unwrap(); - cmd.arg("--embed") - .args(args.iter().skip(1)) + .args(SETTINGS.neovim_arguments.iter().skip(1)) .stderr(Stdio::inherit()); #[cfg(target_os = "windows")] diff --git a/src/main.rs b/src/main.rs index c6eef01..80e1332 100644 --- a/src/main.rs +++ b/src/main.rs @@ -12,37 +12,14 @@ mod settings; #[macro_use] extern crate rust_embed; #[macro_use] extern crate lazy_static; -use std::sync::atomic::Ordering; - use lazy_static::initialize; -use flexi_logger::{Logger, Criterion, Naming, Cleanup}; use bridge::BRIDGE; use window::ui_loop; -use settings::SETTINGS; pub const INITIAL_DIMENSIONS: (u64, u64) = (100, 50); fn main() { - SETTINGS.neovim_arguments.store(Some(std::env::args().filter(|arg| { - if arg == "--log" { - Logger::with_str("neovide") - .log_to_file() - .rotate(Criterion::Size(10_000_000), Naming::Timestamps, Cleanup::KeepLogFiles(1)) - .start() - .expect("Could not start logger"); - false - } else if arg == "--noIdle" { - SETTINGS.no_idle.store(true, Ordering::Relaxed); - false - } else if arg == "--extraBufferFrames" { - SETTINGS.buffer_frames.store(60, Ordering::Relaxed); - false - } else { - true - } - }).collect::>())); - initialize(&BRIDGE); ui_loop(); } diff --git a/src/settings.rs b/src/settings.rs index d79717f..95da4a0 100644 --- a/src/settings.rs +++ b/src/settings.rs @@ -1,23 +1,45 @@ use std::sync::atomic::{AtomicBool, AtomicU16}; -use crossbeam::atomic::AtomicCell; +use flexi_logger::{Logger, Criterion, Naming, Cleanup}; lazy_static! { pub static ref SETTINGS: Settings = Settings::new(); } pub struct Settings { - pub neovim_arguments: AtomicCell>>, + pub neovim_arguments: Vec, pub no_idle: AtomicBool, pub buffer_frames: AtomicU16 } impl Settings { pub fn new() -> Settings { + let mut no_idle = false; + let mut buffer_frames = 1; + + let neovim_arguments = std::env::args().filter(|arg| { + if arg == "--log" { + Logger::with_str("neovide") + .log_to_file() + .rotate(Criterion::Size(10_000_000), Naming::Timestamps, Cleanup::KeepLogFiles(1)) + .start() + .expect("Could not start logger"); + false + } else if arg == "--noIdle" { + no_idle = true; + false + } else if arg == "--extraBufferFrames" { + buffer_frames = 60; + false + } else { + true + } + }).collect::>(); + Settings { - neovim_arguments: AtomicCell::new(None), - no_idle: AtomicBool::new(false), - buffer_frames: AtomicU16::new(1), + neovim_arguments, + no_idle: AtomicBool::new(no_idle), + buffer_frames: AtomicU16::new(buffer_frames), } } }