mirror of
https://github.com/neovim/neovim.git
synced 2025-09-29 14:38:32 +00:00
vim-patch:8.0.0612
Problem: Package directories are added to 'runtimepath' only after loading
non-package plugins.
Solution: Split off the code to add package directories to 'runtimepath'.
(Ingo Karkat, closes vim/vim#1680)
ce876aaa9a
This commit is contained in:
@@ -2623,23 +2623,31 @@ theend:
|
|||||||
xfree(ffname);
|
xfree(ffname);
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool did_source_packages = false;
|
/// Add all packages in the "start" directory to 'runtimepath'.
|
||||||
|
void add_pack_start_dirs(void)
|
||||||
|
{
|
||||||
|
do_in_path(p_pp, (char_u *)"pack/*/start/*", DIP_ALL + DIP_DIR, // NOLINT
|
||||||
|
add_pack_plugin, &APP_ADD_DIR);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Load plugins from all packages in the "start" directory.
|
||||||
|
void load_start_packages(void)
|
||||||
|
{
|
||||||
|
did_source_packages = true;
|
||||||
|
do_in_path(p_pp, (char_u *)"pack/*/start/*", DIP_ALL + DIP_DIR, // NOLINT
|
||||||
|
add_pack_plugin, &APP_LOAD);
|
||||||
|
}
|
||||||
|
|
||||||
// ":packloadall"
|
// ":packloadall"
|
||||||
// Find plugins in the package directories and source them.
|
// Find plugins in the package directories and source them.
|
||||||
// "eap" is NULL when invoked during startup.
|
|
||||||
void ex_packloadall(exarg_T *eap)
|
void ex_packloadall(exarg_T *eap)
|
||||||
{
|
{
|
||||||
if (!did_source_packages || (eap != NULL && eap->forceit)) {
|
if (!did_source_packages || eap->forceit) {
|
||||||
did_source_packages = true;
|
|
||||||
|
|
||||||
// First do a round to add all directories to 'runtimepath', then load
|
// First do a round to add all directories to 'runtimepath', then load
|
||||||
// the plugins. This allows for plugins to use an autoload directory
|
// the plugins. This allows for plugins to use an autoload directory
|
||||||
// of another plugin.
|
// of another plugin.
|
||||||
do_in_path(p_pp, (char_u *)"pack/*/start/*", DIP_ALL + DIP_DIR, // NOLINT
|
add_pack_start_dirs();
|
||||||
add_pack_plugin, &APP_ADD_DIR);
|
load_start_packages();
|
||||||
do_in_path(p_pp, (char_u *)"pack/*/start/*", DIP_ALL + DIP_DIR, // NOLINT
|
|
||||||
add_pack_plugin, &APP_LOAD);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -407,6 +407,9 @@ EXTERN int garbage_collect_at_exit INIT(= FALSE);
|
|||||||
|
|
||||||
/* ID of script being sourced or was sourced to define the current function. */
|
/* ID of script being sourced or was sourced to define the current function. */
|
||||||
EXTERN scid_T current_SID INIT(= 0);
|
EXTERN scid_T current_SID INIT(= 0);
|
||||||
|
|
||||||
|
EXTERN bool did_source_packages INIT(= false);
|
||||||
|
|
||||||
// Scope information for the code that indirectly triggered the current
|
// Scope information for the code that indirectly triggered the current
|
||||||
// provider function call
|
// provider function call
|
||||||
EXTERN struct caller_scope {
|
EXTERN struct caller_scope {
|
||||||
|
@@ -1291,10 +1291,21 @@ static void set_window_layout(mparm_T *paramp)
|
|||||||
static void load_plugins(void)
|
static void load_plugins(void)
|
||||||
{
|
{
|
||||||
if (p_lpl) {
|
if (p_lpl) {
|
||||||
|
// First add all package directories to 'runtimepath', so that their
|
||||||
|
// autoload directories can be found. Only if not done already with a
|
||||||
|
// :packloadall command.
|
||||||
|
if (!did_source_packages) {
|
||||||
|
add_pack_start_dirs();
|
||||||
|
}
|
||||||
|
|
||||||
source_runtime((char_u *)"plugin/**/*.vim", DIP_ALL | DIP_NOAFTER); // NOLINT
|
source_runtime((char_u *)"plugin/**/*.vim", DIP_ALL | DIP_NOAFTER); // NOLINT
|
||||||
TIME_MSG("loading plugins");
|
TIME_MSG("loading plugins");
|
||||||
|
|
||||||
ex_packloadall(NULL);
|
// Only source "start" packages if not done already with a :packloadall
|
||||||
|
// command.
|
||||||
|
if (!did_source_packages) {
|
||||||
|
load_start_packages();
|
||||||
|
}
|
||||||
TIME_MSG("loading packages");
|
TIME_MSG("loading packages");
|
||||||
|
|
||||||
source_runtime((char_u *)"plugin/**/*.vim", DIP_ALL | DIP_AFTER);
|
source_runtime((char_u *)"plugin/**/*.vim", DIP_ALL | DIP_AFTER);
|
||||||
|
@@ -62,6 +62,38 @@ func Test_after_comes_later()
|
|||||||
call delete('Xafter', 'rf')
|
call delete('Xafter', 'rf')
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
|
func Test_pack_in_rtp_when_plugins_run()
|
||||||
|
if !has('packages')
|
||||||
|
return
|
||||||
|
endif
|
||||||
|
let before = [
|
||||||
|
\ 'set nocp viminfo+=nviminfo',
|
||||||
|
\ 'set guioptions+=M',
|
||||||
|
\ 'let $HOME = "/does/not/exist"',
|
||||||
|
\ 'set loadplugins',
|
||||||
|
\ 'set rtp=Xhere',
|
||||||
|
\ 'set packpath=Xhere',
|
||||||
|
\ 'set nomore',
|
||||||
|
\ ]
|
||||||
|
let after = [
|
||||||
|
\ 'quit',
|
||||||
|
\ ]
|
||||||
|
call mkdir('Xhere/plugin', 'p')
|
||||||
|
call writefile(['redir! > Xtestout', 'silent set runtimepath?', 'silent! call foo#Trigger()', 'redir END'], 'Xhere/plugin/here.vim')
|
||||||
|
call mkdir('Xhere/pack/foo/start/foobar/autoload', 'p')
|
||||||
|
call writefile(['function! foo#Trigger()', 'echo "autoloaded foo"', 'endfunction'], 'Xhere/pack/foo/start/foobar/autoload/foo.vim')
|
||||||
|
|
||||||
|
if RunVim(before, after, '')
|
||||||
|
|
||||||
|
let lines = filter(readfile('Xtestout'), '!empty(v:val)')
|
||||||
|
call assert_match('Xhere[/\\]pack[/\\]foo[/\\]start[/\\]foobar', get(lines, 0))
|
||||||
|
call assert_match('autoloaded foo', get(lines, 1))
|
||||||
|
endif
|
||||||
|
|
||||||
|
call delete('Xtestout')
|
||||||
|
call delete('Xhere', 'rf')
|
||||||
|
endfunc
|
||||||
|
|
||||||
func Test_help_arg()
|
func Test_help_arg()
|
||||||
if !has('unix') && has('gui')
|
if !has('unix') && has('gui')
|
||||||
" this doesn't work with gvim on MS-Windows
|
" this doesn't work with gvim on MS-Windows
|
||||||
|
@@ -340,7 +340,7 @@ static const int included_patches[] = {
|
|||||||
// 615,
|
// 615,
|
||||||
614,
|
614,
|
||||||
// 613,
|
// 613,
|
||||||
// 612,
|
612,
|
||||||
// 611,
|
// 611,
|
||||||
// 610,
|
// 610,
|
||||||
// 609,
|
// 609,
|
||||||
|
Reference in New Issue
Block a user