Hi, This updates Neovim to the latest version and enables LuaJIT on architectures where that is possible (see this thread for initial disucssion on LuaJIT: https://marc.info/?l=openbsd-ports&m=163153228730587&w=2)
Things to know: - I've enabled LuaJIT on the same arches that lang/luajit supports, with the addition of aarch64. I think that's right (we are embedding a never version of LuaJIT with aarch64 support). - I've also copied over (from lang/luajit) any patches which still look relevant in the context of embedding a static LuaJIT. - We can use Lua-5.1 modules, even with LuaJIT: https://luajit.org/extensions.html - Test suite broken in this release (fixed upstream now): https://github.com/neovim/neovim/issues/15856 - Removed instructions for migrating from vim to neovim. They were out-dated and I think most users know what they are doing now. - Attempted to make the port compatible with SEPARATE_BUILD. I've used this lightly with some pretty advanced Lua plugins (e.g. rust-analyzer, telescope) and all seems well. I'd be grateful for testing, especially on !amd64. It's a large change, so I'm sure there will be comments. Please fire away. Index: Makefile =================================================================== RCS file: /cvs/ports/editors/neovim/Makefile,v retrieving revision 1.23 diff -u -p -r1.23 Makefile --- Makefile 18 Jul 2021 09:18:07 -0000 1.23 +++ Makefile 4 Oct 2021 12:00:44 -0000 @@ -1,36 +1,61 @@ # $OpenBSD: Makefile,v 1.23 2021/07/18 09:18:07 paco Exp $ +# Use LuaJIT where possible, as some plugins assume it's available. Arches +# that can't use LuaJIT have to use the system Lua (and some plugins may not +# work). +.if ${MACHINE_ARCH} == "arm" || ${MACHINE_ARCH} == "aarch64" || \ + ${MACHINE_ARCH} == "amd64" || ${MACHINE_ARCH} == "i386" || \ + ${MACHINE_ARCH} == "powerpc" +EMBED_LUAJIT = Yes +.else +EMBED_LUAJIT = No +.endif + COMMENT = continuation and extension of Vim GH_ACCOUNT = neovim GH_PROJECT = neovim -GH_TAGNAME = v0.5.0 +GH_TAGNAME = v0.5.1 CATEGORIES = editors devel HOMEPAGE = https://neovim.io MAINTAINER = Edd Barrett <[email protected]> -# Neovim must be statically linked with libluv, which isn't yet ported. +# The versions listed here must match those in third-party/CMakeLists.txt. LUV_VER = 1.30.1-1 -LUV = luv-${LUV_VER} +LUAJIT_VER = 787736990ac3b7d5ceaba2697c7d0f58f77bb782 + MASTER_SITES0 = https://github.com/luvit/luv/releases/download/${LUV_VER}/ +MASTER_SITES1 = https://github.com/LuaJIT/LuaJIT/archive/ DISTFILES = ${DISTNAME}${EXTRACT_SUFX} \ - ${LUV}${EXTRACT_SUFX}:0 + luv-${LUV_VER}${EXTRACT_SUFX}:0 \ + luajit-{}${LUAJIT_VER}${EXTRACT_SUFX}:1 -# Apache 2.0 + Vim License +# Neovim: Apache 2.0 + Vim License +# LuaJIT: MIT + public domain +# libluv: Apache 2.0 PERMIT_PACKAGE = Yes DEBUG_PACKAGES = ${BUILD_PACKAGES} -WANTLIB += c iconv intl ${MODLUA_WANTLIB} m msgpackc pthread termkey +WANTLIB += ${COMPILER_LIBCXX} c iconv intl m msgpackc pthread termkey WANTLIB += tree-sitter unibilium util uv vterm +.if ${EMBED_LUAJIT} != "Yes" +WANTLIB += ${MODLUA_WANTLIB} +.endif + COMPILER = base-clang ports-gcc base-gcc MODULES = devel/cmake \ lang/lua \ textproc/intltool +# LuaJIT is binary compatible with Lua-5.1 extension modules, so we can use +# them directly, even on architectures where we will be embedding LuaJIT. +# https://luajit.org/extensions.html +MODLUA_VERSION = 5.1 + BUILD_DEPENDS = ${RUN_DEPENDS} \ devel/gperf \ devel/lpeg \ @@ -46,37 +71,77 @@ LIB_DEPENDS = devel/gettext,-runtime \ RUN_DEPENDS += devel/libmpack/lua \ devel/libmpack/main \ - devel/desktop-file-utils - -MAKE_FLAGS += USE_BUNDLED=OFF -CONFIGURE_ARGS += -DLUA_PRG=${MODLUA_BIN} \ + devel/desktop-file-utils \ + devel/lua-compat53 \ + x11/gtk+3,-guic + +SEPARATE_BUILD = Yes +CONFIGURE_ARGS += -DUSE_BUNDLED=OFF \ + -DLIBLUV_INCLUDE_DIR=${STATIC_DEPS_INST}/include \ + -DLIBLUV_LIBRARY=${STATIC_DEPS_INST}/lib/libluv.a +.if ${EMBED_LUAJIT} == "Yes" +CONFIGURE_ARGS += -DLUA_PRG=${STATIC_DEPS_INST}/bin/luajit-2.1.0-beta3 \ + -DLUAJIT_INCLUDE_DIR=${STATIC_DEPS_INST}/include/luajit-2.1 \ + -DLUAJIT_LIBRARY=${STATIC_DEPS_INST}/lib/libluajit-5.1.a +.else +CONFIGURE_ARGS += -DPREFER_LUA=ON \ + -DLUA_PRG=${MODLUA_BIN} \ -DLUA_INCLUDE_DIR=${MODLUA_INCL_DIR} \ - -DLUA_LIBRARIES=${MODLUA_LIB} \ - -DLIBLUV_INCLUDE_DIR=${WRKBUILD}/deps/include \ - -DLIBLUV_LIBRARY=${WRKBUILD}/deps/lib/libluv.a \ - -DPREFER_LUA=ON # disables LuaJIT + -DLUA_LIBRARIES=${MODLUA_LIB} +.endif # Tests need gmake USE_GMAKE = Yes # `test_startup_utf8.vim' requires either bash or zsh MODULES += lang/python MODPY_RUNDEP = No -MODPY_BUILDDEP = No +MODPY_BUILDDEP =No TEST_DEPENDS = shells/bash \ editors/py-neovim \ editors/py-neovim${MODPY_FLAVOR} -# Build libluv first as a static library. We opted not to create a libluv -# port because it must be built for a specific Lua version and we don't know -# what version future ports might need. Currently no other port requires -# libluv, so it's simpler to build a static library here. +# Move static deps source code under WRKDIST so that they can be patched. +STATIC_DEPS_WRKSRC=${WRKDIST}/static-deps/ +post-extract: + mkdir ${STATIC_DEPS_WRKSRC} + mv ${WRKDIR}/LuaJIT-${LUAJIT_VER} ${STATIC_DEPS_WRKSRC}/luajit + mv ${WRKDIR}/luv-${LUV_VER} ${STATIC_DEPS_WRKSRC}/luv + +# Build LuaJIT (if requiried) and libluv as static libraries. +# +# We opted not to create a libluv port because it must be built for a specific +# Lua version and we don't know what version future ports might need. Currently +# no other port requires libluv, so it's simpler to build a static library +# here. +# +# Most of the libluv target is lifted from ${MODCMAKE_configure} in +# cmake.port.mk. Unfortunately we can't use it directly, as some of the +# arguments make assumptions that can't work for us here. # -# Most of this target is lifted from ${MODCMAKE_configure} in cmake.port.mk. -# Unfortunately we can't use it directly, as some of the arguments make -# assumptions that can't work for us here. +# Neovim plugins expect a very specific version of LuaJIT, so it only really +# makes sense to embed it. +STATIC_DEPS_WRKBUILD=${WRKBUILD}/static-deps-build +STATIC_DEPS_INST=${WRKBUILD}/static-deps-inst pre-configure: - mkdir -p ${WRKBUILD}/build - cd ${WRKBUILD}/build && \ + mkdir -p ${STATIC_DEPS_WRKBUILD} ${STATIC_DEPS_PREFIX} + +.if ${EMBED_LUAJIT} == "Yes" + # Build LuaJIT. + # We can't build LuaJIT out of its src dir, so copy it so that we can + # support SEPARATE_BUILD. + cp -r ${STATIC_DEPS_WRKSRC}/luajit ${STATIC_DEPS_WRKBUILD}/luajit + cd ${STATIC_DEPS_WRKBUILD}/luajit/src && \ + ${SETENV} ${MAKE_ENV} ${MAKE_PROGRAM} \ + PREFIX=${STATIC_DEPS_INST} CC=${CC} CCOPT="${CFLAGS}" \ + CCOPT_x86="" Q="" LDFLAGS="-lstdc++" BUILDMODE=static + cd ${STATIC_DEPS_WRKBUILD}/luajit && \ + ${SETENV} ${MAKE_ENV} Q="" ${MAKE_PROGRAM} install \ + PREFIX=${STATIC_DEPS_INST} +.endif + + # Build luv. + mkdir -p ${STATIC_DEPS_WRKBUILD}/luv + cd ${STATIC_DEPS_WRKBUILD}/luv && \ ${SETENV} CC="${CC}" \ CXX="${CXX}" \ CFLAGS="${CFLAGS}" \ @@ -87,16 +152,16 @@ pre-configure: -DCMAKE_COLOR_MAKEFILE=OFF \ -DCMAKE_SKIP_INSTALL_ALL_DEPENDENCY=ON \ -DCMAKE_SUPPRESS_REGENERATION=ON \ - -DCMAKE_INSTALL_PREFIX=${WRKBUILD}/deps \ + -DCMAKE_INSTALL_PREFIX=${STATIC_DEPS_INST} \ -DLUA_BUILD_TYPE=System \ -DLUA_INCLUDE_DIR=${MODLUA_INCL_DIR} \ - -DLUA_LIBRARIES=${MODLUA_LIB} \ + -DLUA_LIBRARIES=${MODLUA_LIBDIR} \ -DWITH_LUA_ENGINE=Lua \ - ${WRKDIR}/${LUV} - cd ${WRKBUILD}/build && \ + ${STATIC_DEPS_WRKSRC}/luv + cd ${STATIC_DEPS_WRKBUILD}/luv && \ ${SETENV} ${MAKE_ENV} VERBOSE=1 \ ${MAKE_PROGRAM} - cd ${WRKBUILD}/build && \ + cd ${STATIC_DEPS_WRKBUILD}/luv && \ ${SETENV} ${MAKE_ENV} VERBOSE=1 \ ${MAKE_PROGRAM} install @@ -105,8 +170,14 @@ pre-configure: # # If cscope is installed, one test fails: # https://github.com/neovim/neovim/issues/12744 -do-test: - cd ${WRKSRC}/src/nvim/testdir && ${SETENV} LC_CTYPE=en_US.UTF-8 \ - ${MAKE_PROGRAM} NVIM_PRG=${WRKBUILD}/bin/nvim ${MAKE_FLAGS} +# +# XXX: This is broken. The tarball doesn't contain the necessary 'ci' +# directory. Will be fixed for the next release though: +# https://github.com/neovim/neovim/issues/15856 +NO_TEST = Yes +#do-test: +# true +# cd ${WRKSRC}/src/nvim/testdir && ${SETENV} LC_CTYPE=en_US.UTF-8 \ +# ${MAKE_PROGRAM} NVIM_PRG=${WRKBUILD}/bin/nvim ${MAKE_FLAGS} .include <bsd.port.mk> Index: distinfo =================================================================== RCS file: /cvs/ports/editors/neovim/distinfo,v retrieving revision 1.9 diff -u -p -r1.9 distinfo --- distinfo 18 Jul 2021 09:18:07 -0000 1.9 +++ distinfo 2 Oct 2021 10:10:22 -0000 @@ -1,4 +1,6 @@ +SHA256 (luajit-787736990ac3b7d5ceaba2697c7d0f58f77bb782.tar.gz) = Lj90vCefRsxGOr/Gezbmn6rwNmI3AEdx9MrEvyqfXvs= SHA256 (luv-1.30.1-1.tar.gz) = Tih77W9R/VDOA7p/qMwz2E4bnLhpEcSBK7H0eh4+0So= -SHA256 (neovim-0.5.0.tar.gz) = IpTKqdIBGZZJn71w5ABuTvVdt1uZtnGRVMCSYuI3ZO8= +SHA256 (neovim-0.5.1.tar.gz) = qkSXleXMab3S7u1wlfILnAhsbs/N4Ktiq5ep0EJD7IQ= +SIZE (luajit-787736990ac3b7d5ceaba2697c7d0f58f77bb782.tar.gz) = 1037727 SIZE (luv-1.30.1-1.tar.gz) = 1354232 -SIZE (neovim-0.5.0.tar.gz) = 10337976 +SIZE (neovim-0.5.1.tar.gz) = 10349190 Index: patches/patch-src_nvim_CMakeLists_txt =================================================================== RCS file: patches/patch-src_nvim_CMakeLists_txt diff -N patches/patch-src_nvim_CMakeLists_txt --- patches/patch-src_nvim_CMakeLists_txt 18 Aug 2020 19:15:54 -0000 1.3 +++ /dev/null 1 Jan 1970 00:00:00 -0000 @@ -1,19 +0,0 @@ -$OpenBSD: patch-src_nvim_CMakeLists_txt,v 1.3 2020/08/18 19:15:54 edd Exp $ - -No need for libc++abi, only available on clang archs and only needed for -luajit (we use lua instead). - -Index: src/nvim/CMakeLists.txt ---- src/nvim/CMakeLists.txt.orig -+++ src/nvim/CMakeLists.txt -@@ -366,10 +366,6 @@ endforeach() - - # Our dependencies come first. - --if (CMAKE_SYSTEM_NAME MATCHES "OpenBSD") -- list(APPEND NVIM_LINK_LIBRARIES pthread c++abi) --endif() -- - if (LibIntl_FOUND) - list(APPEND NVIM_LINK_LIBRARIES ${LibIntl_LIBRARY}) - endif() Index: patches/patch-static-deps_luajit_src_host_buildvm_asm_c =================================================================== RCS file: patches/patch-static-deps_luajit_src_host_buildvm_asm_c diff -N patches/patch-static-deps_luajit_src_host_buildvm_asm_c --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ patches/patch-static-deps_luajit_src_host_buildvm_asm_c 2 Oct 2021 10:10:22 -0000 @@ -0,0 +1,16 @@ +$OpenBSD$ + +.gnu_attribute requires binutils 2.18 + +Index: static-deps/luajit/src/host/buildvm_asm.c +--- static-deps/luajit/src/host/buildvm_asm.c.orig ++++ static-deps/luajit/src/host/buildvm_asm.c +@@ -327,7 +327,7 @@ void emit_asm(BuildCtx *ctx) + #if !(LJ_TARGET_PS3 || LJ_TARGET_PSVITA) + fprintf(ctx->fp, "\t.section .note.GNU-stack,\"\"," ELFASM_PX "progbits\n"); + #endif +-#if LJ_TARGET_PPC && !LJ_TARGET_PS3 && !LJ_ABI_SOFTFP ++#if 0 || LJ_TARGET_PPC && !LJ_TARGET_PS3 && !LJ_ABI_SOFTFP + /* Hard-float ABI. */ + fprintf(ctx->fp, "\t.gnu_attribute 4, 1\n"); + #endif Index: patches/patch-static-deps_luajit_src_lj_arch_h =================================================================== RCS file: patches/patch-static-deps_luajit_src_lj_arch_h diff -N patches/patch-static-deps_luajit_src_lj_arch_h --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ patches/patch-static-deps_luajit_src_lj_arch_h 2 Oct 2021 10:10:22 -0000 @@ -0,0 +1,18 @@ +$OpenBSD$ + +Our base-clang poses as gcc-4.2.1, but building with clang on powerpc +"requires" gcc>=4.3, unlike other archs requiring lower versions. Instead, +ignore the gcc version check ifdef hell for all base-clang arches. + +Index: static-deps/luajit/src/lj_arch.h +--- static-deps/luajit/src/lj_arch.h.orig ++++ static-deps/luajit/src/lj_arch.h +@@ -427,7 +427,7 @@ + /* -- Checks for requirements --------------------------------------------- */ + + /* Check for minimum required compiler versions. */ +-#if defined(__GNUC__) ++#if defined(__GNUC__) && !defined(__clang__) + #if LJ_TARGET_X86 + #if (__GNUC__ < 3) || ((__GNUC__ == 3) && __GNUC_MINOR__ < 4) + #error "Need at least GCC 3.4 or newer" Index: pkg/PLIST =================================================================== RCS file: /cvs/ports/editors/neovim/pkg/PLIST,v retrieving revision 1.9 diff -u -p -r1.9 PLIST --- pkg/PLIST 18 Jul 2021 09:18:07 -0000 1.9 +++ pkg/PLIST 4 Oct 2021 10:55:15 -0000 @@ -4,10 +4,6 @@ lib/nvim/ @man man/man1/nvim.1 share/applications/nvim.desktop share/doc/pkg-readmes/${PKGSTEM} -share/icons/ -share/icons/hicolor/ -share/icons/hicolor/128x128/ -share/icons/hicolor/128x128/apps/ share/icons/hicolor/128x128/apps/nvim.png share/locale/af/LC_MESSAGES/nvim.mo share/locale/ca/LC_MESSAGES/nvim.mo @@ -844,6 +840,7 @@ share/nvim/runtime/lua/vim/highlight.lua share/nvim/runtime/lua/vim/inspect.lua share/nvim/runtime/lua/vim/lsp/ share/nvim/runtime/lua/vim/lsp.lua +share/nvim/runtime/lua/vim/lsp/_snippet.lua share/nvim/runtime/lua/vim/lsp/buf.lua share/nvim/runtime/lua/vim/lsp/codelens.lua share/nvim/runtime/lua/vim/lsp/diagnostic.lua @@ -1610,3 +1607,4 @@ share/nvim/runtime/tutor/en/vim-01-begin share/nvim/runtime/tutor/tutor.tutor share/nvim/runtime/tutor/tutor.tutor.json @tag update-desktop-database +@tag gtk-update-icon-cache %D/share/icons/hicolor Index: pkg/README =================================================================== RCS file: /cvs/ports/editors/neovim/pkg/README,v retrieving revision 1.3 diff -u -p -r1.3 README --- pkg/README 4 Sep 2018 12:46:11 -0000 1.3 +++ pkg/README 4 Oct 2021 11:41:43 -0000 @@ -4,22 +4,14 @@ $OpenBSD: README,v 1.3 2018/09/04 12:46: | Running ${PKGSTEM} on OpenBSD +------------------------------------------------------------------------------- +LuaJIT Support +============== + +Some Neovim plugins now require LuaJIT. Those plugins won't work on +architectures that have no LuaJIT support. + Why is the Escape Key Not Working Right? ======================================== If you use Neovim under tmux, you are likely being bitten by a libtermkey bug. Read the libtermkey package README for a workaround. - -Migrating from Vim to Neovim -============================ - -Note that in Neovim some paths are different from traditional vim. The config -dir is ~/.config/nvim, and the main config file is ~/.config/nvim/init.vim. You -can symlink your existing traditional vim config and directory to the new -paths, and this will work. - -The first time you invoke nvim, run ':checkhealth' to see what else you might -need to do to migrate. - -Please note that ':checkhealth' was called ':CheckHealth' (with different -capitalisation) prior to neovim version 0.3.0. -- Best Regards Edd Barrett https://www.theunixzoo.co.uk
