Pass arguments after --
directly to Neovim
This commit is contained in:
parent
f7ee2ea3d8
commit
5e46003028
11
src/main.rs
11
src/main.rs
@ -103,16 +103,19 @@ fn main() {
|
|||||||
|
|
||||||
gtk::Window::set_default_icon_name("org.daa.NeovimGtk");
|
gtk::Window::set_default_icon_name("org.daa.NeovimGtk");
|
||||||
|
|
||||||
let args: Vec<String> = env::args().collect();
|
let argv: Vec<String> = env::args()
|
||||||
let argv: Vec<String> = args.iter()
|
.take_while(|a| *a != "--")
|
||||||
.filter(|a| !a.starts_with(BIN_PATH_ARG))
|
.filter(|a| !a.starts_with(BIN_PATH_ARG))
|
||||||
.filter(|a| !a.starts_with(TIMEOUT_ARG))
|
.filter(|a| !a.starts_with(TIMEOUT_ARG))
|
||||||
.filter(|a| !a.starts_with(DISABLE_WIN_STATE_RESTORE))
|
.filter(|a| !a.starts_with(DISABLE_WIN_STATE_RESTORE))
|
||||||
.cloned()
|
|
||||||
.collect();
|
.collect();
|
||||||
app.run(&argv);
|
app.run(&argv);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn collect_args_for_nvim() -> Vec<String> {
|
||||||
|
std::env::args().skip_while(|a| *a != "--").skip(1).collect()
|
||||||
|
}
|
||||||
|
|
||||||
fn open(app: >k::Application, files: &[gio::File], _: &str) {
|
fn open(app: >k::Application, files: &[gio::File], _: &str) {
|
||||||
let files_list: Vec<String> = files
|
let files_list: Vec<String> = files
|
||||||
.into_iter()
|
.into_iter()
|
||||||
@ -122,6 +125,7 @@ fn open(app: >k::Application, files: &[gio::File], _: &str) {
|
|||||||
nvim_bin_path(std::env::args()),
|
nvim_bin_path(std::env::args()),
|
||||||
files_list,
|
files_list,
|
||||||
nvim_timeout(std::env::args()),
|
nvim_timeout(std::env::args()),
|
||||||
|
collect_args_for_nvim(),
|
||||||
None,
|
None,
|
||||||
));
|
));
|
||||||
|
|
||||||
@ -133,6 +137,7 @@ fn activate(app: >k::Application, input_data: Option<String>) {
|
|||||||
nvim_bin_path(std::env::args()),
|
nvim_bin_path(std::env::args()),
|
||||||
Vec::new(),
|
Vec::new(),
|
||||||
nvim_timeout(std::env::args()),
|
nvim_timeout(std::env::args()),
|
||||||
|
collect_args_for_nvim(),
|
||||||
input_data,
|
input_data,
|
||||||
));
|
));
|
||||||
|
|
||||||
|
@ -84,6 +84,7 @@ pub fn start(
|
|||||||
handler: NvimHandler,
|
handler: NvimHandler,
|
||||||
nvim_bin_path: Option<&String>,
|
nvim_bin_path: Option<&String>,
|
||||||
timeout: Option<Duration>,
|
timeout: Option<Duration>,
|
||||||
|
args_for_neovim: Vec<String>,
|
||||||
) -> result::Result<Neovim, NvimInitError> {
|
) -> result::Result<Neovim, NvimInitError> {
|
||||||
let mut cmd = if let Some(path) = nvim_bin_path {
|
let mut cmd = if let Some(path) = nvim_bin_path {
|
||||||
Command::new(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 session = Session::new_child_cmd(&mut cmd);
|
||||||
|
|
||||||
let mut session = match session {
|
let mut session = match session {
|
||||||
|
@ -530,6 +530,7 @@ pub struct ShellOptions {
|
|||||||
nvim_bin_path: Option<String>,
|
nvim_bin_path: Option<String>,
|
||||||
open_paths: Vec<String>,
|
open_paths: Vec<String>,
|
||||||
timeout: Option<Duration>,
|
timeout: Option<Duration>,
|
||||||
|
args_for_neovim: Vec<String>,
|
||||||
input_data: Option<String>,
|
input_data: Option<String>,
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -538,12 +539,14 @@ impl ShellOptions {
|
|||||||
nvim_bin_path: Option<String>,
|
nvim_bin_path: Option<String>,
|
||||||
open_paths: Vec<String>,
|
open_paths: Vec<String>,
|
||||||
timeout: Option<Duration>,
|
timeout: Option<Duration>,
|
||||||
|
args_for_neovim: Vec<String>,
|
||||||
input_data: Option<String>,
|
input_data: Option<String>,
|
||||||
) -> Self {
|
) -> Self {
|
||||||
ShellOptions {
|
ShellOptions {
|
||||||
nvim_bin_path,
|
nvim_bin_path,
|
||||||
open_paths,
|
open_paths,
|
||||||
timeout,
|
timeout,
|
||||||
|
args_for_neovim,
|
||||||
input_data,
|
input_data,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1093,6 +1096,7 @@ fn init_nvim_async(
|
|||||||
nvim_handler,
|
nvim_handler,
|
||||||
options.nvim_bin_path.as_ref(),
|
options.nvim_bin_path.as_ref(),
|
||||||
options.timeout,
|
options.timeout,
|
||||||
|
options.args_for_neovim,
|
||||||
) {
|
) {
|
||||||
Ok(nvim) => nvim,
|
Ok(nvim) => nvim,
|
||||||
Err(err) => {
|
Err(err) => {
|
||||||
|
Loading…
Reference in New Issue
Block a user