diff --git a/packages/neovim-nightly/build.sh b/packages/neovim-nightly/build.sh new file mode 100644 index 000000000..621aaeb0c --- /dev/null +++ b/packages/neovim-nightly/build.sh @@ -0,0 +1,125 @@ +TERMUX_PKG_HOMEPAGE=https://neovim.io +TERMUX_PKG_DESCRIPTION="Ambitious Vim-fork focused on extensibility and agility (nvim-nightly)" +TERMUX_PKG_LICENSE="Apache-2.0" +TERMUX_PKG_MAINTAINER="Aditya Alok " +TERMUX_PKG_VERSION=0.7.0-dev+1333-g71b4c30ad +TERMUX_PKG_SRCURL="https://github.com/neovim/neovim/archive/nightly.tar.gz" +TERMUX_PKG_SHA256=ab3d8087cfee9dd4684e1e460162a1a13f86c2a7e84b16ba7ea64e0b83061466 +TERMUX_PKG_DEPENDS="libiconv, libuv, luv, libmsgpack, libandroid-support, libvterm, libtermkey, libluajit, libunibilium, libtreesitter" +TERMUX_PKG_HOSTBUILD=true + +TERMUX_PKG_EXTRA_CONFIGURE_ARGS=" +-DCMAKE_BUILD_TYPE=RelWithDebInfo +-DENABLE_JEMALLOC=OFF +-DGETTEXT_MSGFMT_EXECUTABLE=$(which msgfmt) +-DGETTEXT_MSGMERGE_EXECUTABLE=$(which msgmerge) +-DGPERF_PRG=$TERMUX_PKG_HOSTBUILD_DIR/deps/usr/bin/gperf +-DLUA_PRG=$TERMUX_PKG_HOSTBUILD_DIR/deps/usr/bin/luajit +-DPKG_CONFIG_EXECUTABLE=$(which pkg-config) +-DXGETTEXT_PRG=$(which xgettext) +-DLUAJIT_INCLUDE_DIR=$TERMUX_PREFIX/include/luajit-2.1 +" +TERMUX_PKG_CONFFILES="share/nvim/sysinit.vim" +TERMUX_PKG_CONFLICTS="neovim" + +TERMUX_PKG_AUTO_UPDATE=true + +termux_pkg_auto_update() { + # Scrap and parse github release page to get version of nightly build. + # Neovim just uses 'nightly' tag for release and not nightly version specific, so cannot use github api. + local curl_response=$( + curl \ + --silent \ + "https://github.com/neovim/neovim/releases/tag/nightly" \ + --write-out '|%{http_code}' + ) + local http_code="${curl_response##*|}" + + if [ "$http_code" != "200" ]; then + echo "Error: failed to get latest neovim-nightly tag page." + echo -e "http code: ${http_code}\ncurl response: ${curl_response}" + exit 1 + fi + + # this outputs in the following format: "0.6.0-dev+575-g2ef9d2a66" + local remote_nvim_version=$( + echo "$curl_response" | + cut -d"|" -f1 | + grep "
NVIM" | cut -d " " -f2 | sed "0,/v/s///"
+	)
+
+	# since we are using a nightly build, therefore no need to check for version increment/decrement.
+	if [ "${TERMUX_PKG_VERSION}" != "${remote_nvim_version}" ]; then
+		termux_pkg_upgrade_version "${remote_nvim_version}" --skip-version-check
+	fi
+}
+
+_patch_luv() {
+	# git submodule update --init deps/lua-compat-5.3 failed
+	cp -r $1/build/src/lua-compat-5.3/* $1/build/src/luv/deps/lua-compat-5.3/
+	cp -r $1/build/src/luajit/* $1/build/src/luv/deps/luajit/
+	cp -r $1/build/src/libuv/* $1/build/src/luv/deps/libuv/
+}
+
+termux_step_host_build() {
+	termux_setup_cmake
+
+	TERMUX_ORIGINAL_CMAKE=$(which cmake)
+	if [ ! -f "$TERMUX_ORIGINAL_CMAKE.orig" ]; then
+		mv "$TERMUX_ORIGINAL_CMAKE" "$TERMUX_ORIGINAL_CMAKE.orig"
+	fi
+	cp "$TERMUX_PKG_BUILDER_DIR/custom-bin/cmake" "$TERMUX_ORIGINAL_CMAKE"
+	chmod +x "$TERMUX_ORIGINAL_CMAKE"
+	export TERMUX_ORIGINAL_CMAKE="$TERMUX_ORIGINAL_CMAKE.orig"
+
+	mkdir -p $TERMUX_PKG_HOSTBUILD_DIR/deps
+	cd $TERMUX_PKG_HOSTBUILD_DIR/deps
+	cmake $TERMUX_PKG_SRCDIR/third-party
+
+	make -j 1 ||
+		(_patch_luv $TERMUX_PKG_HOSTBUILD_DIR/deps && make -j 1)
+
+	cd $TERMUX_PKG_SRCDIR
+
+	make CMAKE_EXTRA_FLAGS="-DCMAKE_INSTALL_PREFIX=$TERMUX_PKG_HOSTBUILD_DIR -DUSE_BUNDLED_LUAROCKS=ON" install ||
+		(_patch_luv $TERMUX_PKG_SRCDIR/.deps && make CMAKE_EXTRA_FLAGS="-DCMAKE_INSTALL_PREFIX=$TERMUX_PKG_HOSTBUILD_DIR -DUSE_BUNDLED_LUAROCKS=ON" install)
+
+	make distclean
+	rm -Rf build/
+
+	cd $TERMUX_PKG_HOSTBUILD_DIR
+}
+
+termux_step_pre_configure() {
+	TERMUX_PKG_EXTRA_CONFIGURE_ARGS+=" -DLUA_MATH_LIBRARY=$TERMUX_STANDALONE_TOOLCHAIN/sysroot/usr/lib/$TERMUX_HOST_PLATFORM/$TERMUX_PKG_API_LEVEL/libm.so"
+}
+
+termux_step_post_make_install() {
+	local _CONFIG_DIR=$TERMUX_PREFIX/share/nvim
+	mkdir -p $_CONFIG_DIR
+	cp $TERMUX_PKG_BUILDER_DIR/sysinit.vim $_CONFIG_DIR/
+}
+
+termux_step_create_debscripts() {
+	cat <<-EOF >./postinst
+		#!$TERMUX_PREFIX/bin/sh
+		if [ "$TERMUX_PACKAGE_FORMAT" = "pacman" ] || [ "\$1" = "configure" ] || [ "\$1" = "abort-upgrade" ]; then
+			if [ -x "$TERMUX_PREFIX/bin/update-alternatives" ]; then
+				update-alternatives --install \
+					$TERMUX_PREFIX/bin/editor editor $TERMUX_PREFIX/bin/nvim 40
+				update-alternatives --install \
+					$TERMUX_PREFIX/bin/vi vi $TERMUX_PREFIX/bin/nvim 15
+			fi
+		fi
+	EOF
+
+	cat <<-EOF >./prerm
+		#!$TERMUX_PREFIX/bin/sh
+		if [ "$TERMUX_PACKAGE_FORMAT" = "pacman" ] || [ "\$1" != "upgrade" ]; then
+			if [ -x "$TERMUX_PREFIX/bin/update-alternatives" ]; then
+				update-alternatives --remove editor $TERMUX_PREFIX/bin/nvim
+				update-alternatives --remove vi $TERMUX_PREFIX/bin/nvim
+			fi
+		fi
+	EOF
+}
diff --git a/packages/neovim-nightly/custom-bin/cmake b/packages/neovim-nightly/custom-bin/cmake
new file mode 100755
index 000000000..a310d5c4d
--- /dev/null
+++ b/packages/neovim-nightly/custom-bin/cmake
@@ -0,0 +1,77 @@
+#!/bin/bash
+
+if [ -z $TERMUX_ORIGINAL_CMAKE ]; then
+    SCRIPTPATH="$( cd -- "$(dirname "$0")" >/dev/null 2>&1 ; pwd -P )"
+    TERMUX_ORIGINAL_CMAKE="$SCRIPTPATH/cmake.orig"
+fi
+
+# Need to move --build argument to first due to following error:
+#  CMake Error: Unknown argument --build
+#  CMake Error: Run 'cmake --help' for all supported options.
+HAS_BUILD=false
+for arg in "$@"; do
+    if [ "$arg" == "--build" ]; then
+        HAS_BUILD=true
+    fi
+done
+
+if ! $HAS_BUILD; then
+    $TERMUX_ORIGINAL_CMAKE "$@"
+    exit $?
+fi
+
+
+BUILD_FLAG=false
+BUILD_VALUE=
+NEW_ARGS=()
+UPDATE_CMAKE_CACHE=()
+for arg in "$@"
+do
+    if [ "$arg" == "--build" ]; then
+        BUILD_FLAG=true
+    else
+        if $BUILD_FLAG; then
+            BUILD_VALUE="$arg"
+            BUILD_FLAG=false
+        else
+            case "$arg" in
+                -D*=*)
+                    UPDATE_CMAKE_CACHE+=("${arg:2}")
+                    ;;
+                *)
+                    NEW_ARGS+=("$arg")
+                    ;;
+            esac
+        fi
+    fi
+done
+
+if [ ! -z $BUILD_VALUE ]; then
+    NEW_ARGS=(--build "$BUILD_VALUE" "${NEW_ARGS[@]}")
+fi
+
+function update_cmake_cache() {
+    [ ${#UPDATE_CMAKE_CACHE[@]} -eq 0 ] && return
+    [ -z $BUILD_VALUE ] && return
+    if [ -f "$BUILD_VALUE/CMakeCache.txt" ]; then
+        rm -rf "$BUILD_VALUE/.tmp-orig.CMakeCache.tmp"
+        cp "$BUILD_VALUE/CMakeCache.txt" "$BUILD_VALUE/.tmp-orig.CMakeCache.tmp"
+        cat "$BUILD_VALUE/.tmp-orig.CMakeCache.tmp" | sed -E "$(python3 -c 'import os, sys
+def z(x): return x.replace("/","\\/")
+for a in sys.argv[2:]: print("-e s/^"+z(a.split("=",1)[0])+":(.*)=.*$/"+z(a.split("=",1)[0])+":\\1="+z(a.split("=",1)[1])+"/g", end=" ")
+' -- "${UPDATE_CMAKE_CACHE[@]}")" > "$BUILD_VALUE/CMakeCache.txt"
+    fi
+}
+
+function undo_update_cmake_cache() {
+    [ ${#UPDATE_CMAKE_CACHE[@]} -eq 0 ] && return
+    [ -z $BUILD_VALUE ] && return
+    [ ! -f "$BUILD_VALUE/.tmp-orig.CMakeCache.tmp" ] && return
+    mv -f "$BUILD_VALUE/.tmp-orig.CMakeCache.tmp" "$BUILD_VALUE/CMakeCache.txt"
+}
+
+update_cmake_cache
+trap undo_update_cmake_cache EXIT
+
+
+$TERMUX_ORIGINAL_CMAKE "${NEW_ARGS[@]}"
diff --git a/packages/neovim-nightly/runtime-CMakeLists.txt.patch b/packages/neovim-nightly/runtime-CMakeLists.txt.patch
new file mode 100644
index 000000000..eae593d4a
--- /dev/null
+++ b/packages/neovim-nightly/runtime-CMakeLists.txt.patch
@@ -0,0 +1,21 @@
+diff -u -r ../neovim-0.3.2/runtime/CMakeLists.txt ./runtime/CMakeLists.txt
+--- ../neovim-0.3.2/runtime/CMakeLists.txt	2018-12-31 00:06:17.000000000 +0000
++++ ./runtime/CMakeLists.txt	2019-01-03 00:07:55.652628776 +0000
+@@ -32,7 +32,7 @@
+     add_custom_target("${PACKNAME}-tags"
+       COMMAND ${CMAKE_COMMAND} -E copy_directory
+         ${PACKAGE} ${GENERATED_PACKAGE_DIR}/${PACKNAME}
+-      COMMAND "${PROJECT_BINARY_DIR}/bin/nvim"
++      COMMAND "${PROJECT_BINARY_DIR}/../host-build/bin/nvim"
+         -u NONE -i NONE -e --headless -c "helptags doc" -c quit
+       DEPENDS
+         nvim
+@@ -71,7 +71,7 @@
+   COMMAND ${CMAKE_COMMAND} -E remove doc/*
+   COMMAND ${CMAKE_COMMAND} -E copy_directory
+     ${PROJECT_SOURCE_DIR}/runtime/doc doc
+-  COMMAND "${PROJECT_BINARY_DIR}/bin/nvim"
++  COMMAND "${PROJECT_BINARY_DIR}/../host-build/bin/nvim"
+     -u NONE -i NONE -e --headless -c "helptags ++t doc" -c quit
+   DEPENDS
+     nvim
diff --git a/packages/neovim-nightly/runtime-autoload-man.vim.patch b/packages/neovim-nightly/runtime-autoload-man.vim.patch
new file mode 100644
index 000000000..6e42ff5e7
--- /dev/null
+++ b/packages/neovim-nightly/runtime-autoload-man.vim.patch
@@ -0,0 +1,12 @@
+diff -u -r ../neovim-0851057a8deaa1197bd0af22babb62c1146d836c/runtime/autoload/man.vim ./runtime/autoload/man.vim
+--- ../neovim-0851057a8deaa1197bd0af22babb62c1146d836c/runtime/autoload/man.vim	2018-02-04 12:54:30.000000000 +0000
++++ ./runtime/autoload/man.vim	2018-02-05 00:48:37.422608665 +0000
+@@ -149,7 +149,7 @@
+   " Force MANPAGER=cat to ensure Vim is not recursively invoked (by man-db).
+   " http://comments.gmane.org/gmane.editors.vim.devel/29085
+   " Set MAN_KEEP_FORMATTING so Debian man doesn't discard backspaces.
+-  let cmd = ['env', 'MANPAGER=cat', 'MANWIDTH='.manwidth, 'MAN_KEEP_FORMATTING=1', 'man']
++  let cmd = ['env', 'MANPAGER=cat', 'MANWIDTH='.manwidth, 'MAN_KEEP_FORMATTING=1', 'mandoc']
+   return s:system(cmd + (s:localfile_arg ? ['-l', a:path] : [a:path]))
+ endfunction
+ 
diff --git a/packages/neovim-nightly/src-nvim-eval-funcs.c.patch b/packages/neovim-nightly/src-nvim-eval-funcs.c.patch
new file mode 100644
index 000000000..9cd269192
--- /dev/null
+++ b/packages/neovim-nightly/src-nvim-eval-funcs.c.patch
@@ -0,0 +1,13 @@
+diff --git a/src/nvim/eval/funcs.c b/src/nvim/eval/funcs.c
+index 801b0f9..35c54df 100644
+--- a/src/nvim/eval/funcs.c
++++ b/src/nvim/eval/funcs.c
+@@ -4306,6 +4306,8 @@ static void f_has(typval_T *argvars, typval_T *rettv, FunPtr fptr)
+ #ifdef _WIN64
+     "win64",
+ #endif
++    "android",
++    "termux",
+ #ifndef CASE_INSENSITIVE_FILENAME
+     "fname_case",
+ #endif
diff --git a/packages/neovim-nightly/src-nvim-os-stdpaths.c.patch b/packages/neovim-nightly/src-nvim-os-stdpaths.c.patch
new file mode 100644
index 000000000..9801e302c
--- /dev/null
+++ b/packages/neovim-nightly/src-nvim-os-stdpaths.c.patch
@@ -0,0 +1,14 @@
+diff -u -r ../neovim-master/src/nvim/os/stdpaths.c ./src/nvim/os/stdpaths.c
+--- ../neovim-master/src/nvim/os/stdpaths.c	2015-11-01 16:16:38.000000000 -0500
++++ ./src/nvim/os/stdpaths.c	2015-11-02 14:12:12.770172673 -0500
+@@ -34,8 +34,8 @@
+   [kXDGDataHome] = "~/.local/share",
+   [kXDGCacheHome] = "~/.cache",
+   [kXDGRuntimeDir] = NULL,
+-  [kXDGConfigDirs] = "/etc/xdg/",
+-  [kXDGDataDirs] = "/usr/local/share/:/usr/share/",
++  [kXDGConfigDirs] = "@TERMUX_PREFIX@/etc/xdg/",
++  [kXDGDataDirs] = "@TERMUX_PREFIX@/local/share/:@TERMUX_PREFIX@/share/",
+ #endif
+ };
+ 
diff --git a/packages/neovim-nightly/sysinit.vim b/packages/neovim-nightly/sysinit.vim
new file mode 100644
index 000000000..50944a79a
--- /dev/null
+++ b/packages/neovim-nightly/sysinit.vim
@@ -0,0 +1,6 @@
+" Scroll only one line for mouse wheel events to get smooth scrolling on touch screens
+set mouse=a
+map  
+imap  
+map  
+imap