# Template file for 'neovim'
pkgname=neovim
version=0.12.3
revision=1
build_style=cmake
build_helper="qemu"
configure_args="-DCOMPILE_LUA=OFF -DENABLE_TRANSLATIONS=ON -DPREFER_LUA=$(vopt_if luajit OFF ON)"
hostmakedepends="gettext patchelf"
makedepends="libuv-devel libluv-devel libutf8proc-devel tree-sitter-devel unibilium-devel
 lua51-lpeg $(vopt_if luajit LuaJIT-devel lua51-devel)"
depends="tree-sitter-c tree-sitter-lua tree-sitter-markdown tree-sitter-query
 tree-sitter-vim tree-sitter-vimdoc"
short_desc="Fork of Vim aiming to improve user experience, plugins and GUIs"
maintainer="tranzystorekk <tranzystorek.io@protonmail.com>"
license="Apache-2.0 AND Vim"
homepage="https://neovim.io"
changelog="https://github.com/neovim/neovim/releases"
distfiles="https://github.com/neovim/neovim/archive/refs/tags/v${version}.tar.gz"
checksum=36a6c66bfbba5d96fa512110aecddb981148a4d013b5ecd01a42877c49855a41

build_options="luajit"
build_options_default="luajit"

alternatives="
 vi:vi:/usr/bin/nvim
 vi:vi.1:/usr/share/man/man1/nvim.1
 vi:view:/usr/bin/nvim
 vi:view.1:/usr/share/man/man1/nvim.1
 vim:vim:/usr/bin/nvim
 vim:vim.1:/usr/share/man/man1/nvim.1"

# They want assertion
CFLAGS=-UNDEBUG

post_install() {
	vlicense LICENSE.txt

	if [ "${CROSS_BUILD}" ]; then
		patchelf --replace-needed \
			${XBPS_CROSS_BASE}/usr/lib/lua/5.1/lpeg.so /usr/lib/lua/5.1/lpeg.so \
			${DESTDIR}/usr/bin/nvim
	fi

	# put system-provided tree-sitter grammars on runtimepath
	ln -s "../../../lib/tree-sitter" "${DESTDIR}/usr/share/nvim/runtime/parser"
}
