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 73d0f2c5..44253ce5 100644 --- a/Makefile +++ b/Makefile @@ -4,28 +4,32 @@ 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-flatpak: install + mkdir -p /app/share/metainfo/ + cp desktop/com.github.Lyude.neovim-gtk.metainfo.xml /app/share/metainfo/ 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/ cp -r runtime $(DESTDIR)$(PREFIX)/share/nvim-gtk/ mkdir -p $(DESTDIR)$(PREFIX)/share/applications/ sed -e "s|Exec=nvim-gtk|Exec=$(PREFIX)/bin/nvim-gtk|" \ - desktop/org.daa.NeovimGtk.desktop \ - >$(DESTDIR)$(PREFIX)/share/applications/org.daa.NeovimGtk.desktop + desktop/com.github.Lyude.neovim-gtk.desktop \ + >$(DESTDIR)$(PREFIX)/share/applications/com.github.Lyude.neovim-gtk.desktop mkdir -p $(DESTDIR)$(PREFIX)/share/icons/hicolor/128x128/apps/ - cp desktop/org.daa.NeovimGtk_128.png $(DESTDIR)$(PREFIX)/share/icons/hicolor/128x128/apps/org.daa.NeovimGtk.png + cp desktop/com.github.Lyude.neovim-gtk_128.png $(DESTDIR)$(PREFIX)/share/icons/hicolor/128x128/apps/com.github.Lyude.neovim-gtk.png mkdir -p $(DESTDIR)$(PREFIX)/share/icons/hicolor/48x48/apps/ - cp desktop/org.daa.NeovimGtk_48.png $(DESTDIR)$(PREFIX)/share/icons/hicolor/48x48/apps/org.daa.NeovimGtk.png + cp desktop/com.github.Lyude.neovim-gtk_48.png $(DESTDIR)$(PREFIX)/share/icons/hicolor/48x48/apps/com.github.Lyude.neovim-gtk.png mkdir -p $(DESTDIR)$(PREFIX)/share/icons/hicolor/scalable/apps/ - cp desktop/org.daa.NeovimGtk.svg $(DESTDIR)$(PREFIX)/share/icons/hicolor/scalable/apps/ + cp desktop/com.github.Lyude.neovim-gtk.svg $(DESTDIR)$(PREFIX)/share/icons/hicolor/scalable/apps/ mkdir -p $(DESTDIR)$(PREFIX)/share/icons/hicolor/symbolic/apps/ - cp desktop/org.daa.NeovimGtk-symbolic.svg $(DESTDIR)$(PREFIX)/share/icons/hicolor/symbolic/apps/ + cp desktop/com.github.Lyude.neovim-gtk-symbolic.svg $(DESTDIR)$(PREFIX)/share/icons/hicolor/symbolic/apps/ .PHONY: all clean test diff --git a/com.github.Lyude.neovim-gtk.yaml b/com.github.Lyude.neovim-gtk.yaml new file mode 100644 index 00000000..b5ee2d14 --- /dev/null +++ b/com.github.Lyude.neovim-gtk.yaml @@ -0,0 +1,32 @@ +app-id: com.github.Lyude.neovim-gtk +runtime: org.gnome.Platform +runtime-version: '45' +sdk: org.gnome.Sdk +sdk-extensions: +- org.freedesktop.Sdk.Extension.rust-stable +command: nvim-gtk +finish-args: +- --share=ipc +- --socket=fallback-x11 +- --socket=wayland +- --device=dri +- --socket=session-bus # for `flatpak-spawn --host nvim` +build-options: + append-path: "/usr/lib/sdk/rust-stable/bin" + build-args: + - "--share=network" # for cargo fetching dependencies + env: + CARGO_HOME: "/run/build/neovim-gtk" # for caching + CARGO_ARGS: "--features flatpak" + PREFIX: "/app" +modules: +- name: neovim-gtk + buildsystem: simple + build-commands: + - make install-flatpak + sources: + - type: archive + #url: https://github.com/Lyude/neovim-gtk/archive/refs/tags/v1.0.4.tar.gz + #sha256: d0d0dacfbfca16168361f517dee20259785379910173cc33d7d48bd301d30f18 + url: https://github.com/Lyude/neovim-gtk/archive/3739f961d28d2a7c98b1fd8be912fc4bb9d9d216.tar.gz + sha256: 78f0a12bdbf5d085fdbc0a57d877b695c5ae4873d036dd5e190141a927da2819 diff --git a/desktop/org.daa.NeovimGtk-symbolic.svg b/desktop/com.github.Lyude.neovim-gtk-symbolic.svg similarity index 99% rename from desktop/org.daa.NeovimGtk-symbolic.svg rename to desktop/com.github.Lyude.neovim-gtk-symbolic.svg index 3cc09cba..5bc45a4e 100644 --- a/desktop/org.daa.NeovimGtk-symbolic.svg +++ b/desktop/com.github.Lyude.neovim-gtk-symbolic.svg @@ -13,7 +13,7 @@ viewBox="0 0 212.20267 212.20267" version="1.1" id="svg27" - sodipodi:docname="org.daa.NeovimGtk-symbolic.svg" + sodipodi:docname="com.github.Lyude.neovim-gtk-symbolic.svg" inkscape:version="0.92.3 (2405546, 2018-03-11)"> diff --git a/desktop/org.daa.NeovimGtk.desktop b/desktop/com.github.Lyude.neovim-gtk.desktop similarity index 92% rename from desktop/org.daa.NeovimGtk.desktop rename to desktop/com.github.Lyude.neovim-gtk.desktop index f1687fc9..a12d26c4 100644 --- a/desktop/org.daa.NeovimGtk.desktop +++ b/desktop/com.github.Lyude.neovim-gtk.desktop @@ -2,7 +2,7 @@ Name=NeovimGtk Comment=Gtk GUI for Neovim text editor Exec=nvim-gtk -- %F -Icon=org.daa.NeovimGtk +Icon=com.github.Lyude.neovim-gtk Type=Application Terminal=false Categories=GTK;Utility;TextEditor; diff --git a/desktop/com.github.Lyude.neovim-gtk.metainfo.xml b/desktop/com.github.Lyude.neovim-gtk.metainfo.xml new file mode 100644 index 00000000..fc19f4b5 --- /dev/null +++ b/desktop/com.github.Lyude.neovim-gtk.metainfo.xml @@ -0,0 +1,35 @@ + + + + com.github.Lyude.neovim-gtk + neovim-gtk + GTK UI for neovim written in rust using gtk-rs bindings + Lyude Paul, @daa84 + +

