Skip to content

Commit 2d8f56a

Browse files
committed
patch 7.4.1550
Problem: Cannot load packages early. Solution: Add the ":packloadall" command.
1 parent c835293 commit 2d8f56a

6 files changed

Lines changed: 33 additions & 5 deletions

File tree

src/ex_cmds.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1014,6 +1014,9 @@ EX(CMD_print, "print", ex_print,
10141014
EX(CMD_packadd, "packadd", ex_packadd,
10151015
BANG|FILE1|NEEDARG|TRLBAR|SBOXOK|CMDWIN,
10161016
ADDR_LINES),
1017+
EX(CMD_packloadall, "packloadall", ex_packloadall,
1018+
BANG|TRLBAR|SBOXOK|CMDWIN,
1019+
ADDR_LINES),
10171020
EX(CMD_pclose, "pclose", ex_pclose,
10181021
BANG|TRLBAR,
10191022
ADDR_LINES),

src/ex_cmds2.c

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3189,14 +3189,21 @@ add_pack_plugin(char_u *fname, void *cookie)
31893189
vim_free(ffname);
31903190
}
31913191

3192+
static int did_source_packages = FALSE;
3193+
31923194
/*
3195+
* ":packloadall"
31933196
* Find plugins in the package directories and source them.
31943197
*/
31953198
void
3196-
source_packages()
3199+
ex_packloadall(exarg_T *eap)
31973200
{
3198-
do_in_path(p_pp, (char_u *)"pack/*/start/*", DIP_ALL + DIP_DIR,
3201+
if (!did_source_packages || (eap != NULL && eap->forceit))
3202+
{
3203+
did_source_packages = TRUE;
3204+
do_in_path(p_pp, (char_u *)"pack/*/start/*", DIP_ALL + DIP_DIR,
31993205
add_pack_plugin, p_pp);
3206+
}
32003207
}
32013208

32023209
/*

src/main.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -634,7 +634,7 @@ vim_main2(int argc UNUSED, char **argv UNUSED)
634634
# endif
635635
TIME_MSG("loading plugins");
636636

637-
source_packages();
637+
ex_packloadall(NULL);
638638
TIME_MSG("loading packages");
639639
}
640640
#endif

src/proto/ex_cmds2.pro

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,7 @@ void ex_compiler(exarg_T *eap);
6262
void ex_runtime(exarg_T *eap);
6363
int source_runtime(char_u *name, int all);
6464
int do_in_runtimepath(char_u *name, int all, void (*callback)(char_u *fname, void *ck), void *cookie);
65-
void source_packages(void);
66-
void ex_loadplugin(exarg_T *eap);
65+
void ex_packloadall(exarg_T *eap);
6766
void ex_packadd(exarg_T *eap);
6867
void ex_options(exarg_T *eap);
6968
void ex_source(exarg_T *eap);

src/testdir/test_packadd.vim

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,3 +80,20 @@ func Test_packadd_completion()
8080
call assert_equal("packadd pluginC", li[2])
8181
call assert_equal("packadd ", li[3])
8282
endfunc
83+
84+
func Test_packloadall()
85+
let plugindir = &packpath . '/pack/mine/start/foo/plugin'
86+
call mkdir(plugindir, 'p')
87+
call writefile(['let g:plugin_foo_number = 1234'], plugindir . '/bar.vim')
88+
packloadall
89+
call assert_equal(1234, g:plugin_foo_number)
90+
91+
" only works once
92+
call writefile(['let g:plugin_bar_number = 4321'], plugindir . '/bar2.vim')
93+
packloadall
94+
call assert_false(exists('g:plugin_bar_number'))
95+
96+
" works when ! used
97+
packloadall!
98+
call assert_equal(4321, g:plugin_bar_number)
99+
endfunc

src/version.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -743,6 +743,8 @@ static char *(features[]) =
743743

744744
static int included_patches[] =
745745
{ /* Add new patch number below this line */
746+
/**/
747+
1550,
746748
/**/
747749
1549,
748750
/**/

0 commit comments

Comments
 (0)