# Maintainer: dr460nf1r3 <dr460nf1r3@garudalinux.org>
# Contributor: Felix Yan <felixonmars@archlinux.org>
# Contributor: Antonio Rojas <arojas@archlinux.org>
# Contributor: Andrea Scarpino <andrea@archlinux.org>

pkgname=kate-git
_pkgname=${pkgname%-git}
pkgver=26.11.70_r23957.gf48b776e20
pkgrel=1
pkgdesc="Advanced Text Editor"
groups=('kde-applications-git' 'kde-utilities-git')
url="https://www.kde.org/applications/utilities/${_pkgname}/"
depends=('kbookmarks'
	'kcolorscheme'
	'kcompletion'
	'kconfig'
	'kconfigwidgets'
	'kcoreaddons'
	'kcrash'
	'kdbusaddons'
	'kguiaddons'
	'ki18n'
	'kiconthemes'
	'kio'
	'knewstuff'
	'kparts'
	'kservice'
	'ktexteditor'
	'ktextwidgets'
	'kuserfeedback'
	'kwidgetsaddons'
	'kwindowsystem'
	'kxmlgui'
	'qt6-base'
	'syntax-highlighting')
optdepends=('konsole-git: open a terminal in Kate'
	'clang: C and C++ LSP support'
	'python-language-server: Python LSP support'
	'texlab: LaTeX LSP support'
	'rust: Rust LSP support')
arch=('x86_64')
license=('LGPL-2.1-or-later')
makedepends=('extra-cmake-modules' 'kdoctools' 'git')
provides=("${_pkgname}" "kwrite")
conflicts=("${_pkgname}" "kwrite")
replaces=("kwrite")
source=("git+https://invent.kde.org/utilities/${_pkgname}.git")
sha256sums=('SKIP')

pkgver() {
	cd "${_pkgname}/"
	_major_ver="$(grep -m1 'set *(RELEASE_SERVICE_VERSION_MAJOR' CMakeLists.txt | cut -d '"' -f2)"
	_minor_ver="$(grep -m1 'set *(RELEASE_SERVICE_VERSION_MINOR' CMakeLists.txt | cut -d '"' -f2)"
	_micro_ver="$(grep -m1 'set *(RELEASE_SERVICE_VERSION_MICRO' CMakeLists.txt | cut -d '"' -f2)"
	echo "${_major_ver}.${_minor_ver}.${_micro_ver}_r$(git rev-list --count HEAD).g$(git rev-parse --short HEAD)"
}

build() {
	cmake -B build -S "${_pkgname}" \
		-DCMAKE_INSTALL_PREFIX=/usr \
		-DBUILD_TESTING=OFF

	cmake --build build
}

package() {
	DESTDIR="${pkgdir}" cmake --install build
}
