* [gentoo-dev] [PATCH v5 0/9] Vim eclasses
@ 2022-04-11 12:32 Anna Vyalkova
2022-04-11 12:32 ` [gentoo-dev] [PATCH v5 1/9] vim-doc.eclass: support EAPI 8 Anna Vyalkova
` (8 more replies)
0 siblings, 9 replies; 16+ messages in thread
From: Anna Vyalkova @ 2022-04-11 12:32 UTC (permalink / raw
To: gentoo-dev; +Cc: vim
I hope this is the final one. Most changes are in "vim-doc.eclass".
Also available as a pull request:
https://github.com/gentoo/gentoo/pull/24941
^ permalink raw reply [flat|nested] 16+ messages in thread
* [gentoo-dev] [PATCH v5 1/9] vim-doc.eclass: support EAPI 8
2022-04-11 12:32 [gentoo-dev] [PATCH v5 0/9] Vim eclasses Anna Vyalkova
@ 2022-04-11 12:32 ` Anna Vyalkova
2022-04-11 12:32 ` [gentoo-dev] [PATCH v5 2/9] vim-plugin.eclass: " Anna Vyalkova
` (7 subsequent siblings)
8 siblings, 0 replies; 16+ messages in thread
From: Anna Vyalkova @ 2022-04-11 12:32 UTC (permalink / raw
To: gentoo-dev; +Cc: vim, Thomas Bracht Laumann Jespersen
From: Thomas Bracht Laumann Jespersen <t@laumann.xyz>
* Added "|| die" statements
* Create links only if they don't exist yet
* `readlink` -> `readlink -f`
* Quoted variables
Signed-off-by: Thomas Bracht Laumann Jespersen <t@laumann.xyz>
Signed-off-by: Anna Vyalkova <cyber+gentoo@sysrq.in>
---
eclass/vim-doc.eclass | 66 +++++++++++++++++++++++++------------------
1 file changed, 39 insertions(+), 27 deletions(-)
diff --git a/eclass/vim-doc.eclass b/eclass/vim-doc.eclass
index ba9d00f4f5..f0c5c6edc6 100644
--- a/eclass/vim-doc.eclass
+++ b/eclass/vim-doc.eclass
@@ -1,86 +1,98 @@
-# Copyright 1999-2021 Gentoo Authors
+# Copyright 1999-2022 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2
# @ECLASS: vim-doc.eclass
# @MAINTAINER:
# vim@gentoo.org
-# @SUPPORTED_EAPIS: 6 7
+# @SUPPORTED_EAPIS: 6 7 8
# @BLURB: Eclass for vim{,-plugin}.eclass to update documentation tags.
# @DESCRIPTION:
# This eclass is used by vim.eclass and vim-plugin.eclass to update
# the documentation tags. This is necessary since vim doesn't look in
# /usr/share/vim/vimfiles/doc for documentation; it only uses the
# versioned directory, for example /usr/share/vim/vim62/doc
#
# We depend on vim being installed, which is satisfied by either the
# DEPEND in vim-plugin or by whatever version of vim is being
# installed by the eclass.
-case ${EAPI:-0} in
- [67]) ;;
+case ${EAPI} in
+ 6|7|8) ;;
*) die "${ECLASS}: EAPI ${EAPI:-0} not supported" ;;
esac
-if [[ -z ${_VIM_DOC_ECLASS} ]] ; then
-_VIM_DOC_ECLASS=1
+if [[ ! ${_VIM_DOC_ECLASS} ]] ; then
update_vim_helptags() {
- local vimfiles vim d s
+ local vimfiles helpfile files vim d
# This is where vim plugins are installed
vimfiles="${EROOT}"/usr/share/vim/vimfiles
- if [[ $PN != vim-core ]]; then
+ if [[ ${PN} != vim-core ]]; then
# Find a suitable vim binary for updating tags :helptags
vim=$(type -P vim 2>/dev/null)
- [[ -z "$vim" ]] && vim=$(type -P gvim 2>/dev/null)
- [[ -z "$vim" ]] && vim=$(type -P kvim 2>/dev/null)
- if [[ -z "$vim" ]]; then
+ [[ -z "${vim}" ]] && vim=$(type -P gvim 2>/dev/null)
+ [[ -z "${vim}" ]] && vim=$(type -P kvim 2>/dev/null)
+ if [[ -z "${vim}" ]]; then
ewarn "No suitable vim binary to rebuild documentation tags"
fi
fi
# Make vim not try to connect to X. See :help gui-x11-start
# in vim for how this evil trickery works.
if [[ -n "${vim}" ]] ; then
- ln -s "${vim}" "${T}/tagvim"
+ ln -s "${vim}" "${T}/tagvim" || die
vim="${T}/tagvim"
fi
# Install the documentation symlinks into the versioned vim
# directory and run :helptags
for d in "${EROOT%/}"/usr/share/vim/vim[0-9]*; do
- [[ -d "$d/doc" ]] || continue # catch a failed glob
+ [[ -d "${d}/doc" ]] || continue # catch a failed glob
- # Remove links, and possibly remove stale dirs
- find $d/doc -name \*.txt -type l | while read s; do
- [[ $(readlink "$s") = $vimfiles/* ]] && rm -f "$s"
+ # Remove links
+ readarray -d '' files < <(find "${d}"/doc -name "*.txt" -type l -print0 || die "cannot traverse ${d}/doc" )
+ for helpfile in "${files[@]}"; do
+ if [[ $(readlink -f "${helpfile}") == "${vimfiles}"/* ]]; then
+ rm "${helpfile}" || die
+ fi
done
- if [[ -f "$d/doc/tags" && $(find "$d" | wc -l | tr -d ' ') = 3 ]]; then
+
+ # Remove stale dirs, if possible
+ readarray -d '' files < <(find "${d}" -print0 || die "cannot traverse ${d}")
+ if [[ -f "${d}/doc/tags" && ${#files[@]} -eq 3 ]]; then
# /usr/share/vim/vim61
# /usr/share/vim/vim61/doc
# /usr/share/vim/vim61/doc/tags
- einfo "Removing $d"
- rm -r "$d"
+ einfo "Removing ${d}"
+ rm -r "${d}" || die
continue
fi
# Re-create / install new links
- if [[ -d $vimfiles/doc ]]; then
- ln -s $vimfiles/doc/*.txt $d/doc 2>/dev/null
+ if [[ -d "${vimfiles}"/doc ]]; then
+ for helpfile in "${vimfiles}"/doc/*.txt; do
+ if [[ ! -e "${d}/doc/$(basename "${helpfile}")" ]]; then
+ ln -s "${helpfile}" "${d}/doc" || die
+ fi
+ done
fi
# Update tags; need a vim binary for this
- if [[ -n "$vim" ]]; then
- einfo "Updating documentation tags in $d"
- DISPLAY= $vim -u NONE -U NONE -T xterm -X -n -f \
+ if [[ -n "${vim}" ]]; then
+ einfo "Updating documentation tags in ${d}"
+ DISPLAY= "${vim}" -u NONE -U NONE -T xterm -X -n -f \
'+set nobackup nomore' \
- "+helptags $d/doc" \
- '+qa!' </dev/null &>/dev/null
+ "+helptags ${d}/doc" \
+ '+qa!' </dev/null &>/dev/null || die
fi
done
- [[ -n "${vim}" && -f "${vim}" ]] && rm "${vim}"
+ if [[ -n "${vim}" && -f "${vim}" ]]; then
+ rm "${vim}" || die
+ fi
}
+_VIM_DOC_ECLASS=1
fi
--
2.35.1
^ permalink raw reply related [flat|nested] 16+ messages in thread
* [gentoo-dev] [PATCH v5 2/9] vim-plugin.eclass: support EAPI 8
2022-04-11 12:32 [gentoo-dev] [PATCH v5 0/9] Vim eclasses Anna Vyalkova
2022-04-11 12:32 ` [gentoo-dev] [PATCH v5 1/9] vim-doc.eclass: support EAPI 8 Anna Vyalkova
@ 2022-04-11 12:32 ` Anna Vyalkova
2022-04-11 12:33 ` [gentoo-dev] [PATCH v5 3/9] vim-plugin.eclass: EAPI 8: install allowed dirs only Anna Vyalkova
` (6 subsequent siblings)
8 siblings, 0 replies; 16+ messages in thread
From: Anna Vyalkova @ 2022-04-11 12:32 UTC (permalink / raw
To: gentoo-dev; +Cc: vim, Thomas Bracht Laumann Jespersen
From: Thomas Bracht Laumann Jespersen <t@laumann.xyz>
* Drop EAPI 0, 1, 2 workarounds
* Move EXPORT_FUNCTIONS to end of file
* Add required @USAGE on functions
* Add _VIM_PLUGIN_ECLASS guard
Bug: https://bugs.gentoo.org/830867
Bug: https://bugs.gentoo.org/830866
Signed-off-by: Thomas Bracht Laumann Jespersen <t@laumann.xyz>
Signed-off-by: Anna Vyalkova <cyber+gentoo@sysrq.in>
---
eclass/vim-plugin.eclass | 35 ++++++++++++++++++++---------------
1 file changed, 20 insertions(+), 15 deletions(-)
diff --git a/eclass/vim-plugin.eclass b/eclass/vim-plugin.eclass
index 50e727e98f..a457f3a037 100644
--- a/eclass/vim-plugin.eclass
+++ b/eclass/vim-plugin.eclass
@@ -1,162 +1,167 @@
-# 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
# /usr/share/vim/vimfiles. This is a version-independent directory
# which is read automatically by vim. The only exception is
# 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) ;;
+ *) 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}"
DEPEND="|| ( >=app-editors/vim-${VIM_PLUGIN_VIM_VERSION}
>=app-editors/gvim-${VIM_PLUGIN_VIM_VERSION} )"
RDEPEND="${DEPEND}"
if [[ ${PV} != 9999* ]] ; then
SRC_URI="mirror://gentoo/${P}.tar.bz2
https://dev.gentoo.org/~radhermit/vim/${P}.tar.bz2"
fi
SLOT="0"
# @FUNCTION: vim-plugin_src_install
+# @USAGE:
# @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.
vim-plugin_src_install() {
- has "${EAPI:-0}" 0 1 2 && ! use prefix && ED="${D}"
-
# Install non-vim-help-docs
einstalldocs
# Install remainder of plugin
insinto /usr/share/vim/vimfiles/
local d
for d in *; do
[[ -d "${d}" ]] || continue
doins -r "${d}"
done
}
# @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
+ update_vim_helptags # from vim-doc
update_vim_afterscripts # see below
display_vim_plugin_help # see below
}
# @FUNCTION: vim-plugin_pkg_postrm
# @DESCRIPTION:
# Overrides the pkg_postrm phase for this eclass.
# 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
+ update_vim_helptags # from vim-doc
update_vim_afterscripts # see below
# Remove empty dirs; this allows
# /usr/share/vim to be removed if vim-core is unmerged
find "${EPREFIX}/usr/share/vim/vimfiles" -depth -type d -exec rmdir {} \; 2>/dev/null || \
die "rmdir failed"
}
# @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=
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' ]] \
|| continue
# This is a generated file, but might be abandoned. Check
# if there's no corresponding .d directory, or if the
# file's effectively empty
if [[ ! -d "${f}.d" || -z "$(grep -v '^"' "${f}")" ]]; then
rm "${f}" || die
fi
done
}
# @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
# should be separated by spaces. If no help files are available, but the env
# var VIM_PLUGIN_HELPTEXT is set, that is displayed instead. Finally, if we
# have nothing else, this functions displays a link to VIM_PLUGIN_HELPURI. An
# extra message regarding enabling filetype plugins is displayed if
# VIM_PLUGIN_MESSAGES includes the word "filetype".
display_vim_plugin_help() {
local h
if [[ -z ${REPLACING_VERSIONS} ]]; then
if [[ -n ${VIM_PLUGIN_HELPFILES} ]]; then
elog " "
elog "This plugin provides documentation via vim's help system. To"
elog "view it, use:"
for h in ${VIM_PLUGIN_HELPFILES}; do
elog " :help ${h}"
done
elog " "
elif [[ -n ${VIM_PLUGIN_HELPTEXT} ]]; then
elog " "
while read h ; do
elog "$h"
done <<<"${VIM_PLUGIN_HELPTEXT}"
elog " "
elif [[ -n ${VIM_PLUGIN_HELPURI} ]]; then
elog " "
elog "Documentation for this plugin is available online at:"
elog " ${VIM_PLUGIN_HELPURI}"
elog " "
fi
if has filetype ${VIM_PLUGIN_MESSAGES}; then
elog "This plugin makes use of filetype settings. To enable these,"
elog "add lines like:"
elog " filetype plugin on"
elog " filetype indent on"
elog "to your ~/.vimrc file."
elog " "
fi
fi
}
+
+_VIM_PLUGIN_ECLASS=1
+fi
+
+EXPORT_FUNCTIONS src_install pkg_postinst pkg_postrm
--
2.35.1
^ permalink raw reply related [flat|nested] 16+ messages in thread
* [gentoo-dev] [PATCH v5 3/9] vim-plugin.eclass: EAPI 8: install allowed dirs only
2022-04-11 12:32 [gentoo-dev] [PATCH v5 0/9] Vim eclasses Anna Vyalkova
2022-04-11 12:32 ` [gentoo-dev] [PATCH v5 1/9] vim-doc.eclass: support EAPI 8 Anna Vyalkova
2022-04-11 12:32 ` [gentoo-dev] [PATCH v5 2/9] vim-plugin.eclass: " Anna Vyalkova
@ 2022-04-11 12:33 ` Anna Vyalkova
2022-04-11 12:51 ` Thomas Bracht Laumann Jespersen
2022-04-11 12:33 ` [gentoo-dev] [PATCH v5 4/9] vim-plugin.eclass: EAPI 8: add src_prepare Anna Vyalkova
` (5 subsequent siblings)
8 siblings, 1 reply; 16+ messages in thread
From: Anna Vyalkova @ 2022-04-11 12:33 UTC (permalink / raw
To: gentoo-dev; +Cc: vim
Signed-off-by: Anna Vyalkova <cyber+gentoo@sysrq.in>
---
eclass/vim-plugin.eclass | 39 ++++++++++++++++++++++++++++++++-------
1 file changed, 32 insertions(+), 7 deletions(-)
diff --git a/eclass/vim-plugin.eclass b/eclass/vim-plugin.eclass
index a457f3a037..0c323e0d09 100644
--- a/eclass/vim-plugin.eclass
+++ b/eclass/vim-plugin.eclass
@@ -1,167 +1,192 @@
# 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 8
# @BLURB: used for installing vim plugins
# @DESCRIPTION:
# This eclass simplifies installation of app-vim plugins into
# /usr/share/vim/vimfiles. This is a version-independent directory
# which is read automatically by vim. The only exception is
# documentation, for which we make a special case via vim-doc.eclass.
case ${EAPI} in
6|7|8) ;;
*) die "${ECLASS}: EAPI ${EAPI:-0} not supported" ;;
esac
if [[ ! ${_VIM_PLUGIN_ECLASS} ]]; then
inherit vim-doc
VIM_PLUGIN_VIM_VERSION="${VIM_PLUGIN_VIM_VERSION:-7.3}"
DEPEND="|| ( >=app-editors/vim-${VIM_PLUGIN_VIM_VERSION}
>=app-editors/gvim-${VIM_PLUGIN_VIM_VERSION} )"
RDEPEND="${DEPEND}"
if [[ ${PV} != 9999* ]] ; then
SRC_URI="mirror://gentoo/${P}.tar.bz2
https://dev.gentoo.org/~radhermit/vim/${P}.tar.bz2"
fi
SLOT="0"
+# @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:
+# @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() {
# Install non-vim-help-docs
einstalldocs
# 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
update_vim_afterscripts # see below
display_vim_plugin_help # see below
}
# @FUNCTION: vim-plugin_pkg_postrm
# @DESCRIPTION:
# Overrides the pkg_postrm phase for this eclass.
# This function calls the update_vim_helptags and update_vim_afterscripts
# functions and eventually removes a bunch of empty directories.
vim-plugin_pkg_postrm() {
update_vim_helptags # from vim-doc
update_vim_afterscripts # see below
# Remove empty dirs; this allows
# /usr/share/vim to be removed if vim-core is unmerged
find "${EPREFIX}/usr/share/vim/vimfiles" -depth -type d -exec rmdir {} \; 2>/dev/null || \
die "rmdir failed"
}
# @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() {
local d f afterdir="${EROOT}"/usr/share/vim/vimfiles/after
# Nothing to do if the dir isn't there
[[ -d "${afterdir}" ]] || return 0
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 ${afterdir}"
find "${afterdir}" -type f -name \*.vim | \
while read f; do
[[ "$(head -n 1 ${f})" == '" Generated by update_vim_afterscripts' ]] \
|| continue
# This is a generated file, but might be abandoned. Check
# if there's no corresponding .d directory, or if the
# file's effectively empty
if [[ ! -d "${f}.d" || -z "$(grep -v '^"' "${f}")" ]]; then
rm "${f}" || die
fi
done
}
# @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
# should be separated by spaces. If no help files are available, but the env
# var VIM_PLUGIN_HELPTEXT is set, that is displayed instead. Finally, if we
# have nothing else, this functions displays a link to VIM_PLUGIN_HELPURI. An
# extra message regarding enabling filetype plugins is displayed if
# VIM_PLUGIN_MESSAGES includes the word "filetype".
display_vim_plugin_help() {
local h
if [[ -z ${REPLACING_VERSIONS} ]]; then
if [[ -n ${VIM_PLUGIN_HELPFILES} ]]; then
elog " "
elog "This plugin provides documentation via vim's help system. To"
elog "view it, use:"
for h in ${VIM_PLUGIN_HELPFILES}; do
elog " :help ${h}"
done
elog " "
elif [[ -n ${VIM_PLUGIN_HELPTEXT} ]]; then
elog " "
while read h ; do
elog "$h"
done <<<"${VIM_PLUGIN_HELPTEXT}"
elog " "
elif [[ -n ${VIM_PLUGIN_HELPURI} ]]; then
elog " "
elog "Documentation for this plugin is available online at:"
elog " ${VIM_PLUGIN_HELPURI}"
elog " "
fi
if has filetype ${VIM_PLUGIN_MESSAGES}; then
elog "This plugin makes use of filetype settings. To enable these,"
elog "add lines like:"
elog " filetype plugin on"
elog " filetype indent on"
elog "to your ~/.vimrc file."
elog " "
fi
fi
}
_VIM_PLUGIN_ECLASS=1
fi
EXPORT_FUNCTIONS src_install pkg_postinst pkg_postrm
--
2.35.1
^ permalink raw reply related [flat|nested] 16+ messages in thread
* [gentoo-dev] [PATCH v5 4/9] vim-plugin.eclass: EAPI 8: add src_prepare
2022-04-11 12:32 [gentoo-dev] [PATCH v5 0/9] Vim eclasses Anna Vyalkova
` (2 preceding siblings ...)
2022-04-11 12:33 ` [gentoo-dev] [PATCH v5 3/9] vim-plugin.eclass: EAPI 8: install allowed dirs only Anna Vyalkova
@ 2022-04-11 12:33 ` Anna Vyalkova
2022-04-11 12:53 ` Thomas Bracht Laumann Jespersen
2022-04-14 3:14 ` [gentoo-dev] [PATCH v5.5] " Anna Vyalkova
2022-04-11 12:33 ` [gentoo-dev] [PATCH v5 5/9] vim-plugin.eclass: document VIM_PLUGIN_VIM_VERSION Anna Vyalkova
` (4 subsequent siblings)
8 siblings, 2 replies; 16+ messages in thread
From: Anna Vyalkova @ 2022-04-11 12:33 UTC (permalink / raw
To: gentoo-dev; +Cc: vim
Signed-off-by: Anna Vyalkova <cyber+gentoo@sysrq.in>
---
eclass/vim-plugin.eclass | 39 ++++++++++++++++++++++++++++++++++++---
1 file changed, 36 insertions(+), 3 deletions(-)
diff --git a/eclass/vim-plugin.eclass b/eclass/vim-plugin.eclass
index 0c323e0d09..a7b5f258b0 100644
--- a/eclass/vim-plugin.eclass
+++ b/eclass/vim-plugin.eclass
@@ -1,192 +1,225 @@
# 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 8
# @BLURB: used for installing vim plugins
# @DESCRIPTION:
# This eclass simplifies installation of app-vim plugins into
# /usr/share/vim/vimfiles. This is a version-independent directory
# which is read automatically by vim. The only exception is
# documentation, for which we make a special case via vim-doc.eclass.
case ${EAPI} in
- 6|7|8) ;;
+ 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
+fi
+
+EXPORT_FUNCTIONS src_install pkg_postinst pkg_postrm
+
+# src_prepare is only exported in EAPI >= 8
+case ${EAPI:-0} in
+ 6|7) ;;
+ 8) EXPORT_FUNCTIONS src_prepare ;;
+esac
+
+if [[ ! ${_VIM_PLUGIN_ECLASS} ]]; then
VIM_PLUGIN_VIM_VERSION="${VIM_PLUGIN_VIM_VERSION:-7.3}"
DEPEND="|| ( >=app-editors/vim-${VIM_PLUGIN_VIM_VERSION}
>=app-editors/gvim-${VIM_PLUGIN_VIM_VERSION} )"
RDEPEND="${DEPEND}"
if [[ ${PV} != 9999* ]] ; then
SRC_URI="mirror://gentoo/${P}.tar.bz2
https://dev.gentoo.org/~radhermit/vim/${P}.tar.bz2"
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() {
+ 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:
# * installs help and documentation files.
# * 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() {
# Install non-vim-help-docs
einstalldocs
# Install remainder of plugin
insinto /usr/share/vim/vimfiles/
local d
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
update_vim_afterscripts # see below
display_vim_plugin_help # see below
}
# @FUNCTION: vim-plugin_pkg_postrm
# @DESCRIPTION:
# Overrides the pkg_postrm phase for this eclass.
# This function calls the update_vim_helptags and update_vim_afterscripts
# functions and eventually removes a bunch of empty directories.
vim-plugin_pkg_postrm() {
update_vim_helptags # from vim-doc
update_vim_afterscripts # see below
# Remove empty dirs; this allows
# /usr/share/vim to be removed if vim-core is unmerged
find "${EPREFIX}/usr/share/vim/vimfiles" -depth -type d -exec rmdir {} \; 2>/dev/null || \
die "rmdir failed"
}
# @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() {
local d f afterdir="${EROOT}"/usr/share/vim/vimfiles/after
# Nothing to do if the dir isn't there
[[ -d "${afterdir}" ]] || return 0
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 ${afterdir}"
find "${afterdir}" -type f -name \*.vim | \
while read f; do
[[ "$(head -n 1 ${f})" == '" Generated by update_vim_afterscripts' ]] \
|| continue
# This is a generated file, but might be abandoned. Check
# if there's no corresponding .d directory, or if the
# file's effectively empty
if [[ ! -d "${f}.d" || -z "$(grep -v '^"' "${f}")" ]]; then
rm "${f}" || die
fi
done
}
# @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
# should be separated by spaces. If no help files are available, but the env
# var VIM_PLUGIN_HELPTEXT is set, that is displayed instead. Finally, if we
# have nothing else, this functions displays a link to VIM_PLUGIN_HELPURI. An
# extra message regarding enabling filetype plugins is displayed if
# VIM_PLUGIN_MESSAGES includes the word "filetype".
display_vim_plugin_help() {
local h
if [[ -z ${REPLACING_VERSIONS} ]]; then
if [[ -n ${VIM_PLUGIN_HELPFILES} ]]; then
elog " "
elog "This plugin provides documentation via vim's help system. To"
elog "view it, use:"
for h in ${VIM_PLUGIN_HELPFILES}; do
elog " :help ${h}"
done
elog " "
elif [[ -n ${VIM_PLUGIN_HELPTEXT} ]]; then
elog " "
while read h ; do
elog "$h"
done <<<"${VIM_PLUGIN_HELPTEXT}"
elog " "
elif [[ -n ${VIM_PLUGIN_HELPURI} ]]; then
elog " "
elog "Documentation for this plugin is available online at:"
elog " ${VIM_PLUGIN_HELPURI}"
elog " "
fi
if has filetype ${VIM_PLUGIN_MESSAGES}; then
elog "This plugin makes use of filetype settings. To enable these,"
elog "add lines like:"
elog " filetype plugin on"
elog " filetype indent on"
elog "to your ~/.vimrc file."
elog " "
fi
fi
}
_VIM_PLUGIN_ECLASS=1
fi
-
-EXPORT_FUNCTIONS src_install pkg_postinst pkg_postrm
--
2.35.1
^ permalink raw reply related [flat|nested] 16+ messages in thread
* [gentoo-dev] [PATCH v5 5/9] vim-plugin.eclass: document VIM_PLUGIN_VIM_VERSION
2022-04-11 12:32 [gentoo-dev] [PATCH v5 0/9] Vim eclasses Anna Vyalkova
` (3 preceding siblings ...)
2022-04-11 12:33 ` [gentoo-dev] [PATCH v5 4/9] vim-plugin.eclass: EAPI 8: add src_prepare Anna Vyalkova
@ 2022-04-11 12:33 ` Anna Vyalkova
2022-04-11 12:33 ` [gentoo-dev] [PATCH v5 6/9] vim-doc.eclass: add debug-print-function call Anna Vyalkova
` (3 subsequent siblings)
8 siblings, 0 replies; 16+ messages in thread
From: Anna Vyalkova @ 2022-04-11 12:33 UTC (permalink / raw
To: gentoo-dev; +Cc: vim
Signed-off-by: Anna Vyalkova <cyber+gentoo@sysrq.in>
---
eclass/vim-plugin.eclass | 3 +++
1 file changed, 3 insertions(+)
diff --git a/eclass/vim-plugin.eclass b/eclass/vim-plugin.eclass
index a7b5f258b0..a521c3673c 100644
--- a/eclass/vim-plugin.eclass
+++ b/eclass/vim-plugin.eclass
@@ -1,225 +1,228 @@
# 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 8
# @BLURB: used for installing vim plugins
# @DESCRIPTION:
# This eclass simplifies installation of app-vim plugins into
# /usr/share/vim/vimfiles. This is a version-independent directory
# which is read automatically by vim. The only exception is
# documentation, for which we make a special case via vim-doc.eclass.
case ${EAPI} in
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
fi
EXPORT_FUNCTIONS src_install pkg_postinst pkg_postrm
# src_prepare is only exported in EAPI >= 8
case ${EAPI:-0} in
6|7) ;;
8) EXPORT_FUNCTIONS src_prepare ;;
esac
if [[ ! ${_VIM_PLUGIN_ECLASS} ]]; then
+# @ECLASS_VARIABLE: VIM_PLUGIN_VIM_VERSION
+# @DESCRIPTION:
+# Minimum Vim version the plugin supports.
VIM_PLUGIN_VIM_VERSION="${VIM_PLUGIN_VIM_VERSION:-7.3}"
DEPEND="|| ( >=app-editors/vim-${VIM_PLUGIN_VIM_VERSION}
>=app-editors/gvim-${VIM_PLUGIN_VIM_VERSION} )"
RDEPEND="${DEPEND}"
if [[ ${PV} != 9999* ]] ; then
SRC_URI="mirror://gentoo/${P}.tar.bz2
https://dev.gentoo.org/~radhermit/vim/${P}.tar.bz2"
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() {
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:
# * installs help and documentation files.
# * 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() {
# Install non-vim-help-docs
einstalldocs
# Install remainder of plugin
insinto /usr/share/vim/vimfiles/
local d
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
update_vim_afterscripts # see below
display_vim_plugin_help # see below
}
# @FUNCTION: vim-plugin_pkg_postrm
# @DESCRIPTION:
# Overrides the pkg_postrm phase for this eclass.
# This function calls the update_vim_helptags and update_vim_afterscripts
# functions and eventually removes a bunch of empty directories.
vim-plugin_pkg_postrm() {
update_vim_helptags # from vim-doc
update_vim_afterscripts # see below
# Remove empty dirs; this allows
# /usr/share/vim to be removed if vim-core is unmerged
find "${EPREFIX}/usr/share/vim/vimfiles" -depth -type d -exec rmdir {} \; 2>/dev/null || \
die "rmdir failed"
}
# @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() {
local d f afterdir="${EROOT}"/usr/share/vim/vimfiles/after
# Nothing to do if the dir isn't there
[[ -d "${afterdir}" ]] || return 0
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 ${afterdir}"
find "${afterdir}" -type f -name \*.vim | \
while read f; do
[[ "$(head -n 1 ${f})" == '" Generated by update_vim_afterscripts' ]] \
|| continue
# This is a generated file, but might be abandoned. Check
# if there's no corresponding .d directory, or if the
# file's effectively empty
if [[ ! -d "${f}.d" || -z "$(grep -v '^"' "${f}")" ]]; then
rm "${f}" || die
fi
done
}
# @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
# should be separated by spaces. If no help files are available, but the env
# var VIM_PLUGIN_HELPTEXT is set, that is displayed instead. Finally, if we
# have nothing else, this functions displays a link to VIM_PLUGIN_HELPURI. An
# extra message regarding enabling filetype plugins is displayed if
# VIM_PLUGIN_MESSAGES includes the word "filetype".
display_vim_plugin_help() {
local h
if [[ -z ${REPLACING_VERSIONS} ]]; then
if [[ -n ${VIM_PLUGIN_HELPFILES} ]]; then
elog " "
elog "This plugin provides documentation via vim's help system. To"
elog "view it, use:"
for h in ${VIM_PLUGIN_HELPFILES}; do
elog " :help ${h}"
done
elog " "
elif [[ -n ${VIM_PLUGIN_HELPTEXT} ]]; then
elog " "
while read h ; do
elog "$h"
done <<<"${VIM_PLUGIN_HELPTEXT}"
elog " "
elif [[ -n ${VIM_PLUGIN_HELPURI} ]]; then
elog " "
elog "Documentation for this plugin is available online at:"
elog " ${VIM_PLUGIN_HELPURI}"
elog " "
fi
if has filetype ${VIM_PLUGIN_MESSAGES}; then
elog "This plugin makes use of filetype settings. To enable these,"
elog "add lines like:"
elog " filetype plugin on"
elog " filetype indent on"
elog "to your ~/.vimrc file."
elog " "
fi
fi
}
_VIM_PLUGIN_ECLASS=1
fi
--
2.35.1
^ permalink raw reply related [flat|nested] 16+ messages in thread
* [gentoo-dev] [PATCH v5 6/9] vim-doc.eclass: add debug-print-function call
2022-04-11 12:32 [gentoo-dev] [PATCH v5 0/9] Vim eclasses Anna Vyalkova
` (4 preceding siblings ...)
2022-04-11 12:33 ` [gentoo-dev] [PATCH v5 5/9] vim-plugin.eclass: document VIM_PLUGIN_VIM_VERSION Anna Vyalkova
@ 2022-04-11 12:33 ` Anna Vyalkova
2022-04-11 12:33 ` [gentoo-dev] [PATCH v5 7/9] vim-doc.eclass: document update_vim_helptags Anna Vyalkova
` (2 subsequent siblings)
8 siblings, 0 replies; 16+ messages in thread
From: Anna Vyalkova @ 2022-04-11 12:33 UTC (permalink / raw
To: gentoo-dev; +Cc: vim
Signed-off-by: Anna Vyalkova <cyber+gentoo@sysrq.in>
---
eclass/vim-doc.eclass | 2 ++
1 file changed, 2 insertions(+)
diff --git a/eclass/vim-doc.eclass b/eclass/vim-doc.eclass
index f0c5c6edc6..968f4657b6 100644
--- a/eclass/vim-doc.eclass
+++ b/eclass/vim-doc.eclass
@@ -1,98 +1,100 @@
# Copyright 1999-2022 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2
# @ECLASS: vim-doc.eclass
# @MAINTAINER:
# vim@gentoo.org
# @SUPPORTED_EAPIS: 6 7 8
# @BLURB: Eclass for vim{,-plugin}.eclass to update documentation tags.
# @DESCRIPTION:
# This eclass is used by vim.eclass and vim-plugin.eclass to update
# the documentation tags. This is necessary since vim doesn't look in
# /usr/share/vim/vimfiles/doc for documentation; it only uses the
# versioned directory, for example /usr/share/vim/vim62/doc
#
# We depend on vim being installed, which is satisfied by either the
# DEPEND in vim-plugin or by whatever version of vim is being
# installed by the eclass.
case ${EAPI} in
6|7|8) ;;
*) die "${ECLASS}: EAPI ${EAPI:-0} not supported" ;;
esac
if [[ ! ${_VIM_DOC_ECLASS} ]] ; then
update_vim_helptags() {
+ debug-print-function ${FUNCNAME} "${@}"
+
local vimfiles helpfile files vim d
# This is where vim plugins are installed
vimfiles="${EROOT}"/usr/share/vim/vimfiles
if [[ ${PN} != vim-core ]]; then
# Find a suitable vim binary for updating tags :helptags
vim=$(type -P vim 2>/dev/null)
[[ -z "${vim}" ]] && vim=$(type -P gvim 2>/dev/null)
[[ -z "${vim}" ]] && vim=$(type -P kvim 2>/dev/null)
if [[ -z "${vim}" ]]; then
ewarn "No suitable vim binary to rebuild documentation tags"
fi
fi
# Make vim not try to connect to X. See :help gui-x11-start
# in vim for how this evil trickery works.
if [[ -n "${vim}" ]] ; then
ln -s "${vim}" "${T}/tagvim" || die
vim="${T}/tagvim"
fi
# Install the documentation symlinks into the versioned vim
# directory and run :helptags
for d in "${EROOT%/}"/usr/share/vim/vim[0-9]*; do
[[ -d "${d}/doc" ]] || continue # catch a failed glob
# Remove links
readarray -d '' files < <(find "${d}"/doc -name "*.txt" -type l -print0 || die "cannot traverse ${d}/doc" )
for helpfile in "${files[@]}"; do
if [[ $(readlink -f "${helpfile}") == "${vimfiles}"/* ]]; then
rm "${helpfile}" || die
fi
done
# Remove stale dirs, if possible
readarray -d '' files < <(find "${d}" -print0 || die "cannot traverse ${d}")
if [[ -f "${d}/doc/tags" && ${#files[@]} -eq 3 ]]; then
# /usr/share/vim/vim61
# /usr/share/vim/vim61/doc
# /usr/share/vim/vim61/doc/tags
einfo "Removing ${d}"
rm -r "${d}" || die
continue
fi
# Re-create / install new links
if [[ -d "${vimfiles}"/doc ]]; then
for helpfile in "${vimfiles}"/doc/*.txt; do
if [[ ! -e "${d}/doc/$(basename "${helpfile}")" ]]; then
ln -s "${helpfile}" "${d}/doc" || die
fi
done
fi
# Update tags; need a vim binary for this
if [[ -n "${vim}" ]]; then
einfo "Updating documentation tags in ${d}"
DISPLAY= "${vim}" -u NONE -U NONE -T xterm -X -n -f \
'+set nobackup nomore' \
"+helptags ${d}/doc" \
'+qa!' </dev/null &>/dev/null || die
fi
done
if [[ -n "${vim}" && -f "${vim}" ]]; then
rm "${vim}" || die
fi
}
_VIM_DOC_ECLASS=1
fi
--
2.35.1
^ permalink raw reply related [flat|nested] 16+ messages in thread
* [gentoo-dev] [PATCH v5 7/9] vim-doc.eclass: document update_vim_helptags
2022-04-11 12:32 [gentoo-dev] [PATCH v5 0/9] Vim eclasses Anna Vyalkova
` (5 preceding siblings ...)
2022-04-11 12:33 ` [gentoo-dev] [PATCH v5 6/9] vim-doc.eclass: add debug-print-function call Anna Vyalkova
@ 2022-04-11 12:33 ` Anna Vyalkova
2022-04-11 12:33 ` [gentoo-dev] [PATCH v5 8/9] vim-plugin.eclass: add debug-print-function calls Anna Vyalkova
2022-04-11 12:33 ` [gentoo-dev] [PATCH v5 9/9] vim-plugin.eclass: fix manpage formatting Anna Vyalkova
8 siblings, 0 replies; 16+ messages in thread
From: Anna Vyalkova @ 2022-04-11 12:33 UTC (permalink / raw
To: gentoo-dev; +Cc: vim
Signed-off-by: Anna Vyalkova <cyber+gentoo@sysrq.in>
---
eclass/vim-doc.eclass | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/eclass/vim-doc.eclass b/eclass/vim-doc.eclass
index 968f4657b6..119ce79307 100644
--- a/eclass/vim-doc.eclass
+++ b/eclass/vim-doc.eclass
@@ -1,100 +1,104 @@
# Copyright 1999-2022 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2
# @ECLASS: vim-doc.eclass
# @MAINTAINER:
# vim@gentoo.org
# @SUPPORTED_EAPIS: 6 7 8
# @BLURB: Eclass for vim{,-plugin}.eclass to update documentation tags.
# @DESCRIPTION:
# This eclass is used by vim.eclass and vim-plugin.eclass to update
# the documentation tags. This is necessary since vim doesn't look in
# /usr/share/vim/vimfiles/doc for documentation; it only uses the
# versioned directory, for example /usr/share/vim/vim62/doc
#
# We depend on vim being installed, which is satisfied by either the
# DEPEND in vim-plugin or by whatever version of vim is being
# installed by the eclass.
case ${EAPI} in
6|7|8) ;;
*) die "${ECLASS}: EAPI ${EAPI:-0} not supported" ;;
esac
if [[ ! ${_VIM_DOC_ECLASS} ]] ; then
+# @FUNCTION: update_vim_helptags
+# @USAGE:
+# @DESCRIPTION:
+# Update the documentation tags in the versioned Vim directory.
update_vim_helptags() {
debug-print-function ${FUNCNAME} "${@}"
local vimfiles helpfile files vim d
# This is where vim plugins are installed
vimfiles="${EROOT}"/usr/share/vim/vimfiles
if [[ ${PN} != vim-core ]]; then
# Find a suitable vim binary for updating tags :helptags
vim=$(type -P vim 2>/dev/null)
[[ -z "${vim}" ]] && vim=$(type -P gvim 2>/dev/null)
[[ -z "${vim}" ]] && vim=$(type -P kvim 2>/dev/null)
if [[ -z "${vim}" ]]; then
ewarn "No suitable vim binary to rebuild documentation tags"
fi
fi
# Make vim not try to connect to X. See :help gui-x11-start
# in vim for how this evil trickery works.
if [[ -n "${vim}" ]] ; then
ln -s "${vim}" "${T}/tagvim" || die
vim="${T}/tagvim"
fi
# Install the documentation symlinks into the versioned vim
# directory and run :helptags
for d in "${EROOT%/}"/usr/share/vim/vim[0-9]*; do
[[ -d "${d}/doc" ]] || continue # catch a failed glob
# Remove links
readarray -d '' files < <(find "${d}"/doc -name "*.txt" -type l -print0 || die "cannot traverse ${d}/doc" )
for helpfile in "${files[@]}"; do
if [[ $(readlink -f "${helpfile}") == "${vimfiles}"/* ]]; then
rm "${helpfile}" || die
fi
done
# Remove stale dirs, if possible
readarray -d '' files < <(find "${d}" -print0 || die "cannot traverse ${d}")
if [[ -f "${d}/doc/tags" && ${#files[@]} -eq 3 ]]; then
# /usr/share/vim/vim61
# /usr/share/vim/vim61/doc
# /usr/share/vim/vim61/doc/tags
einfo "Removing ${d}"
rm -r "${d}" || die
continue
fi
# Re-create / install new links
if [[ -d "${vimfiles}"/doc ]]; then
for helpfile in "${vimfiles}"/doc/*.txt; do
if [[ ! -e "${d}/doc/$(basename "${helpfile}")" ]]; then
ln -s "${helpfile}" "${d}/doc" || die
fi
done
fi
# Update tags; need a vim binary for this
if [[ -n "${vim}" ]]; then
einfo "Updating documentation tags in ${d}"
DISPLAY= "${vim}" -u NONE -U NONE -T xterm -X -n -f \
'+set nobackup nomore' \
"+helptags ${d}/doc" \
'+qa!' </dev/null &>/dev/null || die
fi
done
if [[ -n "${vim}" && -f "${vim}" ]]; then
rm "${vim}" || die
fi
}
_VIM_DOC_ECLASS=1
fi
--
2.35.1
^ permalink raw reply related [flat|nested] 16+ messages in thread
* [gentoo-dev] [PATCH v5 8/9] vim-plugin.eclass: add debug-print-function calls
2022-04-11 12:32 [gentoo-dev] [PATCH v5 0/9] Vim eclasses Anna Vyalkova
` (6 preceding siblings ...)
2022-04-11 12:33 ` [gentoo-dev] [PATCH v5 7/9] vim-doc.eclass: document update_vim_helptags Anna Vyalkova
@ 2022-04-11 12:33 ` Anna Vyalkova
2022-04-11 12:33 ` [gentoo-dev] [PATCH v5 9/9] vim-plugin.eclass: fix manpage formatting Anna Vyalkova
8 siblings, 0 replies; 16+ messages in thread
From: Anna Vyalkova @ 2022-04-11 12:33 UTC (permalink / raw
To: gentoo-dev; +Cc: vim
Signed-off-by: Anna Vyalkova <cyber+gentoo@sysrq.in>
---
eclass/vim-plugin.eclass | 12 ++++++++++++
1 file changed, 12 insertions(+)
diff --git a/eclass/vim-plugin.eclass b/eclass/vim-plugin.eclass
index a521c3673c..97b6097726 100644
--- a/eclass/vim-plugin.eclass
+++ b/eclass/vim-plugin.eclass
@@ -1,228 +1,240 @@
# 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 8
# @BLURB: used for installing vim plugins
# @DESCRIPTION:
# This eclass simplifies installation of app-vim plugins into
# /usr/share/vim/vimfiles. This is a version-independent directory
# which is read automatically by vim. The only exception is
# documentation, for which we make a special case via vim-doc.eclass.
case ${EAPI} in
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
fi
EXPORT_FUNCTIONS src_install pkg_postinst pkg_postrm
# src_prepare is only exported in EAPI >= 8
case ${EAPI:-0} in
6|7) ;;
8) EXPORT_FUNCTIONS src_prepare ;;
esac
if [[ ! ${_VIM_PLUGIN_ECLASS} ]]; then
# @ECLASS_VARIABLE: VIM_PLUGIN_VIM_VERSION
# @DESCRIPTION:
# Minimum Vim version the plugin supports.
VIM_PLUGIN_VIM_VERSION="${VIM_PLUGIN_VIM_VERSION:-7.3}"
DEPEND="|| ( >=app-editors/vim-${VIM_PLUGIN_VIM_VERSION}
>=app-editors/gvim-${VIM_PLUGIN_VIM_VERSION} )"
RDEPEND="${DEPEND}"
if [[ ${PV} != 9999* ]] ; then
SRC_URI="mirror://gentoo/${P}.tar.bz2
https://dev.gentoo.org/~radhermit/vim/${P}.tar.bz2"
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:
# * installs help and documentation files.
# * 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() {
+ debug-print-function ${FUNCNAME} "${@}"
+
# Install non-vim-help-docs
einstalldocs
# Install remainder of plugin
insinto /usr/share/vim/vimfiles/
local d
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() {
+ debug-print-function ${FUNCNAME} "${@}"
+
update_vim_helptags # from vim-doc
update_vim_afterscripts # see below
display_vim_plugin_help # see below
}
# @FUNCTION: vim-plugin_pkg_postrm
# @DESCRIPTION:
# Overrides the pkg_postrm phase for this eclass.
# This function calls the update_vim_helptags and update_vim_afterscripts
# functions and eventually removes a bunch of empty directories.
vim-plugin_pkg_postrm() {
+ debug-print-function ${FUNCNAME} "${@}"
+
update_vim_helptags # from vim-doc
update_vim_afterscripts # see below
# Remove empty dirs; this allows
# /usr/share/vim to be removed if vim-core is unmerged
find "${EPREFIX}/usr/share/vim/vimfiles" -depth -type d -exec rmdir {} \; 2>/dev/null || \
die "rmdir failed"
}
# @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() {
+ 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
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 ${afterdir}"
find "${afterdir}" -type f -name \*.vim | \
while read f; do
[[ "$(head -n 1 ${f})" == '" Generated by update_vim_afterscripts' ]] \
|| continue
# This is a generated file, but might be abandoned. Check
# if there's no corresponding .d directory, or if the
# file's effectively empty
if [[ ! -d "${f}.d" || -z "$(grep -v '^"' "${f}")" ]]; then
rm "${f}" || die
fi
done
}
# @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
# should be separated by spaces. If no help files are available, but the env
# var VIM_PLUGIN_HELPTEXT is set, that is displayed instead. Finally, if we
# have nothing else, this functions displays a link to VIM_PLUGIN_HELPURI. An
# 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
if [[ -n ${VIM_PLUGIN_HELPFILES} ]]; then
elog " "
elog "This plugin provides documentation via vim's help system. To"
elog "view it, use:"
for h in ${VIM_PLUGIN_HELPFILES}; do
elog " :help ${h}"
done
elog " "
elif [[ -n ${VIM_PLUGIN_HELPTEXT} ]]; then
elog " "
while read h ; do
elog "$h"
done <<<"${VIM_PLUGIN_HELPTEXT}"
elog " "
elif [[ -n ${VIM_PLUGIN_HELPURI} ]]; then
elog " "
elog "Documentation for this plugin is available online at:"
elog " ${VIM_PLUGIN_HELPURI}"
elog " "
fi
if has filetype ${VIM_PLUGIN_MESSAGES}; then
elog "This plugin makes use of filetype settings. To enable these,"
elog "add lines like:"
elog " filetype plugin on"
elog " filetype indent on"
elog "to your ~/.vimrc file."
elog " "
fi
fi
}
_VIM_PLUGIN_ECLASS=1
fi
--
2.35.1
^ permalink raw reply related [flat|nested] 16+ messages in thread
* [gentoo-dev] [PATCH v5 9/9] vim-plugin.eclass: fix manpage formatting
2022-04-11 12:32 [gentoo-dev] [PATCH v5 0/9] Vim eclasses Anna Vyalkova
` (7 preceding siblings ...)
2022-04-11 12:33 ` [gentoo-dev] [PATCH v5 8/9] vim-plugin.eclass: add debug-print-function calls Anna Vyalkova
@ 2022-04-11 12:33 ` Anna Vyalkova
8 siblings, 0 replies; 16+ messages in thread
From: Anna Vyalkova @ 2022-04-11 12:33 UTC (permalink / raw
To: gentoo-dev; +Cc: vim
Signed-off-by: Anna Vyalkova <cyber+gentoo@sysrq.in>
---
eclass/vim-plugin.eclass | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/eclass/vim-plugin.eclass b/eclass/vim-plugin.eclass
index 97b6097726..0fd2b9b81d 100644
--- a/eclass/vim-plugin.eclass
+++ b/eclass/vim-plugin.eclass
@@ -1,240 +1,245 @@
# 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 8
# @BLURB: used for installing vim plugins
# @DESCRIPTION:
# This eclass simplifies installation of app-vim plugins into
# /usr/share/vim/vimfiles. This is a version-independent directory
# which is read automatically by vim. The only exception is
# documentation, for which we make a special case via vim-doc.eclass.
case ${EAPI} in
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
fi
EXPORT_FUNCTIONS src_install pkg_postinst pkg_postrm
# src_prepare is only exported in EAPI >= 8
case ${EAPI:-0} in
6|7) ;;
8) EXPORT_FUNCTIONS src_prepare ;;
esac
if [[ ! ${_VIM_PLUGIN_ECLASS} ]]; then
# @ECLASS_VARIABLE: VIM_PLUGIN_VIM_VERSION
# @DESCRIPTION:
# Minimum Vim version the plugin supports.
VIM_PLUGIN_VIM_VERSION="${VIM_PLUGIN_VIM_VERSION:-7.3}"
DEPEND="|| ( >=app-editors/vim-${VIM_PLUGIN_VIM_VERSION}
>=app-editors/gvim-${VIM_PLUGIN_VIM_VERSION} )"
RDEPEND="${DEPEND}"
if [[ ${PV} != 9999* ]] ; then
SRC_URI="mirror://gentoo/${P}.tar.bz2
https://dev.gentoo.org/~radhermit/vim/${P}.tar.bz2"
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:
+#
# * installs help and documentation files.
+#
# * 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() {
debug-print-function ${FUNCNAME} "${@}"
# Install non-vim-help-docs
einstalldocs
# Install remainder of plugin
insinto /usr/share/vim/vimfiles/
local d
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() {
debug-print-function ${FUNCNAME} "${@}"
update_vim_helptags # from vim-doc
update_vim_afterscripts # see below
display_vim_plugin_help # see below
}
# @FUNCTION: vim-plugin_pkg_postrm
# @DESCRIPTION:
# Overrides the pkg_postrm phase for this eclass.
# This function calls the update_vim_helptags and update_vim_afterscripts
# functions and eventually removes a bunch of empty directories.
vim-plugin_pkg_postrm() {
debug-print-function ${FUNCNAME} "${@}"
update_vim_helptags # from vim-doc
update_vim_afterscripts # see below
# Remove empty dirs; this allows
# /usr/share/vim to be removed if vim-core is unmerged
find "${EPREFIX}/usr/share/vim/vimfiles" -depth -type d -exec rmdir {} \; 2>/dev/null || \
die "rmdir failed"
}
# @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() {
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
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 ${afterdir}"
find "${afterdir}" -type f -name \*.vim | \
while read f; do
[[ "$(head -n 1 ${f})" == '" Generated by update_vim_afterscripts' ]] \
|| continue
# This is a generated file, but might be abandoned. Check
# if there's no corresponding .d directory, or if the
# file's effectively empty
if [[ ! -d "${f}.d" || -z "$(grep -v '^"' "${f}")" ]]; then
rm "${f}" || die
fi
done
}
# @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
# should be separated by spaces. If no help files are available, but the env
# var VIM_PLUGIN_HELPTEXT is set, that is displayed instead. Finally, if we
# have nothing else, this functions displays a link to VIM_PLUGIN_HELPURI. An
# 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
if [[ -n ${VIM_PLUGIN_HELPFILES} ]]; then
elog " "
elog "This plugin provides documentation via vim's help system. To"
elog "view it, use:"
for h in ${VIM_PLUGIN_HELPFILES}; do
elog " :help ${h}"
done
elog " "
elif [[ -n ${VIM_PLUGIN_HELPTEXT} ]]; then
elog " "
while read h ; do
elog "$h"
done <<<"${VIM_PLUGIN_HELPTEXT}"
elog " "
elif [[ -n ${VIM_PLUGIN_HELPURI} ]]; then
elog " "
elog "Documentation for this plugin is available online at:"
elog " ${VIM_PLUGIN_HELPURI}"
elog " "
fi
if has filetype ${VIM_PLUGIN_MESSAGES}; then
elog "This plugin makes use of filetype settings. To enable these,"
elog "add lines like:"
elog " filetype plugin on"
elog " filetype indent on"
elog "to your ~/.vimrc file."
elog " "
fi
fi
}
_VIM_PLUGIN_ECLASS=1
fi
--
2.35.1
^ permalink raw reply related [flat|nested] 16+ messages in thread
* Re: [gentoo-dev] [PATCH v5 3/9] vim-plugin.eclass: EAPI 8: install allowed dirs only
2022-04-11 12:33 ` [gentoo-dev] [PATCH v5 3/9] vim-plugin.eclass: EAPI 8: install allowed dirs only Anna Vyalkova
@ 2022-04-11 12:51 ` Thomas Bracht Laumann Jespersen
2022-04-11 13:08 ` Anna Vyalkova
0 siblings, 1 reply; 16+ messages in thread
From: Thomas Bracht Laumann Jespersen @ 2022-04-11 12:51 UTC (permalink / raw
To: gentoo-dev; +Cc: vim
> + 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
Could you use "8)" instead of "*)" here? There should only be 6, 7, and 8 to
handle here.
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [gentoo-dev] [PATCH v5 4/9] vim-plugin.eclass: EAPI 8: add src_prepare
2022-04-11 12:33 ` [gentoo-dev] [PATCH v5 4/9] vim-plugin.eclass: EAPI 8: add src_prepare Anna Vyalkova
@ 2022-04-11 12:53 ` Thomas Bracht Laumann Jespersen
2022-04-11 13:07 ` Anna Vyalkova
2022-04-14 3:14 ` [gentoo-dev] [PATCH v5.5] " Anna Vyalkova
1 sibling, 1 reply; 16+ messages in thread
From: Thomas Bracht Laumann Jespersen @ 2022-04-11 12:53 UTC (permalink / raw
To: gentoo-dev; +Cc: vim
> case ${EAPI} in
> - 6|7|8) ;;
> + 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
>
> +fi
> +
> +EXPORT_FUNCTIONS src_install pkg_postinst pkg_postrm
Not sure how to deal with this best, but EXPORT_FUNCTIONS should still go
_after_ the inherit guard, at the bottom of the file.
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [gentoo-dev] [PATCH v5 4/9] vim-plugin.eclass: EAPI 8: add src_prepare
2022-04-11 12:53 ` Thomas Bracht Laumann Jespersen
@ 2022-04-11 13:07 ` Anna Vyalkova
0 siblings, 0 replies; 16+ messages in thread
From: Anna Vyalkova @ 2022-04-11 13:07 UTC (permalink / raw
To: gentoo-dev; +Cc: vim
On 2022-04-11 14:53, Thomas Bracht Laumann Jespersen wrote:
> > case ${EAPI} in
> > - 6|7|8) ;;
> > + 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
> >
> > +fi
> > +
> > +EXPORT_FUNCTIONS src_install pkg_postinst pkg_postrm
>
> Not sure how to deal with this best, but EXPORT_FUNCTIONS should still go
> _after_ the inherit guard, at the bottom of the file.
Copycat from distutils-r1. Phase functions are exported after inherits
outside of the guard, so it should be correct.
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [gentoo-dev] [PATCH v5 3/9] vim-plugin.eclass: EAPI 8: install allowed dirs only
2022-04-11 12:51 ` Thomas Bracht Laumann Jespersen
@ 2022-04-11 13:08 ` Anna Vyalkova
0 siblings, 0 replies; 16+ messages in thread
From: Anna Vyalkova @ 2022-04-11 13:08 UTC (permalink / raw
To: gentoo-dev; +Cc: vim
On 2022-04-11 14:51, Thomas Bracht Laumann Jespersen wrote:
> > + 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
>
> Could you use "8)" instead of "*)" here? There should only be 6, 7, and 8 to
> handle here.
Other versions don't pass the EAPI guard. Also this solution is
more future-proof.
^ permalink raw reply [flat|nested] 16+ messages in thread
* [gentoo-dev] [PATCH v5.5] vim-plugin.eclass: EAPI 8: add src_prepare
2022-04-11 12:33 ` [gentoo-dev] [PATCH v5 4/9] vim-plugin.eclass: EAPI 8: add src_prepare Anna Vyalkova
2022-04-11 12:53 ` Thomas Bracht Laumann Jespersen
@ 2022-04-14 3:14 ` Anna Vyalkova
2022-04-14 5:10 ` Ulrich Mueller
1 sibling, 1 reply; 16+ messages in thread
From: Anna Vyalkova @ 2022-04-14 3:14 UTC (permalink / raw
To: gentoo-dev; +Cc: vim
Signed-off-by: Anna Vyalkova <cyber+gentoo@sysrq.in>
---
Changed _DEFINE_VIM_PLUGIN_SRC_PREPARE as floppym suggested.
https://github.com/gentoo/gentoo/pull/24941#discussion_r848445641
eclass/vim-plugin.eclass | 39 ++++++++++++++++++++++++++++++++++++---
1 file changed, 36 insertions(+), 3 deletions(-)
diff --git a/eclass/vim-plugin.eclass b/eclass/vim-plugin.eclass
index 0c323e0d09..5a68b2957d 100644
--- a/eclass/vim-plugin.eclass
+++ b/eclass/vim-plugin.eclass
@@ -1,192 +1,225 @@
# 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 8
# @BLURB: used for installing vim plugins
# @DESCRIPTION:
# This eclass simplifies installation of app-vim plugins into
# /usr/share/vim/vimfiles. This is a version-independent directory
# which is read automatically by vim. The only exception is
# documentation, for which we make a special case via vim-doc.eclass.
case ${EAPI} in
- 6|7|8) ;;
+ 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
+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
+
+if [[ ! ${_VIM_PLUGIN_ECLASS} ]]; then
VIM_PLUGIN_VIM_VERSION="${VIM_PLUGIN_VIM_VERSION:-7.3}"
DEPEND="|| ( >=app-editors/vim-${VIM_PLUGIN_VIM_VERSION}
>=app-editors/gvim-${VIM_PLUGIN_VIM_VERSION} )"
RDEPEND="${DEPEND}"
if [[ ${PV} != 9999* ]] ; then
SRC_URI="mirror://gentoo/${P}.tar.bz2
https://dev.gentoo.org/~radhermit/vim/${P}.tar.bz2"
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() {
+ 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:
# * installs help and documentation files.
# * 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() {
# Install non-vim-help-docs
einstalldocs
# Install remainder of plugin
insinto /usr/share/vim/vimfiles/
local d
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
update_vim_afterscripts # see below
display_vim_plugin_help # see below
}
# @FUNCTION: vim-plugin_pkg_postrm
# @DESCRIPTION:
# Overrides the pkg_postrm phase for this eclass.
# This function calls the update_vim_helptags and update_vim_afterscripts
# functions and eventually removes a bunch of empty directories.
vim-plugin_pkg_postrm() {
update_vim_helptags # from vim-doc
update_vim_afterscripts # see below
# Remove empty dirs; this allows
# /usr/share/vim to be removed if vim-core is unmerged
find "${EPREFIX}/usr/share/vim/vimfiles" -depth -type d -exec rmdir {} \; 2>/dev/null || \
die "rmdir failed"
}
# @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() {
local d f afterdir="${EROOT}"/usr/share/vim/vimfiles/after
# Nothing to do if the dir isn't there
[[ -d "${afterdir}" ]] || return 0
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 ${afterdir}"
find "${afterdir}" -type f -name \*.vim | \
while read f; do
[[ "$(head -n 1 ${f})" == '" Generated by update_vim_afterscripts' ]] \
|| continue
# This is a generated file, but might be abandoned. Check
# if there's no corresponding .d directory, or if the
# file's effectively empty
if [[ ! -d "${f}.d" || -z "$(grep -v '^"' "${f}")" ]]; then
rm "${f}" || die
fi
done
}
# @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
# should be separated by spaces. If no help files are available, but the env
# var VIM_PLUGIN_HELPTEXT is set, that is displayed instead. Finally, if we
# have nothing else, this functions displays a link to VIM_PLUGIN_HELPURI. An
# extra message regarding enabling filetype plugins is displayed if
# VIM_PLUGIN_MESSAGES includes the word "filetype".
display_vim_plugin_help() {
local h
if [[ -z ${REPLACING_VERSIONS} ]]; then
if [[ -n ${VIM_PLUGIN_HELPFILES} ]]; then
elog " "
elog "This plugin provides documentation via vim's help system. To"
elog "view it, use:"
for h in ${VIM_PLUGIN_HELPFILES}; do
elog " :help ${h}"
done
elog " "
elif [[ -n ${VIM_PLUGIN_HELPTEXT} ]]; then
elog " "
while read h ; do
elog "$h"
done <<<"${VIM_PLUGIN_HELPTEXT}"
elog " "
elif [[ -n ${VIM_PLUGIN_HELPURI} ]]; then
elog " "
elog "Documentation for this plugin is available online at:"
elog " ${VIM_PLUGIN_HELPURI}"
elog " "
fi
if has filetype ${VIM_PLUGIN_MESSAGES}; then
elog "This plugin makes use of filetype settings. To enable these,"
elog "add lines like:"
elog " filetype plugin on"
elog " filetype indent on"
elog "to your ~/.vimrc file."
elog " "
fi
fi
}
_VIM_PLUGIN_ECLASS=1
fi
-
-EXPORT_FUNCTIONS src_install pkg_postinst pkg_postrm
--
2.35.1
^ permalink raw reply related [flat|nested] 16+ messages in thread
* Re: [gentoo-dev] [PATCH v5.5] vim-plugin.eclass: EAPI 8: add src_prepare
2022-04-14 3:14 ` [gentoo-dev] [PATCH v5.5] " Anna Vyalkova
@ 2022-04-14 5:10 ` Ulrich Mueller
0 siblings, 0 replies; 16+ messages in thread
From: Ulrich Mueller @ 2022-04-14 5:10 UTC (permalink / raw
To: Anna Vyalkova; +Cc: gentoo-dev, vim
[-- Attachment #1: Type: text/plain, Size: 570 bytes --]
>>>>> On Thu, 14 Apr 2022, Anna Vyalkova wrote:
> +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
> +
> +if [[ ! ${_VIM_PLUGIN_ECLASS} ]]; then
> [...]
> -EXPORT_FUNCTIONS src_install pkg_postinst pkg_postrm
What is the rationale for moving EXPORT_FUNCTIONS? The standard nowadays
is to have it at the end of the eclass (so it's immediately clear that
inherit order will be as expected).
Ulrich
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 507 bytes --]
^ permalink raw reply [flat|nested] 16+ messages in thread
end of thread, other threads:[~2022-04-14 5:10 UTC | newest]
Thread overview: 16+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-04-11 12:32 [gentoo-dev] [PATCH v5 0/9] Vim eclasses Anna Vyalkova
2022-04-11 12:32 ` [gentoo-dev] [PATCH v5 1/9] vim-doc.eclass: support EAPI 8 Anna Vyalkova
2022-04-11 12:32 ` [gentoo-dev] [PATCH v5 2/9] vim-plugin.eclass: " Anna Vyalkova
2022-04-11 12:33 ` [gentoo-dev] [PATCH v5 3/9] vim-plugin.eclass: EAPI 8: install allowed dirs only Anna Vyalkova
2022-04-11 12:51 ` Thomas Bracht Laumann Jespersen
2022-04-11 13:08 ` Anna Vyalkova
2022-04-11 12:33 ` [gentoo-dev] [PATCH v5 4/9] vim-plugin.eclass: EAPI 8: add src_prepare Anna Vyalkova
2022-04-11 12:53 ` Thomas Bracht Laumann Jespersen
2022-04-11 13:07 ` Anna Vyalkova
2022-04-14 3:14 ` [gentoo-dev] [PATCH v5.5] " Anna Vyalkova
2022-04-14 5:10 ` Ulrich Mueller
2022-04-11 12:33 ` [gentoo-dev] [PATCH v5 5/9] vim-plugin.eclass: document VIM_PLUGIN_VIM_VERSION Anna Vyalkova
2022-04-11 12:33 ` [gentoo-dev] [PATCH v5 6/9] vim-doc.eclass: add debug-print-function call Anna Vyalkova
2022-04-11 12:33 ` [gentoo-dev] [PATCH v5 7/9] vim-doc.eclass: document update_vim_helptags Anna Vyalkova
2022-04-11 12:33 ` [gentoo-dev] [PATCH v5 8/9] vim-plugin.eclass: add debug-print-function calls Anna Vyalkova
2022-04-11 12:33 ` [gentoo-dev] [PATCH v5 9/9] vim-plugin.eclass: fix manpage formatting Anna Vyalkova
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox