mirror of
https://github.com/neovim/neovim.git
synced 2025-09-30 15:08:35 +00:00
vim-patch:7.4.1553
Problem: ":runtime" does not use 'packpath'.
Solution: Add "what" argument.
8dcf259d90
This commit is contained in:
@@ -174,10 +174,12 @@ For writing a Vim script, see chapter 41 of the user manual |usr_41.txt|.
|
||||
commands.
|
||||
|
||||
*:ru* *:runtime*
|
||||
:ru[ntime][!] {file} ..
|
||||
:ru[ntime][!] [where] {file} ..
|
||||
Read Ex commands from {file} in each directory given
|
||||
by 'runtimepath'. There is no error for non-existing
|
||||
files. Example: >
|
||||
by 'runtimepath' and/or 'packpath'. There is no error
|
||||
for non-existing files.
|
||||
|
||||
Example: >
|
||||
:runtime syntax/c.vim
|
||||
|
||||
< There can be multiple {file} arguments, separated by
|
||||
@@ -191,6 +193,15 @@ For writing a Vim script, see chapter 41 of the user manual |usr_41.txt|.
|
||||
When it is not included only the first found file is
|
||||
sourced.
|
||||
|
||||
When [where] is omitted only 'runtimepath' is used.
|
||||
Other values:
|
||||
START search under "start" in 'packpath'
|
||||
OPT search under "opt" in 'packpath'
|
||||
PACK search under "start" and "opt" in
|
||||
'packpath'
|
||||
ALL first use 'runtimepath', then search
|
||||
under "start" and "opt" in 'packpath'
|
||||
|
||||
When {file} contains wildcards it is expanded to all
|
||||
matching files. Example: >
|
||||
:runtime! plugin/*.vim
|
||||
@@ -229,6 +240,16 @@ For writing a Vim script, see chapter 41 of the user manual |usr_41.txt|.
|
||||
|
||||
Also see |pack-add|.
|
||||
|
||||
:packloadall[!] Load all packages in the "start" directories under
|
||||
'packpath'. The directories found are added to
|
||||
'runtimepath'.
|
||||
This normally done during startup, after loading your
|
||||
.vimrc file. With this command it can be done
|
||||
earlier.
|
||||
Packages will be loaded only once. After this command
|
||||
it won't happen again. When the optional ! is added
|
||||
this command will load packages even when done before.
|
||||
See |packages|.
|
||||
|
||||
:scripte[ncoding] [encoding] *:scripte* *:scriptencoding* *E167*
|
||||
Specify the character encoding used in the script.
|
||||
@@ -446,8 +467,13 @@ Note that the files under "pack/foo/opt" or not loaded automatically, only the
|
||||
ones under "pack/foo/start". See |pack-add| below for how the "opt" directory
|
||||
is used.
|
||||
|
||||
Loading packages will not happen if loading plugins is disabled, see
|
||||
|load-plugins|.
|
||||
Loading packages automatically will not happen if loading plugins is disabled,
|
||||
see |load-plugins|.
|
||||
|
||||
To load packages earlier, so that 'runtimepath' gets updated: >
|
||||
:packloadall
|
||||
This also works when loading plugins is disabled. The automatic loading will
|
||||
only happen once.
|
||||
|
||||
|
||||
Using a single plugin and loading it automatically ~
|
||||
|
@@ -2263,10 +2263,29 @@ void ex_compiler(exarg_T *eap)
|
||||
}
|
||||
}
|
||||
|
||||
/// ":runtime {name}"
|
||||
/// ":runtime [what] {name}"
|
||||
void ex_runtime(exarg_T *eap)
|
||||
{
|
||||
source_runtime(eap->arg, eap->forceit ? DIP_ALL : 0);
|
||||
char_u *arg = eap->arg;
|
||||
char_u *p = skiptowhite(arg);
|
||||
ptrdiff_t len = p - arg;
|
||||
int flags = eap->forceit ? DIP_ALL : 0;
|
||||
|
||||
if (STRNCMP(arg, "START", len) == 0) {
|
||||
flags += DIP_START + DIP_NORTP;
|
||||
arg = skipwhite(arg + len);
|
||||
} else if (STRNCMP(arg, "OPT", len) == 0) {
|
||||
flags += DIP_OPT + DIP_NORTP;
|
||||
arg = skipwhite(arg + len);
|
||||
} else if (STRNCMP(arg, "PACK", len) == 0) {
|
||||
flags += DIP_START + DIP_OPT + DIP_NORTP;
|
||||
arg = skipwhite(arg + len);
|
||||
} else if (STRNCMP(arg, "ALL", len) == 0) {
|
||||
flags += DIP_START + DIP_OPT;
|
||||
arg = skipwhite(arg + len);
|
||||
}
|
||||
|
||||
source_runtime(arg, flags);
|
||||
}
|
||||
|
||||
|
||||
@@ -2388,9 +2407,13 @@ int do_in_path(char_u *path, char_u *name, int flags,
|
||||
int do_in_runtimepath(char_u *name, int flags, DoInRuntimepathCB callback,
|
||||
void *cookie)
|
||||
{
|
||||
int done = do_in_path(p_rtp, name, flags, callback, cookie);
|
||||
int done = FAIL;
|
||||
|
||||
if (done == FAIL && (flags & DIP_START)) {
|
||||
if ((flags & DIP_NORTP) == 0) {
|
||||
done = do_in_path(p_rtp, name, flags, callback, cookie);
|
||||
}
|
||||
|
||||
if ((done == FAIL || (flags & DIP_ALL)) && (flags & DIP_START)) {
|
||||
char *start_dir = "pack/*/start/*/%s";
|
||||
size_t len = STRLEN(start_dir) + STRLEN(name);
|
||||
char_u *s = xmallocz(len);
|
||||
@@ -2401,7 +2424,7 @@ int do_in_runtimepath(char_u *name, int flags, DoInRuntimepathCB callback,
|
||||
xfree(s);
|
||||
}
|
||||
|
||||
if (done == FAIL && (flags & DIP_OPT)) {
|
||||
if ((done == FAIL || (flags & DIP_ALL)) && (flags & DIP_OPT)) {
|
||||
char *opt_dir = "pack/*/opt/*/%s";
|
||||
size_t len = STRLEN(opt_dir) + STRLEN(name);
|
||||
char_u *s = xmallocz(len);
|
||||
|
@@ -142,7 +142,7 @@ static int included_patches[] = {
|
||||
// 1556 NA
|
||||
// 1555 NA
|
||||
// 1554,
|
||||
// 1553,
|
||||
1553,
|
||||
1552,
|
||||
1551,
|
||||
1550,
|
||||
|
@@ -314,5 +314,6 @@ enum {
|
||||
#define DIP_ERR 0x04 // give an error message when none found
|
||||
#define DIP_START 0x08 // also use "start" directory in 'packpath'
|
||||
#define DIP_OPT 0x10 // also use "opt" directory in 'packpath'
|
||||
#define DIP_NORTP 0x20 // do not use 'runtimepath'
|
||||
|
||||
#endif /* NVIM_VIM_H */
|
||||
|
@@ -127,6 +127,53 @@ describe('packadd', function()
|
||||
colorscheme three
|
||||
call assert_equal(1, g:found_three)
|
||||
endfunc
|
||||
|
||||
func Test_runtime()
|
||||
let rundir = &packpath . '/runtime/extra'
|
||||
let startdir = &packpath . '/pack/mine/start/foo/extra'
|
||||
let optdir = &packpath . '/pack/mine/opt/bar/extra'
|
||||
call mkdir(rundir, 'p')
|
||||
call mkdir(startdir, 'p')
|
||||
call mkdir(optdir, 'p')
|
||||
call writefile(['let g:sequence .= "run"'], rundir . '/bar.vim')
|
||||
call writefile(['let g:sequence .= "start"'], startdir . '/bar.vim')
|
||||
call writefile(['let g:sequence .= "foostart"'], startdir . '/foo.vim')
|
||||
call writefile(['let g:sequence .= "opt"'], optdir . '/bar.vim')
|
||||
call writefile(['let g:sequence .= "xxxopt"'], optdir . '/xxx.vim')
|
||||
exe 'set rtp=' . &packpath . '/runtime'
|
||||
|
||||
let g:sequence = ''
|
||||
runtime extra/bar.vim
|
||||
call assert_equal('run', g:sequence)
|
||||
let g:sequence = ''
|
||||
runtime START extra/bar.vim
|
||||
call assert_equal('start', g:sequence)
|
||||
let g:sequence = ''
|
||||
runtime OPT extra/bar.vim
|
||||
call assert_equal('opt', g:sequence)
|
||||
let g:sequence = ''
|
||||
runtime PACK extra/bar.vim
|
||||
call assert_equal('start', g:sequence)
|
||||
let g:sequence = ''
|
||||
runtime! PACK extra/bar.vim
|
||||
call assert_equal('startopt', g:sequence)
|
||||
let g:sequence = ''
|
||||
runtime PACK extra/xxx.vim
|
||||
call assert_equal('xxxopt', g:sequence)
|
||||
|
||||
let g:sequence = ''
|
||||
runtime ALL extra/bar.vim
|
||||
call assert_equal('run', g:sequence)
|
||||
let g:sequence = ''
|
||||
runtime ALL extra/foo.vim
|
||||
call assert_equal('foostart', g:sequence)
|
||||
let g:sequence = ''
|
||||
runtime! ALL extra/xxx.vim
|
||||
call assert_equal('xxxopt', g:sequence)
|
||||
let g:sequence = ''
|
||||
runtime! ALL extra/bar.vim
|
||||
call assert_equal('runstartopt', g:sequence)
|
||||
endfunc
|
||||
]=])
|
||||
call('SetUp')
|
||||
end)
|
||||
@@ -160,6 +207,11 @@ describe('packadd', function()
|
||||
expected_empty()
|
||||
end)
|
||||
|
||||
it('works with :runtime [what]', function()
|
||||
call('Test_runtime')
|
||||
expected_empty()
|
||||
end)
|
||||
|
||||
describe('command line completion', function()
|
||||
local Screen = require('test.functional.ui.screen')
|
||||
local screen
|
||||
|
Reference in New Issue
Block a user