# Copyright 1999-2024 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2

EAPI=8

CRATES="
	addr2line@0.21.0
	adler@1.0.2
	ahash@0.8.11
	aho-corasick@1.1.3
	allocator-api2@0.2.18
	anstream@0.6.13
	anstyle@1.0.6
	anstyle-parse@0.2.3
	anstyle-query@1.0.2
	anstyle-wincon@3.0.2
	anyhow@1.0.82
	async-trait@0.1.80
	autocfg@1.2.0
	backtrace@0.3.71
	bitflags@1.3.2
	bitflags@2.5.0
	build-version@0.1.1
	byteorder@1.5.0
	bytes@0.4.12
	bytes@1.6.0
	cairo-rs@0.19.4
	cairo-sys-rs@0.19.2
	cc@1.0.94
	cfg-expr@0.15.8
	cfg-if@1.0.0
	clap@4.5.4
	clap_builder@4.5.2
	clap_derive@4.5.4
	clap_lex@0.7.0
	colorchoice@1.0.0
	content_inspector@0.2.4
	crossbeam-deque@0.8.5
	crossbeam-epoch@0.9.18
	crossbeam-utils@0.8.19
	dunce@1.0.4
	either@1.11.0
	env_filter@0.1.0
	env_logger@0.11.3
	equivalent@1.0.1
	errno@0.3.8
	fastrand@2.0.2
	field-offset@0.3.6
	filetime@0.2.23
	fnv@1.0.7
	fork@0.1.23
	futures@0.1.31
	futures@0.3.30
	futures-channel@0.3.30
	futures-core@0.3.30
	futures-executor@0.3.30
	futures-io@0.3.30
	futures-macro@0.3.30
	futures-sink@0.3.30
	futures-task@0.3.30
	futures-util@0.3.30
	gdk-pixbuf@0.19.2
	gdk-pixbuf-sys@0.19.0
	gdk4@0.8.1
	gdk4-sys@0.8.1
	getrandom@0.1.16
	gimli@0.28.1
	gio@0.19.4
	gio-sys@0.19.0
	glib@0.19.4
	glib-macros@0.19.4
	glib-sys@0.19.0
	glob@0.3.1
	gobject-sys@0.19.0
	graphene-rs@0.19.2
	graphene-sys@0.19.0
	gsk4@0.8.1
	gsk4-sys@0.8.1
	gtk4@0.8.1
	gtk4-macros@0.8.1
	gtk4-sys@0.8.1
	hashbrown@0.14.3
	heck@0.5.0
	hermit-abi@0.3.9
	html-escape@0.2.13
	humantime@2.1.0
	humantime-serde@1.1.1
	indexmap@2.2.6
	iovec@0.1.4
	is-terminal@0.4.12
	itoa@1.0.11
	libc@0.2.153
	linux-raw-sys@0.4.13
	lock_api@0.4.11
	log@0.4.21
	memchr@2.7.2
	memoffset@0.9.1
	miniz_oxide@0.7.2
	mio@0.8.11
	normalize-line-endings@0.3.0
	num-traits@0.2.18
	num_cpus@1.16.0
	nvim-rs@0.7.0
	object@0.32.2
	once_cell@1.19.0
	os_pipe@1.1.5
	pango@0.19.3
	pango-sys@0.19.0
	parity-tokio-ipc@0.9.0
	parking_lot@0.12.1
	parking_lot_core@0.9.9
	paste@1.0.14
	percent-encoding@2.3.1
	phf@0.11.2
	phf_codegen@0.11.2
	phf_generator@0.11.2
	phf_shared@0.11.2
	pin-project-lite@0.2.14
	pin-utils@0.1.0
	pkg-config@0.3.30
	ppv-lite86@0.2.17
	proc-macro-crate@3.1.0
	proc-macro-error@1.0.4
	proc-macro-error-attr@1.0.4
	proc-macro2@1.0.81
	quick-error@1.2.3
	quote@1.0.36
	rand@0.7.3
	rand@0.8.5
	rand_chacha@0.2.2
	rand_core@0.5.1
	rand_core@0.6.4
	rand_hc@0.2.0
	rayon@1.10.0
	rayon-core@1.12.1
	redox_syscall@0.4.1
	regex@1.10.4
	regex-automata@0.4.6
	regex-syntax@0.8.3
	rmp@0.8.14
	rmpv@1.0.2
	rustc-demangle@0.1.23
	rustc_version@0.4.0
	rustix@0.38.32
	ryu@1.0.17
	same-file@1.0.6
	scopeguard@1.2.0
	semver@1.0.22
	serde@1.0.198
	serde_bytes@0.11.14
	serde_derive@1.0.198
	serde_json@1.0.116
	serde_spanned@0.6.5
	shlex@1.3.0
	signal-hook-registry@1.4.1
	similar@2.5.0
	siphasher@0.3.11
	slab@0.4.9
	smallvec@1.13.2
	snapbox@0.5.9
	snapbox-macros@0.3.8
	socket2@0.5.6
	strsim@0.11.1
	syn@1.0.109
	syn@2.0.60
	system-deps@6.2.2
	target-lexicon@0.12.14
	tempfile@3.10.1
	terminal_size@0.3.0
	thiserror@1.0.58
	thiserror-impl@1.0.58
	tokio@1.37.0
	tokio-io@0.1.13
	tokio-macros@2.2.0
	tokio-util@0.7.10
	toml@0.5.11
	toml@0.8.12
	toml_datetime@0.6.5
	toml_edit@0.21.1
	toml_edit@0.22.11
	tracing@0.1.40
	tracing-core@0.1.32
	trycmd@0.15.1
	unicode-ident@1.0.12
	unicode-segmentation@1.11.0
	unicode-width@0.1.11
	utf8-width@0.1.7
	utf8parse@0.2.1
	version-compare@0.2.0
	version_check@0.9.4
	wait-timeout@0.2.0
	walkdir@2.5.0
	wasi@0.9.0+wasi-snapshot-preview1
	wasi@0.11.0+wasi-snapshot-preview1
	winapi@0.3.9
	winapi-i686-pc-windows-gnu@0.4.0
	winapi-util@0.1.6
	winapi-x86_64-pc-windows-gnu@0.4.0
	windows-sys@0.48.0
	windows-sys@0.52.0
	windows-targets@0.48.5
	windows-targets@0.52.5
	windows_aarch64_gnullvm@0.48.5
	windows_aarch64_gnullvm@0.52.5
	windows_aarch64_msvc@0.48.5
	windows_aarch64_msvc@0.52.5
	windows_i686_gnu@0.48.5
	windows_i686_gnu@0.52.5
	windows_i686_gnullvm@0.52.5
	windows_i686_msvc@0.48.5
	windows_i686_msvc@0.52.5
	windows_x86_64_gnu@0.48.5
	windows_x86_64_gnu@0.52.5
	windows_x86_64_gnullvm@0.48.5
	windows_x86_64_gnullvm@0.52.5
	windows_x86_64_msvc@0.48.5
	windows_x86_64_msvc@0.52.5
	winnow@0.5.40
	winnow@0.6.6
	winres@0.1.12
	zerocopy@0.7.32
	zerocopy-derive@0.7.32
