# Template file for 'neovim'
pkgname=neovim
version=0.9.5
revision=1
build_style=cmake
build_helper="qemu"
configure_args="-DCOMPILE_LUA=OFF -DPREFER_LUA=$(vopt_if luajit OFF ON)"
hostmakedepends="gettext lua51-lpeg lua51-mpack lua51-BitOp
 $(vopt_if luajit LuaJIT lua51)"
makedepends="libtermkey-devel libuv-devel libvterm-devel msgpack-devel
 libluv-devel tree-sitter-devel $(vopt_if luajit LuaJIT-devel lua51-devel)"
short_desc="Fork of Vim aiming to improve user experience, plugins and GUIs"
maintainer="Marcin Puc <tranzystorek.io@protonmail.com>"
license="Apache-2.0, 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=fe74369fc30a32ec7a086b1013acd0eacd674e7570eb1acc520a66180c9e9719

build_options=luajit

case "$XBPS_TARGET_MACHINE" in
	riscv64*) build_options_default="" ;;
	*) build_options_default="luajit" ;;
esac

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

pre_configure() {
	vsed -i runtime/CMakeLists.txt \
		-e "s|\".*/bin/nvim|\${CMAKE_CROSSCOMPILING_EMULATOR} &|g"
	vsed -i src/nvim/po/CMakeLists.txt \
		-e "s|\$<TARGET_FILE:nvim|\${CMAKE_CROSSCOMPILING_EMULATOR} &|g"
}

post_install() {
	vlicense LICENSE.txt
}
