diff --git a/.gitignore b/.gitignore index 3b1d4a0e..eb28f067 100644 --- a/.gitignore +++ b/.gitignore @@ -8,4 +8,7 @@ container-images-uris.txt container-images.txt cached-container-images.tar +# Flatpak +.flatpak-builder + # vim: tw=100 colorcolumn=100 diff --git a/Cargo.toml b/Cargo.toml index 34bf65fb..da4f2b45 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -9,6 +9,10 @@ build = "build.rs" edition = "2018" license = "GPLv3" +[features] +default = [] +flatpak = [] + [dependencies] clap = { version = "4.0", features = ["color", "help", "std", "usage", "error-context", "suggestions", "wrap_help", "derive"] } glib = "0.18.0" diff --git a/Makefile b/Makefile index 2195fdeb..b20222a7 100644 --- a/Makefile +++ b/Makefile @@ -4,13 +4,13 @@ test: RUST_BACKTRACE=1 cargo test run: - RUST_LOG=warn RUST_BACKTRACE=1 cargo run -- --no-fork + RUST_LOG=warn RUST_BACKTRACE=1 cargo run $(CARGO_ARGS) -- --no-fork install: install-resources - cargo install --path . --force --root $(DESTDIR)$(PREFIX) + cargo install $(CARGO_ARGS) --path . --force --root $(DESTDIR)$(PREFIX) install-debug: install-resources - cargo install --debug --path . --force --root $(DESTDIR)$(PREFIX) + cargo install $(CARGO_ARGS) --debug --path . --force --root $(DESTDIR)$(PREFIX) install-resources: mkdir -p $(DESTDIR)$(PREFIX)/share/nvim-gtk/ diff --git a/src/nvim/mod.rs b/src/nvim/mod.rs index 696c0674..79866013 100644 --- a/src/nvim/mod.rs +++ b/src/nvim/mod.rs @@ -504,11 +504,13 @@ pub fn start<'a>( timeout: Option, args_for_neovim: Vec, ) -> result::Result<(NvimSession, IoFuture<'a>), NvimInitError> { - let mut cmd = if let Some(path) = nvim_bin_path { - Command::new(path) - } else { - Command::new("nvim") - }; + let nvim_cmd = nvim_bin_path.unwrap_or_else(|| "nvim".into()); + #[cfg(not(feature = "flatpak"))] + let mut cmd = Command::new(nvim_cmd); + #[cfg(feature = "flatpak")] + let mut cmd = Command::new("flatpak-spawn"); + #[cfg(feature = "flatpak")] + cmd.arg("--host").arg(nvim_cmd); cmd.arg("--embed") .arg("--cmd")