diff options
author | V3n3RiX <venerix@koprulu.sector> | 2022-06-29 12:04:12 +0100 |
---|---|---|
committer | V3n3RiX <venerix@koprulu.sector> | 2022-06-29 12:04:12 +0100 |
commit | 0f558761aa2dee1017b4751e4017205e015a9560 (patch) | |
tree | 037df795519468a25d9362b4e95cdaeb84eb1cf9 /eclass/vim-plugin.eclass | |
parent | 752d6256e5204b958b0ef7905675a940b5e9172f (diff) |
gentoo resync : 29.12.2022
Diffstat (limited to 'eclass/vim-plugin.eclass')
-rw-r--r-- | eclass/vim-plugin.eclass | 122 |
1 files changed, 101 insertions, 21 deletions
diff --git a/eclass/vim-plugin.eclass b/eclass/vim-plugin.eclass index 50e727e98f4e..edf1c94d31b1 100644 --- a/eclass/vim-plugin.eclass +++ b/eclass/vim-plugin.eclass @@ -1,10 +1,10 @@ -# Copyright 1999-2021 Gentoo Authors +# Copyright 1999-2022 Gentoo Authors # Distributed under the terms of the GNU General Public License v2 # @ECLASS: vim-plugin.eclass # @MAINTAINER: # vim@gentoo.org -# @SUPPORTED_EAPIS: 6 7 +# @SUPPORTED_EAPIS: 6 7 8 # @BLURB: used for installing vim plugins # @DESCRIPTION: # This eclass simplifies installation of app-vim plugins into @@ -13,14 +13,19 @@ # documentation, for which we make a special case via vim-doc.eclass. case ${EAPI} in - 6|7);; - *) die "EAPI ${EAPI:-0} unsupported (too old)";; + 6|7) ;; + 8) _DEFINE_VIM_PLUGIN_SRC_PREPARE=true ;; + *) die "${ECLASS}: EAPI ${EAPI:-0} not supported" ;; esac +if [[ ! ${_VIM_PLUGIN_ECLASS} ]]; then + inherit vim-doc -EXPORT_FUNCTIONS src_install pkg_postinst pkg_postrm -VIM_PLUGIN_VIM_VERSION="${VIM_PLUGIN_VIM_VERSION:-7.3}" +# @ECLASS_VARIABLE: VIM_PLUGIN_VIM_VERSION +# @DESCRIPTION: +# Minimum Vim version the plugin supports. +: ${VIM_PLUGIN_VIM_VERSION:=7.3} DEPEND="|| ( >=app-editors/vim-${VIM_PLUGIN_VIM_VERSION} >=app-editors/gvim-${VIM_PLUGIN_VIM_VERSION} )" @@ -31,14 +36,59 @@ if [[ ${PV} != 9999* ]] ; then fi SLOT="0" +if [[ ${_DEFINE_VIM_PLUGIN_SRC_PREPARE} ]]; then +# @FUNCTION: vim-plugin_src_prepare +# @USAGE: +# @DESCRIPTION: +# Moves "after/syntax" plugins to directories to avoid file collisions with +# other packages. +# Note that this function is only defined and exported in EAPIs >= 8. +vim-plugin_src_prepare() { + debug-print-function ${FUNCNAME} "${@}" + + default_src_prepare + + # return if there's nothing to do + [[ -d after/syntax ]] || return + + pushd after/syntax >/dev/null || die + for file in *.vim; do + [[ -f "${file}" ]] || continue + mkdir "${file%.vim}" || die + mv "${file}" "${file%.vim}/${PN}.vim" || die + done + popd >/dev/null || die +} +fi + +# @ECLASS_VARIABLE: _VIM_PLUGIN_ALLOWED_DIRS +# @INTERNAL +# @DESCRIPTION: +# Vanilla Vim dirs. +# See /usr/share/vim/vim* for reference. +_VIM_PLUGIN_ALLOWED_DIRS=( + after autoload colors compiler doc ftdetect ftplugin indent keymap + macros plugin spell syntax +) + # @FUNCTION: vim-plugin_src_install +# @USAGE: [<dir>...] # @DESCRIPTION: # Overrides the default src_install phase. In order, this function: -# * fixes file permission across all files in ${S}. +# # * installs help and documentation files. -# * installs all files in "${ED}"/usr/share/vim/vimfiles. +# +# * installs all files recognized by default Vim installation and directories +# passed to this function as arguments in "${ED}"/usr/share/vim/vimfiles. +# +# Example use: +# @CODE +# src_install() { +# vim-plugin_src_install syntax_checkers +# } +# @CODE vim-plugin_src_install() { - has "${EAPI:-0}" 0 1 2 && ! use prefix && ED="${D}" + debug-print-function ${FUNCNAME} "${@}" # Install non-vim-help-docs einstalldocs @@ -46,21 +96,35 @@ vim-plugin_src_install() { # Install remainder of plugin insinto /usr/share/vim/vimfiles/ local d - for d in *; do - [[ -d "${d}" ]] || continue - doins -r "${d}" - done + case ${EAPI:-0} in + 6|7) + for d in *; do + [[ -d "${d}" ]] || continue + doins -r "${d}" + done ;; + *) + for d in "${_VIM_PLUGIN_ALLOWED_DIRS[@]}" "${@}"; do + [[ -d "${d}" ]] || continue + doins -r "${d}" + done ;; + esac } # @FUNCTION: vim-plugin_pkg_postinst +# @USAGE: # @DESCRIPTION: # Overrides the pkg_postinst phase for this eclass. # The following functions are called: +# # * update_vim_helptags +# # * update_vim_afterscripts +# # * display_vim_plugin_help vim-plugin_pkg_postinst() { - update_vim_helptags # from vim-doc + debug-print-function ${FUNCNAME} "${@}" + + update_vim_helptags # from vim-doc update_vim_afterscripts # see below display_vim_plugin_help # see below } @@ -71,8 +135,9 @@ vim-plugin_pkg_postinst() { # This function calls the update_vim_helptags and update_vim_afterscripts # functions and eventually removes a bunch of empty directories. vim-plugin_pkg_postrm() { - has "${EAPI:-0}" 0 1 2 && ! use prefix && EPREFIX= - update_vim_helptags # from vim-doc + debug-print-function ${FUNCNAME} "${@}" + + update_vim_helptags # from vim-doc update_vim_afterscripts # see below # Remove empty dirs; this allows @@ -82,25 +147,26 @@ vim-plugin_pkg_postrm() { } # @FUNCTION: update_vim_afterscripts +# @USAGE: # @DESCRIPTION: # Creates scripts in /usr/share/vim/vimfiles/after/* # comprised of the snippets in /usr/share/vim/vimfiles/after/*/*.d update_vim_afterscripts() { - has "${EAPI:-0}" 0 1 2 && ! use prefix && EROOT="${ROOT}" - has "${EAPI:-0}" 0 1 2 && ! use prefix && EPREFIX= + debug-print-function ${FUNCNAME} "${@}" + local d f afterdir="${EROOT}"/usr/share/vim/vimfiles/after # Nothing to do if the dir isn't there - [ -d "${afterdir}" ] || return 0 + [[ -d "${afterdir}" ]] || return 0 - einfo "Updating scripts in ${EPREFIX}/usr/share/vim/vimfiles/after" + einfo "Updating scripts in ${afterdir}" find "${afterdir}" -type d -name \*.vim.d | while read d; do echo '" Generated by update_vim_afterscripts' > "${d%.d}" || die find "${d}" -name \*.vim -type f -maxdepth 1 -print0 | sort -z | \ xargs -0 cat >> "${d%.d}" || die "update_vim_afterscripts failed" done - einfo "Removing dead scripts in ${EPREFIX}/usr/share/vim/vimfiles/after" + einfo "Removing dead scripts in ${afterdir}" find "${afterdir}" -type f -name \*.vim | \ while read f; do [[ "$(head -n 1 ${f})" == '" Generated by update_vim_afterscripts' ]] \ @@ -115,6 +181,7 @@ update_vim_afterscripts() { } # @FUNCTION: display_vim_plugin_help +# @USAGE: # @DESCRIPTION: # Displays a message with the plugin's help file if one is available. Uses the # VIM_PLUGIN_HELPFILES env var. If multiple help files are available, they @@ -124,6 +191,8 @@ update_vim_afterscripts() { # extra message regarding enabling filetype plugins is displayed if # VIM_PLUGIN_MESSAGES includes the word "filetype". display_vim_plugin_help() { + debug-print-function ${FUNCNAME} "${@}" + local h if [[ -z ${REPLACING_VERSIONS} ]]; then @@ -160,3 +229,14 @@ display_vim_plugin_help() { fi fi } + +_VIM_PLUGIN_ECLASS=1 +fi + +EXPORT_FUNCTIONS src_install pkg_postinst pkg_postrm + +# src_prepare is only exported in EAPI >= 8 +case ${EAPI} in + 6|7) ;; + *) EXPORT_FUNCTIONS src_prepare ;; +esac |