"
inherit cargo xdg
if [[ -z ${PV%%*9999} ]]; then
	inherit git-r3
	EGIT_REPO_URI="https://github.com/Lyude/${PN}.git"
else
	MY_PV="92edb36"
	[[ -n ${PV%%*_p*} ]] && MY_PV="v${PV}"
	SRC_URI="
		mirror://githubcl/Lyude/${PN}/tar.gz/${MY_PV} -> ${P}.tar.gz
		$(cargo_crate_uris ${CRATES})
	"
	RESTRICT="primaryuri"
	KEYWORDS="~amd64"
	S="${WORKDIR}/${PN}-${MY_PV#v}"
fi

DESCRIPTION="GTK UI for neovim written in rust using gtk-rs bindings"
HOMEPAGE="https://github.com/Lyude/${PN}"

LICENSE="GPL-3 MIT BSD LGPL-3"
SLOT="0"

DEPEND="
	gui-libs/gtk:4
"
RDEPEND="
	${DEPEND}
	app-editors/neovim
"

src_unpack() {
	if [[ -z ${PV%%*9999} ]]; then
		git-r3_src_unpack
		cargo_live_src_unpack
	else
		cargo_src_unpack
	fi
}

src_install() {
	dobin target/$(usex debug debug release)/nvim-gtk
	emake install-resources DESTDIR="${D}" PREFIX="${EPREFIX}/usr"
	einstalldocs
}