Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Flatpak #104

Merged
merged 3 commits into from
Dec 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,7 @@ container-images-uris.txt
container-images.txt
cached-container-images.tar

# Flatpak
.flatpak-builder

# vim: tw=100 colorcolumn=100
4 changes: 4 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
22 changes: 13 additions & 9 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
32 changes: 32 additions & 0 deletions com.github.Lyude.neovim-gtk.yaml
Original file line number Diff line number Diff line change
@@ -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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
35 changes: 35 additions & 0 deletions desktop/com.github.Lyude.neovim-gtk.metainfo.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<?xml version="1.0"?>
<!-- Following https://www.freedesktop.org/software/appstream/docs/chap-CatalogData.html, but only component allowed? Not <components>? -->
<component type="desktop-application">
<id>com.github.Lyude.neovim-gtk</id>
<name>neovim-gtk</name>
<summary>GTK UI for neovim written in rust using gtk-rs bindings</summary>
<developer_name>Lyude Paul, @daa84</developer_name>
<description>
<p>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.</p>
<p>There are a very large number of improvements from @daa84's version, including:
<ul>
<li>Lots of bugfixes</li>
<li>We're fully ported to GTK4, and have a Snapshot based renderer instead of a cairo based renderer</li>
<li>Smooth resizing</li>
</ul>
</p>
</description>
<metadata_license>GPL-3.0</metadata_license>
<keywords>
<keyword>neovim</keyword>
<keyword>vim</keyword>
<keyword>editor</keyword>
</keywords>
<categories>
<category>network</category>
<category>web</category>
</categories>
<url type="homepage">https://github.com/Lyude/neovim-gtk</url>
<url type="bugtracker">https://github.com/Lyude/neovim-gtk/issues/new</url>
<screenshots>
<screenshot type="default">
<image type="source" width="916" height="668">https://raw.githubusercontent.com/Lyude/neovim-gtk/main/screenshots/neovimgtk-screen.png</image>
</screenshot>
</screenshots>
</component>
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 3 additions & 3 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down Expand Up @@ -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());
Expand Down
12 changes: 7 additions & 5 deletions src/nvim/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -504,11 +504,13 @@ pub fn start<'a>(
timeout: Option<Duration>,
args_for_neovim: Vec<String>,
) -> 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")
Expand Down