GTK ui for neovim written in rust using gtk-rs bindings. With ligatures support. This project began as a fork of @daa84's neovim-gtk.

+

There are a very large number of improvements from @daa84's version, including: +

    +
  • Lots of bugfixes
  • +
  • We're fully ported to GTK4, and have a Snapshot based renderer instead of a cairo based renderer
  • +
  • Smooth resizing
  • +
+

+
+ GPL-3.0 + + neovim + vim + editor + + + network + web + + https://github.com/Lyude/neovim-gtk + https://github.com/Lyude/neovim-gtk/issues/new + + + https://raw.githubusercontent.com/Lyude/neovim-gtk/main/screenshots/neovimgtk-screen.png + + +
diff --git a/desktop/org.daa.NeovimGtk.svg b/desktop/com.github.Lyude.neovim-gtk.svg similarity index 98% rename from desktop/org.daa.NeovimGtk.svg rename to desktop/com.github.Lyude.neovim-gtk.svg index d8957867..23174fc8 100644 --- a/desktop/org.daa.NeovimGtk.svg +++ b/desktop/com.github.Lyude.neovim-gtk.svg @@ -16,7 +16,7 @@ id="svg2" version="1.1" inkscape:version="0.92.3 (2405546, 2018-03-11)" - sodipodi:docname="org.daa.NeovimGtk.svg" + sodipodi:docname="com.github.Lyude.neovim-gtk.svg" enable-background="new" inkscape:export-filename="/home/daa/projects/neovim-gtk/desktop/nvim-gtk.png" inkscape:export-xdpi="90" diff --git a/desktop/org.daa.NeovimGtk_128.png b/desktop/com.github.Lyude.neovim-gtk_128.png similarity index 100% rename from desktop/org.daa.NeovimGtk_128.png rename to desktop/com.github.Lyude.neovim-gtk_128.png diff --git a/desktop/org.daa.NeovimGtk_48.png b/desktop/com.github.Lyude.neovim-gtk_48.png similarity index 100% rename from desktop/org.daa.NeovimGtk_48.png rename to desktop/com.github.Lyude.neovim-gtk_48.png diff --git a/src/main.rs b/src/main.rs index 9c5286be..16c8b149 100644 --- a/src/main.rs +++ b/src/main.rs @@ -284,9 +284,9 @@ fn main() { glib::set_program_name(Some("NeovimGtk")); let app = if cfg!(debug_assertions) { - gtk::Application::new(Some("org.daa.NeovimGtkDebug"), app_flags) + gtk::Application::new(Some("com.github.Lyude.neovim-gtkDebug"), app_flags) } else { - gtk::Application::new(Some("org.daa.NeovimGtk"), app_flags) + gtk::Application::new(Some("com.github.Lyude.neovim-gtk"), app_flags) }; let app_cmdline = Rc::new(RefCell::new(None)); @@ -335,7 +335,7 @@ fn main() { )); app.add_action(&new_window_action); - gtk::Window::set_default_icon_name("org.daa.NeovimGtk"); + gtk::Window::set_default_icon_name("com.github.Lyude.neovim-gtk"); app.run(); std::process::exit(app_cmdline.borrow().as_ref().unwrap().exit_status()); 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")