1 |
Signed-off-by: Anna Vyalkova <cyber+gentoo@×××××.in> |
2 |
--- |
3 |
eclass/vim-plugin.eclass | 12 ++++++++++++ |
4 |
1 file changed, 12 insertions(+) |
5 |
|
6 |
diff --git a/eclass/vim-plugin.eclass b/eclass/vim-plugin.eclass |
7 |
index a521c3673c..97b6097726 100644 |
8 |
--- a/eclass/vim-plugin.eclass |
9 |
+++ b/eclass/vim-plugin.eclass |
10 |
@@ -1,228 +1,240 @@ |
11 |
# Copyright 1999-2022 Gentoo Authors |
12 |
# Distributed under the terms of the GNU General Public License v2 |
13 |
|
14 |
# @ECLASS: vim-plugin.eclass |
15 |
# @MAINTAINER: |
16 |
# vim@g.o |
17 |
# @SUPPORTED_EAPIS: 6 7 8 |
18 |
# @BLURB: used for installing vim plugins |
19 |
# @DESCRIPTION: |
20 |
# This eclass simplifies installation of app-vim plugins into |
21 |
# /usr/share/vim/vimfiles. This is a version-independent directory |
22 |
# which is read automatically by vim. The only exception is |
23 |
# documentation, for which we make a special case via vim-doc.eclass. |
24 |
|
25 |
case ${EAPI} in |
26 |
6|7) ;; |
27 |
8) _DEFINE_VIM_PLUGIN_SRC_PREPARE=true ;; |
28 |
*) die "${ECLASS}: EAPI ${EAPI:-0} not supported" ;; |
29 |
esac |
30 |
|
31 |
if [[ ! ${_VIM_PLUGIN_ECLASS} ]]; then |
32 |
|
33 |
inherit vim-doc |
34 |
|
35 |
fi |
36 |
|
37 |
EXPORT_FUNCTIONS src_install pkg_postinst pkg_postrm |
38 |
|
39 |
# src_prepare is only exported in EAPI >= 8 |
40 |
case ${EAPI:-0} in |
41 |
6|7) ;; |
42 |
8) EXPORT_FUNCTIONS src_prepare ;; |
43 |
esac |
44 |
|
45 |
if [[ ! ${_VIM_PLUGIN_ECLASS} ]]; then |
46 |
# @ECLASS_VARIABLE: VIM_PLUGIN_VIM_VERSION |
47 |
# @DESCRIPTION: |
48 |
# Minimum Vim version the plugin supports. |
49 |
VIM_PLUGIN_VIM_VERSION="${VIM_PLUGIN_VIM_VERSION:-7.3}" |
50 |
|
51 |
DEPEND="|| ( >=app-editors/vim-${VIM_PLUGIN_VIM_VERSION} |
52 |
>=app-editors/gvim-${VIM_PLUGIN_VIM_VERSION} )" |
53 |
RDEPEND="${DEPEND}" |
54 |
if [[ ${PV} != 9999* ]] ; then |
55 |
SRC_URI="mirror://gentoo/${P}.tar.bz2 |
56 |
https://dev.gentoo.org/~radhermit/vim/${P}.tar.bz2" |
57 |
fi |
58 |
SLOT="0" |
59 |
|
60 |
if ${_DEFINE_VIM_PLUGIN_SRC_PREPARE}; then |
61 |
# @FUNCTION: vim-plugin_src_prepare |
62 |
# @USAGE: |
63 |
# @DESCRIPTION: |
64 |
# Moves "after/syntax" plugins to directories to avoid file collisions with |
65 |
# other packages. |
66 |
# Note that this function is only defined and exported in EAPIs >= 8. |
67 |
vim-plugin_src_prepare() { |
68 |
+ debug-print-function ${FUNCNAME} "${@}" |
69 |
+ |
70 |
default_src_prepare |
71 |
|
72 |
# return if there's nothing to do |
73 |
[[ -d after/syntax ]] || return |
74 |
|
75 |
pushd after/syntax >/dev/null || die |
76 |
for file in *.vim; do |
77 |
[[ -f "${file}" ]] || continue |
78 |
mkdir "${file%.vim}" || die |
79 |
mv "${file}" "${file%.vim}/${PN}.vim" || die |
80 |
done |
81 |
popd >/dev/null || die |
82 |
} |
83 |
fi |
84 |
|
85 |
# @ECLASS_VARIABLE: _VIM_PLUGIN_ALLOWED_DIRS |
86 |
# @INTERNAL |
87 |
# @DESCRIPTION: |
88 |
# Vanilla Vim dirs. |
89 |
# See /usr/share/vim/vim* for reference. |
90 |
_VIM_PLUGIN_ALLOWED_DIRS=( |
91 |
after autoload colors compiler doc ftdetect ftplugin indent keymap |
92 |
macros plugin spell syntax |
93 |
) |
94 |
|
95 |
# @FUNCTION: vim-plugin_src_install |
96 |
# @USAGE: [<dir>...] |
97 |
# @DESCRIPTION: |
98 |
# Overrides the default src_install phase. In order, this function: |
99 |
# * installs help and documentation files. |
100 |
# * installs all files recognized by default Vim installation and directories |
101 |
# passed to this function as arguments in "${ED}"/usr/share/vim/vimfiles. |
102 |
# |
103 |
# Example use: |
104 |
# @CODE |
105 |
# src_install() { |
106 |
# vim-plugin_src_install syntax_checkers |
107 |
# } |
108 |
# @CODE |
109 |
vim-plugin_src_install() { |
110 |
+ debug-print-function ${FUNCNAME} "${@}" |
111 |
+ |
112 |
# Install non-vim-help-docs |
113 |
einstalldocs |
114 |
|
115 |
# Install remainder of plugin |
116 |
insinto /usr/share/vim/vimfiles/ |
117 |
local d |
118 |
case ${EAPI:-0} in |
119 |
6|7) |
120 |
for d in *; do |
121 |
[[ -d "${d}" ]] || continue |
122 |
doins -r "${d}" |
123 |
done ;; |
124 |
*) |
125 |
for d in "${_VIM_PLUGIN_ALLOWED_DIRS[@]}" "${@}"; do |
126 |
[[ -d "${d}" ]] || continue |
127 |
doins -r "${d}" |
128 |
done ;; |
129 |
esac |
130 |
} |
131 |
|
132 |
# @FUNCTION: vim-plugin_pkg_postinst |
133 |
# @USAGE: |
134 |
# @DESCRIPTION: |
135 |
# Overrides the pkg_postinst phase for this eclass. |
136 |
# The following functions are called: |
137 |
# * update_vim_helptags |
138 |
# * update_vim_afterscripts |
139 |
# * display_vim_plugin_help |
140 |
vim-plugin_pkg_postinst() { |
141 |
+ debug-print-function ${FUNCNAME} "${@}" |
142 |
+ |
143 |
update_vim_helptags # from vim-doc |
144 |
update_vim_afterscripts # see below |
145 |
display_vim_plugin_help # see below |
146 |
} |
147 |
|
148 |
# @FUNCTION: vim-plugin_pkg_postrm |
149 |
# @DESCRIPTION: |
150 |
# Overrides the pkg_postrm phase for this eclass. |
151 |
# This function calls the update_vim_helptags and update_vim_afterscripts |
152 |
# functions and eventually removes a bunch of empty directories. |
153 |
vim-plugin_pkg_postrm() { |
154 |
+ debug-print-function ${FUNCNAME} "${@}" |
155 |
+ |
156 |
update_vim_helptags # from vim-doc |
157 |
update_vim_afterscripts # see below |
158 |
|
159 |
# Remove empty dirs; this allows |
160 |
# /usr/share/vim to be removed if vim-core is unmerged |
161 |
find "${EPREFIX}/usr/share/vim/vimfiles" -depth -type d -exec rmdir {} \; 2>/dev/null || \ |
162 |
die "rmdir failed" |
163 |
} |
164 |
|
165 |
# @FUNCTION: update_vim_afterscripts |
166 |
# @USAGE: |
167 |
# @DESCRIPTION: |
168 |
# Creates scripts in /usr/share/vim/vimfiles/after/* |
169 |
# comprised of the snippets in /usr/share/vim/vimfiles/after/*/*.d |
170 |
update_vim_afterscripts() { |
171 |
+ debug-print-function ${FUNCNAME} "${@}" |
172 |
+ |
173 |
local d f afterdir="${EROOT}"/usr/share/vim/vimfiles/after |
174 |
|
175 |
# Nothing to do if the dir isn't there |
176 |
[[ -d "${afterdir}" ]] || return 0 |
177 |
|
178 |
einfo "Updating scripts in ${afterdir}" |
179 |
find "${afterdir}" -type d -name \*.vim.d | while read d; do |
180 |
echo '" Generated by update_vim_afterscripts' > "${d%.d}" || die |
181 |
find "${d}" -name \*.vim -type f -maxdepth 1 -print0 | sort -z | \ |
182 |
xargs -0 cat >> "${d%.d}" || die "update_vim_afterscripts failed" |
183 |
done |
184 |
|
185 |
einfo "Removing dead scripts in ${afterdir}" |
186 |
find "${afterdir}" -type f -name \*.vim | \ |
187 |
while read f; do |
188 |
[[ "$(head -n 1 ${f})" == '" Generated by update_vim_afterscripts' ]] \ |
189 |
|| continue |
190 |
# This is a generated file, but might be abandoned. Check |
191 |
# if there's no corresponding .d directory, or if the |
192 |
# file's effectively empty |
193 |
if [[ ! -d "${f}.d" || -z "$(grep -v '^"' "${f}")" ]]; then |
194 |
rm "${f}" || die |
195 |
fi |
196 |
done |
197 |
} |
198 |
|
199 |
# @FUNCTION: display_vim_plugin_help |
200 |
# @USAGE: |
201 |
# @DESCRIPTION: |
202 |
# Displays a message with the plugin's help file if one is available. Uses the |
203 |
# VIM_PLUGIN_HELPFILES env var. If multiple help files are available, they |
204 |
# should be separated by spaces. If no help files are available, but the env |
205 |
# var VIM_PLUGIN_HELPTEXT is set, that is displayed instead. Finally, if we |
206 |
# have nothing else, this functions displays a link to VIM_PLUGIN_HELPURI. An |
207 |
# extra message regarding enabling filetype plugins is displayed if |
208 |
# VIM_PLUGIN_MESSAGES includes the word "filetype". |
209 |
display_vim_plugin_help() { |
210 |
+ debug-print-function ${FUNCNAME} "${@}" |
211 |
+ |
212 |
local h |
213 |
|
214 |
if [[ -z ${REPLACING_VERSIONS} ]]; then |
215 |
if [[ -n ${VIM_PLUGIN_HELPFILES} ]]; then |
216 |
elog " " |
217 |
elog "This plugin provides documentation via vim's help system. To" |
218 |
elog "view it, use:" |
219 |
for h in ${VIM_PLUGIN_HELPFILES}; do |
220 |
elog " :help ${h}" |
221 |
done |
222 |
elog " " |
223 |
|
224 |
elif [[ -n ${VIM_PLUGIN_HELPTEXT} ]]; then |
225 |
elog " " |
226 |
while read h ; do |
227 |
elog "$h" |
228 |
done <<<"${VIM_PLUGIN_HELPTEXT}" |
229 |
elog " " |
230 |
|
231 |
elif [[ -n ${VIM_PLUGIN_HELPURI} ]]; then |
232 |
elog " " |
233 |
elog "Documentation for this plugin is available online at:" |
234 |
elog " ${VIM_PLUGIN_HELPURI}" |
235 |
elog " " |
236 |
fi |
237 |
|
238 |
if has filetype ${VIM_PLUGIN_MESSAGES}; then |
239 |
elog "This plugin makes use of filetype settings. To enable these," |
240 |
elog "add lines like:" |
241 |
elog " filetype plugin on" |
242 |
elog " filetype indent on" |
243 |
elog "to your ~/.vimrc file." |
244 |
elog " " |
245 |
fi |
246 |
fi |
247 |
} |
248 |
|
249 |
_VIM_PLUGIN_ECLASS=1 |
250 |
fi |
251 |
-- |
252 |
2.35.1 |