# -*- coding: utf-8; mode: tcl; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- vim:fenc=utf-8:ft=tcl:et:sw=4:ts=4:sts=4

PortSystem              1.0
PortGroup               github 1.0
PortGroup               cmake 1.1

github.setup            neovim neovim 0.11.0 v
revision                0
categories              editors
platforms               {darwin >= 15}
maintainers             {l2dy @l2dy} \
                        {judaew @judaew} \
                        openmaintainer
license                 Apache-2 Vim GPL-2+

conflicts               neovim-devel

description             Neovim is a aggressively refactored fork of Vim

long_description \
    Neovim is a project that seeks to aggressively refactor Vim. It already adds \
    a new plugin architecture, job control, and a remote API.

homepage                https://neovim.io

github.tarball_from     archive
checksums               rmd160  454f3f3caeb1fa82b5f3396978efc0195c71577d \
                        sha256  6826c4812e96995d29a98586d44fbee7c9b2045485d50d174becd6d5242b3319 \
                        size    12901255

depends_build-append    port:pkgconfig

depends_lib             port:gettext \
                        port:libuv \
                        port:unibilium \
                        path:lib/libluajit-5.1.2.dylib:luajit \
                        port:lua51-lpeg \
                        port:luv-luajit \
                        port:libiconv \
                        port:libutf8proc \
                        port:tree-sitter

cmake.build_type        Release

configure.args-append   -DLUA_PRG=${prefix}/bin/luajit

patch.pre_args-replace  -p0 -p1

# Building parsers is normally an extra step, see https://github.com/neovim/neovim/issues/29042
patchfiles              0001-build-and-install-tree-sitter-parsers.patch \
                        0002-include-lua51-headers-to-build-properly.patch

post-patch {
    reinplace "s|@PREFIX@|${prefix}|g" ${worksrcpath}/CMakeLists.txt

    # workaround for https://github.com/neovim/neovim/pull/30749
    reinplace "s|lpeg.so lpeg\${CMAKE_SHARED_LIBRARY_SUFFIX}|lpeg\${CMAKE_SHARED_LIBRARY_SUFFIX} lpeg.so|g" ${worksrcpath}/cmake/FindLpeg.cmake
}

subport neovim-devel {
    github.setup    neovim neovim ae98d0a560b08d901ee9aae85df634de0ae3fe0a
    version         20250328-[string range ${github.version} 0 6]
    revision        0

    github.tarball_from tarball
    checksums       rmd160  851cd14a3d5cde7eca7bfb98c2ebc40b323aa36e \
                    sha256  eb8f99f501d587a9493dd526bc3e9109ff2c1783d85f34d2971b2a62b60de5dd \
                    size    12909640

    conflicts       neovim

    livecheck.url   ${github.homepage}/commits/nightly.atom
}

notes {
    If you would like to re-use your existing Vim configuration with Neovim,
    follow the advice in `:help nvim-from-vim`:

        nvim -c 'tab h nvim-from-vim'

    For a full list of differences with Vim, read `:help vim-differences`.
}
