From e902a172ef1a58e93eeae0919bddb3578a2142a2 Mon Sep 17 00:00:00 2001 From: James McCoy Date: Mon, 25 Apr 2016 23:07:51 -0400 Subject: vim-patch:7.4.1384 Problem: It is not easy to use a set of plugins and their dependencies. Solution: Add packages, ":loadopt", 'packpath'. https://github.com/vim/vim/commit/f6fee0e2d4341c0c2f5339c1268e5877fafd07cf --- src/nvim/eval.c | 1 + src/nvim/ex_cmds.lua | 6 +++ src/nvim/ex_cmds2.c | 115 +++++++++++++++++++++++++++++++++++++++++-------- src/nvim/main.c | 3 ++ src/nvim/option.c | 1 + src/nvim/option_defs.h | 1 + src/nvim/options.lua | 10 +++++ src/nvim/version.c | 2 +- 8 files changed, 119 insertions(+), 20 deletions(-) (limited to 'src') diff --git a/src/nvim/eval.c b/src/nvim/eval.c index 9a86c5765c..d2b9bf66e1 100644 --- a/src/nvim/eval.c +++ b/src/nvim/eval.c @@ -10782,6 +10782,7 @@ static void f_has(typval_T *argvars, typval_T *rettv) "mouse", "multi_byte", "multi_lang", + "packages", "path_extra", "persistent_undo", "postscript", diff --git a/src/nvim/ex_cmds.lua b/src/nvim/ex_cmds.lua index 6c58879d58..7bfb592ea7 100644 --- a/src/nvim/ex_cmds.lua +++ b/src/nvim/ex_cmds.lua @@ -1452,6 +1452,12 @@ return { addr_type=ADDR_LINES, func='ex_loadkeymap', }, + { + command='loadplugin', + flags=bit.bor(BANG, FILE1, TRLBAR, SBOXOK, CMDWIN), + addr_type=ADDR_LINES, + func='ex_loadplugin', + }, { command='lockmarks', flags=bit.bor(NEEDARG, EXTRA, NOTRLCOM), diff --git a/src/nvim/ex_cmds2.c b/src/nvim/ex_cmds2.c index 40074f726c..d5740e224b 100644 --- a/src/nvim/ex_cmds2.c +++ b/src/nvim/ex_cmds2.c @@ -2284,21 +2284,9 @@ int source_runtime(char_u *name, int all) return do_in_runtimepath(name, all, source_callback, NULL); } -/// Find "name" in 'runtimepath'. When found, invoke the callback function for -/// it: callback(fname, "cookie") -/// When "all" is true repeat for all matches, otherwise only the first one is -/// used. -/// Returns OK when at least one match found, FAIL otherwise. -/// If "name" is NULL calls callback for each entry in runtimepath. Cookie is -/// passed by reference in this case, setting it to NULL indicates that callback -/// has done its job. -int do_in_runtimepath(char_u *name, int all, DoInRuntimepathCB callback, - void *cookie) +static int do_in_path(char_u *path, char_u *name, bool all, + DoInRuntimepathCB callback, void *cookie) { - char_u *rtp; - char_u *np; - char_u *buf; - char_u *rtp_copy; char_u *tail; int num_files; char_u **files; @@ -2307,18 +2295,18 @@ int do_in_runtimepath(char_u *name, int all, DoInRuntimepathCB callback, // Make a copy of 'runtimepath'. Invoking the callback may change the // value. - rtp_copy = vim_strsave(p_rtp); - buf = xmallocz(MAXPATHL); + char_u *rtp_copy = vim_strsave(path); + char_u *buf = xmallocz(MAXPATHL); { if (p_verbose > 1 && name != NULL) { verbose_enter(); smsg(_("Searching for \"%s\" in \"%s\""), - (char *)name, (char *)p_rtp); + (char *)name, (char *)path); verbose_leave(); } // Loop over all entries in 'runtimepath'. - rtp = rtp_copy; + char_u *rtp = rtp_copy; while (*rtp != NUL && (all || !did_one)) { // Copy the path from 'runtimepath' to buf[]. copy_option_part(&rtp, buf, MAXPATHL, ","); @@ -2332,7 +2320,7 @@ int do_in_runtimepath(char_u *name, int all, DoInRuntimepathCB callback, tail = buf + STRLEN(buf); // Loop over all patterns in "name" - np = name; + char_u *np = name; while (*np != NUL && (all || !did_one)) { // Append the pattern from "name" to buf[]. assert(MAXPATHL >= (tail - buf)); @@ -2373,6 +2361,95 @@ int do_in_runtimepath(char_u *name, int all, DoInRuntimepathCB callback, return did_one ? OK : FAIL; } +/// Find "name" in 'runtimepath'. When found, invoke the callback function for +/// it: callback(fname, "cookie") +/// When "all" is true repeat for all matches, otherwise only the first one is +/// used. +/// Returns OK when at least one match found, FAIL otherwise. +/// If "name" is NULL calls callback for each entry in runtimepath. Cookie is +/// passed by reference in this case, setting it to NULL indicates that callback +/// has done its job. +int do_in_runtimepath(char_u *name, bool all, DoInRuntimepathCB callback, + void *cookie) +{ + return do_in_path(p_rtp, name, all, callback, cookie); +} + +static void source_pack_plugin(char_u *fname, void *cookie) +{ + char_u *p6, *p5, *p4, *p3, *p2, *p1, *p; + char_u *new_rtp; + + p4 = p3 = p2 = p1 = get_past_head(fname); + for (p = p1; *p; mb_ptr_adv(p)) { + if (vim_ispathsep_nocolon(*p)) { + p6 = p5; p5 = p4; p4 = p3; p3 = p2; p2 = p1; p1 = p; + } + } + + // now we have: + // rtp/pack/name/ever/name/plugin/name.vim + // p6 p5 p4 p3 p2 p1 + + // find the part up to "pack" in 'runtimepath' + char_u c = *p6; + *p6 = NUL; + p = (char_u *)strstr((char *)p_rtp, (char *)fname); + if (p == NULL) { + // not found, append at the end + p = p_rtp + STRLEN(p_rtp); + } else { + // append after the matching directory. + p += STRLEN(fname); + } + *p6 = c; + + c = *p2; + *p2 = NUL; + if (strstr((char *)p_rtp, (char *)fname) == NULL) { + // directory not in 'runtimepath', add it + size_t oldlen = STRLEN(p_rtp); + size_t addlen = STRLEN(fname); + new_rtp = try_malloc(oldlen + addlen + 1); + if (new_rtp == NULL) { + *p2 = c; + return; + } + uintptr_t keep = (uintptr_t)(p - p_rtp); + memmove(new_rtp, p_rtp, keep); + new_rtp[keep] = ','; + memmove(new_rtp + keep + 1, fname, addlen + 1); + if (p_rtp[keep] != NUL) { + memmove(new_rtp + keep + 1 + addlen, p_rtp + keep, + oldlen - keep + 1); + } + free_string_option(p_rtp); + p_rtp = new_rtp; + } + *p2 = c; + + (void)do_source(fname, false, DOSO_NONE); +} + +// Source the plugins in the package directories. +void source_packages(void) +{ + do_in_path(p_pp, (char_u *)"pack/*/ever/*/plugin/*.vim", + true, source_pack_plugin, NULL); +} + +// ":loadplugin {name}" +void ex_loadplugin(exarg_T *eap) +{ + static const char *pattern = "pack/*/opt/%s/plugin/*.vim"; + + size_t len = STRLEN(pattern) + STRLEN(eap->arg); + char *pat = xmallocz(len); + vim_snprintf(pat, len, pattern, eap->arg); + do_in_path(p_pp, (char_u *)pat, true, source_pack_plugin, NULL); + xfree(pat); +} + /// ":options" void ex_options(exarg_T *eap) { diff --git a/src/nvim/main.c b/src/nvim/main.c index 5cd1dbb467..dcfd9b0fdf 100644 --- a/src/nvim/main.c +++ b/src/nvim/main.c @@ -1243,6 +1243,9 @@ static void load_plugins(void) if (p_lpl) { source_runtime((char_u *)"plugin/**/*.vim", TRUE); TIME_MSG("loading plugins"); + + source_packages(); + TIME_MSG("loading packages"); } } diff --git a/src/nvim/option.c b/src/nvim/option.c index a844c4ed80..be3cb914b2 100644 --- a/src/nvim/option.c +++ b/src/nvim/option.c @@ -5839,6 +5839,7 @@ set_context_in_set_cmd ( if (p == (char_u *)&p_bdir || p == (char_u *)&p_dir || p == (char_u *)&p_path + || p == (char_u *)&p_pp || p == (char_u *)&p_rtp || p == (char_u *)&p_cdpath || p == (char_u *)&p_vdir diff --git a/src/nvim/option_defs.h b/src/nvim/option_defs.h index b1a2b00bdb..833da7907c 100644 --- a/src/nvim/option_defs.h +++ b/src/nvim/option_defs.h @@ -521,6 +521,7 @@ EXTERN int p_ari; /* 'allowrevins' */ EXTERN int p_ri; /* 'revins' */ EXTERN int p_ru; /* 'ruler' */ EXTERN char_u *p_ruf; /* 'rulerformat' */ +EXTERN char_u *p_pp; /* 'packpath' */ EXTERN char_u *p_rtp; /* 'runtimepath' */ EXTERN long p_sj; /* 'scrolljump' */ EXTERN long p_so; /* 'scrolloff' */ diff --git a/src/nvim/options.lua b/src/nvim/options.lua index 218e34f595..d19af4f73f 100644 --- a/src/nvim/options.lua +++ b/src/nvim/options.lua @@ -1639,6 +1639,16 @@ return { varname='p_opfunc', defaults={if_true={vi=""}} }, + { + full_name='packpath', abbreviation='pp', + type='string', list='onecomma', scope={'global'}, + deny_duplicates=true, + secure=true, + vi_def=true, + expand=true, + varname='p_pp', + defaults={if_true={vi=''}} + }, { full_name='paragraphs', abbreviation='para', type='string', scope={'global'}, diff --git a/src/nvim/version.c b/src/nvim/version.c index 278255c904..95f924d6a1 100644 --- a/src/nvim/version.c +++ b/src/nvim/version.c @@ -311,7 +311,7 @@ static int included_patches[] = { // 1387 NA // 1386 NA // 1385 NA - // 1384, + 1384, // 1383 NA // 1382 NA // 1381 NA -- cgit From bca53fdca0cbcbfc28f3d016494b65925e8081bd Mon Sep 17 00:00:00 2001 From: James McCoy Date: Tue, 26 Apr 2016 00:18:32 -0400 Subject: vim-patch:7.4.1388 Problem: Compiler warning. (Cesar Romani) Solution: Initialize variable. https://github.com/vim/vim/commit/bdcd75275002c3b74015bb9bc0a01b13bb6107d4 --- src/nvim/ex_cmds2.c | 2 +- src/nvim/version.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/nvim/ex_cmds2.c b/src/nvim/ex_cmds2.c index d5740e224b..6f301658bf 100644 --- a/src/nvim/ex_cmds2.c +++ b/src/nvim/ex_cmds2.c @@ -2380,7 +2380,7 @@ static void source_pack_plugin(char_u *fname, void *cookie) char_u *p6, *p5, *p4, *p3, *p2, *p1, *p; char_u *new_rtp; - p4 = p3 = p2 = p1 = get_past_head(fname); + p6 = p5 = p4 = p3 = p2 = p1 = get_past_head(fname); for (p = p1; *p; mb_ptr_adv(p)) { if (vim_ispathsep_nocolon(*p)) { p6 = p5; p5 = p4; p4 = p3; p3 = p2; p2 = p1; p1 = p; diff --git a/src/nvim/version.c b/src/nvim/version.c index 95f924d6a1..9b8dac43bc 100644 --- a/src/nvim/version.c +++ b/src/nvim/version.c @@ -307,7 +307,7 @@ static int included_patches[] = { // 1391 NA // 1390 NA // 1389 NA - // 1388, + 1388, // 1387 NA // 1386 NA // 1385 NA -- cgit From 562b17260fb1eafe5e49412997bc81de29d24ccb Mon Sep 17 00:00:00 2001 From: James McCoy Date: Tue, 26 Apr 2016 00:21:39 -0400 Subject: vim-patch:7.4.1396 Problem: Compiler warnings for conversions. Solution: Add type cast. https://github.com/vim/vim/commit/1daae446e58fd90f98c51ff3af8f54bfa5197751 --- src/nvim/version.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/nvim/version.c b/src/nvim/version.c index 9b8dac43bc..c546bc0d19 100644 --- a/src/nvim/version.c +++ b/src/nvim/version.c @@ -299,7 +299,7 @@ static int included_patches[] = { // 1399 NA // 1398 NA 1397, - // 1396, + 1396, // 1395 NA 1394, // 1393 NA -- cgit From 9dc621e77deded9d7fe8ca478a17443da50b88ef Mon Sep 17 00:00:00 2001 From: James McCoy Date: Tue, 26 Apr 2016 00:24:25 -0400 Subject: vim-patch:7.4.1478 Problem: ":loadplugin" doesn't take care of ftdetect files. Solution: Also load ftdetect scripts when appropriate. https://github.com/vim/vim/commit/1bdd42627d619258d0e847f217cfc1c2795f1ac5 --- src/nvim/ex_cmds2.c | 27 ++++++++++++++++++++++++--- src/nvim/version.c | 2 +- 2 files changed, 25 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/nvim/ex_cmds2.c b/src/nvim/ex_cmds2.c index 6f301658bf..8389ed9400 100644 --- a/src/nvim/ex_cmds2.c +++ b/src/nvim/ex_cmds2.c @@ -2375,6 +2375,21 @@ int do_in_runtimepath(char_u *name, bool all, DoInRuntimepathCB callback, return do_in_path(p_rtp, name, all, callback, cookie); } +// Source filetype detection scripts, if filetype.vim was already done. +static void may_do_filetypes(char_u *pat) +{ + char_u *cmd = vim_strsave((char_u *)"did_load_filetypes"); + + // If runtime/filetype.vim wasn't loaded yet, the scripts will be found + // when it loads. + if (cmd != NULL && eval_to_number(cmd) > 0) { + do_cmdline_cmd("augroup filetypedetect"); + source_runtime(pat, TRUE); + do_cmdline_cmd("augroup END"); + } + xfree(cmd); +} + static void source_pack_plugin(char_u *fname, void *cookie) { char_u *p6, *p5, *p4, *p3, *p2, *p1, *p; @@ -2436,17 +2451,23 @@ void source_packages(void) { do_in_path(p_pp, (char_u *)"pack/*/ever/*/plugin/*.vim", true, source_pack_plugin, NULL); + may_do_filetypes((char_u *)"pack/*/ever/*/ftdetect/*.vim"); } // ":loadplugin {name}" void ex_loadplugin(exarg_T *eap) { - static const char *pattern = "pack/*/opt/%s/plugin/*.vim"; + static const char *plugpat = "pack/*/opt/%s/plugin/*.vim"; + static const char *ftpat = "pack/*/opt/%s/ftdetect/*.vim"; - size_t len = STRLEN(pattern) + STRLEN(eap->arg); + size_t len = STRLEN(ftpat) + STRLEN(eap->arg); char *pat = xmallocz(len); - vim_snprintf(pat, len, pattern, eap->arg); + vim_snprintf(pat, len, plugpat, eap->arg); do_in_path(p_pp, (char_u *)pat, true, source_pack_plugin, NULL); + + vim_snprintf(pat, len, ftpat, eap->arg); + may_do_filetypes((char_u *)pat); + xfree(pat); } diff --git a/src/nvim/version.c b/src/nvim/version.c index c546bc0d19..896bf47a53 100644 --- a/src/nvim/version.c +++ b/src/nvim/version.c @@ -217,7 +217,7 @@ static int included_patches[] = { // 1481 NA // 1480, // 1479, - // 1478, + 1478, // 1477, // 1476 NA // 1475 NA -- cgit From d43ac790f2454e2173eb645bdcd97c7a7c7e4846 Mon Sep 17 00:00:00 2001 From: James McCoy Date: Thu, 28 Apr 2016 19:23:15 -0400 Subject: vim-patch:7.4.1479 Problem: No testfor ":loadplugin". Solution: Add a test. Fix how option is being set. https://github.com/vim/vim/commit/863c1a9079fa340d663ccafb011729a29186d73e --- src/nvim/ex_cmds2.c | 8 ++++---- src/nvim/version.c | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/nvim/ex_cmds2.c b/src/nvim/ex_cmds2.c index 8389ed9400..bafd4ee666 100644 --- a/src/nvim/ex_cmds2.c +++ b/src/nvim/ex_cmds2.c @@ -2378,13 +2378,13 @@ int do_in_runtimepath(char_u *name, bool all, DoInRuntimepathCB callback, // Source filetype detection scripts, if filetype.vim was already done. static void may_do_filetypes(char_u *pat) { - char_u *cmd = vim_strsave((char_u *)"did_load_filetypes"); + char_u *cmd = vim_strsave((char_u *)"g:did_load_filetypes"); // If runtime/filetype.vim wasn't loaded yet, the scripts will be found // when it loads. if (cmd != NULL && eval_to_number(cmd) > 0) { do_cmdline_cmd("augroup filetypedetect"); - source_runtime(pat, TRUE); + do_in_path(p_pp, pat, true, source_callback, NULL); do_cmdline_cmd("augroup END"); } xfree(cmd); @@ -2438,8 +2438,8 @@ static void source_pack_plugin(char_u *fname, void *cookie) memmove(new_rtp + keep + 1 + addlen, p_rtp + keep, oldlen - keep + 1); } - free_string_option(p_rtp); - p_rtp = new_rtp; + set_option_value((char_u *)"rtp", 0L, new_rtp, 0); + xfree(new_rtp); } *p2 = c; diff --git a/src/nvim/version.c b/src/nvim/version.c index 896bf47a53..da717b9319 100644 --- a/src/nvim/version.c +++ b/src/nvim/version.c @@ -216,7 +216,7 @@ static int included_patches[] = { // 1482 NA // 1481 NA // 1480, - // 1479, + 1479, 1478, // 1477, // 1476 NA -- cgit From 67d8e586318a3f2f13df22f9a3b25c6d8a109e6c Mon Sep 17 00:00:00 2001 From: James McCoy Date: Thu, 28 Apr 2016 20:47:27 -0400 Subject: vim-patch:7.4.1480 Problem: Cannot add a pack direcory without loading a plugin. Solution: Add the :packadd command. https://github.com/vim/vim/commit/91715873d19a1859c08eeded7848113596e2f2bd --- src/nvim/ex_cmds.lua | 6 ++++ src/nvim/ex_cmds2.c | 86 ++++++++++++++++++++++++++++++++++++---------------- src/nvim/version.c | 2 +- 3 files changed, 67 insertions(+), 27 deletions(-) (limited to 'src') diff --git a/src/nvim/ex_cmds.lua b/src/nvim/ex_cmds.lua index 7bfb592ea7..de538ce733 100644 --- a/src/nvim/ex_cmds.lua +++ b/src/nvim/ex_cmds.lua @@ -1854,6 +1854,12 @@ return { addr_type=ADDR_LINES, func='ex_print', }, + { + command='packadd', + flags=bit.bor(BANG, FILE1, TRLBAR, SBOXOK, CMDWIN), + addr_type=ADDR_LINES, + func='ex_packadd', + }, { command='pclose', flags=bit.bor(BANG, TRLBAR), diff --git a/src/nvim/ex_cmds2.c b/src/nvim/ex_cmds2.c index bafd4ee666..93da08a629 100644 --- a/src/nvim/ex_cmds2.c +++ b/src/nvim/ex_cmds2.c @@ -2277,14 +2277,19 @@ static void source_callback(char_u *fname, void *cookie) /// Source the file "name" from all directories in 'runtimepath'. /// "name" can contain wildcards. -/// When "all" is true, source all files, otherwise only the first one. +/// When "flags" has DIP_ALL: source all files, otherwise only the first one. +/// When "flags" has DIP_DIR: find directories instead of files. +/// /// return FAIL when no file could be sourced, OK otherwise. int source_runtime(char_u *name, int all) { return do_in_runtimepath(name, all, source_callback, NULL); } -static int do_in_path(char_u *path, char_u *name, bool all, +#define DIP_ALL 1 // all matches, not just the first one +#define DIP_DIR 2 // find directories instead of files. + +static int do_in_path(char_u *path, char_u *name, int flags, DoInRuntimepathCB callback, void *cookie) { char_u *tail; @@ -2307,7 +2312,7 @@ static int do_in_path(char_u *path, char_u *name, bool all, // Loop over all entries in 'runtimepath'. char_u *rtp = rtp_copy; - while (*rtp != NUL && (all || !did_one)) { + while (*rtp != NUL && ((flags & DIP_ALL) || !did_one)) { // Copy the path from 'runtimepath' to buf[]. copy_option_part(&rtp, buf, MAXPATHL, ","); if (name == NULL) { @@ -2321,7 +2326,7 @@ static int do_in_path(char_u *path, char_u *name, bool all, // Loop over all patterns in "name" char_u *np = name; - while (*np != NUL && (all || !did_one)) { + while (*np != NUL && ((flags & DIP_ALL) || !did_one)) { // Append the pattern from "name" to buf[]. assert(MAXPATHL >= (tail - buf)); copy_option_part(&np, tail, (size_t)(MAXPATHL - (tail - buf)), @@ -2335,11 +2340,12 @@ static int do_in_path(char_u *path, char_u *name, bool all, // Expand wildcards, invoke the callback for each match. if (gen_expand_wildcards(1, &buf, &num_files, &files, - EW_FILE) == OK) { - for (i = 0; i < num_files; i++) { + (flags & DIP_DIR) ? EW_DIR + : EW_FILE) == OK) { + for (i = 0; i < num_files; ++i) { (*callback)(files[i], cookie); did_one = true; - if (!all) { + if (!(flags & DIP_ALL)) { break; } } @@ -2372,7 +2378,7 @@ static int do_in_path(char_u *path, char_u *name, bool all, int do_in_runtimepath(char_u *name, bool all, DoInRuntimepathCB callback, void *cookie) { - return do_in_path(p_rtp, name, all, callback, cookie); + return do_in_path(p_rtp, name, all ? DIP_ALL : 0, callback, cookie); } // Source filetype detection scripts, if filetype.vim was already done. @@ -2384,47 +2390,61 @@ static void may_do_filetypes(char_u *pat) // when it loads. if (cmd != NULL && eval_to_number(cmd) > 0) { do_cmdline_cmd("augroup filetypedetect"); - do_in_path(p_pp, pat, true, source_callback, NULL); + do_in_path(p_pp, pat, DIP_ALL, source_callback, NULL); do_cmdline_cmd("augroup END"); } xfree(cmd); } -static void source_pack_plugin(char_u *fname, void *cookie) +static void add_pack_plugin(char_u *fname, void *cookie) { char_u *p6, *p5, *p4, *p3, *p2, *p1, *p; char_u *new_rtp; + char_u *ffname = (char_u *)fix_fname((char *)fname); + bool load_file = cookie != NULL; - p6 = p5 = p4 = p3 = p2 = p1 = get_past_head(fname); + if (ffname == NULL) { + return; + } + p6 = p5 = p4 = p3 = p2 = p1 = get_past_head(ffname); for (p = p1; *p; mb_ptr_adv(p)) { if (vim_ispathsep_nocolon(*p)) { p6 = p5; p5 = p4; p4 = p3; p3 = p2; p2 = p1; p1 = p; } } - // now we have: + // now we have: load_file == true // rtp/pack/name/ever/name/plugin/name.vim // p6 p5 p4 p3 p2 p1 + // + // with load_file == false + // rtp/pack/name/ever/name + // p4 p3 p2 p1 + if (load_file) { + p4 = p6; + } // find the part up to "pack" in 'runtimepath' - char_u c = *p6; - *p6 = NUL; - p = (char_u *)strstr((char *)p_rtp, (char *)fname); + char_u c = *p4; + *p4 = NUL; + p = (char_u *)strstr((char *)p_rtp, (char *)ffname); if (p == NULL) { // not found, append at the end p = p_rtp + STRLEN(p_rtp); } else { // append after the matching directory. - p += STRLEN(fname); + p += STRLEN(ffname); } - *p6 = c; + *p4 = c; - c = *p2; - *p2 = NUL; - if (strstr((char *)p_rtp, (char *)fname) == NULL) { + if (load_file) { + c = *p2; + *p2 = NUL; + } + if (strstr((char *)p_rtp, (char *)ffname) == NULL) { // directory not in 'runtimepath', add it size_t oldlen = STRLEN(p_rtp); - size_t addlen = STRLEN(fname); + size_t addlen = STRLEN(ffname); new_rtp = try_malloc(oldlen + addlen + 1); if (new_rtp == NULL) { *p2 = c; @@ -2433,7 +2453,7 @@ static void source_pack_plugin(char_u *fname, void *cookie) uintptr_t keep = (uintptr_t)(p - p_rtp); memmove(new_rtp, p_rtp, keep); new_rtp[keep] = ','; - memmove(new_rtp + keep + 1, fname, addlen + 1); + memmove(new_rtp + keep + 1, ffname, addlen + 1); if (p_rtp[keep] != NUL) { memmove(new_rtp + keep + 1 + addlen, p_rtp + keep, oldlen - keep + 1); @@ -2441,16 +2461,18 @@ static void source_pack_plugin(char_u *fname, void *cookie) set_option_value((char_u *)"rtp", 0L, new_rtp, 0); xfree(new_rtp); } - *p2 = c; + xfree(ffname); - (void)do_source(fname, false, DOSO_NONE); + if (load_file) { + (void)do_source(fname, false, DOSO_NONE); + } } // Source the plugins in the package directories. void source_packages(void) { do_in_path(p_pp, (char_u *)"pack/*/ever/*/plugin/*.vim", - true, source_pack_plugin, NULL); + DIP_ALL, add_pack_plugin, p_pp); may_do_filetypes((char_u *)"pack/*/ever/*/ftdetect/*.vim"); } @@ -2463,7 +2485,7 @@ void ex_loadplugin(exarg_T *eap) size_t len = STRLEN(ftpat) + STRLEN(eap->arg); char *pat = xmallocz(len); vim_snprintf(pat, len, plugpat, eap->arg); - do_in_path(p_pp, (char_u *)pat, true, source_pack_plugin, NULL); + do_in_path(p_pp, (char_u *)pat, DIP_ALL, add_pack_plugin, p_pp); vim_snprintf(pat, len, ftpat, eap->arg); may_do_filetypes((char_u *)pat); @@ -2471,6 +2493,18 @@ void ex_loadplugin(exarg_T *eap) xfree(pat); } +/// ":packadd {name}" +void ex_packadd(exarg_T *eap) +{ + static const char *plugpat = "pack/*/opt/%s"; + + size_t len = STRLEN(plugpat) + STRLEN(eap->arg); + char *pat = (char *)xmallocz(len); + vim_snprintf(pat, len, plugpat, eap->arg); + do_in_path(p_pp, (char_u *)pat, DIP_ALL + DIP_DIR, add_pack_plugin, NULL); + xfree(pat); +} + /// ":options" void ex_options(exarg_T *eap) { diff --git a/src/nvim/version.c b/src/nvim/version.c index da717b9319..4320190592 100644 --- a/src/nvim/version.c +++ b/src/nvim/version.c @@ -215,7 +215,7 @@ static int included_patches[] = { // 1483 NA // 1482 NA // 1481 NA - // 1480, + 1480, 1479, 1478, // 1477, -- cgit From 2f72f34f0407dcdf189bb4f3a4b79b51e96744bf Mon Sep 17 00:00:00 2001 From: James McCoy Date: Thu, 28 Apr 2016 22:58:24 -0400 Subject: vim-patch:7.4.1486 Problem: ":loadplugin" is not optimal, some people find it confusing. Solution: Only use ":packadd" with an optional "!". https://github.com/vim/vim/commit/f3654827368e6204608036353a0360e9e7c21e02 --- src/nvim/ex_cmds.lua | 6 --- src/nvim/ex_cmds2.c | 147 +++++++++++++++++++++++++-------------------------- src/nvim/version.c | 2 +- 3 files changed, 73 insertions(+), 82 deletions(-) (limited to 'src') diff --git a/src/nvim/ex_cmds.lua b/src/nvim/ex_cmds.lua index de538ce733..81a0610a90 100644 --- a/src/nvim/ex_cmds.lua +++ b/src/nvim/ex_cmds.lua @@ -1452,12 +1452,6 @@ return { addr_type=ADDR_LINES, func='ex_loadkeymap', }, - { - command='loadplugin', - flags=bit.bor(BANG, FILE1, TRLBAR, SBOXOK, CMDWIN), - addr_type=ADDR_LINES, - func='ex_loadplugin', - }, { command='lockmarks', flags=bit.bor(NEEDARG, EXTRA, NOTRLCOM), diff --git a/src/nvim/ex_cmds2.c b/src/nvim/ex_cmds2.c index 93da08a629..6bfa494094 100644 --- a/src/nvim/ex_cmds2.c +++ b/src/nvim/ex_cmds2.c @@ -2381,76 +2381,67 @@ int do_in_runtimepath(char_u *name, bool all, DoInRuntimepathCB callback, return do_in_path(p_rtp, name, all ? DIP_ALL : 0, callback, cookie); } -// Source filetype detection scripts, if filetype.vim was already done. -static void may_do_filetypes(char_u *pat) +// Expand wildcards in "pat" and invoke do_source() for each match. +static void source_all_matches(char_u *pat) { - char_u *cmd = vim_strsave((char_u *)"g:did_load_filetypes"); + int num_files; + char_u **files; - // If runtime/filetype.vim wasn't loaded yet, the scripts will be found - // when it loads. - if (cmd != NULL && eval_to_number(cmd) > 0) { - do_cmdline_cmd("augroup filetypedetect"); - do_in_path(p_pp, pat, DIP_ALL, source_callback, NULL); - do_cmdline_cmd("augroup END"); + if (gen_expand_wildcards(1, &pat, &num_files, &files, EW_FILE) == OK) { + for (int i = 0; i < num_files; i++) { + (void)do_source(files[i], false, DOSO_NONE); + } + FreeWild(num_files, files); } - xfree(cmd); } static void add_pack_plugin(char_u *fname, void *cookie) { - char_u *p6, *p5, *p4, *p3, *p2, *p1, *p; + char_u *p4, *p3, *p2, *p1, *p; char_u *new_rtp; char_u *ffname = (char_u *)fix_fname((char *)fname); - bool load_file = cookie != NULL; + bool load_files = cookie != NULL; if (ffname == NULL) { return; } - p6 = p5 = p4 = p3 = p2 = p1 = get_past_head(ffname); - for (p = p1; *p; mb_ptr_adv(p)) { - if (vim_ispathsep_nocolon(*p)) { - p6 = p5; p5 = p4; p4 = p3; p3 = p2; p2 = p1; p1 = p; - } - } - // now we have: load_file == true - // rtp/pack/name/ever/name/plugin/name.vim - // p6 p5 p4 p3 p2 p1 - // - // with load_file == false - // rtp/pack/name/ever/name - // p4 p3 p2 p1 - if (load_file) { - p4 = p6; - } - - // find the part up to "pack" in 'runtimepath' - char_u c = *p4; - *p4 = NUL; - p = (char_u *)strstr((char *)p_rtp, (char *)ffname); - if (p == NULL) { - // not found, append at the end - p = p_rtp + STRLEN(p_rtp); - } else { - // append after the matching directory. - p += STRLEN(ffname); - } - *p4 = c; - - if (load_file) { - c = *p2; - *p2 = NUL; - } if (strstr((char *)p_rtp, (char *)ffname) == NULL) { // directory not in 'runtimepath', add it + p4 = p3 = p2 = p1 = get_past_head(ffname); + for (p = p1; *p; mb_ptr_adv(p)) { + if (vim_ispathsep_nocolon(*p)) { + p4 = p3; p3 = p2; p2 = p1; p1 = p; + } + } + + // now we have: + // rtp/pack/name/ever/name + // p4 p3 p2 p1 + // + // find the part up to "pack" in 'runtimepath' + char_u c = *p4; + *p4 = NUL; + char_u *insp = (char_u *)strstr((char *)p_rtp, (char *)ffname); + if (insp == NULL) { + // not found, append at the end + insp = p_rtp + STRLEN(p_rtp); + } else { + // append after the matching directory. + insp += STRLEN(ffname); + while (*insp != NUL && *insp != ',') { + insp++; + } + } + *p4 = c; + size_t oldlen = STRLEN(p_rtp); size_t addlen = STRLEN(ffname); new_rtp = try_malloc(oldlen + addlen + 1); if (new_rtp == NULL) { - *p2 = c; - return; + goto theend; } - uintptr_t keep = (uintptr_t)(p - p_rtp); + uintptr_t keep = (uintptr_t)(insp - p_rtp); memmove(new_rtp, p_rtp, keep); new_rtp[keep] = ','; memmove(new_rtp + keep + 1, ffname, addlen + 1); @@ -2461,39 +2452,44 @@ static void add_pack_plugin(char_u *fname, void *cookie) set_option_value((char_u *)"rtp", 0L, new_rtp, 0); xfree(new_rtp); } - xfree(ffname); - if (load_file) { - (void)do_source(fname, false, DOSO_NONE); - } -} + if (load_files) { + static const char *plugpat = "%s/plugin/*.vim"; + static const char *ftpat = "%s/ftdetect/*.vim"; -// Source the plugins in the package directories. -void source_packages(void) -{ - do_in_path(p_pp, (char_u *)"pack/*/ever/*/plugin/*.vim", - DIP_ALL, add_pack_plugin, p_pp); - may_do_filetypes((char_u *)"pack/*/ever/*/ftdetect/*.vim"); -} + size_t len = STRLEN(ffname) + STRLEN(ftpat); + char_u *pat = try_malloc(len + 1); + if (pat == NULL) { + goto theend; + } + vim_snprintf((char *)pat, len, plugpat, ffname); + source_all_matches(pat); -// ":loadplugin {name}" -void ex_loadplugin(exarg_T *eap) -{ - static const char *plugpat = "pack/*/opt/%s/plugin/*.vim"; - static const char *ftpat = "pack/*/opt/%s/ftdetect/*.vim"; + char_u *cmd = vim_strsave((char_u *)"g:did_load_filetypes"); - size_t len = STRLEN(ftpat) + STRLEN(eap->arg); - char *pat = xmallocz(len); - vim_snprintf(pat, len, plugpat, eap->arg); - do_in_path(p_pp, (char_u *)pat, DIP_ALL, add_pack_plugin, p_pp); + // If runtime/filetype.vim wasn't loaded yet, the scripts will be + // found when it loads. + if (eval_to_number(cmd) > 0) { + do_cmdline_cmd("augroup filetypedetect"); + vim_snprintf((char *)pat, len, ftpat, ffname); + source_all_matches(pat); + do_cmdline_cmd("augroup END"); + } + xfree(cmd); + } - vim_snprintf(pat, len, ftpat, eap->arg); - may_do_filetypes((char_u *)pat); +theend: + xfree(ffname); +} - xfree(pat); +// Find plugins in the package directories and source them. +void source_packages(void) +{ + do_in_path(p_pp, (char_u *)"pack/*/ever/*", DIP_ALL + DIP_DIR, + add_pack_plugin, p_pp); } -/// ":packadd {name}" +/// ":packadd[!] {name}" void ex_packadd(exarg_T *eap) { static const char *plugpat = "pack/*/opt/%s"; @@ -2501,7 +2497,8 @@ void ex_packadd(exarg_T *eap) size_t len = STRLEN(plugpat) + STRLEN(eap->arg); char *pat = (char *)xmallocz(len); vim_snprintf(pat, len, plugpat, eap->arg); - do_in_path(p_pp, (char_u *)pat, DIP_ALL + DIP_DIR, add_pack_plugin, NULL); + do_in_path(p_pp, (char_u *)pat, DIP_ALL + DIP_DIR, add_pack_plugin, + eap->forceit ? NULL : p_pp); xfree(pat); } diff --git a/src/nvim/version.c b/src/nvim/version.c index 4320190592..569a755429 100644 --- a/src/nvim/version.c +++ b/src/nvim/version.c @@ -209,7 +209,7 @@ static int included_patches[] = { // 1489 NA // 1488 NA // 1487 NA - // 1486, + 1486, // 1485 NA // 1484 NA // 1483 NA -- cgit From 85e539c99609cec0b5a0eab3aded394d0bbab555 Mon Sep 17 00:00:00 2001 From: James McCoy Date: Mon, 2 May 2016 21:15:57 -0400 Subject: vim-patch:7.4.1492 Problem: No command line completion for ":packadd". Solution: Implement completion. (Hirohito Higashi) https://github.com/vim/vim/commit/35ca0e7a1cb6e6daef8e0052a8437801226cef19 --- src/nvim/ex_docmd.c | 6 ++++++ src/nvim/ex_getln.c | 43 ++++++++++++++++++++++++++++++++++++++++++- src/nvim/version.c | 2 +- src/nvim/vim.h | 1 + 4 files changed, 50 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/nvim/ex_docmd.c b/src/nvim/ex_docmd.c index ad17d4dcbd..80dad3605a 100644 --- a/src/nvim/ex_docmd.c +++ b/src/nvim/ex_docmd.c @@ -3316,6 +3316,11 @@ set_one_cmd_context ( xp->xp_pattern = arg; break; + case CMD_packadd: + xp->xp_context = EXPAND_PACKADD; + xp->xp_pattern = arg; + break; + #ifdef HAVE_WORKING_LIBINTL case CMD_language: p = skiptowhite(arg); @@ -4688,6 +4693,7 @@ static struct { {EXPAND_OWNSYNTAX, "syntax"}, {EXPAND_SYNTIME, "syntime"}, {EXPAND_SETTINGS, "option"}, + {EXPAND_PACKADD, "packadd"}, {EXPAND_SHELLCMD, "shellcmd"}, {EXPAND_SIGN, "sign"}, {EXPAND_TAGS, "tag"}, diff --git a/src/nvim/ex_getln.c b/src/nvim/ex_getln.c index 65144dace8..688be3c67c 100644 --- a/src/nvim/ex_getln.c +++ b/src/nvim/ex_getln.c @@ -3440,6 +3440,7 @@ addstar ( || context == EXPAND_COMPILER || context == EXPAND_OWNSYNTAX || context == EXPAND_FILETYPE + || context == EXPAND_PACKADD || (context == EXPAND_TAGS && fname[0] == '/')) retval = vim_strnsave(fname, len); else { @@ -3809,8 +3810,12 @@ ExpandFromContext ( char *directories[] = {"syntax", "indent", "ftplugin", NULL}; return ExpandRTDir(pat, num_file, file, directories); } - if (xp->xp_context == EXPAND_USER_LIST) + if (xp->xp_context == EXPAND_USER_LIST) { return ExpandUserList(xp, num_file, file); + } + if (xp->xp_context == EXPAND_PACKADD) { + return ExpandPackAddDir(pat, num_file, file); + } regmatch.regprog = vim_regcomp(pat, p_magic ? RE_MAGIC : 0); if (regmatch.regprog == NULL) @@ -4241,6 +4246,42 @@ static int ExpandRTDir(char_u *pat, int *num_file, char_u ***file, char *dirname return OK; } +/// Expand loadplugin names: +/// 'packpath'/pack/ * /opt/{pat} +static int ExpandPackAddDir(char_u *pat, int *num_file, char_u ***file) +{ + garray_T ga; + + *num_file = 0; + *file = NULL; + size_t pat_len = STRLEN(pat); + ga_init(&ga, (int)sizeof(char *), 10); + + char_u *s = xmalloc((unsigned)(pat_len + 26)); + sprintf((char *)s, "pack/*/opt/%s*", pat); + globpath(p_pp, s, &ga, 0); + xfree(s); + + for (int i = 0; i < ga.ga_len; ++i) { + char_u *match = ((char_u **)ga.ga_data)[i]; + s = path_tail(match); + char_u *e = s + STRLEN(s); + memmove(match, s, e - s + 1); + } + + if (GA_EMPTY(&ga)) { + return FAIL; + } + + // Sort and remove duplicates which can happen when specifying multiple + // directories in dirnames. + ga_remove_duplicate_strings(&ga); + + *file = ga.ga_data; + *num_file = ga.ga_len; + return OK; +} + /// Expand `file` for all comma-separated directories in `path`. /// Adds matches to `ga`. diff --git a/src/nvim/version.c b/src/nvim/version.c index 569a755429..36f9fecf64 100644 --- a/src/nvim/version.c +++ b/src/nvim/version.c @@ -203,7 +203,7 @@ static int included_patches[] = { // 1495 NA // 1494, // 1493 NA - // 1492, + 1492, // 1491, // 1490 NA // 1489 NA diff --git a/src/nvim/vim.h b/src/nvim/vim.h index 165a44a148..c2f0a0ebd3 100644 --- a/src/nvim/vim.h +++ b/src/nvim/vim.h @@ -174,6 +174,7 @@ enum { EXPAND_USER, EXPAND_SYNTIME, EXPAND_USER_ADDR_TYPE, + EXPAND_PACKADD, }; -- cgit From 8ecdc571b0cf679c5195088d140f2988bcbe87e1 Mon Sep 17 00:00:00 2001 From: James McCoy Date: Mon, 20 Jun 2016 10:12:07 -0400 Subject: vim-patch:7.4.1499 Problem: No error message when :packadd does not find anything. Solution: Add an error message. (Hirohito Higashi) https://github.com/vim/vim/commit/be82c254862e475a582c0717455e1db6bf96b0d0 --- src/nvim/ex_cmds.lua | 2 +- src/nvim/ex_cmds2.c | 28 +++++++++++++++++++++------- src/nvim/globals.h | 1 + src/nvim/version.c | 2 +- 4 files changed, 24 insertions(+), 9 deletions(-) (limited to 'src') diff --git a/src/nvim/ex_cmds.lua b/src/nvim/ex_cmds.lua index 81a0610a90..0e8cf21d69 100644 --- a/src/nvim/ex_cmds.lua +++ b/src/nvim/ex_cmds.lua @@ -1850,7 +1850,7 @@ return { }, { command='packadd', - flags=bit.bor(BANG, FILE1, TRLBAR, SBOXOK, CMDWIN), + flags=bit.bor(BANG, FILE1, NEEDARG, TRLBAR, SBOXOK, CMDWIN), addr_type=ADDR_LINES, func='ex_packadd', }, diff --git a/src/nvim/ex_cmds2.c b/src/nvim/ex_cmds2.c index 6bfa494094..8e88a55d41 100644 --- a/src/nvim/ex_cmds2.c +++ b/src/nvim/ex_cmds2.c @@ -2277,8 +2277,7 @@ static void source_callback(char_u *fname, void *cookie) /// Source the file "name" from all directories in 'runtimepath'. /// "name" can contain wildcards. -/// When "flags" has DIP_ALL: source all files, otherwise only the first one. -/// When "flags" has DIP_DIR: find directories instead of files. +/// When "all" is true: source all files, otherwise only the first one. /// /// return FAIL when no file could be sourced, OK otherwise. int source_runtime(char_u *name, int all) @@ -2288,7 +2287,16 @@ int source_runtime(char_u *name, int all) #define DIP_ALL 1 // all matches, not just the first one #define DIP_DIR 2 // find directories instead of files. +#define DIP_ERR 4 // give an error message when none found. +/// Find the file "name" in all directories in "path" and invoke +/// "callback(fname, cookie)". +/// "name" can contain wildcards. +/// When "flags" has DIP_ALL: source all files, otherwise only the first one. +/// When "flags" has DIP_DIR: find directories instead of files. +/// When "flags" has DIP_ERR: give an error message if there is no match. +/// +/// return FAIL when no file could be sourced, OK otherwise. static int do_in_path(char_u *path, char_u *name, int flags, DoInRuntimepathCB callback, void *cookie) { @@ -2357,10 +2365,16 @@ static int do_in_path(char_u *path, char_u *name, int flags, } xfree(buf); xfree(rtp_copy); - if (p_verbose > 0 && !did_one && name != NULL) { - verbose_enter(); - smsg(_("not found in 'runtimepath': \"%s\""), name); - verbose_leave(); + if (!did_one && name != NULL) { + char *basepath = path == p_rtp ? "runtimepath" : "packpath"; + + if (flags & DIP_ERR) { + EMSG3(_(e_dirnotf), basepath, name); + } else if (p_verbose > 0) { + verbose_enter(); + smsg(_("not found in '%s': \"%s\""), basepath, name); + verbose_leave(); + } } @@ -2497,7 +2511,7 @@ void ex_packadd(exarg_T *eap) size_t len = STRLEN(plugpat) + STRLEN(eap->arg); char *pat = (char *)xmallocz(len); vim_snprintf(pat, len, plugpat, eap->arg); - do_in_path(p_pp, (char_u *)pat, DIP_ALL + DIP_DIR, add_pack_plugin, + do_in_path(p_pp, (char_u *)pat, DIP_ALL + DIP_DIR + DIP_ERR, add_pack_plugin, eap->forceit ? NULL : p_pp); xfree(pat); } diff --git a/src/nvim/globals.h b/src/nvim/globals.h index 7f91903106..bfe2ec7fc7 100644 --- a/src/nvim/globals.h +++ b/src/nvim/globals.h @@ -1223,6 +1223,7 @@ EXTERN char_u e_invalpat[] INIT(= N_( EXTERN char_u e_bufloaded[] INIT(= N_("E139: File is loaded in another buffer")); EXTERN char_u e_notset[] INIT(= N_("E764: Option '%s' is not set")); EXTERN char_u e_invalidreg[] INIT(= N_("E850: Invalid register name")); +EXTERN char_u e_dirnotf[] INIT(= N_("E919: Directory not found in '%s': \"%s\"")); EXTERN char_u e_unsupportedoption[] INIT(= N_("E519: Option not supported")); diff --git a/src/nvim/version.c b/src/nvim/version.c index 36f9fecf64..6f5ebb751d 100644 --- a/src/nvim/version.c +++ b/src/nvim/version.c @@ -196,7 +196,7 @@ static int included_patches[] = { // 1502 NA // 1501 NA 1500, - // 1499, + 1499, // 1498 NA // 1497 NA // 1496 NA -- cgit From 1f54d253e169fbc483cc485f9b3092a8da1f62db Mon Sep 17 00:00:00 2001 From: James McCoy Date: Mon, 20 Jun 2016 10:35:38 -0400 Subject: vim-patch:7.4.1528 Problem: Using "ever" for packages is confusing. Solution: Use "start", as it's related to startup. https://github.com/vim/vim/commit/af1a0e371e739f8dff337fd31da0ff8ffb347b43 --- src/nvim/ex_cmds2.c | 4 ++-- src/nvim/version.c | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/nvim/ex_cmds2.c b/src/nvim/ex_cmds2.c index 8e88a55d41..3f211d7ab8 100644 --- a/src/nvim/ex_cmds2.c +++ b/src/nvim/ex_cmds2.c @@ -2430,7 +2430,7 @@ static void add_pack_plugin(char_u *fname, void *cookie) } // now we have: - // rtp/pack/name/ever/name + // rtp/pack/name/start/name // p4 p3 p2 p1 // // find the part up to "pack" in 'runtimepath' @@ -2499,7 +2499,7 @@ theend: // Find plugins in the package directories and source them. void source_packages(void) { - do_in_path(p_pp, (char_u *)"pack/*/ever/*", DIP_ALL + DIP_DIR, + do_in_path(p_pp, (char_u *)"pack/*/start/*", DIP_ALL + DIP_DIR, add_pack_plugin, p_pp); } diff --git a/src/nvim/version.c b/src/nvim/version.c index 6f5ebb751d..9fcc811f7a 100644 --- a/src/nvim/version.c +++ b/src/nvim/version.c @@ -167,7 +167,7 @@ static int included_patches[] = { // 1531 NA // 1530 NA // 1529 NA - // 1528, + 1528, // 1527 NA // 1526 NA // 1525 NA -- cgit From 26f74fdf61827f5afc6fe4e90b9e9497264cb039 Mon Sep 17 00:00:00 2001 From: James McCoy Date: Mon, 20 Jun 2016 20:24:13 -0400 Subject: vim-patch:7.4.1550 Problem: Cannot load packages early. Solution: Add the ":packloadall" command. https://github.com/vim/vim/commit/2d8f56acb32428d0f965d42dd13b27100b46fa15 --- src/nvim/ex_cmds.lua | 6 ++++++ src/nvim/ex_cmds2.c | 12 +++++++++--- src/nvim/main.c | 2 +- src/nvim/version.c | 2 +- 4 files changed, 17 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/nvim/ex_cmds.lua b/src/nvim/ex_cmds.lua index 0e8cf21d69..76191d5a56 100644 --- a/src/nvim/ex_cmds.lua +++ b/src/nvim/ex_cmds.lua @@ -1854,6 +1854,12 @@ return { addr_type=ADDR_LINES, func='ex_packadd', }, + { + command='packloadall', + flags=bit.bor(BANG, TRLBAR, SBOXOK, CMDWIN), + addr_type=ADDR_LINES, + func='ex_packloadall', + }, { command='pclose', flags=bit.bor(BANG, TRLBAR), diff --git a/src/nvim/ex_cmds2.c b/src/nvim/ex_cmds2.c index 3f211d7ab8..17125ec798 100644 --- a/src/nvim/ex_cmds2.c +++ b/src/nvim/ex_cmds2.c @@ -2496,11 +2496,17 @@ theend: xfree(ffname); } +static bool did_source_packages = false; + +// ":packloadall" // Find plugins in the package directories and source them. -void source_packages(void) +void ex_packloadall(exarg_T *eap) { - do_in_path(p_pp, (char_u *)"pack/*/start/*", DIP_ALL + DIP_DIR, - add_pack_plugin, p_pp); + if (!did_source_packages || (eap != NULL && eap->forceit)) { + did_source_packages = true; + do_in_path(p_pp, (char_u *)"pack/*/start/*", DIP_ALL + DIP_DIR, + add_pack_plugin, p_pp); + } } /// ":packadd[!] {name}" diff --git a/src/nvim/main.c b/src/nvim/main.c index dcfd9b0fdf..787a99802b 100644 --- a/src/nvim/main.c +++ b/src/nvim/main.c @@ -1244,7 +1244,7 @@ static void load_plugins(void) source_runtime((char_u *)"plugin/**/*.vim", TRUE); TIME_MSG("loading plugins"); - source_packages(); + ex_packloadall(NULL); TIME_MSG("loading packages"); } } diff --git a/src/nvim/version.c b/src/nvim/version.c index 9fcc811f7a..97cd65700f 100644 --- a/src/nvim/version.c +++ b/src/nvim/version.c @@ -145,7 +145,7 @@ static int included_patches[] = { // 1553, // 1552, // 1551, - // 1550, + 1550, // 1549, // 1548, // 1547, -- cgit From 55dcf0918c364dd58e700cde5f2efbf7da4b3051 Mon Sep 17 00:00:00 2001 From: James McCoy Date: Mon, 20 Jun 2016 21:04:08 -0400 Subject: vim-patch:7.4.1551 Problem: Cannot generate help tags in all doc directories. Solution: Make ":helptags ALL" work. https://github.com/vim/vim/commit/6bef5306e4f2cacb3a93667992c2312d4b293c9d --- src/nvim/ex_cmds.c | 236 ++++++++++++++++++++++++++++------------------------ src/nvim/ex_cmds2.c | 8 +- src/nvim/version.c | 2 +- src/nvim/vim.h | 5 ++ 4 files changed, 135 insertions(+), 116 deletions(-) (limited to 'src') diff --git a/src/nvim/ex_cmds.c b/src/nvim/ex_cmds.c index d0661b6b9b..d74f39bf39 100644 --- a/src/nvim/ex_cmds.c +++ b/src/nvim/ex_cmds.c @@ -4796,115 +4796,7 @@ void ex_viusage(exarg_T *eap) } -/* - * ":helptags" - */ -void ex_helptags(exarg_T *eap) -{ - garray_T ga; - int len; - char_u lang[2]; - expand_T xpc; - char_u *dirname; - char_u ext[5]; - char_u fname[8]; - int filecount; - char_u **files; - int add_help_tags = FALSE; - - /* Check for ":helptags ++t {dir}". */ - if (STRNCMP(eap->arg, "++t", 3) == 0 && ascii_iswhite(eap->arg[3])) { - add_help_tags = TRUE; - eap->arg = skipwhite(eap->arg + 3); - } - - ExpandInit(&xpc); - xpc.xp_context = EXPAND_DIRECTORIES; - dirname = ExpandOne(&xpc, eap->arg, NULL, - WILD_LIST_NOTFOUND|WILD_SILENT, WILD_EXPAND_FREE); - if (dirname == NULL || !os_isdir(dirname)) { - EMSG2(_("E150: Not a directory: %s"), eap->arg); - xfree(dirname); - return; - } - - /* Get a list of all files in the help directory and in subdirectories. */ - STRCPY(NameBuff, dirname); - add_pathsep((char *)NameBuff); - STRCAT(NameBuff, "**"); - - // Note: We cannot just do `&NameBuff` because it is a statically sized array - // so `NameBuff == &NameBuff` according to C semantics. - char_u *buff_list[1] = {NameBuff}; - if (gen_expand_wildcards(1, buff_list, &filecount, &files, - EW_FILE|EW_SILENT) == FAIL - || filecount == 0) { - EMSG2("E151: No match: %s", NameBuff); - xfree(dirname); - return; - } - - /* Go over all files in the directory to find out what languages are - * present. */ - ga_init(&ga, 1, 10); - for (int i = 0; i < filecount; ++i) { - len = (int)STRLEN(files[i]); - if (len <= 4) { - continue; - } - if (STRICMP(files[i] + len - 4, ".txt") == 0) { - /* ".txt" -> language "en" */ - lang[0] = 'e'; - lang[1] = 'n'; - } else if (files[i][len - 4] == '.' - && ASCII_ISALPHA(files[i][len - 3]) - && ASCII_ISALPHA(files[i][len - 2]) - && TOLOWER_ASC(files[i][len - 1]) == 'x') { - /* ".abx" -> language "ab" */ - lang[0] = TOLOWER_ASC(files[i][len - 3]); - lang[1] = TOLOWER_ASC(files[i][len - 2]); - } else - continue; - - int j; - /* Did we find this language already? */ - for (j = 0; j < ga.ga_len; j += 2) - if (STRNCMP(lang, ((char_u *)ga.ga_data) + j, 2) == 0) - break; - if (j == ga.ga_len) { - /* New language, add it. */ - ga_grow(&ga, 2); - ((char_u *)ga.ga_data)[ga.ga_len++] = lang[0]; - ((char_u *)ga.ga_data)[ga.ga_len++] = lang[1]; - } - } - - /* - * Loop over the found languages to generate a tags file for each one. - */ - for (int j = 0; j < ga.ga_len; j += 2) { - STRCPY(fname, "tags-xx"); - fname[5] = ((char_u *)ga.ga_data)[j]; - fname[6] = ((char_u *)ga.ga_data)[j + 1]; - if (fname[5] == 'e' && fname[6] == 'n') { - /* English is an exception: use ".txt" and "tags". */ - fname[4] = NUL; - STRCPY(ext, ".txt"); - } else { - /* Language "ab" uses ".abx" and "tags-ab". */ - STRCPY(ext, ".xxx"); - ext[1] = fname[5]; - ext[2] = fname[6]; - } - helptags_one(dirname, ext, fname, add_help_tags); - } - - ga_clear(&ga); - FreeWild(filecount, files); - - xfree(dirname); -} - +/// Generate tags in one help directory static void helptags_one ( char_u *dir, /* doc directory */ @@ -5111,6 +5003,132 @@ helptags_one ( fclose(fd_tags); /* there is no check for an error... */ } +/// Generate tags in one help directory, taking care of translations. +static void do_helptags(char_u *dirname, int add_help_tags) +{ + int len; + garray_T ga; + char_u lang[2]; + char_u ext[5]; + char_u fname[8]; + int filecount; + char_u **files; + + // Get a list of all files in the help directory and in subdirectories. + STRCPY(NameBuff, dirname); + add_pathsep((char *)NameBuff); + STRCAT(NameBuff, "**"); + + // Note: We cannot just do `&NameBuff` because it is a statically sized array + // so `NameBuff == &NameBuff` according to C semantics. + char_u *buff_list[1] = {NameBuff}; + if (gen_expand_wildcards(1, buff_list, &filecount, &files, + EW_FILE|EW_SILENT) == FAIL + || filecount == 0) { + EMSG2("E151: No match: %s", NameBuff); + xfree(dirname); + return; + } + + /* Go over all files in the directory to find out what languages are + * present. */ + int j; + ga_init(&ga, 1, 10); + for (int i = 0; i < filecount; ++i) + { + len = (int)STRLEN(files[i]); + if (len <= 4) { + continue; + } + if (STRICMP(files[i] + len - 4, ".txt") == 0) { + /* ".txt" -> language "en" */ + lang[0] = 'e'; + lang[1] = 'n'; + } else if (files[i][len - 4] == '.' + && ASCII_ISALPHA(files[i][len - 3]) + && ASCII_ISALPHA(files[i][len - 2]) + && TOLOWER_ASC(files[i][len - 1]) == 'x') { + /* ".abx" -> language "ab" */ + lang[0] = TOLOWER_ASC(files[i][len - 3]); + lang[1] = TOLOWER_ASC(files[i][len - 2]); + } else + continue; + + /* Did we find this language already? */ + for (j = 0; j < ga.ga_len; j += 2) + if (STRNCMP(lang, ((char_u *)ga.ga_data) + j, 2) == 0) + break; + if (j == ga.ga_len) + { + /* New language, add it. */ + ga_grow(&ga, 2); + ((char_u *)ga.ga_data)[ga.ga_len++] = lang[0]; + ((char_u *)ga.ga_data)[ga.ga_len++] = lang[1]; + } + } + + /* + * Loop over the found languages to generate a tags file for each one. + */ + for (j = 0; j < ga.ga_len; j += 2) { + STRCPY(fname, "tags-xx"); + fname[5] = ((char_u *)ga.ga_data)[j]; + fname[6] = ((char_u *)ga.ga_data)[j + 1]; + if (fname[5] == 'e' && fname[6] == 'n') { + /* English is an exception: use ".txt" and "tags". */ + fname[4] = NUL; + STRCPY(ext, ".txt"); + } else { + /* Language "ab" uses ".abx" and "tags-ab". */ + STRCPY(ext, ".xxx"); + ext[1] = fname[5]; + ext[2] = fname[6]; + } + helptags_one(dirname, ext, fname, add_help_tags); + } + + ga_clear(&ga); + FreeWild(filecount, files); +} + + static void +helptags_cb(char_u *fname, void *cookie) +{ + do_helptags(fname, *(bool *)cookie); +} + +/* + * ":helptags" + */ +void ex_helptags(exarg_T *eap) +{ + expand_T xpc; + char_u *dirname; + bool add_help_tags = false; + + /* Check for ":helptags ++t {dir}". */ + if (STRNCMP(eap->arg, "++t", 3) == 0 && ascii_iswhite(eap->arg[3])) { + add_help_tags = true; + eap->arg = skipwhite(eap->arg + 3); + } + + if (STRCMP(eap->arg, "ALL") == 0) { + do_in_path(p_rtp, (char_u *)"doc", DIP_ALL + DIP_DIR, + helptags_cb, &add_help_tags); + } else { + ExpandInit(&xpc); + xpc.xp_context = EXPAND_DIRECTORIES; + dirname = ExpandOne(&xpc, eap->arg, NULL, + WILD_LIST_NOTFOUND|WILD_SILENT, WILD_EXPAND_FREE); + if (dirname == NULL || !os_isdir(dirname)) { + EMSG2(_("E150: Not a directory: %s"), eap->arg); + } else { + do_helptags(dirname, add_help_tags); + } + xfree(dirname); + } +} + struct sign { sign_T *sn_next; /* next sign in list */ diff --git a/src/nvim/ex_cmds2.c b/src/nvim/ex_cmds2.c index 17125ec798..dda8bf782e 100644 --- a/src/nvim/ex_cmds2.c +++ b/src/nvim/ex_cmds2.c @@ -2285,10 +2285,6 @@ int source_runtime(char_u *name, int all) return do_in_runtimepath(name, all, source_callback, NULL); } -#define DIP_ALL 1 // all matches, not just the first one -#define DIP_DIR 2 // find directories instead of files. -#define DIP_ERR 4 // give an error message when none found. - /// Find the file "name" in all directories in "path" and invoke /// "callback(fname, cookie)". /// "name" can contain wildcards. @@ -2297,8 +2293,8 @@ int source_runtime(char_u *name, int all) /// When "flags" has DIP_ERR: give an error message if there is no match. /// /// return FAIL when no file could be sourced, OK otherwise. -static int do_in_path(char_u *path, char_u *name, int flags, - DoInRuntimepathCB callback, void *cookie) +int do_in_path(char_u *path, char_u *name, int flags, + DoInRuntimepathCB callback, void *cookie) { char_u *tail; int num_files; diff --git a/src/nvim/version.c b/src/nvim/version.c index 97cd65700f..e44b4441d0 100644 --- a/src/nvim/version.c +++ b/src/nvim/version.c @@ -144,7 +144,7 @@ static int included_patches[] = { // 1554, // 1553, // 1552, - // 1551, + 1551, 1550, // 1549, // 1548, diff --git a/src/nvim/vim.h b/src/nvim/vim.h index c2f0a0ebd3..745888af6a 100644 --- a/src/nvim/vim.h +++ b/src/nvim/vim.h @@ -308,4 +308,9 @@ enum { # define SET_NO_HLSEARCH(flag) no_hlsearch = (flag); set_vim_var_nr( \ VV_HLSEARCH, !no_hlsearch && p_hls) +// Used for flags of do_in_path() +#define DIP_ALL 1 // all matches, not just the first one +#define DIP_DIR 2 // find directories instead of files +#define DIP_ERR 4 // give an error message when none found + #endif /* NVIM_VIM_H */ -- cgit From 080476882be32768a97e26af22133435ccb8fc2a Mon Sep 17 00:00:00 2001 From: James McCoy Date: Mon, 20 Jun 2016 20:34:24 -0400 Subject: vim-patch:7.4.1552 Problem: ":colorscheme" does not use 'packpath'. Solution: Also use in "start" and "opt" directories in 'packpath'. https://github.com/vim/vim/commit/7f8989dd8a627af2185df381195351a913f3777f --- src/nvim/digraph.c | 4 ++-- src/nvim/eval.c | 2 +- src/nvim/ex_cmds2.c | 42 +++++++++++++++++++++++++++++++++--------- src/nvim/ex_docmd.c | 12 ++++++------ src/nvim/hardcopy.c | 3 +-- src/nvim/main.c | 2 +- src/nvim/option.c | 2 +- src/nvim/spell.c | 6 +++--- src/nvim/syntax.c | 6 +++--- src/nvim/tag.c | 5 ++--- src/nvim/version.c | 2 +- src/nvim/vim.h | 10 ++++++---- 12 files changed, 60 insertions(+), 36 deletions(-) (limited to 'src') diff --git a/src/nvim/digraph.c b/src/nvim/digraph.c index 9525024c1b..aad145b3e5 100644 --- a/src/nvim/digraph.c +++ b/src/nvim/digraph.c @@ -1757,12 +1757,12 @@ char_u* keymap_init(void) vim_snprintf(buf, buflen, "keymap/%s_%s.vim", curbuf->b_p_keymap, p_enc); - if (source_runtime((char_u *)buf, FALSE) == FAIL) { + if (source_runtime((char_u *)buf, 0) == FAIL) { // try finding "keymap/'keymap'.vim" in 'runtimepath' vim_snprintf(buf, buflen, "keymap/%s.vim", curbuf->b_p_keymap); - if (source_runtime((char_u *)buf, FALSE) == FAIL) { + if (source_runtime((char_u *)buf, 0) == FAIL) { xfree(buf); return (char_u *)N_("E544: Keymap file not found"); } diff --git a/src/nvim/eval.c b/src/nvim/eval.c index d2b9bf66e1..89b1702be2 100644 --- a/src/nvim/eval.c +++ b/src/nvim/eval.c @@ -20499,7 +20499,7 @@ script_autoload ( } /* Try loading the package from $VIMRUNTIME/autoload/.vim */ - if (source_runtime(scriptname, FALSE) == OK) + if (source_runtime(scriptname, 0) == OK) ret = TRUE; } diff --git a/src/nvim/ex_cmds2.c b/src/nvim/ex_cmds2.c index dda8bf782e..8d298ee0a3 100644 --- a/src/nvim/ex_cmds2.c +++ b/src/nvim/ex_cmds2.c @@ -2237,7 +2237,7 @@ void ex_compiler(exarg_T *eap) do_unlet((char_u *)"b:current_compiler", true); snprintf((char *)buf, bufsize, "compiler/%s.vim", eap->arg); - if (source_runtime(buf, true) == FAIL) { + if (source_runtime(buf, DIP_ALL) == FAIL) { EMSG2(_("E666: compiler not supported: %s"), eap->arg); } xfree(buf); @@ -2266,7 +2266,7 @@ void ex_compiler(exarg_T *eap) /// ":runtime {name}" void ex_runtime(exarg_T *eap) { - source_runtime(eap->arg, eap->forceit); + source_runtime(eap->arg, eap->forceit ? DIP_ALL : 0); } @@ -2277,12 +2277,12 @@ static void source_callback(char_u *fname, void *cookie) /// Source the file "name" from all directories in 'runtimepath'. /// "name" can contain wildcards. -/// When "all" is true: source all files, otherwise only the first one. +/// When "flags" has DIP_ALL: source all files, otherwise only the first one. /// /// return FAIL when no file could be sourced, OK otherwise. -int source_runtime(char_u *name, int all) +int source_runtime(char_u *name, int flags) { - return do_in_runtimepath(name, all, source_callback, NULL); + return do_in_runtimepath(name, flags, source_callback, NULL); } /// Find the file "name" in all directories in "path" and invoke @@ -2379,16 +2379,40 @@ int do_in_path(char_u *path, char_u *name, int flags, /// Find "name" in 'runtimepath'. When found, invoke the callback function for /// it: callback(fname, "cookie") -/// When "all" is true repeat for all matches, otherwise only the first one is -/// used. +/// When "flags" has DIP_ALL repeat for all matches, otherwise only the first +/// one is used. /// Returns OK when at least one match found, FAIL otherwise. /// If "name" is NULL calls callback for each entry in runtimepath. Cookie is /// passed by reference in this case, setting it to NULL indicates that callback /// has done its job. -int do_in_runtimepath(char_u *name, bool all, DoInRuntimepathCB callback, +int do_in_runtimepath(char_u *name, int flags, DoInRuntimepathCB callback, void *cookie) { - return do_in_path(p_rtp, name, all ? DIP_ALL : 0, callback, cookie); + int done = do_in_path(p_rtp, name, flags, callback, cookie); + + if (done == FAIL && (flags & DIP_START)) { + char *start_dir = "pack/*/start/*/%s"; + size_t len = STRLEN(start_dir) + STRLEN(name); + char_u *s = xmallocz(len); + + vim_snprintf((char *)s, len, start_dir, name); + done = do_in_path(p_pp, s, flags, callback, cookie); + + xfree(s); + } + + if (done == FAIL && (flags & DIP_OPT)) { + char *opt_dir = "pack/*/opt/*/%s"; + size_t len = STRLEN(opt_dir) + STRLEN(name); + char_u *s = xmallocz(len); + + vim_snprintf((char *)s, len, opt_dir, name); + done = do_in_path(p_pp, s, flags, callback, cookie); + + xfree(s); + } + + return done; } // Expand wildcards in "pat" and invoke do_source() for each match. diff --git a/src/nvim/ex_docmd.c b/src/nvim/ex_docmd.c index 80dad3605a..31d2da9bb9 100644 --- a/src/nvim/ex_docmd.c +++ b/src/nvim/ex_docmd.c @@ -9336,14 +9336,14 @@ static void ex_filetype(exarg_T *eap) } if (STRCMP(arg, "on") == 0 || STRCMP(arg, "detect") == 0) { if (*arg == 'o' || !filetype_detect) { - source_runtime((char_u *)FILETYPE_FILE, true); + source_runtime((char_u *)FILETYPE_FILE, DIP_ALL); filetype_detect = kTrue; if (plugin) { - source_runtime((char_u *)FTPLUGIN_FILE, true); + source_runtime((char_u *)FTPLUGIN_FILE, DIP_ALL); filetype_plugin = kTrue; } if (indent) { - source_runtime((char_u *)INDENT_FILE, true); + source_runtime((char_u *)INDENT_FILE, DIP_ALL); filetype_indent = kTrue; } } @@ -9354,15 +9354,15 @@ static void ex_filetype(exarg_T *eap) } else if (STRCMP(arg, "off") == 0) { if (plugin || indent) { if (plugin) { - source_runtime((char_u *)FTPLUGOF_FILE, true); + source_runtime((char_u *)FTPLUGOF_FILE, DIP_ALL); filetype_plugin = kFalse; } if (indent) { - source_runtime((char_u *)INDOFF_FILE, true); + source_runtime((char_u *)INDOFF_FILE, DIP_ALL); filetype_indent = kFalse; } } else { - source_runtime((char_u *)FTOFF_FILE, true); + source_runtime((char_u *)FTOFF_FILE, DIP_ALL); filetype_detect = kFalse; } } else diff --git a/src/nvim/hardcopy.c b/src/nvim/hardcopy.c index 916d27a964..1c9b8e18ef 100644 --- a/src/nvim/hardcopy.c +++ b/src/nvim/hardcopy.c @@ -1526,8 +1526,7 @@ static int prt_find_resource(char *name, struct prt_ps_resource_S *resource) vim_strcat(buffer, (char_u *)name, MAXPATHL); vim_strcat(buffer, (char_u *)".ps", MAXPATHL); resource->filename[0] = NUL; - retval = (do_in_runtimepath(buffer, FALSE, prt_resource_name, - resource->filename) + retval = (do_in_runtimepath(buffer, 0, prt_resource_name, resource->filename) && resource->filename[0] != NUL); xfree(buffer); return retval; diff --git a/src/nvim/main.c b/src/nvim/main.c index 787a99802b..c7eafb4741 100644 --- a/src/nvim/main.c +++ b/src/nvim/main.c @@ -1241,7 +1241,7 @@ static void set_window_layout(mparm_T *paramp) static void load_plugins(void) { if (p_lpl) { - source_runtime((char_u *)"plugin/**/*.vim", TRUE); + source_runtime((char_u *)"plugin/**/*.vim", DIP_ALL); TIME_MSG("loading plugins"); ex_packloadall(NULL); diff --git a/src/nvim/option.c b/src/nvim/option.c index be3cb914b2..fad46ddf2d 100644 --- a/src/nvim/option.c +++ b/src/nvim/option.c @@ -3188,7 +3188,7 @@ did_set_string_option ( if (vim_strchr((char_u *)"_.,", *p) != NULL) break; vim_snprintf((char *)fname, 200, "spell/%.*s.vim", (int)(p - q), q); - source_runtime(fname, TRUE); + source_runtime(fname, DIP_ALL); } } diff --git a/src/nvim/spell.c b/src/nvim/spell.c index fba6fac821..d688b3e7f4 100644 --- a/src/nvim/spell.c +++ b/src/nvim/spell.c @@ -2319,14 +2319,14 @@ static void spell_load_lang(char_u *lang) vim_snprintf((char *)fname_enc, sizeof(fname_enc) - 5, "spell/%s.%s.spl", lang, spell_enc()); - r = do_in_runtimepath(fname_enc, FALSE, spell_load_cb, &sl); + r = do_in_runtimepath(fname_enc, 0, spell_load_cb, &sl); if (r == FAIL && *sl.sl_lang != NUL) { // Try loading the ASCII version. vim_snprintf((char *)fname_enc, sizeof(fname_enc) - 5, "spell/%s.ascii.spl", lang); - r = do_in_runtimepath(fname_enc, FALSE, spell_load_cb, &sl); + r = do_in_runtimepath(fname_enc, 0, spell_load_cb, &sl); if (r == FAIL && *sl.sl_lang != NUL && round == 1 && apply_autocmds(EVENT_SPELLFILEMISSING, lang, @@ -2354,7 +2354,7 @@ static void spell_load_lang(char_u *lang) } else if (sl.sl_slang != NULL) { // At least one file was loaded, now load ALL the additions. STRCPY(fname_enc + STRLEN(fname_enc) - 3, "add.spl"); - do_in_runtimepath(fname_enc, TRUE, spell_load_cb, &sl); + do_in_runtimepath(fname_enc, DIP_ALL, spell_load_cb, &sl); } } diff --git a/src/nvim/syntax.c b/src/nvim/syntax.c index 05141eaf1e..8792e80bcf 100644 --- a/src/nvim/syntax.c +++ b/src/nvim/syntax.c @@ -4208,7 +4208,7 @@ static void syn_cmd_include(exarg_T *eap, int syncing) prev_toplvl_grp = curwin->w_s->b_syn_topgrp; curwin->w_s->b_syn_topgrp = sgl_id; if (source ? do_source(eap->arg, FALSE, DOSO_NONE) == FAIL - : source_runtime(eap->arg, TRUE) == FAIL) + : source_runtime(eap->arg, DIP_ALL) == FAIL) EMSG2(_(e_notopen), eap->arg); curwin->w_s->b_syn_topgrp = prev_toplvl_grp; current_syn_inc_tag = prev_syn_inc_tag; @@ -6027,7 +6027,7 @@ init_highlight ( EMSG(_("E679: recursive loop loading syncolor.vim")); else { ++recursive; - (void)source_runtime((char_u *)"syntax/syncolor.vim", TRUE); + (void)source_runtime((char_u *)"syntax/syncolor.vim", DIP_ALL); --recursive; } } @@ -6052,7 +6052,7 @@ int load_colors(char_u *name) recursive = TRUE; buf = xmalloc(STRLEN(name) + 12); sprintf((char *)buf, "colors/%s.vim", name); - retval = source_runtime(buf, FALSE); + retval = source_runtime(buf, DIP_START + DIP_OPT); xfree(buf); apply_autocmds(EVENT_COLORSCHEME, name, curbuf->b_fname, FALSE, curbuf); diff --git a/src/nvim/tag.c b/src/nvim/tag.c index 5d15196784..dfecfb776d 100644 --- a/src/nvim/tag.c +++ b/src/nvim/tag.c @@ -2023,9 +2023,8 @@ get_tagfname ( if (first) { ga_clear_strings(&tag_fnames); ga_init(&tag_fnames, (int)sizeof(char_u *), 10); - do_in_runtimepath((char_u *) - "doc/tags doc/tags-??" - , TRUE, found_tagfile_cb, NULL); + do_in_runtimepath((char_u *)"doc/tags doc/tags-??", DIP_ALL, + found_tagfile_cb, NULL); } if (tnp->tn_hf_idx >= tag_fnames.ga_len) { diff --git a/src/nvim/version.c b/src/nvim/version.c index e44b4441d0..9b4221863c 100644 --- a/src/nvim/version.c +++ b/src/nvim/version.c @@ -143,7 +143,7 @@ static int included_patches[] = { // 1555 NA // 1554, // 1553, - // 1552, + 1552, 1551, 1550, // 1549, diff --git a/src/nvim/vim.h b/src/nvim/vim.h index 745888af6a..47c5a0465a 100644 --- a/src/nvim/vim.h +++ b/src/nvim/vim.h @@ -308,9 +308,11 @@ enum { # define SET_NO_HLSEARCH(flag) no_hlsearch = (flag); set_vim_var_nr( \ VV_HLSEARCH, !no_hlsearch && p_hls) -// Used for flags of do_in_path() -#define DIP_ALL 1 // all matches, not just the first one -#define DIP_DIR 2 // find directories instead of files -#define DIP_ERR 4 // give an error message when none found +// Used for flags in do_in_path() +#define DIP_ALL 0x01 // all matches, not just the first one +#define DIP_DIR 0x02 // find directories instead of files +#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' #endif /* NVIM_VIM_H */ -- cgit From 53613e7fcd27feda32844904f4ef88bf82841015 Mon Sep 17 00:00:00 2001 From: James McCoy Date: Tue, 21 Jun 2016 23:13:46 -0400 Subject: vim-patch:7.4.1553 Problem: ":runtime" does not use 'packpath'. Solution: Add "what" argument. https://github.com/vim/vim/commit/8dcf259d904cfb965d31841dc74a5cfaf5a351d9 --- src/nvim/ex_cmds2.c | 33 ++++++++++++++++++++++++++++----- src/nvim/version.c | 2 +- src/nvim/vim.h | 1 + 3 files changed, 30 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/nvim/ex_cmds2.c b/src/nvim/ex_cmds2.c index 8d298ee0a3..755cca3884 100644 --- a/src/nvim/ex_cmds2.c +++ b/src/nvim/ex_cmds2.c @@ -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 ((flags & DIP_NORTP) == 0) { + done = do_in_path(p_rtp, name, flags, callback, cookie); + } - if (done == FAIL && (flags & DIP_START)) { + 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); diff --git a/src/nvim/version.c b/src/nvim/version.c index 9b4221863c..2fdb443ca6 100644 --- a/src/nvim/version.c +++ b/src/nvim/version.c @@ -142,7 +142,7 @@ static int included_patches[] = { // 1556 NA // 1555 NA // 1554, - // 1553, + 1553, 1552, 1551, 1550, diff --git a/src/nvim/vim.h b/src/nvim/vim.h index 47c5a0465a..09e9e850a7 100644 --- a/src/nvim/vim.h +++ b/src/nvim/vim.h @@ -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 */ -- cgit From 443d335ce31929f0e1c3b2ad6e403f98067c9526 Mon Sep 17 00:00:00 2001 From: James McCoy Date: Wed, 22 Jun 2016 11:04:46 -0400 Subject: vim-patch:7.4.1554 Problem: Completion for :colorscheme does not use 'packpath'. Solution: Make it work, add a test. (Hirohito Higashi) https://github.com/vim/vim/commit/52f9c19015df5ee1ee8592b6f3f15b8a57c8f5be --- src/nvim/ex_getln.c | 44 ++++++++++++++++++++++++++++++++++---------- src/nvim/version.c | 2 +- 2 files changed, 35 insertions(+), 11 deletions(-) (limited to 'src') diff --git a/src/nvim/ex_getln.c b/src/nvim/ex_getln.c index 688be3c67c..7aa49e22ad 100644 --- a/src/nvim/ex_getln.c +++ b/src/nvim/ex_getln.c @@ -3796,19 +3796,19 @@ ExpandFromContext ( return expand_tags(xp->xp_context == EXPAND_TAGS, pat, num_file, file); if (xp->xp_context == EXPAND_COLORS) { char *directories[] = {"colors", NULL}; - return ExpandRTDir(pat, num_file, file, directories); + return ExpandRTDir(pat, DIP_START + DIP_OPT, num_file, file, directories); } if (xp->xp_context == EXPAND_COMPILER) { char *directories[] = {"compiler", NULL}; - return ExpandRTDir(pat, num_file, file, directories); + return ExpandRTDir(pat, 0, num_file, file, directories); } if (xp->xp_context == EXPAND_OWNSYNTAX) { char *directories[] = {"syntax", NULL}; - return ExpandRTDir(pat, num_file, file, directories); + return ExpandRTDir(pat, 0, num_file, file, directories); } if (xp->xp_context == EXPAND_FILETYPE) { char *directories[] = {"syntax", "indent", "ftplugin", NULL}; - return ExpandRTDir(pat, num_file, file, directories); + return ExpandRTDir(pat, 0, num_file, file, directories); } if (xp->xp_context == EXPAND_USER_LIST) { return ExpandUserList(xp, num_file, file); @@ -4195,12 +4195,16 @@ static int ExpandUserList(expand_T *xp, int *num_file, char_u ***file) return OK; } -/* - * Expand color scheme, compiler or filetype names: - * 'runtimepath'/{dirnames}/{pat}.vim - * "dirnames" is an array with one or more directory names. - */ -static int ExpandRTDir(char_u *pat, int *num_file, char_u ***file, char *dirnames[]) +/// Expand color scheme, compiler or filetype names. +/// Search from 'runtimepath': +/// 'runtimepath'/{dirnames}/{pat}.vim +/// When "flags" has DIP_START: search also from 'start' of 'packpath': +/// 'packpath'/pack/ * /start/ * /{dirnames}/{pat}.vim +/// When "flags" has DIP_OPT: search also from 'opt' of 'packpath': +/// 'packpath'/pack/ * /opt/ * /{dirnames}/{pat}.vim +/// "dirnames" is an array with one or more directory names. +static int ExpandRTDir(char_u *pat, int flags, int *num_file, char_u ***file, + char *dirnames[]) { *num_file = 0; *file = NULL; @@ -4217,6 +4221,26 @@ static int ExpandRTDir(char_u *pat, int *num_file, char_u ***file, char *dirname xfree(s); } + if (flags & DIP_START) { + for (int i = 0; dirnames[i] != NULL; i++) { + size_t size = STRLEN(dirnames[i]) + pat_len + 22; + char_u *s = xmalloc(size); + snprintf((char *)s, size, "pack/*/start/*/%s/%s*.vim", dirnames[i], pat); + globpath(p_pp, s, &ga, 0); + xfree(s); + } + } + + if (flags & DIP_OPT) { + for (int i = 0; dirnames[i] != NULL; i++) { + size_t size = STRLEN(dirnames[i]) + pat_len + 20; + char_u *s = xmalloc(size); + snprintf((char *)s, size, "pack/*/opt/*/%s/%s*.vim", dirnames[i], pat); + globpath(p_pp, s, &ga, 0); + xfree(s); + } + } + for (int i = 0; i < ga.ga_len; i++) { char_u *match = ((char_u **)ga.ga_data)[i]; char_u *s = match; diff --git a/src/nvim/version.c b/src/nvim/version.c index 2fdb443ca6..aa27d8279d 100644 --- a/src/nvim/version.c +++ b/src/nvim/version.c @@ -141,7 +141,7 @@ static int included_patches[] = { // 1557, // 1556 NA // 1555 NA - // 1554, + 1554, 1553, 1552, 1551, -- cgit From 4bd14e921b7ac56560f53d54aba1380bc7bc0689 Mon Sep 17 00:00:00 2001 From: James McCoy Date: Wed, 22 Jun 2016 20:10:37 -0400 Subject: vim-patch:7.4.1596 Problem: Memory leak. (Coverity) Solution: Free the pattern. https://github.com/vim/vim/commit/ba8cd122ef60a7c71a7723be0d635f0c2d4556ab --- src/nvim/ex_cmds2.c | 1 + src/nvim/version.c | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/nvim/ex_cmds2.c b/src/nvim/ex_cmds2.c index 755cca3884..bd91968bce 100644 --- a/src/nvim/ex_cmds2.c +++ b/src/nvim/ex_cmds2.c @@ -2533,6 +2533,7 @@ static void add_pack_plugin(char_u *fname, void *cookie) do_cmdline_cmd("augroup END"); } xfree(cmd); + xfree(pat); } theend: diff --git a/src/nvim/version.c b/src/nvim/version.c index aa27d8279d..61d2972caa 100644 --- a/src/nvim/version.c +++ b/src/nvim/version.c @@ -98,7 +98,7 @@ static int included_patches[] = { // 1599 NA // 1598 NA // 1597 NA - // 1596, + 1596, // 1595 NA // 1594 NA // 1593 NA -- cgit From 99e51b81e6ef4c62232429159e893bf748fc5fad Mon Sep 17 00:00:00 2001 From: James McCoy Date: Wed, 22 Jun 2016 22:39:30 -0400 Subject: vim-patch:7.4.1649 Problem: The matchit plugin needs to be copied to be used. Solution: Put the matchit plugin in an optional package. https://github.com/vim/vim/commit/aedfcbe1e6c7df6edcd6756d7601bfdec7dd2087 Ignore changes to * Filelist, src/Makefile: Irrelevant to NeoVim * runtime/vimrc_example.vim, runtime/macros/*, runtime/pack/*: matchit is enabled by default in Neovim. --- src/nvim/version.c | 1 + 1 file changed, 1 insertion(+) (limited to 'src') diff --git a/src/nvim/version.c b/src/nvim/version.c index 61d2972caa..25a5c9d730 100644 --- a/src/nvim/version.c +++ b/src/nvim/version.c @@ -90,6 +90,7 @@ static int included_patches[] = { 1695, 1654, 1652, + 1649, 1643, 1641, // 1624 NA -- cgit From 23b2ee077130182c60d6639d99b45546902c8f80 Mon Sep 17 00:00:00 2001 From: James McCoy Date: Thu, 7 Jul 2016 23:12:33 -0400 Subject: vim-patch:7.4.1712 Problem: For plugins in packages, plugin authors need to take care of all dependencies. Solution: When loading "start" packages and for :packloadall, first add all directories to 'runtimepath' before sourcing plugins. https://github.com/vim/vim/commit/49b27326447d0827c59c6cd201d58f65c1163086 --- src/nvim/ex_cmds2.c | 20 +++++++++++++++----- src/nvim/version.c | 1 + 2 files changed, 16 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/nvim/ex_cmds2.c b/src/nvim/ex_cmds2.c index bd91968bce..900932fbed 100644 --- a/src/nvim/ex_cmds2.c +++ b/src/nvim/ex_cmds2.c @@ -2452,18 +2452,22 @@ static void source_all_matches(char_u *pat) } } +// used for "cookie" of add_pack_plugin() +static int APP_ADD_DIR; +static int APP_LOAD; +static int APP_BOTH; + static void add_pack_plugin(char_u *fname, void *cookie) { char_u *p4, *p3, *p2, *p1, *p; char_u *new_rtp; char_u *ffname = (char_u *)fix_fname((char *)fname); - bool load_files = cookie != NULL; if (ffname == NULL) { return; } - if (strstr((char *)p_rtp, (char *)ffname) == NULL) { + if (cookie != &APP_LOAD && strstr((char *)p_rtp, (char *)ffname) == NULL) { // directory not in 'runtimepath', add it p4 = p3 = p2 = p1 = get_past_head(ffname); for (p = p1; *p; mb_ptr_adv(p)) { @@ -2510,7 +2514,7 @@ static void add_pack_plugin(char_u *fname, void *cookie) xfree(new_rtp); } - if (load_files) { + if (cookie != &APP_ADD_DIR) { static const char *plugpat = "%s/plugin/*.vim"; static const char *ftpat = "%s/ftdetect/*.vim"; @@ -2548,8 +2552,14 @@ void ex_packloadall(exarg_T *eap) { if (!did_source_packages || (eap != NULL && eap->forceit)) { did_source_packages = true; + + // First do a round to add all directories to 'runtimepath', then load + // the plugins. This allows for plugins to use an autoload directory + // of another plugin. + do_in_path(p_pp, (char_u *)"pack/*/start/*", DIP_ALL + DIP_DIR, + add_pack_plugin, &APP_ADD_DIR); do_in_path(p_pp, (char_u *)"pack/*/start/*", DIP_ALL + DIP_DIR, - add_pack_plugin, p_pp); + add_pack_plugin, &APP_LOAD); } } @@ -2562,7 +2572,7 @@ void ex_packadd(exarg_T *eap) char *pat = (char *)xmallocz(len); vim_snprintf(pat, len, plugpat, eap->arg); do_in_path(p_pp, (char_u *)pat, DIP_ALL + DIP_DIR + DIP_ERR, add_pack_plugin, - eap->forceit ? NULL : p_pp); + eap->forceit ? &APP_ADD_DIR : &APP_BOTH); xfree(pat); } diff --git a/src/nvim/version.c b/src/nvim/version.c index 25a5c9d730..b9543cb0b7 100644 --- a/src/nvim/version.c +++ b/src/nvim/version.c @@ -87,6 +87,7 @@ static int included_patches[] = { 1753, 1728, 1716, + 1712, 1695, 1654, 1652, -- cgit From 520a4f06e20c3917e75e3a413a290d9141cb0a0c Mon Sep 17 00:00:00 2001 From: James McCoy Date: Fri, 8 Jul 2016 00:05:35 -0400 Subject: vim-patch:7.4.1840 Problem: When using packages an "after" directory cannot be used. Solution: Add the "after" directory of the package to 'runtimepath' if it exists. https://github.com/vim/vim/commit/a57024453115592b8847af40ddd965a33898e390 --- src/nvim/ex_cmds2.c | 22 +++++++++++++++++----- src/nvim/version.c | 1 + 2 files changed, 18 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/nvim/ex_cmds2.c b/src/nvim/ex_cmds2.c index 900932fbed..56f0ca0904 100644 --- a/src/nvim/ex_cmds2.c +++ b/src/nvim/ex_cmds2.c @@ -2468,7 +2468,7 @@ static void add_pack_plugin(char_u *fname, void *cookie) } if (cookie != &APP_LOAD && strstr((char *)p_rtp, (char *)ffname) == NULL) { - // directory not in 'runtimepath', add it + // directory is not yet in 'runtimepath', add it p4 = p3 = p2 = p1 = get_past_head(ffname); for (p = p1; *p; mb_ptr_adv(p)) { if (vim_ispathsep_nocolon(*p)) { @@ -2496,22 +2496,34 @@ static void add_pack_plugin(char_u *fname, void *cookie) } *p4 = c; + // check if rtp/pack/name/start/name/after exists + char *afterdir = concat_fnames((char *)ffname, "after", true); + size_t afterlen = 0; + if (os_isdir((char_u *)afterdir)) { + afterlen = STRLEN(afterdir) + 1; // add one for comma + } + size_t oldlen = STRLEN(p_rtp); - size_t addlen = STRLEN(ffname); - new_rtp = try_malloc(oldlen + addlen + 1); + size_t addlen = STRLEN(ffname) + 1; // add one for comma + new_rtp = try_malloc(oldlen + addlen + afterlen + 1); // add one for NUL if (new_rtp == NULL) { goto theend; } uintptr_t keep = (uintptr_t)(insp - p_rtp); memmove(new_rtp, p_rtp, keep); new_rtp[keep] = ','; - memmove(new_rtp + keep + 1, ffname, addlen + 1); + memmove(new_rtp + keep + 1, ffname, addlen); if (p_rtp[keep] != NUL) { - memmove(new_rtp + keep + 1 + addlen, p_rtp + keep, + memmove(new_rtp + keep + addlen, p_rtp + keep, oldlen - keep + 1); } + if (afterlen > 0) { + STRCAT(new_rtp, ","); + STRCAT(new_rtp, afterdir); + } set_option_value((char_u *)"rtp", 0L, new_rtp, 0); xfree(new_rtp); + xfree(afterdir); } if (cookie != &APP_ADD_DIR) { diff --git a/src/nvim/version.c b/src/nvim/version.c index b9543cb0b7..358b2cc2f0 100644 --- a/src/nvim/version.c +++ b/src/nvim/version.c @@ -76,6 +76,7 @@ static char *features[] = { // clang-format off static int included_patches[] = { 1960, + 1840, 1832, 1831, 1809, -- cgit From c147766389a11df0bc6cf86bb1a6bd0e22a6026b Mon Sep 17 00:00:00 2001 From: James McCoy Date: Fri, 8 Jul 2016 00:27:05 -0400 Subject: vim-patch:7.4.1973 Problem: On MS-Windows the package directory may be added at the end because of forward/backward slash differences. (Matthew Desjardins) Solution: Ignore slash differences. https://github.com/vim/vim/commit/4c5717ed8a81f5ae9dfe4f38b17a61fc8421054b --- src/nvim/ex_cmds2.c | 16 +++++++++++++++- src/nvim/version.c | 1 + 2 files changed, 16 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/nvim/ex_cmds2.c b/src/nvim/ex_cmds2.c index 56f0ca0904..bf75e635b5 100644 --- a/src/nvim/ex_cmds2.c +++ b/src/nvim/ex_cmds2.c @@ -2483,7 +2483,21 @@ static void add_pack_plugin(char_u *fname, void *cookie) // find the part up to "pack" in 'runtimepath' char_u c = *p4; *p4 = NUL; - char_u *insp = (char_u *)strstr((char *)p_rtp, (char *)ffname); + + // Find "ffname" in "p_rtp", ignoring '/' vs '\' differences + int fname_len = STRLEN(ffname); + char_u *insp = p_rtp; + for (;;) { + if (vim_fnamencmp(insp, ffname, fname_len) == 0) { + break; + } + insp = vim_strchr(insp, ','); + if (insp == NULL) { + break; + } + insp++; + } + if (insp == NULL) { // not found, append at the end insp = p_rtp + STRLEN(p_rtp); diff --git a/src/nvim/version.c b/src/nvim/version.c index 358b2cc2f0..8aa3071395 100644 --- a/src/nvim/version.c +++ b/src/nvim/version.c @@ -75,6 +75,7 @@ static char *features[] = { // clang-format off static int included_patches[] = { + 1973, 1960, 1840, 1832, -- cgit From 86b4f6856b52b311137467af9a631f7e567dcfbf Mon Sep 17 00:00:00 2001 From: James McCoy Date: Fri, 8 Jul 2016 00:35:24 -0400 Subject: vim-patch:7.4.1986 Problem: Compiler warns for loss of data. Solution: Use size_t instead of int. (Christian Brabandt) https://github.com/vim/vim/commit/fef524bbff9aa186838c35212b2f89f61d627cf8 --- src/nvim/ex_cmds2.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/nvim/ex_cmds2.c b/src/nvim/ex_cmds2.c index bf75e635b5..7493bba823 100644 --- a/src/nvim/ex_cmds2.c +++ b/src/nvim/ex_cmds2.c @@ -2485,7 +2485,7 @@ static void add_pack_plugin(char_u *fname, void *cookie) *p4 = NUL; // Find "ffname" in "p_rtp", ignoring '/' vs '\' differences - int fname_len = STRLEN(ffname); + size_t fname_len = STRLEN(ffname); char_u *insp = p_rtp; for (;;) { if (vim_fnamencmp(insp, ffname, fname_len) == 0) { -- cgit From 059e9785dc2fea0a15344162de4a5a7c8da6f491 Mon Sep 17 00:00:00 2001 From: James McCoy Date: Fri, 8 Jul 2016 01:36:23 -0400 Subject: lint --- src/nvim/eval.c | 7 ++- src/nvim/ex_cmds.c | 33 +++++------ src/nvim/ex_cmds2.c | 18 +++--- src/nvim/ex_docmd.c | 68 +++++++++++----------- src/nvim/ex_getln.c | 19 ++++--- src/nvim/globals.h | 3 +- src/nvim/main.c | 2 +- src/nvim/option.c | 3 +- src/nvim/option_defs.h | 150 ++++++++++++++++++++++++------------------------- src/nvim/spell.c | 6 +- src/nvim/syntax.c | 33 ++++++----- 11 files changed, 174 insertions(+), 168 deletions(-) (limited to 'src') diff --git a/src/nvim/eval.c b/src/nvim/eval.c index 89b1702be2..591ed50cfd 100644 --- a/src/nvim/eval.c +++ b/src/nvim/eval.c @@ -20498,9 +20498,10 @@ script_autoload ( tofree = NULL; } - /* Try loading the package from $VIMRUNTIME/autoload/.vim */ - if (source_runtime(scriptname, 0) == OK) - ret = TRUE; + // Try loading the package from $VIMRUNTIME/autoload/.vim + if (source_runtime(scriptname, 0) == OK) { + ret = true; + } } xfree(tofree); diff --git a/src/nvim/ex_cmds.c b/src/nvim/ex_cmds.c index d74f39bf39..da64533708 100644 --- a/src/nvim/ex_cmds.c +++ b/src/nvim/ex_cmds.c @@ -4797,13 +4797,14 @@ void ex_viusage(exarg_T *eap) /// Generate tags in one help directory -static void -helptags_one ( - char_u *dir, /* doc directory */ - char_u *ext, /* suffix, ".txt", ".itx", ".frx", etc. */ - char_u *tagfname, /* "tags" for English, "tags-fr" for French. */ - int add_help_tags /* add "help-tags" tag */ -) +/// +/// @param dir Path to the doc directory +/// @param ext Suffix of the help files (".txt", ".itx", ".frx", etc.) +/// @param tagname Name of the tags file ("tags" for English, "tags-fr" for +/// French) +/// @param add_help_tags Whether to add the "help-tags" tag +static void helptags_one(char_u *dir, char_u *ext, char_u *tagfname, + bool add_help_tags) { FILE *fd_tags; FILE *fd; @@ -5004,7 +5005,7 @@ helptags_one ( } /// Generate tags in one help directory, taking care of translations. -static void do_helptags(char_u *dirname, int add_help_tags) +static void do_helptags(char_u *dirname, bool add_help_tags) { int len; garray_T ga; @@ -5034,8 +5035,7 @@ static void do_helptags(char_u *dirname, int add_help_tags) * present. */ int j; ga_init(&ga, 1, 10); - for (int i = 0; i < filecount; ++i) - { + for (int i = 0; i < filecount; i++) { len = (int)STRLEN(files[i]); if (len <= 4) { continue; @@ -5054,13 +5054,14 @@ static void do_helptags(char_u *dirname, int add_help_tags) } else continue; - /* Did we find this language already? */ - for (j = 0; j < ga.ga_len; j += 2) - if (STRNCMP(lang, ((char_u *)ga.ga_data) + j, 2) == 0) + // Did we find this language already? + for (j = 0; j < ga.ga_len; j += 2) { + if (STRNCMP(lang, ((char_u *)ga.ga_data) + j, 2) == 0) { break; - if (j == ga.ga_len) - { - /* New language, add it. */ + } + } + if (j == ga.ga_len) { + // New language, add it. ga_grow(&ga, 2); ((char_u *)ga.ga_data)[ga.ga_len++] = lang[0]; ((char_u *)ga.ga_data)[ga.ga_len++] = lang[1]; diff --git a/src/nvim/ex_cmds2.c b/src/nvim/ex_cmds2.c index 7493bba823..b56b1cf013 100644 --- a/src/nvim/ex_cmds2.c +++ b/src/nvim/ex_cmds2.c @@ -2329,7 +2329,7 @@ int do_in_path(char_u *path, char_u *name, int flags, if (p_verbose > 1 && name != NULL) { verbose_enter(); smsg(_("Searching for \"%s\" in \"%s\""), - (char *)name, (char *)path); + (char *)name, (char *)path); verbose_leave(); } @@ -2365,7 +2365,7 @@ int do_in_path(char_u *path, char_u *name, int flags, if (gen_expand_wildcards(1, &buf, &num_files, &files, (flags & DIP_DIR) ? EW_DIR : EW_FILE) == OK) { - for (i = 0; i < num_files; ++i) { + for (i = 0; i < num_files; i++) { (*callback)(files[i], cookie); did_one = true; if (!(flags & DIP_ALL)) { @@ -2414,7 +2414,7 @@ int do_in_runtimepath(char_u *name, int flags, DoInRuntimepathCB callback, } if ((done == FAIL || (flags & DIP_ALL)) && (flags & DIP_START)) { - char *start_dir = "pack/*/start/*/%s"; + char *start_dir = "pack/*/start/*/%s"; // NOLINT size_t len = STRLEN(start_dir) + STRLEN(name); char_u *s = xmallocz(len); @@ -2425,7 +2425,7 @@ int do_in_runtimepath(char_u *name, int flags, DoInRuntimepathCB callback, } if ((done == FAIL || (flags & DIP_ALL)) && (flags & DIP_OPT)) { - char *opt_dir = "pack/*/opt/*/%s"; + char *opt_dir = "pack/*/opt/*/%s"; // NOLINT size_t len = STRLEN(opt_dir) + STRLEN(name); char_u *s = xmallocz(len); @@ -2541,8 +2541,8 @@ static void add_pack_plugin(char_u *fname, void *cookie) } if (cookie != &APP_ADD_DIR) { - static const char *plugpat = "%s/plugin/*.vim"; - static const char *ftpat = "%s/ftdetect/*.vim"; + static const char *plugpat = "%s/plugin/*.vim"; // NOLINT + static const char *ftpat = "%s/ftdetect/*.vim"; // NOLINT size_t len = STRLEN(ffname) + STRLEN(ftpat); char_u *pat = try_malloc(len + 1); @@ -2582,9 +2582,9 @@ void ex_packloadall(exarg_T *eap) // First do a round to add all directories to 'runtimepath', then load // the plugins. This allows for plugins to use an autoload directory // of another plugin. - do_in_path(p_pp, (char_u *)"pack/*/start/*", DIP_ALL + DIP_DIR, + do_in_path(p_pp, (char_u *)"pack/*/start/*", DIP_ALL + DIP_DIR, // NOLINT add_pack_plugin, &APP_ADD_DIR); - do_in_path(p_pp, (char_u *)"pack/*/start/*", DIP_ALL + DIP_DIR, + do_in_path(p_pp, (char_u *)"pack/*/start/*", DIP_ALL + DIP_DIR, // NOLINT add_pack_plugin, &APP_LOAD); } } @@ -2592,7 +2592,7 @@ void ex_packloadall(exarg_T *eap) /// ":packadd[!] {name}" void ex_packadd(exarg_T *eap) { - static const char *plugpat = "pack/*/opt/%s"; + static const char *plugpat = "pack/*/opt/%s"; // NOLINT size_t len = STRLEN(plugpat) + STRLEN(eap->arg); char *pat = (char *)xmallocz(len); diff --git a/src/nvim/ex_docmd.c b/src/nvim/ex_docmd.c index 31d2da9bb9..9bc7ec39da 100644 --- a/src/nvim/ex_docmd.c +++ b/src/nvim/ex_docmd.c @@ -4665,42 +4665,42 @@ static struct { char *name; } command_complete[] = { - {EXPAND_AUGROUP, "augroup"}, - {EXPAND_BEHAVE, "behave"}, - {EXPAND_BUFFERS, "buffer"}, - {EXPAND_COLORS, "color"}, - {EXPAND_COMMANDS, "command"}, - {EXPAND_COMPILER, "compiler"}, - {EXPAND_CSCOPE, "cscope"}, - {EXPAND_USER_DEFINED, "custom"}, - {EXPAND_USER_LIST, "customlist"}, - {EXPAND_DIRECTORIES, "dir"}, - {EXPAND_ENV_VARS, "environment"}, - {EXPAND_EVENTS, "event"}, - {EXPAND_EXPRESSION, "expression"}, - {EXPAND_FILES, "file"}, - {EXPAND_FILES_IN_PATH, "file_in_path"}, - {EXPAND_FILETYPE, "filetype"}, - {EXPAND_FUNCTIONS, "function"}, - {EXPAND_HELP, "help"}, - {EXPAND_HIGHLIGHT, "highlight"}, - {EXPAND_HISTORY, "history"}, + { EXPAND_AUGROUP, "augroup" }, + { EXPAND_BEHAVE, "behave" }, + { EXPAND_BUFFERS, "buffer" }, + { EXPAND_COLORS, "color" }, + { EXPAND_COMMANDS, "command" }, + { EXPAND_COMPILER, "compiler" }, + { EXPAND_CSCOPE, "cscope" }, + { EXPAND_USER_DEFINED, "custom" }, + { EXPAND_USER_LIST, "customlist" }, + { EXPAND_DIRECTORIES, "dir" }, + { EXPAND_ENV_VARS, "environment" }, + { EXPAND_EVENTS, "event" }, + { EXPAND_EXPRESSION, "expression" }, + { EXPAND_FILES, "file" }, + { EXPAND_FILES_IN_PATH, "file_in_path" }, + { EXPAND_FILETYPE, "filetype" }, + { EXPAND_FUNCTIONS, "function" }, + { EXPAND_HELP, "help" }, + { EXPAND_HIGHLIGHT, "highlight" }, + { EXPAND_HISTORY, "history" }, #ifdef HAVE_WORKING_LIBINTL - {EXPAND_LOCALES, "locale"}, + { EXPAND_LOCALES, "locale" }, #endif - {EXPAND_MAPPINGS, "mapping"}, - {EXPAND_MENUS, "menu"}, - {EXPAND_OWNSYNTAX, "syntax"}, - {EXPAND_SYNTIME, "syntime"}, - {EXPAND_SETTINGS, "option"}, - {EXPAND_PACKADD, "packadd"}, - {EXPAND_SHELLCMD, "shellcmd"}, - {EXPAND_SIGN, "sign"}, - {EXPAND_TAGS, "tag"}, - {EXPAND_TAGS_LISTFILES, "tag_listfiles"}, - {EXPAND_USER, "user"}, - {EXPAND_USER_VARS, "var"}, - {0, NULL} + { EXPAND_MAPPINGS, "mapping" }, + { EXPAND_MENUS, "menu" }, + { EXPAND_OWNSYNTAX, "syntax" }, + { EXPAND_SYNTIME, "syntime" }, + { EXPAND_SETTINGS, "option" }, + { EXPAND_PACKADD, "packadd" }, + { EXPAND_SHELLCMD, "shellcmd" }, + { EXPAND_SIGN, "sign" }, + { EXPAND_TAGS, "tag" }, + { EXPAND_TAGS_LISTFILES, "tag_listfiles" }, + { EXPAND_USER, "user" }, + { EXPAND_USER_VARS, "var" }, + { 0, NULL } }; static void uc_list(char_u *name, size_t name_len) diff --git a/src/nvim/ex_getln.c b/src/nvim/ex_getln.c index 7aa49e22ad..cd28554970 100644 --- a/src/nvim/ex_getln.c +++ b/src/nvim/ex_getln.c @@ -3795,19 +3795,19 @@ ExpandFromContext ( || xp->xp_context == EXPAND_TAGS_LISTFILES) return expand_tags(xp->xp_context == EXPAND_TAGS, pat, num_file, file); if (xp->xp_context == EXPAND_COLORS) { - char *directories[] = {"colors", NULL}; + char *directories[] = { "colors", NULL }; return ExpandRTDir(pat, DIP_START + DIP_OPT, num_file, file, directories); } if (xp->xp_context == EXPAND_COMPILER) { - char *directories[] = {"compiler", NULL}; + char *directories[] = { "compiler", NULL }; return ExpandRTDir(pat, 0, num_file, file, directories); } if (xp->xp_context == EXPAND_OWNSYNTAX) { - char *directories[] = {"syntax", NULL}; + char *directories[] = { "syntax", NULL }; return ExpandRTDir(pat, 0, num_file, file, directories); } if (xp->xp_context == EXPAND_FILETYPE) { - char *directories[] = {"syntax", "indent", "ftplugin", NULL}; + char *directories[] = { "syntax", "indent", "ftplugin", NULL }; return ExpandRTDir(pat, 0, num_file, file, directories); } if (xp->xp_context == EXPAND_USER_LIST) { @@ -4225,7 +4225,7 @@ static int ExpandRTDir(char_u *pat, int flags, int *num_file, char_u ***file, for (int i = 0; dirnames[i] != NULL; i++) { size_t size = STRLEN(dirnames[i]) + pat_len + 22; char_u *s = xmalloc(size); - snprintf((char *)s, size, "pack/*/start/*/%s/%s*.vim", dirnames[i], pat); + snprintf((char *)s, size, "pack/*/start/*/%s/%s*.vim", dirnames[i], pat); // NOLINT globpath(p_pp, s, &ga, 0); xfree(s); } @@ -4235,7 +4235,7 @@ static int ExpandRTDir(char_u *pat, int flags, int *num_file, char_u ***file, for (int i = 0; dirnames[i] != NULL; i++) { size_t size = STRLEN(dirnames[i]) + pat_len + 20; char_u *s = xmalloc(size); - snprintf((char *)s, size, "pack/*/opt/*/%s/%s*.vim", dirnames[i], pat); + snprintf((char *)s, size, "pack/*/opt/*/%s/%s*.vim", dirnames[i], pat); // NOLINT globpath(p_pp, s, &ga, 0); xfree(s); } @@ -4281,12 +4281,13 @@ static int ExpandPackAddDir(char_u *pat, int *num_file, char_u ***file) size_t pat_len = STRLEN(pat); ga_init(&ga, (int)sizeof(char *), 10); - char_u *s = xmalloc((unsigned)(pat_len + 26)); - sprintf((char *)s, "pack/*/opt/%s*", pat); + size_t buflen = pat_len + 26; + char_u *s = xmalloc(buflen); + snprintf((char *)s, buflen, "pack/*/opt/%s*", pat); // NOLINT globpath(p_pp, s, &ga, 0); xfree(s); - for (int i = 0; i < ga.ga_len; ++i) { + for (int i = 0; i < ga.ga_len; i++) { char_u *match = ((char_u **)ga.ga_data)[i]; s = path_tail(match); char_u *e = s + STRLEN(s); diff --git a/src/nvim/globals.h b/src/nvim/globals.h index bfe2ec7fc7..ed9862a264 100644 --- a/src/nvim/globals.h +++ b/src/nvim/globals.h @@ -1223,7 +1223,8 @@ EXTERN char_u e_invalpat[] INIT(= N_( EXTERN char_u e_bufloaded[] INIT(= N_("E139: File is loaded in another buffer")); EXTERN char_u e_notset[] INIT(= N_("E764: Option '%s' is not set")); EXTERN char_u e_invalidreg[] INIT(= N_("E850: Invalid register name")); -EXTERN char_u e_dirnotf[] INIT(= N_("E919: Directory not found in '%s': \"%s\"")); +EXTERN char_u e_dirnotf[] INIT(= N_( + "E919: Directory not found in '%s': \"%s\"")); EXTERN char_u e_unsupportedoption[] INIT(= N_("E519: Option not supported")); diff --git a/src/nvim/main.c b/src/nvim/main.c index c7eafb4741..64b5de8663 100644 --- a/src/nvim/main.c +++ b/src/nvim/main.c @@ -1241,7 +1241,7 @@ static void set_window_layout(mparm_T *paramp) static void load_plugins(void) { if (p_lpl) { - source_runtime((char_u *)"plugin/**/*.vim", DIP_ALL); + source_runtime((char_u *)"plugin/**/*.vim", DIP_ALL); // NOLINT TIME_MSG("loading plugins"); ex_packloadall(NULL); diff --git a/src/nvim/option.c b/src/nvim/option.c index fad46ddf2d..81f57522b3 100644 --- a/src/nvim/option.c +++ b/src/nvim/option.c @@ -3187,7 +3187,8 @@ did_set_string_option ( for (p = q; *p != NUL; ++p) if (vim_strchr((char_u *)"_.,", *p) != NULL) break; - vim_snprintf((char *)fname, 200, "spell/%.*s.vim", (int)(p - q), q); + vim_snprintf((char *)fname, sizeof(fname), "spell/%.*s.vim", + (int)(p - q), q); source_runtime(fname, DIP_ALL); } } diff --git a/src/nvim/option_defs.h b/src/nvim/option_defs.h index 833da7907c..8d6f42e088 100644 --- a/src/nvim/option_defs.h +++ b/src/nvim/option_defs.h @@ -456,81 +456,81 @@ EXTERN int p_hid; // 'hidden' // Use P_HID to check if a buffer is to be hidden when it is no longer // visible in a window. # define P_HID(buf) (buf_hide(buf)) -EXTERN char_u *p_hl; /* 'highlight' */ -EXTERN int p_hls; /* 'hlsearch' */ -EXTERN long p_hi; /* 'history' */ -EXTERN int p_hkmap; /* 'hkmap' */ -EXTERN int p_hkmapp; /* 'hkmapp' */ -EXTERN int p_fkmap; /* 'fkmap' */ -EXTERN int p_altkeymap; /* 'altkeymap' */ -EXTERN int p_arshape; /* 'arabicshape' */ -EXTERN int p_icon; /* 'icon' */ -EXTERN char_u *p_iconstring; /* 'iconstring' */ -EXTERN int p_ic; /* 'ignorecase' */ -EXTERN int p_is; /* 'incsearch' */ -EXTERN int p_im; /* 'insertmode' */ -EXTERN char_u *p_isf; /* 'isfname' */ -EXTERN char_u *p_isi; /* 'isident' */ -EXTERN char_u *p_isp; /* 'isprint' */ -EXTERN int p_js; /* 'joinspaces' */ -EXTERN char_u *p_kp; /* 'keywordprg' */ -EXTERN char_u *p_km; /* 'keymodel' */ -EXTERN char_u *p_langmap; /* 'langmap'*/ -EXTERN int p_lnr; /* 'langnoremap'*/ -EXTERN char_u *p_lm; /* 'langmenu' */ -EXTERN char_u *p_lispwords; /* 'lispwords' */ -EXTERN long p_ls; /* 'laststatus' */ -EXTERN long p_stal; /* 'showtabline' */ -EXTERN char_u *p_lcs; /* 'listchars' */ - -EXTERN int p_lz; /* 'lazyredraw' */ -EXTERN int p_lpl; /* 'loadplugins' */ -EXTERN int p_magic; /* 'magic' */ -EXTERN char_u *p_mef; /* 'makeef' */ -EXTERN char_u *p_mp; /* 'makeprg' */ -EXTERN char_u *p_cc; /* 'colorcolumn' */ -EXTERN int p_cc_cols[256]; /* array for 'colorcolumn' columns */ -EXTERN long p_mat; /* 'matchtime' */ -EXTERN long p_mco; /* 'maxcombine' */ -EXTERN long p_mfd; /* 'maxfuncdepth' */ -EXTERN long p_mmd; /* 'maxmapdepth' */ -EXTERN long p_mm; /* 'maxmem' */ -EXTERN long p_mmp; /* 'maxmempattern' */ -EXTERN long p_mmt; /* 'maxmemtot' */ -EXTERN long p_mis; /* 'menuitems' */ -EXTERN char_u *p_msm; /* 'mkspellmem' */ -EXTERN long p_mls; /* 'modelines' */ -EXTERN char_u *p_mouse; /* 'mouse' */ -EXTERN char_u *p_mousem; /* 'mousemodel' */ -EXTERN long p_mouset; /* 'mousetime' */ -EXTERN int p_more; /* 'more' */ -EXTERN char_u *p_opfunc; /* 'operatorfunc' */ -EXTERN char_u *p_para; /* 'paragraphs' */ -EXTERN int p_paste; /* 'paste' */ -EXTERN char_u *p_pt; /* 'pastetoggle' */ -EXTERN char_u *p_pex; /* 'patchexpr' */ -EXTERN char_u *p_pm; /* 'patchmode' */ -EXTERN char_u *p_path; /* 'path' */ -EXTERN char_u *p_cdpath; /* 'cdpath' */ -EXTERN long p_rdt; /* 'redrawtime' */ -EXTERN int p_remap; /* 'remap' */ -EXTERN long p_re; /* 'regexpengine' */ -EXTERN long p_report; /* 'report' */ -EXTERN long p_pvh; /* 'previewheight' */ -EXTERN int p_ari; /* 'allowrevins' */ -EXTERN int p_ri; /* 'revins' */ -EXTERN int p_ru; /* 'ruler' */ -EXTERN char_u *p_ruf; /* 'rulerformat' */ -EXTERN char_u *p_pp; /* 'packpath' */ -EXTERN char_u *p_rtp; /* 'runtimepath' */ -EXTERN long p_sj; /* 'scrolljump' */ -EXTERN long p_so; /* 'scrolloff' */ -EXTERN char_u *p_sbo; /* 'scrollopt' */ -EXTERN char_u *p_sections; /* 'sections' */ -EXTERN int p_secure; /* 'secure' */ -EXTERN char_u *p_sel; /* 'selection' */ -EXTERN char_u *p_slm; /* 'selectmode' */ -EXTERN char_u *p_ssop; /* 'sessionoptions' */ +EXTERN char_u *p_hl; // 'highlight' +EXTERN int p_hls; // 'hlsearch' +EXTERN long p_hi; // 'history' +EXTERN int p_hkmap; // 'hkmap' +EXTERN int p_hkmapp; // 'hkmapp' +EXTERN int p_fkmap; // 'fkmap' +EXTERN int p_altkeymap; // 'altkeymap' +EXTERN int p_arshape; // 'arabicshape' +EXTERN int p_icon; // 'icon' +EXTERN char_u *p_iconstring; // 'iconstring' +EXTERN int p_ic; // 'ignorecase' +EXTERN int p_is; // 'incsearch' +EXTERN int p_im; // 'insertmode' +EXTERN char_u *p_isf; // 'isfname' +EXTERN char_u *p_isi; // 'isident' +EXTERN char_u *p_isp; // 'isprint' +EXTERN int p_js; // 'joinspaces' +EXTERN char_u *p_kp; // 'keywordprg' +EXTERN char_u *p_km; // 'keymodel' +EXTERN char_u *p_langmap; // 'langmap'*/ +EXTERN int p_lnr; // 'langnoremap'*/ +EXTERN char_u *p_lm; // 'langmenu' +EXTERN char_u *p_lispwords; // 'lispwords' +EXTERN long p_ls; // 'laststatus' +EXTERN long p_stal; // 'showtabline' +EXTERN char_u *p_lcs; // 'listchars' + +EXTERN int p_lz; // 'lazyredraw' +EXTERN int p_lpl; // 'loadplugins' +EXTERN int p_magic; // 'magic' +EXTERN char_u *p_mef; // 'makeef' +EXTERN char_u *p_mp; // 'makeprg' +EXTERN char_u *p_cc; // 'colorcolumn' +EXTERN int p_cc_cols[256]; // array for 'colorcolumn' columns +EXTERN long p_mat; // 'matchtime' +EXTERN long p_mco; // 'maxcombine' +EXTERN long p_mfd; // 'maxfuncdepth' +EXTERN long p_mmd; // 'maxmapdepth' +EXTERN long p_mm; // 'maxmem' +EXTERN long p_mmp; // 'maxmempattern' +EXTERN long p_mmt; // 'maxmemtot' +EXTERN long p_mis; // 'menuitems' +EXTERN char_u *p_msm; // 'mkspellmem' +EXTERN long p_mls; // 'modelines' +EXTERN char_u *p_mouse; // 'mouse' +EXTERN char_u *p_mousem; // 'mousemodel' +EXTERN long p_mouset; // 'mousetime' +EXTERN int p_more; // 'more' +EXTERN char_u *p_opfunc; // 'operatorfunc' +EXTERN char_u *p_para; // 'paragraphs' +EXTERN int p_paste; // 'paste' +EXTERN char_u *p_pt; // 'pastetoggle' +EXTERN char_u *p_pex; // 'patchexpr' +EXTERN char_u *p_pm; // 'patchmode' +EXTERN char_u *p_path; // 'path' +EXTERN char_u *p_cdpath; // 'cdpath' +EXTERN long p_rdt; // 'redrawtime' +EXTERN int p_remap; // 'remap' +EXTERN long p_re; // 'regexpengine' +EXTERN long p_report; // 'report' +EXTERN long p_pvh; // 'previewheight' +EXTERN int p_ari; // 'allowrevins' +EXTERN int p_ri; // 'revins' +EXTERN int p_ru; // 'ruler' +EXTERN char_u *p_ruf; // 'rulerformat' +EXTERN char_u *p_pp; // 'packpath' +EXTERN char_u *p_rtp; // 'runtimepath' +EXTERN long p_sj; // 'scrolljump' +EXTERN long p_so; // 'scrolloff' +EXTERN char_u *p_sbo; // 'scrollopt' +EXTERN char_u *p_sections; // 'sections' +EXTERN int p_secure; // 'secure' +EXTERN char_u *p_sel; // 'selection' +EXTERN char_u *p_slm; // 'selectmode' +EXTERN char_u *p_ssop; // 'sessionoptions' EXTERN unsigned ssop_flags; # ifdef IN_OPTION_C /* Also used for 'viewoptions'! */ diff --git a/src/nvim/spell.c b/src/nvim/spell.c index d688b3e7f4..610fb660e7 100644 --- a/src/nvim/spell.c +++ b/src/nvim/spell.c @@ -2317,15 +2317,13 @@ static void spell_load_lang(char_u *lang) for (round = 1; round <= 2; ++round) { // Find the first spell file for "lang" in 'runtimepath' and load it. vim_snprintf((char *)fname_enc, sizeof(fname_enc) - 5, - "spell/%s.%s.spl", - lang, spell_enc()); + "spell/%s.%s.spl", lang, spell_enc()); r = do_in_runtimepath(fname_enc, 0, spell_load_cb, &sl); if (r == FAIL && *sl.sl_lang != NUL) { // Try loading the ASCII version. vim_snprintf((char *)fname_enc, sizeof(fname_enc) - 5, - "spell/%s.ascii.spl", - lang); + "spell/%s.ascii.spl", lang); r = do_in_runtimepath(fname_enc, 0, spell_load_cb, &sl); if (r == FAIL && *sl.sl_lang != NUL && round == 1 diff --git a/src/nvim/syntax.c b/src/nvim/syntax.c index 8792e80bcf..27855184df 100644 --- a/src/nvim/syntax.c +++ b/src/nvim/syntax.c @@ -4207,9 +4207,10 @@ static void syn_cmd_include(exarg_T *eap, int syncing) current_syn_inc_tag = ++running_syn_inc_tag; prev_toplvl_grp = curwin->w_s->b_syn_topgrp; curwin->w_s->b_syn_topgrp = sgl_id; - if (source ? do_source(eap->arg, FALSE, DOSO_NONE) == FAIL - : source_runtime(eap->arg, DIP_ALL) == FAIL) + if (source ? do_source(eap->arg, false, DOSO_NONE) == FAIL + : source_runtime(eap->arg, DIP_ALL) == FAIL) { EMSG2(_(e_notopen), eap->arg); + } curwin->w_s->b_syn_topgrp = prev_toplvl_grp; current_syn_inc_tag = prev_syn_inc_tag; } @@ -6023,12 +6024,12 @@ init_highlight ( if (get_var_value((char_u *)"g:syntax_on") != NULL) { static int recursive = 0; - if (recursive >= 5) + if (recursive >= 5) { EMSG(_("E679: recursive loop loading syncolor.vim")); - else { - ++recursive; + } else { + recursive++; (void)source_runtime((char_u *)"syntax/syncolor.vim", DIP_ALL); - --recursive; + recursive--; } } } @@ -6041,22 +6042,24 @@ int load_colors(char_u *name) { char_u *buf; int retval = FAIL; - static int recursive = FALSE; + static int recursive = false; - /* When being called recursively, this is probably because setting - * 'background' caused the highlighting to be reloaded. This means it is - * working, thus we should return OK. */ - if (recursive) + // When being called recursively, this is probably because setting + // 'background' caused the highlighting to be reloaded. This means it is + // working, thus we should return OK. + if (recursive) { return OK; + } - recursive = TRUE; - buf = xmalloc(STRLEN(name) + 12); - sprintf((char *)buf, "colors/%s.vim", name); + recursive = true; + size_t buflen = STRLEN(name) + 12; + buf = xmalloc(buflen); + snprintf((char *)buf, buflen, "colors/%s.vim", name); retval = source_runtime(buf, DIP_START + DIP_OPT); xfree(buf); apply_autocmds(EVENT_COLORSCHEME, name, curbuf->b_fname, FALSE, curbuf); - recursive = FALSE; + recursive = false; ui_refresh(); return retval; -- cgit