From 5018089435e00320314ce4cb64f039f3d8845bc3 Mon Sep 17 00:00:00 2001 From: odrling Date: Thu, 21 Jul 2022 16:31:24 +0200 Subject: [PATCH] Revert "app-editors/neovim: remove ebuild" This reverts commit 31f77ff345599de3cc407b8a9d3b69b4fe0009a5. --- .../neovim-0.4.4-cmake-release-type.patch | 13 ++ .../files/neovim-9999-cmake_lua_version.patch | 11 ++ app-editors/neovim/files/sysinit.vim | 104 +++++++++++++++ app-editors/neovim/metadata.xml | 16 +++ app-editors/neovim/neovim-9999.ebuild | 123 ++++++++++++++++++ 5 files changed, 267 insertions(+) create mode 100644 app-editors/neovim/files/neovim-0.4.4-cmake-release-type.patch create mode 100644 app-editors/neovim/files/neovim-9999-cmake_lua_version.patch create mode 100644 app-editors/neovim/files/sysinit.vim create mode 100644 app-editors/neovim/metadata.xml create mode 100644 app-editors/neovim/neovim-9999.ebuild diff --git a/app-editors/neovim/files/neovim-0.4.4-cmake-release-type.patch b/app-editors/neovim/files/neovim-0.4.4-cmake-release-type.patch new file mode 100644 index 0000000..2c9c80a --- /dev/null +++ b/app-editors/neovim/files/neovim-0.4.4-cmake-release-type.patch @@ -0,0 +1,13 @@ +Ensure that :checkhealth is happy with the Gentoo build type. +https://bugs.gentoo.org/757744 +--- a/runtime/autoload/health/nvim.vim ++++ b/runtime/autoload/health/nvim.vim +@@ -118,7 +118,7 @@ function! s:check_performance() abort + let buildtype = matchstr(execute('version'), '\v\cbuild type:?\s*[^\n\r\t ]+') + if empty(buildtype) + call health#report_error('failed to get build type from :version') +- elseif buildtype =~# '\v(MinSizeRel|Release|RelWithDebInfo)' ++ elseif buildtype =~# '\v(MinSizeRel|Release|RelWithDebInfo|Gentoo)' + call health#report_ok(buildtype) + else + call health#report_info(buildtype) diff --git a/app-editors/neovim/files/neovim-9999-cmake_lua_version.patch b/app-editors/neovim/files/neovim-9999-cmake_lua_version.patch new file mode 100644 index 0000000..d7e0127 --- /dev/null +++ b/app-editors/neovim/files/neovim-9999-cmake_lua_version.patch @@ -0,0 +1,11 @@ +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -384,7 +384,7 @@ + option(PREFER_LUA "Prefer Lua over LuaJIT in the nvim executable." OFF) + + if(PREFER_LUA) +- find_package(Lua 5.1 EXACT REQUIRED) ++ find_package(Lua ${PREFER_LUA} EXACT REQUIRED) + set(LUA_PREFERRED_INCLUDE_DIRS ${LUA_INCLUDE_DIR}) + set(LUA_PREFERRED_LIBRARIES ${LUA_LIBRARIES}) + # Passive (not REQUIRED): if LUAJIT_FOUND is not set, nvim-test is skipped. diff --git a/app-editors/neovim/files/sysinit.vim b/app-editors/neovim/files/sysinit.vim new file mode 100644 index 0000000..92b802f --- /dev/null +++ b/app-editors/neovim/files/sysinit.vim @@ -0,0 +1,104 @@ +" Default Gentoo configuration file for neovim +" Based on the default vimrc shipped by Gentoo with app-editors/vim-core + +" You can override any of these settings on a global basis via the +" "/etc/vim/nvimrc.local" file, and on a per-user basis via "~/.nvimrc". +" You may need to create these. + +" Neovim comes with sensible defaults, see: +" https://github.com/neovim/neovim/issues/2676 +" Most of the general settings from Gentoo's vimrc have been dropped here. +" We add only some necessary fixes and a few Gentoo specific settings. + +" {{{ Locale settings +" If we have a BOM, always honour that rather than trying to guess. +if &fileencodings !~? "ucs-bom" + set fileencodings^=ucs-bom +endif + +" Always check for UTF-8 when trying to determine encodings. +if &fileencodings !~? "utf-8" + " If we have to add this, the default encoding is not Unicode. + let g:added_fenc_utf8 = 1 + set fileencodings+=utf-8 +endif +" }}} + +" {{{ Fix &shell, see bug #101665. +if "" == &shell + if executable("/bin/bash") + set shell=/bin/bash + elseif executable("/bin/sh") + set shell=/bin/sh + endif +endif +"}}} + +" {{{ Our default /bin/sh is bash, not ksh, so syntax highlighting for .sh +" files should default to bash. See :help sh-syntax and bug #101819. +if has("eval") + let is_bash=1 +endif +" }}} + +" {{{ Autocommands +if has("autocmd") + +augroup gentoo + au! + + " Gentoo-specific settings for ebuilds. These are the federally-mandated + " required tab settings. See the following for more information: + " http://www.gentoo.org/proj/en/devrel/handbook/handbook.xml + " Note that the rules below are very minimal and don't cover everything. + " Better to emerge app-vim/gentoo-syntax, which provides full syntax, + " filetype and indent settings for all things Gentoo. + au BufRead,BufNewFile *.e{build,class} set ts=4 sw=4 noexpandtab + + " In text files, limit the width of text to 78 characters, but be careful + " that we don't override the user's setting. + autocmd BufNewFile,BufRead *.txt + \ if &tw == 0 && ! exists("g:leave_my_textwidth_alone") | + \ setlocal textwidth=78 | + \ endif + + " When editing a file, always jump to the last cursor position + autocmd BufReadPost * + \ if ! exists("g:leave_my_cursor_position_alone") | + \ if line("'\"") > 0 && line ("'\"") <= line("$") | + \ exe "normal g'\"" | + \ endif | + \ endif + + " When editing a crontab file, set backupcopy to yes rather than auto. See + " :help crontab and bug #53437. + autocmd FileType crontab set backupcopy=yes + + " If we previously detected that the default encoding is not UTF-8 + " (g:added_fenc_utf8), assume that a file with only ASCII characters (or no + " characters at all) isn't a Unicode file, but is in the default encoding. + " Except of course if a byte-order mark is in effect. + autocmd BufReadPost * + \ if exists("g:added_fenc_utf8") && &fileencoding == "utf-8" && + \ ! &bomb && search('[\x80-\xFF]','nw') == 0 && &modifiable | + \ set fileencoding= | + \ endif + + " Strip trailing spaces on write + autocmd BufWritePre *.e{build,class} + \ if ! exists("g:leave_my_trailing_space_alone") | + \ :%s/\s\+$//e | + \ endif + +augroup END + +endif " has("autocmd") +" }}} + +" {{{ nvimrc.local +if filereadable("/etc/vim/nvimrc.local") + source /etc/vim/nvimrc.local +endif +" }}} + +" vim: set tw=80 sw=2 sts=2 et foldmethod=marker : diff --git a/app-editors/neovim/metadata.xml b/app-editors/neovim/metadata.xml new file mode 100644 index 0000000..555238c --- /dev/null +++ b/app-editors/neovim/metadata.xml @@ -0,0 +1,16 @@ + + + + + vim@gentoo.org + Gentoo Vim Project + + + Build with Link Time Optimization (LTO) + Install nvimpager symlink to less.sh macro + Build the neovim unix tui + + + neovim/neovim + + diff --git a/app-editors/neovim/neovim-9999.ebuild b/app-editors/neovim/neovim-9999.ebuild new file mode 100644 index 0000000..36b222a --- /dev/null +++ b/app-editors/neovim/neovim-9999.ebuild @@ -0,0 +1,123 @@ +# Copyright 1999-2022 Gentoo Authors +# Distributed under the terms of the GNU General Public License v2 + +EAPI=8 + +LUA_COMPAT=( lua5-{1..2} luajit ) + +inherit cmake lua-single optfeature xdg + +DESCRIPTION="Vim-fork focused on extensibility and agility" +HOMEPAGE="https://neovim.io" + +if [[ ${PV} == 9999 ]]; then + inherit git-r3 + EGIT_REPO_URI="https://github.com/neovim/neovim.git" +else + SRC_URI="https://github.com/neovim/neovim/archive/v${PV}.tar.gz -> ${P}.tar.gz" + KEYWORDS="~amd64 ~arm ~arm64 ~riscv ~x86 ~x64-macos" +fi + +LICENSE="Apache-2.0 vim" +SLOT="0" +IUSE="+lto +nvimpager test +tui" + +REQUIRED_USE="${LUA_REQUIRED_USE}" +# Upstream say the test library needs LuaJIT +# https://github.com/neovim/neovim/blob/91109ffda23d0ce61cec245b1f4ffb99e7591b62/CMakeLists.txt#L377 +REQUIRED_USE="test? ( lua_single_target_luajit )" +# TODO: Get tests running +RESTRICT="!test? ( test ) test" + +# Upstream build scripts invoke the Lua interpreter +BDEPEND="${LUA_DEPS} + >=dev-util/gperf-3.1 + virtual/libiconv + virtual/libintl + virtual/pkgconfig +" +# Check https://github.com/neovim/neovim/blob/master/third-party/CMakeLists.txt for +# new dependency bounds and so on on bumps (obviously adjust for right branch/tag). +DEPEND="${LUA_DEPS} + >=dev-lua/luv-1.43.0[${LUA_SINGLE_USEDEP}] + $(lua_gen_cond_dep ' + dev-lua/lpeg[${LUA_USEDEP}] + dev-lua/mpack[${LUA_USEDEP}] + ') + $(lua_gen_cond_dep ' + dev-lua/LuaBitOp[${LUA_USEDEP}] + ' lua5-{1,2}) + >=dev-libs/libuv-1.44.1:= + >=dev-libs/libvterm-0.1.4 + >=dev-libs/msgpack-3.0.0:= + >=dev-libs/tree-sitter-0.20.6:= + tui? ( + >=dev-libs/libtermkey-0.22 + >=dev-libs/unibilium-2.0.0:0= + ) +" +RDEPEND=" + ${DEPEND} + app-eselect/eselect-vi +" +BDEPEND=" + test? ( + $(lua_gen_cond_dep 'dev-lua/busted[${LUA_USEDEP}]') + ) +" + +PATCHES=( + "${FILESDIR}/${PN}-0.4.4-cmake-release-type.patch" +) +if [[ ${PV} == 9999 ]]; then + PATCHES+=("${FILESDIR}/${PN}-9999-cmake_lua_version.patch") +else + PATCHES+=("${FILESDIR}/${PN}-0.4.4-cmake_lua_version.patch") +fi + +src_prepare() { + # Use our system vim dir + sed -e "/^# define SYS_VIMRC_FILE/s|\$VIM|${EPREFIX}/etc/vim|" \ + -i src/nvim/globals.h || die + + cmake_src_prepare +} + +src_configure() { + # Upstream default to LTO on non-debug builds + # Let's expose it as a USE flag because upstream + # have preferences for how we should use LTO + # if we want it on (not just -flto) + # ... but allow turning it off. + # TODO: Investigate USE_BUNDLED, doesn't seem to be needed right now + local mycmakeargs=( + -DENABLE_LTO=$(usex lto) + -DFEAT_TUI=$(usex tui) + -DPREFER_LUA=$(usex lua_single_target_luajit no "$(lua_get_version)") + -DLUA_PRG="${ELUA}" + -DMIN_LOG_LEVEL=3 + ) + cmake_src_configure +} + +src_install() { + cmake_src_install + + # install a default configuration file + insinto /etc/vim + doins "${FILESDIR}"/sysinit.vim + + # conditionally install a symlink for nvimpager + if use nvimpager; then + dosym ../share/nvim/runtime/macros/less.sh /usr/bin/nvimpager + fi +} + +pkg_postinst() { + xdg_pkg_postinst + + optfeature "clipboard support" x11-misc/xsel x11-misc/xclip gui-apps/wl-clipboard + optfeature "Python plugin support" dev-python/pynvim + optfeature "Ruby plugin support" dev-ruby/neovim-ruby-client + optfeature "remote/nvr support" dev-python/neovim-remote +}