# Maintainer: John Vogel <jvogel4@stny.rr.com>
pkgname=nvim-plenary
pkgver=0.1.4_git20240917
_commit=2d9b06177a975543726ce5c73fca176cedbffe9d
pkgrel=0
pkgdesc="lua library for neovim plugins"
url="https://github.com/nvim-lua/plenary.nvim/"
# fails on arches that neovim is not built with luajit
arch="all !loongarch64 !ppc64le !riscv64 !s390x"
license="MIT"
depends="neovim"
checkdepends="bash curl"
options="net" # needed for some of the tests
subpackages="$pkgname-doc"
source="https://github.com/nvim-lua/plenary.nvim/archive/$_commit/nvim-plenary-$pkgver.tar.gz"
builddir="$srcdir/plenary.nvim-$_commit"

prepare() {
	default_prepare

	# enum test fails due to luajit being built with LUAJIT_ENABLELUA52COMPAT
	rm tests/plenary/enum_spec.lua
	# scandir test expects this to be a git repo for hidden file test
	touch .git
}

check() {
	make test
}

package() {
	install -dm755 "$pkgdir"/usr/share/nvim/site/pack/dist/opt/"$pkgname"
	cp -a data doc lua plugin "$pkgdir"/usr/share/nvim/site/pack/dist/opt/"$pkgname"
	install -Dm644 ./*.md -t "$pkgdir"/usr/share/doc/"$pkgname"
	install -Dm644 LICENSE "$pkgdir"/usr/share/licenses/"$pkgname"
}

doc() {
	default_doc
	amove usr/share/nvim/site/pack/dist/opt/"$pkgname"/doc
}

sha512sums="
b52d9865117780107763b1324ddf814b56620ab33d04f3d905de9c3672473e9c2c0f424c660a6021818b772cf67eb7f3c65bca9eedd00a83fdc2146bfc93dfb3  nvim-plenary-0.1.4_git20240917.tar.gz
"
