neovim-9999.ebuild 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141
  1. # Copyright 1999-2024 Gentoo Authors
  2. # Distributed under the terms of the GNU General Public License v2
  3. EAPI=8
  4. LUA_COMPAT=( lua5-{1..2} luajit )
  5. inherit cmake lua-single optfeature xdg
  6. DESCRIPTION="Vim-fork focused on extensibility and agility"
  7. HOMEPAGE="https://neovim.io"
  8. if [[ ${PV} == 9999 ]]; then
  9. inherit git-r3
  10. EGIT_REPO_URI="https://github.com/neovim/neovim.git"
  11. else
  12. SRC_URI="https://github.com/neovim/neovim/archive/v${PV}.tar.gz -> ${P}.tar.gz"
  13. KEYWORDS="~amd64 ~arm ~arm64 ~ppc64 ~riscv ~x86 ~x64-macos"
  14. fi
  15. LICENSE="Apache-2.0 vim"
  16. SLOT="0"
  17. IUSE="debug doc lint +lto +nvimpager test"
  18. # Upstream say the test library needs LuaJIT
  19. # https://github.com/neovim/neovim/blob/91109ffda23d0ce61cec245b1f4ffb99e7591b62/CMakeLists.txt#L377
  20. REQUIRED_USE="${LUA_REQUIRED_USE} test? ( lua_single_target_luajit )"
  21. # TODO: Get tests running
  22. RESTRICT="!test? ( test ) test"
  23. # Upstream build scripts invoke the Lua interpreter
  24. BDEPEND="${LUA_DEPS}
  25. >=dev-util/gperf-3.1
  26. >=sys-devel/gettext-0.20.1
  27. virtual/libiconv
  28. virtual/libintl
  29. virtual/pkgconfig
  30. "
  31. # Check https://github.com/neovim/neovim/blob/master/third-party/CMakeLists.txt for
  32. # new dependency bounds and so on on bumps (obviously adjust for right branch/tag).
  33. DEPEND="${LUA_DEPS}
  34. >=dev-lua/luv-1.45.0[${LUA_SINGLE_USEDEP}]
  35. $(lua_gen_cond_dep '
  36. dev-lua/lpeg[${LUA_USEDEP}]
  37. dev-lua/mpack[${LUA_USEDEP}]
  38. dev-lua/busted[${LUA_USEDEP}]
  39. ')
  40. $(lua_gen_cond_dep '
  41. dev-lua/LuaBitOp[${LUA_USEDEP}]
  42. ' lua5-{1,2})
  43. >=dev-libs/libuv-1.46.0:=
  44. >=dev-libs/libvterm-0.3.3
  45. >=dev-libs/msgpack-3.0.0:=
  46. >=dev-libs/tree-sitter-0.20.8:=
  47. >=dev-libs/libtermkey-0.22
  48. >=dev-libs/unibilium-2.0.0:0=
  49. dev-util/uncrustify
  50. lint? (
  51. dev-util/shellcheck
  52. dev-util/stylua
  53. )
  54. "
  55. RDEPEND="
  56. ${DEPEND}
  57. app-eselect/eselect-vi
  58. "
  59. BDEPEND+="
  60. test? (
  61. $(lua_gen_cond_dep 'dev-lua/busted[${LUA_USEDEP}]')
  62. )
  63. "
  64. PATCHES=(
  65. "${FILESDIR}/${PN}-9999-cmake_lua_version.patch"
  66. "${FILESDIR}/${P}-cmake-darwin.patch"
  67. )
  68. if [[ ${PV} != 9999 ]]; then
  69. PATCHES+=(
  70. "${FILESDIR}/${PN}-0.9.0-cmake-release-type.patch"
  71. )
  72. fi
  73. src_prepare() {
  74. if [[ ${PV} != 9999 ]]; then
  75. use doc || eapply "${FILESDIR}/${P}-cmake-no-doc.patch"
  76. else
  77. use doc || ( sed -e '/file(GLOB DOCFILES CONFIGURE_DEPENDS ${PROJECT_SOURCE_DIR}/runtime/doc/*.txt)/d' -i CMakeLists.txt || die )
  78. fi
  79. # Use our system vim dir
  80. sed -e "/^# define SYS_VIMRC_FILE/s|\$VIM|${EPREFIX}/etc/vim|" \
  81. -i src/nvim/globals.h || die
  82. # https://forums.gentoo.org/viewtopic-p-8750050.html
  83. xdg_environment_reset
  84. cmake_src_prepare
  85. }
  86. src_configure() {
  87. # Upstream default to LTO on non-debug builds
  88. # Let's expose it as a USE flag because upstream
  89. # have preferences for how we should use LTO
  90. # if we want it on (not just -flto)
  91. # ... but allow turning it off.
  92. # TODO: Investigate USE_BUNDLED, doesn't seem to be needed right now
  93. CMAKE_BUILD_TYPE=$(usex debug RelWithDebInfo Release)
  94. local mycmakeargs=(
  95. -DENABLE_LTO=$(usex lto)
  96. -DPREFER_LUA=$(usex lua_single_target_luajit no "$(lua_get_version)")
  97. -DLUA_PRG="${ELUA}"
  98. -DLUA_GEN_PRG="${ELUA}"
  99. -DUSE_BUNDLED_BUSTED=0
  100. -DCOMPILE_LUA=0
  101. -DCI_LINT=$(usex lint)
  102. )
  103. cmake_src_configure
  104. }
  105. src_install() {
  106. cmake_src_install
  107. # install a default configuration file
  108. insinto /etc/vim
  109. doins "${FILESDIR}"/sysinit.vim
  110. # conditionally install a symlink for nvimpager
  111. if use nvimpager; then
  112. dosym ../share/nvim/runtime/macros/less.sh /usr/bin/nvimpager
  113. fi
  114. }
  115. pkg_postinst() {
  116. xdg_pkg_postinst
  117. optfeature "clipboard support" x11-misc/xsel x11-misc/xclip gui-apps/wl-clipboard
  118. optfeature "Python plugin support" dev-python/pynvim
  119. optfeature "Ruby plugin support" dev-ruby/neovim-ruby-client
  120. optfeature "remote/nvr support" dev-python/neovim-remote
  121. }