diff --git a/src/main.rs b/src/main.rs index 02daba6..c7e0c37 100644 --- a/src/main.rs +++ b/src/main.rs @@ -103,16 +103,19 @@ fn main() { gtk::Window::set_default_icon_name("org.daa.NeovimGtk"); - let args: Vec = env::args().collect(); - let argv: Vec = args.iter() + let argv: Vec = env::args() + .take_while(|a| *a != "--") .filter(|a| !a.starts_with(BIN_PATH_ARG)) .filter(|a| !a.starts_with(TIMEOUT_ARG)) .filter(|a| !a.starts_with(DISABLE_WIN_STATE_RESTORE)) - .cloned() .collect(); app.run(&argv); } +fn collect_args_for_nvim() -> Vec { + std::env::args().skip_while(|a| *a != "--").skip(1).collect() +} + fn open(app: >k::Application, files: &[gio::File], _: &str) { let files_list: Vec = files .into_iter() @@ -122,6 +125,7 @@ fn open(app: >k::Application, files: &[gio::File], _: &str) { nvim_bin_path(std::env::args()), files_list, nvim_timeout(std::env::args()), + collect_args_for_nvim(), None, )); @@ -133,6 +137,7 @@ fn activate(app: >k::Application, input_data: Option) { nvim_bin_path(std::env::args()), Vec::new(), nvim_timeout(std::env::args()), + collect_args_for_nvim(), input_data, )); diff --git a/src/nvim/mod.rs b/src/nvim/mod.rs index 898f6da..fb8e747 100644 --- a/src/nvim/mod.rs +++ b/src/nvim/mod.rs @@ -84,6 +84,7 @@ pub fn start( handler: NvimHandler, nvim_bin_path: Option<&String>, timeout: Option, + args_for_neovim: Vec, ) -> result::Result { let mut cmd = if let Some(path) = nvim_bin_path { Command::new(path) @@ -120,6 +121,10 @@ pub fn start( } } + for arg in args_for_neovim { + cmd.arg(arg); + } + let session = Session::new_child_cmd(&mut cmd); let mut session = match session { diff --git a/src/shell.rs b/src/shell.rs index ab2d88b..5fb1b96 100644 --- a/src/shell.rs +++ b/src/shell.rs @@ -530,6 +530,7 @@ pub struct ShellOptions { nvim_bin_path: Option, open_paths: Vec, timeout: Option, + args_for_neovim: Vec, input_data: Option, } @@ -538,12 +539,14 @@ impl ShellOptions { nvim_bin_path: Option, open_paths: Vec, timeout: Option, + args_for_neovim: Vec, input_data: Option, ) -> Self { ShellOptions { nvim_bin_path, open_paths, timeout, + args_for_neovim, input_data, } } @@ -1093,6 +1096,7 @@ fn init_nvim_async( nvim_handler, options.nvim_bin_path.as_ref(), options.timeout, + options.args_for_neovim, ) { Ok(nvim) => nvim, Err(err) => {