1 |
Signed-off-by: Anna Vyalkova <cyber+gentoo@×××××.in> |
2 |
--- |
3 |
eclass/vim-plugin.eclass | 5 +++++ |
4 |
1 file changed, 5 insertions(+) |
5 |
|
6 |
diff --git a/eclass/vim-plugin.eclass b/eclass/vim-plugin.eclass |
7 |
index 97b6097726..0fd2b9b81d 100644 |
8 |
--- a/eclass/vim-plugin.eclass |
9 |
+++ b/eclass/vim-plugin.eclass |
10 |
@@ -1,240 +1,245 @@ |
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 |
+# |
100 |
# * installs help and documentation files. |
101 |
+# |
102 |
# * installs all files recognized by default Vim installation and directories |
103 |
# passed to this function as arguments in "${ED}"/usr/share/vim/vimfiles. |
104 |
# |
105 |
# Example use: |
106 |
# @CODE |
107 |
# src_install() { |
108 |
# vim-plugin_src_install syntax_checkers |
109 |
# } |
110 |
# @CODE |
111 |
vim-plugin_src_install() { |
112 |
debug-print-function ${FUNCNAME} "${@}" |
113 |
|
114 |
# Install non-vim-help-docs |
115 |
einstalldocs |
116 |
|
117 |
# Install remainder of plugin |
118 |
insinto /usr/share/vim/vimfiles/ |
119 |
local d |
120 |
case ${EAPI:-0} in |
121 |
6|7) |
122 |
for d in *; do |
123 |
[[ -d "${d}" ]] || continue |
124 |
doins -r "${d}" |
125 |
done ;; |
126 |
*) |
127 |
for d in "${_VIM_PLUGIN_ALLOWED_DIRS[@]}" "${@}"; do |
128 |
[[ -d "${d}" ]] || continue |
129 |
doins -r "${d}" |
130 |
done ;; |
131 |
esac |
132 |
} |
133 |
|
134 |
# @FUNCTION: vim-plugin_pkg_postinst |
135 |
# @USAGE: |
136 |
# @DESCRIPTION: |
137 |
# Overrides the pkg_postinst phase for this eclass. |
138 |
# The following functions are called: |
139 |
+# |
140 |
# * update_vim_helptags |
141 |
+# |
142 |
# * update_vim_afterscripts |
143 |
+# |
144 |
# * display_vim_plugin_help |
145 |
vim-plugin_pkg_postinst() { |
146 |
debug-print-function ${FUNCNAME} "${@}" |
147 |
|
148 |
update_vim_helptags # from vim-doc |
149 |
update_vim_afterscripts # see below |
150 |
display_vim_plugin_help # see below |
151 |
} |
152 |
|
153 |
# @FUNCTION: vim-plugin_pkg_postrm |
154 |
# @DESCRIPTION: |
155 |
# Overrides the pkg_postrm phase for this eclass. |
156 |
# This function calls the update_vim_helptags and update_vim_afterscripts |
157 |
# functions and eventually removes a bunch of empty directories. |
158 |
vim-plugin_pkg_postrm() { |
159 |
debug-print-function ${FUNCNAME} "${@}" |
160 |
|
161 |
update_vim_helptags # from vim-doc |
162 |
update_vim_afterscripts # see below |
163 |
|
164 |
# Remove empty dirs; this allows |
165 |
# /usr/share/vim to be removed if vim-core is unmerged |
166 |
find "${EPREFIX}/usr/share/vim/vimfiles" -depth -type d -exec rmdir {} \; 2>/dev/null || \ |
167 |
die "rmdir failed" |
168 |
} |
169 |
|
170 |
# @FUNCTION: update_vim_afterscripts |
171 |
# @USAGE: |
172 |
# @DESCRIPTION: |
173 |
# Creates scripts in /usr/share/vim/vimfiles/after/* |
174 |
# comprised of the snippets in /usr/share/vim/vimfiles/after/*/*.d |
175 |
update_vim_afterscripts() { |
176 |
debug-print-function ${FUNCNAME} "${@}" |
177 |
|
178 |
local d f afterdir="${EROOT}"/usr/share/vim/vimfiles/after |
179 |
|
180 |
# Nothing to do if the dir isn't there |
181 |
[[ -d "${afterdir}" ]] || return 0 |
182 |
|
183 |
einfo "Updating scripts in ${afterdir}" |
184 |
find "${afterdir}" -type d -name \*.vim.d | while read d; do |
185 |
echo '" Generated by update_vim_afterscripts' > "${d%.d}" || die |
186 |
find "${d}" -name \*.vim -type f -maxdepth 1 -print0 | sort -z | \ |
187 |
xargs -0 cat >> "${d%.d}" || die "update_vim_afterscripts failed" |
188 |
done |
189 |
|
190 |
einfo "Removing dead scripts in ${afterdir}" |
191 |
find "${afterdir}" -type f -name \*.vim | \ |
192 |
while read f; do |
193 |
[[ "$(head -n 1 ${f})" == '" Generated by update_vim_afterscripts' ]] \ |
194 |
|| continue |
195 |
# This is a generated file, but might be abandoned. Check |
196 |
# if there's no corresponding .d directory, or if the |
197 |
# file's effectively empty |
198 |
if [[ ! -d "${f}.d" || -z "$(grep -v '^"' "${f}")" ]]; then |
199 |
rm "${f}" || die |
200 |
fi |
201 |
done |
202 |
} |
203 |
|
204 |
# @FUNCTION: display_vim_plugin_help |
205 |
# @USAGE: |
206 |
# @DESCRIPTION: |
207 |
# Displays a message with the plugin's help file if one is available. Uses the |
208 |
# VIM_PLUGIN_HELPFILES env var. If multiple help files are available, they |
209 |
# should be separated by spaces. If no help files are available, but the env |
210 |
# var VIM_PLUGIN_HELPTEXT is set, that is displayed instead. Finally, if we |
211 |
# have nothing else, this functions displays a link to VIM_PLUGIN_HELPURI. An |
212 |
# extra message regarding enabling filetype plugins is displayed if |
213 |
# VIM_PLUGIN_MESSAGES includes the word "filetype". |
214 |
display_vim_plugin_help() { |
215 |
debug-print-function ${FUNCNAME} "${@}" |
216 |
|
217 |
local h |
218 |
|
219 |
if [[ -z ${REPLACING_VERSIONS} ]]; then |
220 |
if [[ -n ${VIM_PLUGIN_HELPFILES} ]]; then |
221 |
elog " " |
222 |
elog "This plugin provides documentation via vim's help system. To" |
223 |
elog "view it, use:" |
224 |
for h in ${VIM_PLUGIN_HELPFILES}; do |
225 |
elog " :help ${h}" |
226 |
done |
227 |
elog " " |
228 |
|
229 |
elif [[ -n ${VIM_PLUGIN_HELPTEXT} ]]; then |
230 |
elog " " |
231 |
while read h ; do |
232 |
elog "$h" |
233 |
done <<<"${VIM_PLUGIN_HELPTEXT}" |
234 |
elog " " |
235 |
|
236 |
elif [[ -n ${VIM_PLUGIN_HELPURI} ]]; then |
237 |
elog " " |
238 |
elog "Documentation for this plugin is available online at:" |
239 |
elog " ${VIM_PLUGIN_HELPURI}" |
240 |
elog " " |
241 |
fi |
242 |
|
243 |
if has filetype ${VIM_PLUGIN_MESSAGES}; then |
244 |
elog "This plugin makes use of filetype settings. To enable these," |
245 |
elog "add lines like:" |
246 |
elog " filetype plugin on" |
247 |
elog " filetype indent on" |
248 |
elog "to your ~/.vimrc file." |
249 |
elog " " |
250 |
fi |
251 |
fi |
252 |
} |
253 |
|
254 |
_VIM_PLUGIN_ECLASS=1 |
255 |
fi |
256 |
-- |
257 |
2.35.1 |