From e902a172ef1a58e93eeae0919bddb3578a2142a2 Mon Sep 17 00:00:00 2001 From: James McCoy Date: Mon, 25 Apr 2016 23:07:51 -0400 Subject: [PATCH 01/34] 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 --- runtime/doc/options.txt | 9 ++- runtime/doc/repeat.txt | 76 ++++++++++++++++++++++++-- runtime/doc/starting.txt | 6 +- runtime/optwin.vim | 4 +- 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 +- 12 files changed, 206 insertions(+), 28 deletions(-) diff --git a/runtime/doc/options.txt b/runtime/doc/options.txt index 8c2b7786a7..99b9ca0eb1 100644 --- a/runtime/doc/options.txt +++ b/runtime/doc/options.txt @@ -1,4 +1,4 @@ -*options.txt* For Vim version 7.4. Last change: 2016 Feb 20 +*options.txt* For Vim version 7.4. Last change: 2016 Feb 21 VIM REFERENCE MANUAL by Bram Moolenaar @@ -4499,6 +4499,13 @@ A jump table for the options with a short description can be found at |Q_op|. This option cannot be set from a |modeline| or in the |sandbox|, for security reasons. + *'packpath'* *'pp'* +'packpath' 'pp' string (default: see 'runtimepath') + {not in Vi} + {not available without the |+packages| feature} + Directories used to find packages. See |packages|. + + *'paragraphs'* *'para'* 'paragraphs' 'para' string (default "IPLPPPQPP TPHPLIPpLpItpplpipbp") global diff --git a/runtime/doc/repeat.txt b/runtime/doc/repeat.txt index 5b382f95f2..c41d79214a 100644 --- a/runtime/doc/repeat.txt +++ b/runtime/doc/repeat.txt @@ -1,4 +1,4 @@ -*repeat.txt* For Vim version 7.4. Last change: 2016 Feb 12 +*repeat.txt* For Vim version 7.4. Last change: 2016 Feb 21 VIM REFERENCE MANUAL by Bram Moolenaar @@ -12,8 +12,9 @@ Chapter 26 of the user manual introduces repeating |usr_26.txt|. 2. Multiple repeats |multi-repeat| 3. Complex repeats |complex-repeat| 4. Using Vim scripts |using-scripts| -5. Debugging scripts |debug-scripts| -6. Profiling |profiling| +5. Using Vim packages |packages| +6. Debugging scripts |debug-scripts| +7. Profiling |profiling| ============================================================================== 1. Single repeats *single-repeat* @@ -203,6 +204,22 @@ For writing a Vim script, see chapter 41 of the user manual |usr_41.txt|. When 'verbose' is two or higher, there is a message about each searched file. + *:loadp* *:loadplugin* +:loadp[lugin] {name} Search for an optional plugin directory and source the + plugin files found. It is similar to: > + :runtime pack/*/opt/{name}/plugin/*.vim +< However, `:loadplugin` uses 'packpath' instead of + 'runtimepath'. And the directory found is added to + 'runtimepath'. + + Note that {name} is the directory name, not the name + of the .vim file. If the "{name}/plugin" directory + contains more than one file they are all sourced. + + Also see |load-plugin|. + + {not available without the |+packages| feature} + :scripte[ncoding] [encoding] *:scripte* *:scriptencoding* *E167* Specify the character encoding used in the script. The following lines will be converted from [encoding] @@ -373,7 +390,56 @@ Rationale: < Therefore the unusual leading backslash is used. ============================================================================== -5. Debugging scripts *debug-scripts* +5. Using Vim packages *packages* + +A Vim package is a directory that contains one or more plugins. The +advantages over normal plugins: +- A package can be downloaded as an archive and unpacked in its own directory. + That makes it easy to updated and/or remove. +- A package can be a git, mercurial, etc. respository. That makes it really + easy to update. +- A package can contain multiple plugins that depend on each other. +- A package can contain plugins that are automatically loaded on startup and + ones that are only loaded when needed with `:loadplugin`. + +Let's assume your Vim files are in the "~/.local/share/nvim/site" directory +and you want to add a package from a zip archive "/tmp/mypack.zip": + % mkdir -p ~/.local/share/nvim/site/pack/my + % cd ~/.local/share/nvim/site/pack/my + % unzip /tmp/mypack.zip + +The directory name "my" is arbitrary, you can pick anything you like. + +You would now have these files under ~/.local/share/nvim/site: + pack/my/README.txt + pack/my/ever/always/plugin/always.vim + pack/my/ever/always/syntax/always.vim + pack/my/opt/mydebug/plugin/debugger.vim + +When Vim starts up it scans all directories in 'packpath' for plugins under the +"ever" directory and loads them. When found that directory is added to +'runtimepath'. + +In the example Vim will find "my/ever/always/plugin/always.vim" and adds +"~/.local/share/nvim/site/pack/my/ever/always" to 'runtimepath'. + +If the "always" plugin kicks in and sets the 'filetype' to "always", Vim will +find the syntax/always.vim file, because its directory is in 'runtimepath'. + + *load-plugin* +To load an optional plugin from a pack use the `:loadplugin` command: > + :loadplugin mydebug +This could be done inside always.vim, if some conditions are met. +Or you could add this command to your |.vimrc|. + +It is perfectly normal for a package to only have files in the "opt" +directory. You then need to load each plugin when you want to use it. + +Loading packages will not happen if loading plugins is disabled, see +|load-plugins|. + +============================================================================== +6. Debugging scripts *debug-scripts* Besides the obvious messages that you can add to your scripts to find out what they are doing, Vim offers a debug mode. This allows you to step through a @@ -597,7 +663,7 @@ OBSCURE user, don't use typeahead for debug commands. ============================================================================== -6. Profiling *profile* *profiling* +7. Profiling *profile* *profiling* Profiling means that Vim measures the time that is spent on executing functions and/or scripts. The |+profile| feature is required for this. diff --git a/runtime/doc/starting.txt b/runtime/doc/starting.txt index ad2649b765..0508c52540 100644 --- a/runtime/doc/starting.txt +++ b/runtime/doc/starting.txt @@ -1,4 +1,4 @@ -*starting.txt* For Vim version 7.4. Last change: 2016 Feb 18 +*starting.txt* For Vim version 7.4. Last change: 2016 Feb 21 VIM REFERENCE MANUAL by Bram Moolenaar @@ -463,6 +463,10 @@ accordingly. Vim proceeds in this order: commands from the command line have not been executed yet. You can use "--cmd 'set noloadplugins'" |--cmd|. + Plugin packs are loaded. These are plugins, as above, but found in + 'packpath' directories. Every plugin directory found is added in + 'runtimepath'. See |packages|. + 7. Set 'shellpipe' and 'shellredir' The 'shellpipe' and 'shellredir' options are set according to the value of the 'shell' option, unless they have been set before. diff --git a/runtime/optwin.vim b/runtime/optwin.vim index 68444dde01..7e58c76ec4 100644 --- a/runtime/optwin.vim +++ b/runtime/optwin.vim @@ -1,7 +1,7 @@ " These commands create the option window. " " Maintainer: Bram Moolenaar -" Last Change: 2015 Jul 22 +" Last Change: 2016 Feb 21 " If there already is an option window, jump to that one. if bufwinnr("option-window") > 0 @@ -228,6 +228,8 @@ else endif call append("$", "runtimepath\tlist of directories used for runtime files and plugins") call OptionG("rtp", &rtp) +call append("$", "packpath\tlist of directories used for plugin packages") +call OptionG("pp", &pp) call append("$", "helpfile\tname of the main help file") call OptionG("hf", &hf) 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 From bca53fdca0cbcbfc28f3d016494b65925e8081bd Mon Sep 17 00:00:00 2001 From: James McCoy Date: Tue, 26 Apr 2016 00:18:32 -0400 Subject: [PATCH 02/34] 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(-) 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 From 562b17260fb1eafe5e49412997bc81de29d24ccb Mon Sep 17 00:00:00 2001 From: James McCoy Date: Tue, 26 Apr 2016 00:21:39 -0400 Subject: [PATCH 03/34] 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(-) 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 From 28300a1293b17072c1c5f053a55aae2268454246 Mon Sep 17 00:00:00 2001 From: James McCoy Date: Sun, 19 Jun 2016 23:59:39 -0400 Subject: [PATCH 04/34] vim-patch:f391327 Updated runtime files. https://github.com/vim/vim/commit/f391327adbbffb11180cf6038a92af1ed144e907 Ignore changes to * doc/todo.txt: Irrelevant for Neovim * doc/channel.txt: Channel docs * doc/tags, syntax/vim.vim: Generated at build time --- runtime/doc/eval.txt | 2 +- runtime/doc/help.txt | 2 +- runtime/doc/index.txt | 3 +- runtime/doc/options.txt | 3 +- runtime/doc/quickref.txt | 3 +- runtime/doc/repeat.txt | 4 +- runtime/doc/syntax.txt | 9 +++- runtime/ftplugin/eiffel.vim | 96 +++++++++++++++++++++++++++++++++++++ runtime/indent/sh.vim | 8 ++-- runtime/syntax/sh.vim | 4 +- runtime/syntax/tex.vim | 64 ++++++++++++------------- runtime/syntax/zsh.vim | 25 +++++++--- 12 files changed, 168 insertions(+), 55 deletions(-) create mode 100644 runtime/ftplugin/eiffel.vim diff --git a/runtime/doc/eval.txt b/runtime/doc/eval.txt index 3ebfe8da88..04aff0b3bf 100644 --- a/runtime/doc/eval.txt +++ b/runtime/doc/eval.txt @@ -1,4 +1,4 @@ -*eval.txt* For Vim version 7.4. Last change: 2016 Feb 19 +*eval.txt* For Vim version 7.4. Last change: 2016 Feb 23 VIM REFERENCE MANUAL by Bram Moolenaar diff --git a/runtime/doc/help.txt b/runtime/doc/help.txt index 342c475f9b..fd5b9a99ec 100644 --- a/runtime/doc/help.txt +++ b/runtime/doc/help.txt @@ -1,4 +1,4 @@ -*help.txt* For Vim version 7.4. Last change: 2016 Jan 10 +*help.txt* For Vim version 7.4. Last change: 2016 Feb 22 VIM - main help file k diff --git a/runtime/doc/index.txt b/runtime/doc/index.txt index e75031ccef..a974aa3d08 100644 --- a/runtime/doc/index.txt +++ b/runtime/doc/index.txt @@ -1,4 +1,4 @@ -*index.txt* For Vim version 7.4. Last change: 2016 Jan 19 +*index.txt* For Vim version 7.4. Last change: 2016 Feb 24 VIM REFERENCE MANUAL by Bram Moolenaar @@ -1317,6 +1317,7 @@ tag command action ~ |:lnfile| :lnf[ile] go to first location in next file |:lnoremap| :ln[oremap] like ":noremap!" but includes Lang-Arg mode |:loadkeymap| :loadk[eymap] load the following keymaps until EOF +|:loadplugin| :loadp[lugin] load a plugin from 'packpath' |:loadview| :lo[adview] load view for current window from a file |:lockmarks| :loc[kmarks] following command keeps marks where they are |:lockvar| :lockv[ar] lock variables diff --git a/runtime/doc/options.txt b/runtime/doc/options.txt index 99b9ca0eb1..887cff0707 100644 --- a/runtime/doc/options.txt +++ b/runtime/doc/options.txt @@ -1,4 +1,4 @@ -*options.txt* For Vim version 7.4. Last change: 2016 Feb 21 +*options.txt* For Vim version 7.4. Last change: 2016 Feb 24 VIM REFERENCE MANUAL by Bram Moolenaar @@ -4502,7 +4502,6 @@ A jump table for the options with a short description can be found at |Q_op|. *'packpath'* *'pp'* 'packpath' 'pp' string (default: see 'runtimepath') {not in Vi} - {not available without the |+packages| feature} Directories used to find packages. See |packages|. diff --git a/runtime/doc/quickref.txt b/runtime/doc/quickref.txt index 8e40628e25..b6ab33dd16 100644 --- a/runtime/doc/quickref.txt +++ b/runtime/doc/quickref.txt @@ -1,4 +1,4 @@ -*quickref.txt* For Vim version 7.4. Last change: 2015 Nov 10 +*quickref.txt* For Vim version 7.4. Last change: 2016 Feb 24 VIM REFERENCE MANUAL by Bram Moolenaar @@ -794,6 +794,7 @@ Short explanation of each option: *option-list* 'omnifunc' 'ofu' function for filetype-specific completion 'opendevice' 'odev' allow reading/writing devices on MS-Windows 'operatorfunc' 'opfunc' function to be called for |g@| operator +'packpath' 'pp' list of directories used for packages 'paragraphs' 'para' nroff macros that separate paragraphs 'paste' allow pasting text 'pastetoggle' 'pt' key code that causes 'paste' to toggle diff --git a/runtime/doc/repeat.txt b/runtime/doc/repeat.txt index c41d79214a..4db3580efa 100644 --- a/runtime/doc/repeat.txt +++ b/runtime/doc/repeat.txt @@ -1,4 +1,4 @@ -*repeat.txt* For Vim version 7.4. Last change: 2016 Feb 21 +*repeat.txt* For Vim version 7.4. Last change: 2016 Feb 24 VIM REFERENCE MANUAL by Bram Moolenaar @@ -218,8 +218,6 @@ For writing a Vim script, see chapter 41 of the user manual |usr_41.txt|. Also see |load-plugin|. - {not available without the |+packages| feature} - :scripte[ncoding] [encoding] *:scripte* *:scriptencoding* *E167* Specify the character encoding used in the script. The following lines will be converted from [encoding] diff --git a/runtime/doc/syntax.txt b/runtime/doc/syntax.txt index 4e4ea39e7c..f7e9ece3d8 100644 --- a/runtime/doc/syntax.txt +++ b/runtime/doc/syntax.txt @@ -1,4 +1,4 @@ -*syntax.txt* For Vim version 7.4. Last change: 2016 Jan 28 +*syntax.txt* For Vim version 7.4. Last change: 2016 Feb 24 VIM REFERENCE MANUAL by Bram Moolenaar @@ -3345,6 +3345,13 @@ Note that schemas are not actually limited to plain scalars, but this is the only difference between schemas defined in YAML specification and the only difference defined in the syntax file. + +ZSH *zsh.vim* *ft-zsh-syntax* + +The syntax script for zsh allows for syntax-based folding: > + + :let g:zsh_fold_enable = 1 + ============================================================================== 5. Defining a syntax *:syn-define* *E410* diff --git a/runtime/ftplugin/eiffel.vim b/runtime/ftplugin/eiffel.vim new file mode 100644 index 0000000000..216fdde162 --- /dev/null +++ b/runtime/ftplugin/eiffel.vim @@ -0,0 +1,96 @@ +" Vim filetype plugin +" Language: Eiffel +" Maintainer: Doug Kearns +" Last Change: 2010 Aug 29 + +if (exists("b:did_ftplugin")) + finish +endif +let b:did_ftplugin = 1 + +let s:cpo_save = &cpo +set cpo&vim + +setlocal comments=:-- +setlocal commentstring=--\ %s + +setlocal formatoptions-=t formatoptions+=croql + +if (has("gui_win32") || has("gui_gtk")) && !exists("b:browsefilter") + let b:browsefilter = "Eiffel Source Files (*.e)\t*.e\n" . + \ "Eiffel Control Files (*.ecf, *.ace, *.xace)\t*.ecf;*.ace;*.xace\n" . + \ "All Files (*.*)\t*.*\n" +endif + +if exists("loaded_matchit") && !exists("b:match_words") + let b:match_ignorecase = 0 + " Silly \%^ trick to match note at head of pair and in middle prevents + " 'g%' wrapping from 'note' to 'end' + let b:match_words = '\%^:' . + \ '\<\%(^note\|indexing\|class\|^obsolete\|inherit\|insert\|^create\|convert\|feature\|^invariant\)\>:' . + \ '^end\>,' . + \ '\<\%(do\|deferred\|external\|once\%(\s\+"\)\@!\|check\|debug\|if\|inspect\|from\|across\)\>:' . + \ '\%(\%(^\s\+\)\@<=\%(then\|until\|loop\)\|\%(then\|until\|loop\)\s\+[^ -]\|' . + \ '\<\%(ensure\%(\s\+then\)\=\|rescue\|_then\|elseif\|else\|when\|\s\@<=invariant\|_until\|_loop\|variant\|_as\|alias\)\>\):' . + \ '\s\@<=end\>' + let b:match_skip = 's:\' + noremap [% + noremap ]% + vnoremap a% +endif + +let b:undo_ftplugin = "setl fo< com< cms<" . + \ "| unlet! b:browsefilter b:match_ignorecase b:match_words b:match_skip" + +if !exists("g:no_plugin_maps") && !exists("g:no_eiffel_maps") + function! s:DoMotion(pattern, count, flags) abort + normal! m' + for i in range(a:count) + call search(a:pattern, a:flags) + endfor + endfunction + + let sections = '^\%(note\|indexing\|' . + \ '\%(\%(deferred\|expanded\|external\|frozen\)\s\+\)*class\|' . + \ 'obsolete\|inherit\|insert\|create\|convert\|feature\|' . + \ 'invariant\|end\)\>' + + nnoremap ]] :call DoMotion(sections, v:count1, 'W') + xnoremap ]] :exe "normal! gv"call DoMotion(sections, v:count1, 'W') + nnoremap [[ :call DoMotion(sections, v:count1, 'Wb') + xnoremap [[ :exe "normal! gv"call DoMotion(sections, v:count1, 'Wb') + + function! s:DoFeatureMotion(count, flags) + let view = winsaveview() + call cursor(1, 1) + let [features_start, _] = searchpos('^feature\>') + call search('^\s\+\a') " find the first feature + let spaces = indent(line('.')) + let [features_end, _] = searchpos('^\%(invariant\|note\|end\)\>') + call winrestview(view) + call s:DoMotion('\%>' . features_start . 'l\%<' . features_end . 'l^\s*\%' . (spaces + 1) . 'v\zs\a', a:count, a:flags) + endfunction + + nnoremap ]m :call DoFeatureMotion(v:count1, 'W') + xnoremap ]m :exe "normal! gv"call DoFeatureMotion(v:count1, 'W') + nnoremap [m :call DoFeatureMotion(v:count1, 'Wb') + xnoremap [m :exe "normal! gv"call DoFeatureMotion(v:count1, 'Wb') + + let comment_block_start = '^\%(\s\+--.*\n\)\@ ]- :call DoMotion(comment_block_start, 1, 'W') + xnoremap ]- :exe "normal! gv"call DoMotion(comment_block_start, 1, 'W') + nnoremap [- :call DoMotion(comment_block_end, 1, 'Wb') + xnoremap [- :exe "normal! gv"call DoMotion(comment_block_end, 1, 'Wb') + + let b:undo_ftplugin = b:undo_ftplugin . + \ "| silent! execute 'unmap [[' | silent! execute 'unmap ]]'" . + \ "| silent! execute 'unmap [m' | silent! execute 'unmap ]m'" . + \ "| silent! execute 'unmap [-' | silent! execute 'unmap ]-'" +endif + +let &cpo = s:cpo_save +unlet s:cpo_save + +" vim: nowrap sw=2 sts=2 ts=8 diff --git a/runtime/indent/sh.vim b/runtime/indent/sh.vim index 2d603b0afa..d05bb3770f 100644 --- a/runtime/indent/sh.vim +++ b/runtime/indent/sh.vim @@ -3,7 +3,7 @@ " Maintainer: Christian Brabandt " Previous Maintainer: Peter Aronoff " Original Author: Nikolai Weibull -" Latest Revision: 2016-01-15 +" Latest Revision: 2016-02-15 " License: Vim (see :h license) " Repository: https://github.com/chrisbra/vim-sh-indent @@ -12,14 +12,14 @@ if exists("b:did_indent") endif let b:did_indent = 1 -let b:undo_indent = 'setlocal indentexpr< indentkeys< smartindent<' - setlocal indentexpr=GetShIndent() setlocal indentkeys+=0=then,0=do,0=else,0=elif,0=fi,0=esac,0=done,0=end,),0=;;,0=;& setlocal indentkeys+=0=fin,0=fil,0=fip,0=fir,0=fix setlocal indentkeys-=:,0# setlocal nosmartindent +let b:undo_indent = 'setlocal indentexpr< indentkeys< smartindent<' + if exists("*GetShIndent") finish endif @@ -67,7 +67,7 @@ function! GetShIndent() if !s:is_case_ended(line) let ind += s:indent_value('case-statements') endif - elseif line =~ '^\s*\<\k\+\>\s*()\s*{' || line =~ '^\s*{' + elseif line =~ '^\s*\<\k\+\>\s*()\s*{' || line =~ '^\s*{' || line =~ '^\s*function\s*\w\S\+\s*\%(()\)\?\s*{' if line !~ '}\s*\%(#.*\)\=$' let ind += s:indent_value('default') endif diff --git a/runtime/syntax/sh.vim b/runtime/syntax/sh.vim index 15a00eb516..3fc236f033 100644 --- a/runtime/syntax/sh.vim +++ b/runtime/syntax/sh.vim @@ -2,8 +2,8 @@ " Language: shell (sh) Korn shell (ksh) bash (sh) " Maintainer: Charles E. Campbell " Previous Maintainer: Lennart Schultz -" Last Change: Feb 16, 2016 -" Version: 144 +" Last Change: Feb 18, 2016 +" Version: 145 " URL: http://www.drchip.org/astronaut/vim/index.html#SYNTAX_SH " For options and settings, please use: :help ft-sh-syntax " This file includes many ideas from Eric Brunet (eric.brunet@ens.fr) diff --git a/runtime/syntax/tex.vim b/runtime/syntax/tex.vim index 40013b5b99..cef28d65ed 100644 --- a/runtime/syntax/tex.vim +++ b/runtime/syntax/tex.vim @@ -1,8 +1,8 @@ " Vim syntax file " Language: TeX " Maintainer: Charles E. Campbell -" Last Change: Jan 20, 2016 -" Version: 91 +" Last Change: Feb 18, 2016 +" Version: 92 " URL: http://www.drchip.org/astronaut/vim/index.html#SYNTAX_TEX " " Notes: {{{1 @@ -200,7 +200,7 @@ if !exists("g:tex_no_math") endif " Try to flag {} and () mismatches: {{{1 -if s:tex_fast =~ 'm' +if s:tex_fast =~# 'm' if !s:tex_no_error syn region texMatcher matchgroup=Delimiter start="{" skip="\\\\\|\\[{}]" end="}" transparent contains=@texMatchGroup,texError syn region texMatcher matchgroup=Delimiter start="\[" end="]" transparent contains=@texMatchGroup,texError,@NoSpell @@ -217,7 +217,7 @@ endif if !s:tex_no_error syn match texError "[}\])]" endif -if s:tex_fast =~ 'M' +if s:tex_fast =~# 'M' if !exists("g:tex_no_math") if !s:tex_no_error syn match texMathError "}" contained @@ -260,14 +260,14 @@ syn match texLigature "\\\([ijolL]\|ae\|oe\|ss\|AA\|AE\|OE\)$" " \begin{}/\end{} section markers: {{{1 syn match texBeginEnd "\\begin\>\|\\end\>" nextgroup=texBeginEndName -if s:tex_fast =~ 'm' +if s:tex_fast =~# 'm' syn region texBeginEndName matchgroup=Delimiter start="{" end="}" contained nextgroup=texBeginEndModifier contains=texComment syn region texBeginEndModifier matchgroup=Delimiter start="\[" end="]" contained contains=texComment,@NoSpell endif " \documentclass, \documentstyle, \usepackage: {{{1 syn match texDocType "\\documentclass\>\|\\documentstyle\>\|\\usepackage\>" nextgroup=texBeginEndName,texDocTypeArgs -if s:tex_fast =~ 'm' +if s:tex_fast =~# 'm' syn region texDocTypeArgs matchgroup=Delimiter start="\[" end="]" contained nextgroup=texBeginEndName contains=texComment,@NoSpell endif @@ -281,7 +281,7 @@ syn match texInput "\\input\s\+[a-zA-Z/.0-9_^]\+"hs=s+7 contains=texStatemen syn match texInputFile "\\include\(graphics\|list\)\=\(\[.\{-}\]\)\=\s*{.\{-}}" contains=texStatement,texInputCurlies,texInputFileOpt syn match texInputFile "\\\(epsfig\|input\|usepackage\)\s*\(\[.*\]\)\={.\{-}}" contains=texStatement,texInputCurlies,texInputFileOpt syn match texInputCurlies "[{}]" contained -if s:tex_fast =~ 'm' +if s:tex_fast =~# 'm' syn region texInputFileOpt matchgroup=Delimiter start="\[" end="\]" contained contains=texComment endif @@ -349,7 +349,7 @@ syn match texSpaceCode "\\\(math\|cat\|del\|lc\|sf\|uc\)code`"me=e-1 nextgroup= syn match texSpaceCodeChar "`\\\=.\(\^.\)\==\(\d\|\"\x\{1,6}\|`.\)" contained " Sections, subsections, etc: {{{1 -if s:tex_fast =~ 'p' +if s:tex_fast =~# 'p' if !s:tex_nospell TexFold syn region texDocZone matchgroup=texSection start='\\begin\s*{\s*document\s*}' end='\\end\s*{\s*document\s*}' contains=@texFoldGroup,@texDocGroup,@Spell TexFold syn region texPartZone matchgroup=texSection start='\\part\>' end='\ze\s*\\\%(part\>\|end\s*{\s*document\s*}\)' contains=@texFoldGroup,@texPartGroup,@Spell @@ -376,8 +376,8 @@ if s:tex_fast =~ 'p' endif " particular support for bold and italic {{{1 -if s:tex_fast =~ 'b' - if s:tex_conceal =~ 'b' +if s:tex_fast =~# 'b' + if s:tex_conceal =~# 'b' if !exists("g:tex_nospell") || !g:tex_nospell syn region texBoldStyle matchgroup=texTypeStyle start="\\textbf\s*{" matchgroup=texTypeStyle end="}" concealends contains=@texBoldGroup,@Spell syn region texBoldItalStyle matchgroup=texTypeStyle start="\\textit\s*{" matchgroup=texTypeStyle end="}" concealends contains=@texItalGroup,@Spell @@ -414,7 +414,7 @@ if !exists("g:tex_no_math") let foldcmd= "" endif exe "syn cluster texMathZones add=".grpname - if s:tex_fast =~ 'M' + if s:tex_fast =~# 'M' exe 'syn region '.grpname.' start='."'".'\\begin\s*{\s*'.a:mathzone.'\s*}'."'".' end='."'".'\\end\s*{\s*'.a:mathzone.'\s*}'."'".' keepend contains=@texMathZoneGroup'.foldcmd exe 'syn sync match '.syncname.' grouphere '.grpname.' "\\begin\s*{\s*'.a:mathzone.'\*\s*}"' exe 'syn sync match '.syncname.' grouphere '.grpname.' "\\begin\s*{\s*'.a:mathzone.'\*\s*}"' @@ -424,7 +424,7 @@ if !exists("g:tex_no_math") let grpname = "texMathZone".a:sfx.'S' let syncname = "texSyncMathZone".a:sfx.'S' exe "syn cluster texMathZones add=".grpname - if s:tex_fast =~ 'M' + if s:tex_fast =~# 'M' exe 'syn region '.grpname.' start='."'".'\\begin\s*{\s*'.a:mathzone.'\*\s*}'."'".' end='."'".'\\end\s*{\s*'.a:mathzone.'\*\s*}'."'".' keepend contains=@texMathZoneGroup'.foldcmd exe 'syn sync match '.syncname.' grouphere '.grpname.' "\\begin\s*{\s*'.a:mathzone.'\*\s*}"' exe 'syn sync match '.syncname.' grouphere '.grpname.' "\\begin\s*{\s*'.a:mathzone.'\*\s*}"' @@ -448,8 +448,8 @@ if !exists("g:tex_no_math") call TexNewMathZone("L","xxalignat",0) " Inline Math Zones: {{{2 - if s:tex_fast =~ 'M' - if has("conceal") && &enc == 'utf-8' && s:tex_conceal =~ 'd' + if s:tex_fast =~# 'M' + if has("conceal") && &enc == 'utf-8' && s:tex_conceal =~# 'd' syn region texMathZoneV matchgroup=Delimiter start="\\(" matchgroup=Delimiter end="\\)\|%stopzone\>" keepend concealends contains=@texMathZoneGroup syn region texMathZoneW matchgroup=Delimiter start="\\\[" matchgroup=Delimiter end="\\]\|%stopzone\>" keepend concealends contains=@texMathZoneGroup syn region texMathZoneX matchgroup=Delimiter start="\$" skip="\\\\\|\\\$" matchgroup=Delimiter end="\$" end="%stopzone\>" concealends contains=@texMathZoneGroup @@ -466,7 +466,7 @@ if !exists("g:tex_no_math") syn match texMathOper "[_^=]" contained " Text Inside Math Zones: {{{2 - if s:tex_fast =~ 'M' + if s:tex_fast =~# 'M' if !exists("g:tex_nospell") || !g:tex_nospell syn region texMathText matchgroup=texStatement start='\\\(\(inter\)\=text\|mbox\)\s*{' end='}' contains=@texFoldGroup,@Spell else @@ -476,7 +476,7 @@ if !exists("g:tex_no_math") " \left..something.. and \right..something.. support: {{{2 syn match texMathDelimBad contained "\S" - if has("conceal") && &enc == 'utf-8' && s:tex_conceal =~ 'm' + if has("conceal") && &enc == 'utf-8' && s:tex_conceal =~# 'm' syn match texMathDelim contained "\\left\\{\>" skipwhite nextgroup=texMathDelimSet1,texMathDelimSet2,texMathDelimBad contains=texMathSymbol cchar={ syn match texMathDelim contained "\\right\\}\>" skipwhite nextgroup=texMathDelimSet1,texMathDelimSet2,texMathDelimBad contains=texMathSymbol cchar=} let s:texMathDelimList=[ @@ -568,13 +568,13 @@ else " allows syntax-folding of 2 or more contiguous comment lines " single-line comments are not folded syn match texComment "%.*$" contains=@texCommentGroup - if s:tex_fast =~ 'c' + if s:tex_fast =~# 'c' TexFold syn region texComment start="^\zs\s*%.*\_s*%" skip="^\s*%" end='^\ze\s*[^%]' contains=@texCommentGroup TexFold syn region texNoSpell contained matchgroup=texComment start="%\s*nospell\s*{" end="%\s*nospell\s*}" contains=@texFoldGroup,@NoSpell endif else syn match texComment "%.*$" contains=@texCommentGroup - if s:tex_fast =~ 'c' + if s:tex_fast =~# 'c' syn region texNoSpell contained matchgroup=texComment start="%\s*nospell\s*{" end="%\s*nospell\s*}" contains=@texFoldGroup,@NoSpell endif endif @@ -583,7 +583,7 @@ endif " Separate lines used for verb` and verb# so that the end conditions {{{1 " will appropriately terminate. " If g:tex_verbspell exists, then verbatim texZones will permit spellchecking there. -if s:tex_fast =~ 'v' +if s:tex_fast =~# 'v' if exists("g:tex_verbspell") && g:tex_verbspell syn region texZone start="\\begin{[vV]erbatim}" end="\\end{[vV]erbatim}\|%stopzone\>" contains=@Spell " listings package: @@ -614,7 +614,7 @@ if s:tex_fast =~ 'v' endif " Tex Reference Zones: {{{1 -if s:tex_fast =~ 'r' +if s:tex_fast =~# 'r' syn region texZone matchgroup=texStatement start="@samp{" end="}\|%stopzone\>" contains=@texRefGroup syn region texRefZone matchgroup=texStatement start="\\nocite{" end="}\|%stopzone\>" contains=@texRefGroup syn region texRefZone matchgroup=texStatement start="\\bibliography{" end="}\|%stopzone\>" contains=@texRefGroup @@ -628,13 +628,13 @@ syn match texRefZone '\\cite\%([tp]\*\=\)\=' nextgroup=texRefOption,texCite " Handle newcommand, newenvironment : {{{1 syn match texNewCmd "\\newcommand\>" nextgroup=texCmdName skipwhite skipnl -if s:tex_fast =~ 'V' +if s:tex_fast =~# 'V' syn region texCmdName contained matchgroup=Delimiter start="{"rs=s+1 end="}" nextgroup=texCmdArgs,texCmdBody skipwhite skipnl syn region texCmdArgs contained matchgroup=Delimiter start="\["rs=s+1 end="]" nextgroup=texCmdBody skipwhite skipnl syn region texCmdBody contained matchgroup=Delimiter start="{"rs=s+1 skip="\\\\\|\\[{}]" matchgroup=Delimiter end="}" contains=@texCmdGroup endif syn match texNewEnv "\\newenvironment\>" nextgroup=texEnvName skipwhite skipnl -if s:tex_fast =~ 'V' +if s:tex_fast =~# 'V' syn region texEnvName contained matchgroup=Delimiter start="{"rs=s+1 end="}" nextgroup=texEnvBgn skipwhite skipnl syn region texEnvBgn contained matchgroup=Delimiter start="{"rs=s+1 end="}" nextgroup=texEnvEnd skipwhite skipnl contains=@texEnvGroup syn region texEnvEnd contained matchgroup=Delimiter start="{"rs=s+1 end="}" skipwhite skipnl contains=@texEnvGroup @@ -660,11 +660,11 @@ syn match texString "\(``\|''\|,,\)" " makeatletter -- makeatother sections if !s:tex_no_error - if s:tex_fast =~ 'S' + if s:tex_fast =~# 'S' syn region texStyle matchgroup=texStatement start='\\makeatletter' end='\\makeatother' contains=@texStyleGroup contained endif syn match texStyleStatement "\\[a-zA-Z@]\+" contained - if s:tex_fast =~ 'S' + if s:tex_fast =~# 'S' syn region texStyleMatcher matchgroup=Delimiter start="{" skip="\\\\\|\\[{}]" end="}" contains=@texStyleGroup,texError contained syn region texStyleMatcher matchgroup=Delimiter start="\[" end="]" contains=@texStyleGroup,texError contained endif @@ -675,7 +675,7 @@ if has("conceal") && &enc == 'utf-8' " Math Symbols {{{2 " (many of these symbols were contributed by Björn Winckler) - if s:tex_conceal =~ 'm' + if s:tex_conceal =~# 'm' let s:texMathList=[ \ ['|' , '‖'], \ ['aleph' , 'ℵ'], @@ -956,7 +956,7 @@ if has("conceal") && &enc == 'utf-8' " \ ['uminus' , 'X'] " \ ['uplus' , 'X'] for texmath in s:texMathList - if texmath[0] =~ '\w$' + if texmath[0] =~# '\w$' exe "syn match texMathSymbol '\\\\".texmath[0]."\\>' contained conceal cchar=".texmath[1] else exe "syn match texMathSymbol '\\\\".texmath[0]."' contained conceal cchar=".texmath[1] @@ -995,7 +995,7 @@ if has("conceal") && &enc == 'utf-8' endif " Greek {{{2 - if s:tex_conceal =~ 'g' + if s:tex_conceal =~# 'g' fun! s:Greek(group,pat,cchar) exe 'syn match '.a:group." '".a:pat."' contained conceal cchar=".a:cchar endfun @@ -1042,14 +1042,14 @@ if has("conceal") && &enc == 'utf-8' endif " Superscripts/Subscripts {{{2 - if s:tex_conceal =~ 's' - if s:tex_fast =~ 's' + if s:tex_conceal =~# 's' + if s:tex_fast =~# 's' syn region texSuperscript matchgroup=Delimiter start='\^{' skip="\\\\\|\\[{}]" end='}' contained concealends contains=texSpecialChar,texSuperscripts,texStatement,texSubscript,texSuperscript,texMathMatcher syn region texSubscript matchgroup=Delimiter start='_{' skip="\\\\\|\\[{}]" end='}' contained concealends contains=texSpecialChar,texSubscripts,texStatement,texSubscript,texSuperscript,texMathMatcher endif " s:SuperSub: fun! s:SuperSub(group,leader,pat,cchar) - if a:pat =~ '^\\' || (a:leader == '\^' && a:pat =~ g:tex_superscripts) || (a:leader == '_' && a:pat =~ g:tex_subscripts) + if a:pat =~# '^\\' || (a:leader == '\^' && a:pat =~# g:tex_superscripts) || (a:leader == '_' && a:pat =~# g:tex_subscripts) " call Decho("SuperSub: group<".a:group."> leader<".a:leader."> pat<".a:pat."> cchar<".a:cchar.">") exe 'syn match '.a:group." '".a:leader.a:pat."' contained conceal cchar=".a:cchar exe 'syn match '.a:group."s '".a:pat ."' contained conceal cchar=".a:cchar.' nextgroup='.a:group.'s' @@ -1154,7 +1154,7 @@ if has("conceal") && &enc == 'utf-8' endif " Accented characters: {{{2 - if s:tex_conceal =~ 'a' + if s:tex_conceal =~# 'a' if b:tex_stylish syn match texAccent "\\[bcdvuH][^a-zA-Z@]"me=e-1 syn match texLigature "\\\([ijolL]\|ae\|oe\|ss\|AA\|AE\|OE\)[^a-zA-Z@]"me=e-1 @@ -1169,7 +1169,7 @@ if has("conceal") && &enc == 'utf-8' let i= i + 1 continue endif - if accent =~ '\a' + if accent =~# '\a' exe "syn match texAccent '".'\\'.accent.'\(\s*{'.a:chr.'}\|\s\+'.a:chr.'\)'."' conceal cchar=".a:{i} else exe "syn match texAccent '".'\\'.accent.'\s*\({'.a:chr.'}\|'.a:chr.'\)'."' conceal cchar=".a:{i} diff --git a/runtime/syntax/zsh.vim b/runtime/syntax/zsh.vim index 25d4cd4936..0d385a35d0 100644 --- a/runtime/syntax/zsh.vim +++ b/runtime/syntax/zsh.vim @@ -2,7 +2,7 @@ " Language: Zsh shell script " Maintainer: Christian Brabandt " Previous Maintainer: Nikolai Weibull -" Latest Revision: 2016-01-25 +" Latest Revision: 2016-02-15 " License: Vim (see :h license) " Repository: https://github.com/chrisbra/vim-zsh @@ -13,20 +13,29 @@ endif let s:cpo_save = &cpo set cpo&vim -setlocal iskeyword+=- -setlocal foldmethod=syntax +if v:version > 704 || (v:version == 704 && has("patch1142")) + syn iskeyword @,48-57,_,192-255,#,- +else + setlocal iskeyword+=- +endif +if get(g:, 'zsh_fold_enable', 0) + setlocal foldmethod=syntax +endif syn keyword zshTodo contained TODO FIXME XXX NOTE syn region zshComment oneline start='\%(^\|\s*\)#' end='$' - \ contains=zshTodo,@Spell + \ contains=zshTodo,@Spell fold + +syn region zshComment start='^\s*#' end='^\%(\s*#\)\@!' + \ contains=zshTodo,@Spell fold syn match zshPreProc '^\%1l#\%(!\|compdef\|autoload\).*$' syn match zshQuoted '\\.' syn region zshString matchgroup=zshStringDelimiter start=+"+ end=+"+ - \ contains=zshQuoted,@zshDerefs,@zshSubst -syn region zshString matchgroup=zshStringDelimiter start=+'+ end=+'+ + \ contains=zshQuoted,@zshDerefs,@zshSubst fold +syn region zshString matchgroup=zshStringDelimiter start=+'+ end=+'+ fold " XXX: This should probably be more precise, but Zsh seems a bit confused about it itself syn region zshPOSIXString matchgroup=zshStringDelimiter start=+\$'+ \ end=+'+ contains=zshQuoted @@ -46,7 +55,7 @@ syn keyword zshException always syn keyword zshKeyword function nextgroup=zshKSHFunction skipwhite -syn match zshKSHFunction contained '\k\+' +syn match zshKSHFunction contained '\w\S\+' syn match zshFunction '^\s*\k\+\ze\s*()' syn match zshOperator '||\|&&\|;\|&!\=' @@ -317,6 +326,8 @@ syn region zshMathSubst matchgroup=zshSubstDelim transparent \ @zshDerefs,zshString keepend fold syn region zshBrackets contained transparent start='{' skip='\\}' \ end='}' fold +syn region zshBrackets transparent start='{' skip='\\}' + \ end='}' contains=TOP fold syn region zshSubst matchgroup=zshSubstDelim start='\${' skip='\\}' \ end='}' contains=@zshSubst,zshBrackets,zshQuoted,zshString fold syn region zshOldSubst matchgroup=zshSubstDelim start=+`+ skip=+\\`+ From 8f2505e5942d5e6bdc5250b002b402b10709deb0 Mon Sep 17 00:00:00 2001 From: James McCoy Date: Mon, 20 Jun 2016 00:10:08 -0400 Subject: [PATCH 05/34] vim-patch:dae8d21 Updated runtime files https://github.com/vim/vim/commit/dae8d21dd291df6a6679a00be64e18bca0156576 Ignore changes to * doc/eval.txt: Channel related docs * doc/help.txt, doc/index.txt, doc/os_390.txt: Removal of obsolete features, which already happened in Neovim * doc/tags: Generated at build time * doc/todo.txt, doc/version5.txt: Irrelevant to Neovim --- runtime/doc/help.txt | 2 +- runtime/doc/index.txt | 2 +- runtime/doc/message.txt | 2 +- runtime/doc/repeat.txt | 8 ++++++-- runtime/doc/starting.txt | 4 ++-- runtime/doc/syntax.txt | 4 ++-- runtime/doc/usr_29.txt | 2 +- runtime/doc/various.txt | 2 +- runtime/syntax/fortran.vim | 15 ++++++++------- 9 files changed, 23 insertions(+), 18 deletions(-) diff --git a/runtime/doc/help.txt b/runtime/doc/help.txt index fd5b9a99ec..305eaea924 100644 --- a/runtime/doc/help.txt +++ b/runtime/doc/help.txt @@ -1,4 +1,4 @@ -*help.txt* For Vim version 7.4. Last change: 2016 Feb 22 +*help.txt* For Vim version 7.4. Last change: 2016 Feb 27 VIM - main help file k diff --git a/runtime/doc/index.txt b/runtime/doc/index.txt index a974aa3d08..9efd107226 100644 --- a/runtime/doc/index.txt +++ b/runtime/doc/index.txt @@ -1,4 +1,4 @@ -*index.txt* For Vim version 7.4. Last change: 2016 Feb 24 +*index.txt* For Vim version 7.4. Last change: 2016 Feb 27 VIM REFERENCE MANUAL by Bram Moolenaar diff --git a/runtime/doc/message.txt b/runtime/doc/message.txt index 114bb61d99..7ceddeb674 100644 --- a/runtime/doc/message.txt +++ b/runtime/doc/message.txt @@ -1,4 +1,4 @@ -*message.txt* For Vim version 7.4. Last change: 2013 Feb 23 +*message.txt* For Vim version 7.4. Last change: 2016 Feb 27 VIM REFERENCE MANUAL by Bram Moolenaar diff --git a/runtime/doc/repeat.txt b/runtime/doc/repeat.txt index 4db3580efa..527b84c992 100644 --- a/runtime/doc/repeat.txt +++ b/runtime/doc/repeat.txt @@ -1,4 +1,4 @@ -*repeat.txt* For Vim version 7.4. Last change: 2016 Feb 24 +*repeat.txt* For Vim version 7.4. Last change: 2016 Feb 26 VIM REFERENCE MANUAL by Bram Moolenaar @@ -212,6 +212,10 @@ For writing a Vim script, see chapter 41 of the user manual |usr_41.txt|. 'runtimepath'. And the directory found is added to 'runtimepath'. + If you have a directory under 'packpath' that doesn't + actually have a plugin file, just create an empty one. + This will still add the directory to 'runtimepath'. + Note that {name} is the directory name, not the name of the .vim file. If the "{name}/plugin" directory contains more than one file they are all sourced. @@ -548,7 +552,7 @@ Additionally, these commands can be used: About the additional commands in debug mode: - There is no command-line completion for them, you get the completion for the normal Ex commands only. -- You can shorten them, up to a single character, unless more then one command +- You can shorten them, up to a single character, unless more than one command starts with the same letter. "f" stands for "finish", use "fr" for "frame". - Hitting will repeat the previous one. When doing another command, this is reset (because it's not clear what you want to repeat). diff --git a/runtime/doc/starting.txt b/runtime/doc/starting.txt index 0508c52540..5db65cfaad 100644 --- a/runtime/doc/starting.txt +++ b/runtime/doc/starting.txt @@ -1,4 +1,4 @@ -*starting.txt* For Vim version 7.4. Last change: 2016 Feb 21 +*starting.txt* For Vim version 7.4. Last change: 2016 Feb 27 VIM REFERENCE MANUAL by Bram Moolenaar @@ -714,7 +714,7 @@ There are several ways to exit Vim: - Use `:cquit`. Also when there are changes. When using `:cquit` or when there was an error message Vim exits with exit -code 1. Errors can be avoide by using `:silent!`. +code 1. Errors can be avoided by using `:silent!`. ============================================================================== 6. Saving settings *save-settings* diff --git a/runtime/doc/syntax.txt b/runtime/doc/syntax.txt index f7e9ece3d8..b6f1e4d856 100644 --- a/runtime/doc/syntax.txt +++ b/runtime/doc/syntax.txt @@ -1,4 +1,4 @@ -*syntax.txt* For Vim version 7.4. Last change: 2016 Feb 24 +*syntax.txt* For Vim version 7.4. Last change: 2016 Feb 25 VIM REFERENCE MANUAL by Bram Moolenaar @@ -2886,7 +2886,7 @@ You may wish to embed languages into sh. I'll give an example courtesy of Lorance Stinson on how to do this with awk as an example. Put the following file into $HOME/.config/nvim/after/syntax/sh/awkembed.vim: > - " AWK Embedding: {{{1 + " AWK Embedding: " ============== " Shamelessly ripped from aspperl.vim by Aaron Hope. if exists("b:current_syntax") diff --git a/runtime/doc/usr_29.txt b/runtime/doc/usr_29.txt index e495aad06d..9eb66ce83c 100644 --- a/runtime/doc/usr_29.txt +++ b/runtime/doc/usr_29.txt @@ -1,4 +1,4 @@ -*usr_29.txt* For Vim version 7.4. Last change: 2008 Jun 28 +*usr_29.txt* For Vim version 7.4. Last change: 2016 Feb 27 VIM USER MANUAL - by Bram Moolenaar diff --git a/runtime/doc/various.txt b/runtime/doc/various.txt index e6b05e1ab1..b3e5e2db03 100644 --- a/runtime/doc/various.txt +++ b/runtime/doc/various.txt @@ -1,4 +1,4 @@ -*various.txt* For Vim version 7.4. Last change: 2016 Feb 18 +*various.txt* For Vim version 7.4. Last change: 2016 Feb 27 VIM REFERENCE MANUAL by Bram Moolenaar diff --git a/runtime/syntax/fortran.vim b/runtime/syntax/fortran.vim index 26d063524e..b470e56f60 100644 --- a/runtime/syntax/fortran.vim +++ b/runtime/syntax/fortran.vim @@ -1,15 +1,16 @@ " Vim syntax file " Language: Fortran 2008 (and older: Fortran 2003, 95, 90, and 77) -" Version: 0.96 -" Last Change: 2015 Nov. 30 +" Version: 0.97 +" Last Change: 2016 Feb. 26 " Maintainer: Ajit J. Thakkar ; " Usage: For instructions, do :help fortran-syntax from Vim " Credits: -" Version 0.1 was based on the fortran 77 syntax file by Mario Eusebio and -" Preben Guldberg. Useful suggestions and contributions were made by: Andrej Panjkov, -" Bram Moolenaar, Thomas Olsen, Michael Sternberg, Christian Reile, +" Version 0.1 (April 2000) was based on the fortran 77 syntax file by Mario Eusebio and +" Preben Guldberg. Since then, useful suggestions and contributions have been made, +" in chronological order, by: +" Andrej Panjkov, Bram Moolenaar, Thomas Olsen, Michael Sternberg, Christian Reile, " Walter Dieudonn, Alexander Wagner, Roman Bertle, Charles Rendleman, -" Andrew Griffiths, Joe Krahn, Hendrik Merx, and Matt Thompson. +" Andrew Griffiths, Joe Krahn, Hendrik Merx, Matt Thompson, and Jan Hermann. if exists("b:current_syntax") finish @@ -407,7 +408,7 @@ if exists("fortran_fold") else syn region fortran77Loop transparent fold keepend start="\ Date: Tue, 26 Apr 2016 00:24:25 -0400 Subject: [PATCH 06/34] 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(-) 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 From d43ac790f2454e2173eb645bdcd97c7a7c7e4846 Mon Sep 17 00:00:00 2001 From: James McCoy Date: Thu, 28 Apr 2016 19:23:15 -0400 Subject: [PATCH 07/34] 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 +- test/functional/legacy/loadplugin_spec.lua | 46 ++++++++++++++++++++++ 3 files changed, 51 insertions(+), 5 deletions(-) create mode 100644 test/functional/legacy/loadplugin_spec.lua 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 diff --git a/test/functional/legacy/loadplugin_spec.lua b/test/functional/legacy/loadplugin_spec.lua new file mode 100644 index 0000000000..267520ac5c --- /dev/null +++ b/test/functional/legacy/loadplugin_spec.lua @@ -0,0 +1,46 @@ +-- Tests for :loadplugin + +local helpers = require('test.functional.helpers')(after_each) +local clear, source = helpers.clear, helpers.source +local call, eq, nvim = helpers.call, helpers.eq, helpers.meths + +local function expected_empty() + eq({}, nvim.get_vvar('errors')) +end + +describe('loadplugin', function() + setup(function() + clear() + + source([=[ + func Test_loadplugin() + let topdir = expand('%:p:h') . '/Xdir' + exe 'set packpath=' . topdir + let plugdir = topdir . '/pack/mine/opt/mytest' + call mkdir(plugdir . '/plugin', 'p') + call mkdir(plugdir . '/ftdetect', 'p') + filetype on + try + exe 'split ' . plugdir . '/plugin/test.vim' + call setline(1, 'let g:plugin_works = 42') + wq + + exe 'split ' . plugdir . '/ftdetect/test.vim' + call setline(1, 'let g:ftdetect_works = 17') + wq + + loadplugin mytest + call assert_true(42, g:plugin_works) + call assert_true(17, g:ftdetect_works) + finally + call delete(topdir, 'rf') + endtry + endfunc + ]=]) + end) + + it('is working', function() + call('Test_loadplugin') + expected_empty() + end) +end) From 67d8e586318a3f2f13df22f9a3b25c6d8a109e6c Mon Sep 17 00:00:00 2001 From: James McCoy Date: Thu, 28 Apr 2016 20:47:27 -0400 Subject: [PATCH 08/34] 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 --- runtime/doc/repeat.txt | 4 +- src/nvim/ex_cmds.lua | 6 ++ src/nvim/ex_cmds2.c | 86 +++++++++++++++------- src/nvim/version.c | 2 +- test/functional/legacy/loadplugin_spec.lua | 69 ++++++++++++----- 5 files changed, 121 insertions(+), 46 deletions(-) diff --git a/runtime/doc/repeat.txt b/runtime/doc/repeat.txt index 527b84c992..b9dee8d261 100644 --- a/runtime/doc/repeat.txt +++ b/runtime/doc/repeat.txt @@ -398,7 +398,7 @@ A Vim package is a directory that contains one or more plugins. The advantages over normal plugins: - A package can be downloaded as an archive and unpacked in its own directory. That makes it easy to updated and/or remove. -- A package can be a git, mercurial, etc. respository. That makes it really +- A package can be a git, mercurial, etc. repository. That makes it really easy to update. - A package can contain multiple plugins that depend on each other. - A package can contain plugins that are automatically loaded on startup and @@ -428,6 +428,8 @@ In the example Vim will find "my/ever/always/plugin/always.vim" and adds If the "always" plugin kicks in and sets the 'filetype' to "always", Vim will find the syntax/always.vim file, because its directory is in 'runtimepath'. +Vim will also load ftdetect files, like with |:loadplugin|. + *load-plugin* To load an optional plugin from a pack use the `:loadplugin` command: > :loadplugin mydebug 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, diff --git a/test/functional/legacy/loadplugin_spec.lua b/test/functional/legacy/loadplugin_spec.lua index 267520ac5c..af97db3ae5 100644 --- a/test/functional/legacy/loadplugin_spec.lua +++ b/test/functional/legacy/loadplugin_spec.lua @@ -13,34 +13,67 @@ describe('loadplugin', function() clear() source([=[ + func SetUp() + let s:topdir = expand('%:p:h') . '/Xdir' + exe 'set packpath=' . s:topdir + let s:plugdir = s:topdir . '/pack/mine/opt/mytest' + endfunc + + func TearDown() + call delete(s:topdir, 'rf') + endfunc + func Test_loadplugin() - let topdir = expand('%:p:h') . '/Xdir' - exe 'set packpath=' . topdir - let plugdir = topdir . '/pack/mine/opt/mytest' - call mkdir(plugdir . '/plugin', 'p') - call mkdir(plugdir . '/ftdetect', 'p') + call mkdir(s:plugdir . '/plugin', 'p') + call mkdir(s:plugdir . '/ftdetect', 'p') + set rtp& + let rtp = &rtp filetype on - try - exe 'split ' . plugdir . '/plugin/test.vim' - call setline(1, 'let g:plugin_works = 42') - wq - exe 'split ' . plugdir . '/ftdetect/test.vim' - call setline(1, 'let g:ftdetect_works = 17') - wq + exe 'split ' . s:plugdir . '/plugin/test.vim' + call setline(1, 'let g:plugin_works = 42') + wq - loadplugin mytest - call assert_true(42, g:plugin_works) - call assert_true(17, g:ftdetect_works) - finally - call delete(topdir, 'rf') - endtry + exe 'split ' . s:plugdir . '/ftdetect/test.vim' + call setline(1, 'let g:ftdetect_works = 17') + wq + + loadplugin mytest + + call assert_true(42, g:plugin_works) + call assert_true(17, g:ftdetect_works) + call assert_true(len(&rtp) > len(rtp)) + call assert_true(&rtp =~ (s:plugdir . '\($\|,\)')) + endfunc + + func Test_packadd() + call mkdir(s:plugdir . '/syntax', 'p') + set rtp& + let rtp = &rtp + packadd mytest + call assert_true(len(&rtp) > len(rtp)) + call assert_true(&rtp =~ (s:plugdir . '\($\|,\)')) + + " check the path is not added twice + let new_rtp = &rtp + packadd mytest + call assert_equal(new_rtp, &rtp) endfunc ]=]) + call('SetUp') + end) + + teardown(function() + call('TearDown') end) it('is working', function() call('Test_loadplugin') expected_empty() end) + + it('works with packadd', function() + call('Test_packadd') + expected_empty() + end) end) From 2f72f34f0407dcdf189bb4f3a4b79b51e96744bf Mon Sep 17 00:00:00 2001 From: James McCoy Date: Thu, 28 Apr 2016 22:58:24 -0400 Subject: [PATCH 09/34] 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 --- runtime/doc/repeat.txt | 14 +- src/nvim/ex_cmds.lua | 6 - src/nvim/ex_cmds2.c | 147 +++++++++--------- src/nvim/version.c | 2 +- .../{loadplugin_spec.lua => packadd_spec.lua} | 37 +++-- 5 files changed, 106 insertions(+), 100 deletions(-) rename test/functional/legacy/{loadplugin_spec.lua => packadd_spec.lua} (76%) diff --git a/runtime/doc/repeat.txt b/runtime/doc/repeat.txt index b9dee8d261..bee05d8efa 100644 --- a/runtime/doc/repeat.txt +++ b/runtime/doc/repeat.txt @@ -418,6 +418,12 @@ You would now have these files under ~/.local/share/nvim/site: pack/my/ever/always/syntax/always.vim pack/my/opt/mydebug/plugin/debugger.vim +If you don't have a package but a single plugin, you need to create the extra +directory level: + % mkdir -p ~/.local/share/nvim/site/pack/my/ever/always + % cd ~/.local/share/nvim/site/pack/my/ever/always + % unzip /tmp/myplugin.zip + When Vim starts up it scans all directories in 'packpath' for plugins under the "ever" directory and loads them. When found that directory is added to 'runtimepath'. @@ -428,11 +434,11 @@ In the example Vim will find "my/ever/always/plugin/always.vim" and adds If the "always" plugin kicks in and sets the 'filetype' to "always", Vim will find the syntax/always.vim file, because its directory is in 'runtimepath'. -Vim will also load ftdetect files, like with |:loadplugin|. +Vim will also load ftdetect files, like with |:packadd|. - *load-plugin* -To load an optional plugin from a pack use the `:loadplugin` command: > - :loadplugin mydebug + *pack-add* +To load an optional plugin from a pack use the `:packadd` command: > + :packadd mydebug This could be done inside always.vim, if some conditions are met. Or you could add this command to your |.vimrc|. 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"; + + 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); + + 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 (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); } + +theend: + xfree(ffname); } -// Source the plugins in the package directories. +// Find plugins in the package directories and source them. 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"); + do_in_path(p_pp, (char_u *)"pack/*/ever/*", DIP_ALL + DIP_DIR, + add_pack_plugin, p_pp); } -// ":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"; - - 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); - - vim_snprintf(pat, len, ftpat, eap->arg); - may_do_filetypes((char_u *)pat); - - xfree(pat); -} - -/// ":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 diff --git a/test/functional/legacy/loadplugin_spec.lua b/test/functional/legacy/packadd_spec.lua similarity index 76% rename from test/functional/legacy/loadplugin_spec.lua rename to test/functional/legacy/packadd_spec.lua index af97db3ae5..94b5336b9f 100644 --- a/test/functional/legacy/loadplugin_spec.lua +++ b/test/functional/legacy/packadd_spec.lua @@ -1,4 +1,4 @@ --- Tests for :loadplugin +-- Tests for 'packpath' and :packadd local helpers = require('test.functional.helpers')(after_each) local clear, source = helpers.clear, helpers.source @@ -8,8 +8,8 @@ local function expected_empty() eq({}, nvim.get_vvar('errors')) end -describe('loadplugin', function() - setup(function() +describe('packadd', function() + before_each(function() clear() source([=[ @@ -23,7 +23,7 @@ describe('loadplugin', function() call delete(s:topdir, 'rf') endfunc - func Test_loadplugin() + func Test_packadd() call mkdir(s:plugdir . '/plugin', 'p') call mkdir(s:plugdir . '/ftdetect', 'p') set rtp& @@ -38,7 +38,7 @@ describe('loadplugin', function() call setline(1, 'let g:ftdetect_works = 17') wq - loadplugin mytest + packadd mytest call assert_true(42, g:plugin_works) call assert_true(17, g:ftdetect_works) @@ -46,34 +46,43 @@ describe('loadplugin', function() call assert_true(&rtp =~ (s:plugdir . '\($\|,\)')) endfunc - func Test_packadd() + func Test_packadd_noload() + call mkdir(s:plugdir . '/plugin', 'p') call mkdir(s:plugdir . '/syntax', 'p') set rtp& let rtp = &rtp - packadd mytest + + exe 'split ' . s:plugdir . '/plugin/test.vim' + call setline(1, 'let g:plugin_works = 42') + wq + let g:plugin_works = 0 + + packadd! mytest + call assert_true(len(&rtp) > len(rtp)) call assert_true(&rtp =~ (s:plugdir . '\($\|,\)')) + call assert_equal(0, g:plugin_works) " check the path is not added twice let new_rtp = &rtp - packadd mytest + packadd! mytest call assert_equal(new_rtp, &rtp) endfunc ]=]) call('SetUp') end) - teardown(function() + after_each(function() call('TearDown') end) it('is working', function() - call('Test_loadplugin') - expected_empty() - end) - - it('works with packadd', function() call('Test_packadd') expected_empty() end) + + it('works with packadd!', function() + call('Test_packadd_noload') + expected_empty() + end) end) From 5f3813daf4e68a354800bdf553e75899cf24afba Mon Sep 17 00:00:00 2001 From: James McCoy Date: Mon, 20 Jun 2016 10:02:49 -0400 Subject: [PATCH 10/34] vim-patch:328da0d Update runtime files. https://github.com/vim/vim/commit/328da0dcb7be34b594725eef6dc98d3ea6516d69 Ignore changes to * doc/channel.txt, doc/eval.txt: Channel related docs * doc/tags: Generated at build time * doc/todo.txt: Irrelevant to Neovim --- runtime/doc/eval.txt | 2 +- runtime/doc/index.txt | 4 +- runtime/doc/repeat.txt | 34 +++-- runtime/doc/starting.txt | 2 +- runtime/indent/tex.vim | 253 ++++++++++++++++++++++++---------- runtime/syntax/sshconfig.vim | 85 ++++++++---- runtime/syntax/sshdconfig.vim | 74 ++++++++-- 7 files changed, 328 insertions(+), 126 deletions(-) diff --git a/runtime/doc/eval.txt b/runtime/doc/eval.txt index 04aff0b3bf..146f62c770 100644 --- a/runtime/doc/eval.txt +++ b/runtime/doc/eval.txt @@ -1,4 +1,4 @@ -*eval.txt* For Vim version 7.4. Last change: 2016 Feb 23 +*eval.txt* For Vim version 7.4. Last change: 2016 Mar 03 VIM REFERENCE MANUAL by Bram Moolenaar diff --git a/runtime/doc/index.txt b/runtime/doc/index.txt index 9efd107226..eff03c8daf 100644 --- a/runtime/doc/index.txt +++ b/runtime/doc/index.txt @@ -1,4 +1,4 @@ -*index.txt* For Vim version 7.4. Last change: 2016 Feb 27 +*index.txt* For Vim version 7.4. Last change: 2016 Mar 04 VIM REFERENCE MANUAL by Bram Moolenaar @@ -1317,7 +1317,6 @@ tag command action ~ |:lnfile| :lnf[ile] go to first location in next file |:lnoremap| :ln[oremap] like ":noremap!" but includes Lang-Arg mode |:loadkeymap| :loadk[eymap] load the following keymaps until EOF -|:loadplugin| :loadp[lugin] load a plugin from 'packpath' |:loadview| :lo[adview] load view for current window from a file |:lockmarks| :loc[kmarks] following command keeps marks where they are |:lockvar| :lockv[ar] lock variables @@ -1379,6 +1378,7 @@ tag command action ~ |:ounmap| :ou[nmap] like ":unmap" but for Operator-pending mode |:ounmenu| :ounme[nu] remove menu for Operator-pending mode |:ownsyntax| :ow[nsyntax] set new local syntax highlight for this window +|:packadd| :pa[ckadd] add a plugin from 'packpath' |:pclose| :pc[lose] close preview window |:pedit| :ped[it] edit file in the preview window |:print| :p[rint] print lines diff --git a/runtime/doc/repeat.txt b/runtime/doc/repeat.txt index bee05d8efa..a7873ce002 100644 --- a/runtime/doc/repeat.txt +++ b/runtime/doc/repeat.txt @@ -1,4 +1,4 @@ -*repeat.txt* For Vim version 7.4. Last change: 2016 Feb 26 +*repeat.txt* For Vim version 7.4. Last change: 2016 Mar 04 VIM REFERENCE MANUAL by Bram Moolenaar @@ -204,23 +204,31 @@ For writing a Vim script, see chapter 41 of the user manual |usr_41.txt|. When 'verbose' is two or higher, there is a message about each searched file. - *:loadp* *:loadplugin* -:loadp[lugin] {name} Search for an optional plugin directory and source the - plugin files found. It is similar to: > - :runtime pack/*/opt/{name}/plugin/*.vim -< However, `:loadplugin` uses 'packpath' instead of - 'runtimepath'. And the directory found is added to - 'runtimepath'. - - If you have a directory under 'packpath' that doesn't - actually have a plugin file, just create an empty one. - This will still add the directory to 'runtimepath'. + *:pa* *:packadd* +:pa[ckadd][!] {name} Search for an optional plugin directory in 'packpath' + and source any plugin files found. The directory must + match: + pack/*/opt/{name} ~ + The directory is added to 'runtimepath' if it wasn't + there yet. Note that {name} is the directory name, not the name of the .vim file. If the "{name}/plugin" directory contains more than one file they are all sourced. - Also see |load-plugin|. + If the filetype detection was not enabled yet (this + is usually done with a "syntax enable" or "filetype + on" command in your .vimrc file), this will also look + for "{name}/ftdetect/*.vim" files. + + When the optional ! is added no plugin files or + ftdetect scripts are loaded, only the matching + directories are added to 'runtimepath'. This is + useful in your .vimrc. The plugins will then be + loaded during initialization, see |load-plugins|. + + Also see |pack-add|. + :scripte[ncoding] [encoding] *:scripte* *:scriptencoding* *E167* Specify the character encoding used in the script. diff --git a/runtime/doc/starting.txt b/runtime/doc/starting.txt index 5db65cfaad..bd02e21752 100644 --- a/runtime/doc/starting.txt +++ b/runtime/doc/starting.txt @@ -1,4 +1,4 @@ -*starting.txt* For Vim version 7.4. Last change: 2016 Feb 27 +*starting.txt* For Vim version 7.4. Last change: 2016 Mar 03 VIM REFERENCE MANUAL by Bram Moolenaar diff --git a/runtime/indent/tex.vim b/runtime/indent/tex.vim index 7e3a351083..0150bb9623 100644 --- a/runtime/indent/tex.vim +++ b/runtime/indent/tex.vim @@ -2,10 +2,9 @@ " Language: LaTeX " Maintainer: YiChao Zhou " Created: Sat, 16 Feb 2002 16:50:19 +0100 -" Last Change: 2012 Mar 18 19:19:50 -" Version: 0.7 -" Please email me if you found something we can do. Bug report and -" feature request is welcome. +" Version: 0.9.2 +" Please email me if you found something I can do. Comments, bug report and +" feature request are welcome. " Last Update: {{{ " 25th Sep 2002, by LH : @@ -41,7 +40,7 @@ " (*) Trust user when in "verbatim" and "lstlisting" " 2012/03/11 by Zhou Yichao " (*) Modify "&" so that only indent when current line start with -" "&". +" "&". " 2012/03/12 by Zhou Yichao " (*) Modify indentkeys. " 2012/03/18 by Zhou Yichao @@ -49,6 +48,17 @@ " 2013/05/02 by Zhou Yichao " (*) Fix problem about GetTeXIndent checker. Thank Albert Netymk " for reporting this. +" 2014/06/23 by Zhou Yichao +" (*) Remove the feature g:tex_indent_and because it is buggy. +" (*) If there is not any obvious indentation hints, we do not +" alert our user's current indentation. +" (*) g:tex_indent_brace now only works if the open brace is the +" last character of that line. +" 2014/08/03 by Zhou Yichao +" (*) Indent current line if last line has larger indentation +" 2014/08/09 by Zhou Yichao +" (*) Add missing return value for s:GetEndIndentation(...) +" " }}} " Document: {{{ @@ -60,7 +70,17 @@ " * g:tex_indent_brace " " If this variable is unset or non-zero, it will use smartindent-like style -" for "{}" and "[]" +" for "{}" and "[]". Now this only works if the open brace is the last +" character of that line. +" +" % Example 1 +" \usetikzlibrary{ +" external +" } +" +" % Example 2 +" \tikzexternalize[ +" prefix=tikz] " " * g:tex_indent_items " @@ -98,14 +118,6 @@ " " A list of environment names. separated with '\|', where no indentation is " required. The default is 'document\|verbatim'. -" -" * g:tex_indent_and -" -" If this variable is unset or zero, vim will try to align the line with first -" "&". This is pretty useful when you use environment like table or align. -" Note that this feature need to search back some line, so vim may become -" a little slow. -" " }}} " Only define the function once @@ -126,8 +138,8 @@ endif if !exists("g:tex_indent_brace") let g:tex_indent_brace = 1 endif -if !exists("g:tex_indent_and") - let g:tex_indent_and = 1 +if !exists("g:tex_max_scan_line") + let g:tex_max_scan_line = 60 endif if g:tex_indent_items if !exists("g:tex_itemize_env") @@ -140,10 +152,6 @@ else let g:tex_items = '' endif -if !exists("g:tex_indent_paretheses") - let g:tex_indent_paretheses = 1 -endif - if !exists("g:tex_noindent_env") let g:tex_noindent_env = 'document\|verbatim\|lstlisting' endif "}}} @@ -160,6 +168,7 @@ let g:tex_items = '^\s*' . substitute(g:tex_items, '^\(\^\\s\*\)*', '', '') function! GetTeXIndent() " {{{ " Find a non-blank line above the current line. let lnum = prevnonblank(v:lnum - 1) + let cnum = v:lnum " Comment line is not what we need. while lnum != 0 && getline(lnum) =~ '^\s*%' @@ -171,8 +180,8 @@ function! GetTeXIndent() " {{{ return 0 endif - let line = substitute(getline(lnum), '%.*', ' ','g') " last line - let cline = substitute(getline(v:lnum), '%.*', ' ', 'g') " current line + let line = substitute(getline(lnum), '\s*%.*', '','g') " last line + let cline = substitute(getline(v:lnum), '\s*%.*', '', 'g') " current line " We are in verbatim, so do what our user what. if synIDattr(synID(v:lnum, indent(v:lnum), 1), "name") == "texZone" @@ -183,26 +192,12 @@ function! GetTeXIndent() " {{{ end endif - " You want to align with "&" - if g:tex_indent_and - " Align only when current line start with "&" - if line =~ '&.*\\\\' && cline =~ '^\s*&' - return indent(v:lnum) + stridx(line, "&") - stridx(cline, "&") - endif - - " set line & lnum to the line which doesn't contain "&" - while lnum != 0 && (stridx(line, "&") != -1 || line =~ '^\s*%') - let lnum = prevnonblank(lnum - 1) - let line = getline(lnum) - endwhile - endif - - if lnum == 0 return 0 endif let ind = indent(lnum) + let stay = 1 " New code for comment: retain the indent of current line if cline =~ '^\s*%' @@ -216,77 +211,197 @@ function! GetTeXIndent() " {{{ " ZYC modification : \end after \begin won't cause wrong indent anymore if line =~ '\\begin{.*}' && line !~ g:tex_noindent_env let ind = ind + &sw + let stay = 0 if g:tex_indent_items " Add another sw for item-environments if line =~ g:tex_itemize_env let ind = ind + &sw + let stay = 0 endif endif endif + if cline =~ '\\end{.*}' + let retn = s:GetEndIndentation(v:lnum) + if retn != -1 + return retn + endif + end " Subtract a 'shiftwidth' when an environment ends - if cline =~ '\\end{.*}' && cline !~ g:tex_noindent_env - + if cline =~ '\\end{.*}' + \ && cline !~ g:tex_noindent_env + \ && cline !~ '\\begin{.*}.*\\end{.*}' if g:tex_indent_items " Remove another sw for item-environments if cline =~ g:tex_itemize_env let ind = ind - &sw + let stay = 0 endif endif let ind = ind - &sw + let stay = 0 endif if g:tex_indent_brace - let sum1 = 0 - for i in range(0, strlen(line)-1) - if line[i] == "}" || line[i] == "]" || - \ strpart(line, i, 7) == '\right)' - let sum1 = max([0, sum1-1]) - endif - if line[i] == "{" || line[i] == "[" || - \ strpart(line, i, 6) == '\left(' - let sum1 += 1 + let char = line[strlen(line)-1] + if char == '[' || char == '{' + let ind += &sw + let stay = 0 + endif + + let cind = indent(v:lnum) + let char = cline[cind] + if (char == ']' || char == '}') && + \ s:CheckPairedIsLastCharacter(v:lnum, cind) + let ind -= &sw + let stay = 0 + endif + + for i in range(indent(lnum)+1, strlen(line)-1) + let char = line[i] + if char == ']' || char == '}' + if s:CheckPairedIsLastCharacter(lnum, i) + let ind -= &sw + let stay = 0 + endif endif endfor - - let sum2 = 0 - for i in reverse(range(0, strlen(cline)-1)) - if cline[i] == "{" || cline[i] == "[" || - \ strpart(cline, i, 6) == '\left(' - let sum2 = max([0, sum2-1]) - endif - if cline[i] == "}" || cline[i] == "]" || - \ strpart(cline, i, 7) == '\right)' - let sum2 += 1 - endif - endfor - - let ind += (sum1 - sum2) * &sw - endif - - if g:tex_indent_paretheses endif " Special treatment for 'item' " ---------------------------- if g:tex_indent_items - " '\item' or '\bibitem' itself: if cline =~ g:tex_items let ind = ind - &sw + let stay = 0 endif - " lines following to '\item' are intented once again: if line =~ g:tex_items let ind = ind + &sw + let stay = 0 endif - endif - return ind + if stay + " If there is no obvious indentation hint, we trust our user. + if empty(cline) + return ind + else + return max([indent(v:lnum), s:GetLastBeginIndentation(v:lnum)]) + endif + else + return ind + endif +endfunction "}}} + +function! s:GetLastBeginIndentation(lnum) " {{{ + let matchend = 1 + for lnum in range(a:lnum-1, max([a:lnum - g:tex_max_scan_line, 1]), -1) + let line = getline(lnum) + if line =~ '\\end{.*}' + let matchend += 1 + endif + if line =~ '\\begin{.*}' + let matchend -= 1 + endif + if matchend == 0 + if line =~ g:tex_itemize_env + return indent(lnum) + 2 * &sw + endif + if line =~ g:tex_noindent_env + return indent(lnum) + endif + return indent(lnum) + &sw + endif + endfor + return -1 +endfunction + +function! s:GetEndIndentation(lnum) " {{{ + if getline(a:lnum) =~ '\\begin{.*}.*\\end{.*}' + return -1 + endif + + let min_indent = 100 + let matchend = 1 + for lnum in range(a:lnum-1, max([a:lnum-g:tex_max_scan_line, 1]), -1) + let line = getline(lnum) + if line =~ '\\end{.*}' + let matchend += 1 + endif + if line =~ '\\begin{.*}' + let matchend -= 1 + endif + if matchend == 0 + return indent(lnum) + endif + if !empty(line) + let min_indent = min([min_indent, indent(lnum)]) + endif + endfor + return min_indent - &sw +endfunction + +" Most of the code is from matchparen.vim +function! s:CheckPairedIsLastCharacter(lnum, col) "{{{ + " Get the character under the cursor and check if it's in 'matchpairs'. + let c_lnum = a:lnum + let c_col = a:col+1 + + + let c = getline(c_lnum)[c_col-1] + let plist = split(&matchpairs, '.\zs[:,]') + let i = index(plist, c) + if i < 0 + return 0 + endif + + " Figure out the arguments for searchpairpos(). + if i % 2 == 0 + let s_flags = 'nW' + let c2 = plist[i + 1] + else + let s_flags = 'nbW' + let c2 = c + let c = plist[i - 1] + endif + if c == '[' + let c = '\[' + let c2 = '\]' + endif + + " Find the match. When it was just before the cursor move it there for a + " moment. + let save_cursor = winsaveview() + call cursor(c_lnum, c_col) + + " When not in a string or comment ignore matches inside them. + " We match "escape" for special items, such as lispEscapeSpecial. + let s_skip ='synIDattr(synID(line("."), col("."), 0), "name") ' . + \ '=~? "string\\|character\\|singlequote\\|escape\\|comment"' + execute 'if' s_skip '| let s_skip = 0 | endif' + + let stopline = max([0, c_lnum - g:tex_max_scan_line]) + + " Limit the search time to 300 msec to avoid a hang on very long lines. + " This fails when a timeout is not supported. + try + let [m_lnum, m_col] = searchpairpos(c, '', c2, s_flags, s_skip, stopline, 100) + catch /E118/ + endtry + + call winrestview(save_cursor) + + if m_lnum > 0 + let line = getline(m_lnum) + return strlen(line) == m_col + endif + + return 0 endfunction "}}} let &cpo = s:cpo_save diff --git a/runtime/syntax/sshconfig.vim b/runtime/syntax/sshconfig.vim index ef2ca07976..44b3c67a96 100644 --- a/runtime/syntax/sshconfig.vim +++ b/runtime/syntax/sshconfig.vim @@ -4,8 +4,8 @@ " Maintainer: Dominik Fischer " Contributor: Leonard Ehrenfried " Contributor: Karsten Hopp -" Last Change: 2016 Jan 15 -" SSH Version: 7.1 +" Last Change: 2016 Mar 1 +" SSH Version: 7.2 " " Setup @@ -40,26 +40,57 @@ syn keyword sshconfigYesNo yes no ask syn keyword sshconfigYesNo any auto syn keyword sshconfigYesNo force autoask none -syn keyword sshconfigCipher 3des blowfish -syn keyword sshconfigCiphers aes128-cbc 3des-cbc blowfish blowfish-cbc cast128-cbc -syn keyword sshconfigCiphers aes192-cbc aes256-cbc aes128-ctr aes192-ctr aes256-ctr -syn keyword sshconfigCiphers arcfour arcfour128 arcfour256 cast128-cbc +syn keyword sshconfigCipher 3des blowfish -syn keyword sshconfigMAC hmac-md5 hmac-sha1 hmac-ripemd160 hmac-sha1-96 -syn keyword sshconfigMAC hmac-md5-96 -syn keyword sshconfigMAC hmac-sha2-256 hmac-sha2-256-96 hmac-sha2-512 -syn keyword sshconfigMAC hmac-sha2-512-96 +syn keyword sshconfigCiphers 3des-cbc +syn keyword sshconfigCiphers blowfish-cbc +syn keyword sshconfigCiphers cast128-cbc +syn keyword sshconfigCiphers arcfour +syn keyword sshconfigCiphers arcfour128 +syn keyword sshconfigCiphers arcfour256 +syn keyword sshconfigCiphers aes128-cbc +syn keyword sshconfigCiphers aes192-cbc +syn keyword sshconfigCiphers aes256-cbc +syn match sshconfigCiphers "\" +syn keyword sshconfigCiphers aes128-ctr +syn keyword sshconfigCiphers aes192-ctr +syn keyword sshconfigCiphers aes256-ctr +syn match sshconfigCiphers "\" +syn match sshconfigCiphers "\" +syn match sshconfigCiphers "\" + +syn keyword sshconfigMAC hmac-sha1 +syn keyword sshconfigMAC mac-sha1-96 +syn keyword sshconfigMAC mac-sha2-256 +syn keyword sshconfigMAC mac-sha2-512 +syn keyword sshconfigMAC mac-md5 +syn keyword sshconfigMAC mac-md5-96 +syn keyword sshconfigMAC mac-ripemd160 +syn match sshconfigMAC "\" syn match sshconfigMAC "\" +syn match sshconfigMAC "\" +syn match sshconfigMAC "\" +syn match sshconfigMAC "\" +syn match sshconfigMAC "\" +syn match sshconfigMAC "\" +syn match sshconfigMAC "\" +syn match sshconfigMAC "\" +syn match sshconfigMAC "\" +syn match sshconfigMAC "\" +syn match sshconfigMAC "\" -syn keyword sshconfigHostKeyAlg ssh-rsa ssh-dss -syn match sshconfigHostKeyAlg "\" -syn match sshconfigHostKeyAlg "\" -syn match sshconfigHostKeyAlg "\" -syn match sshconfigHostKeyAlg "\" -syn match sshconfigHostKeyAlg "\" -syn match sshconfigHostKeyAlg "\" -syn match sshconfigHostKeyAlg "\" -syn keyword sshconfigHostKeyAlg ecdsa-sha2-nistp256 ecdsa-sha2-nistp384 ecdsa-sha2-nistp521 +syn keyword sshconfigHostKeyAlgo ssh-ed25519 +syn match sshconfigHostKeyAlgo "\" +syn keyword sshconfigHostKeyAlgo ssh-rsa +syn keyword sshconfigHostKeyAlgo ssh-dss +syn keyword sshconfigHostKeyAlgo ecdsa-sha2-nistp256 +syn keyword sshconfigHostKeyAlgo ecdsa-sha2-nistp384 +syn keyword sshconfigHostKeyAlgo ecdsa-sha2-nistp521 +syn match sshconfigHostKeyAlgo "\" +syn match sshconfigHostKeyAlgo "\" +syn match sshconfigHostKeyAlgo "\" +syn match sshconfigHostKeyAlgo "\" +syn match sshconfigHostKeyAlgo "\" syn keyword sshconfigPreferredAuth hostbased publickey password gssapi-with-mic syn keyword sshconfigPreferredAuth keyboard-interactive @@ -78,11 +109,14 @@ syn match sshconfigIPQoS "cs[0-7]" syn keyword sshconfigIPQoS ef lowdelay throughput reliability syn keyword sshconfigKbdInteractive bsdauth pam skey -syn keyword sshconfigKexAlgo ecdh-sha2-nistp256 ecdh-sha2-nistp384 ecdh-sha2-nistp521 -syn keyword sshconfigKexAlgo diffie-hellman-group-exchange-sha256 -syn keyword sshconfigKexAlgo diffie-hellman-group-exchange-sha1 -syn keyword sshconfigKexAlgo diffie-hellman-group14-sha1 -syn keyword sshconfigKexAlgo diffie-hellman-group1-sha1 +syn keyword sshconfigKexAlgo diffie-hellman-group1-sha1 +syn keyword sshconfigKexAlgo diffie-hellman-group14-sha1 +syn keyword sshconfigKexAlgo diffie-hellman-group-exchange-sha1 +syn keyword sshconfigKexAlgo diffie-hellman-group-exchange-sha256 +syn keyword sshconfigKexAlgo ecdh-sha2-nistp256 +syn keyword sshconfigKexAlgo ecdh-sha2-nistp384 +syn keyword sshconfigKexAlgo ecdh-sha2-nistp521 +syn match sshconfigKexAlgo "\" syn keyword sshconfigTunnel point-to-point ethernet @@ -111,6 +145,7 @@ syn keyword sshconfigKeyword CanonicalDomains syn keyword sshconfigKeyword CanonicalizeFallbackLocal syn keyword sshconfigKeyword CanonicalizeHostname syn keyword sshconfigKeyword CanonicalizeMaxDots +syn keyword sshconfigKeyword CertificateFile syn keyword sshconfigKeyword ChallengeResponseAuthentication syn keyword sshconfigKeyword CheckHostIP syn keyword sshconfigKeyword Cipher @@ -212,7 +247,7 @@ if version >= 508 || !exists("did_sshconfig_syntax_inits") HiLink sshconfigCipher sshconfigEnum HiLink sshconfigCiphers sshconfigEnum HiLink sshconfigMAC sshconfigEnum - HiLink sshconfigHostKeyAlg sshconfigEnum + HiLink sshconfigHostKeyAlgo sshconfigEnum HiLink sshconfigLogLevel sshconfigEnum HiLink sshconfigSysLogFacility sshconfigEnum HiLink sshconfigAddressFamily sshconfigEnum diff --git a/runtime/syntax/sshdconfig.vim b/runtime/syntax/sshdconfig.vim index 4203047d2c..6b7b98d893 100644 --- a/runtime/syntax/sshdconfig.vim +++ b/runtime/syntax/sshdconfig.vim @@ -6,8 +6,8 @@ " Contributor: Leonard Ehrenfried " Contributor: Karsten Hopp " Originally: 2009-07-09 -" Last Change: 2016 Jan 12 -" SSH Version: 7.1 +" Last Change: 2016 Mar 1 +" SSH Version: 7.2 " " Setup @@ -47,15 +47,55 @@ syn keyword sshdconfigTcpForwarding local remote syn keyword sshdconfigRootLogin prohibit-password without-password forced-commands-only -syn keyword sshdconfigCipher aes128-cbc 3des-cbc blowfish-cbc cast128-cbc -syn keyword sshdconfigCipher aes192-cbc aes256-cbc aes128-ctr aes192-ctr aes256-ctr -syn keyword sshdconfigCipher arcfour arcfour128 arcfour256 cast128-cbc +syn keyword sshdconfigCiphers 3des-cbc +syn keyword sshdconfigCiphers blowfish-cbc +syn keyword sshdconfigCiphers cast128-cbc +syn keyword sshdconfigCiphers arcfour +syn keyword sshdconfigCiphers arcfour128 +syn keyword sshdconfigCiphers arcfour256 +syn keyword sshdconfigCiphers aes128-cbc +syn keyword sshdconfigCiphers aes192-cbc +syn keyword sshdconfigCiphers aes256-cbc +syn match sshdconfigCiphers "\" +syn keyword sshdconfigCiphers aes128-ctr +syn keyword sshdconfigCiphers aes192-ctr +syn keyword sshdconfigCiphers aes256-ctr +syn match sshdconfigCiphers "\" +syn match sshdconfigCiphers "\" +syn match sshdconfigCiphers "\" -syn keyword sshdconfigMAC hmac-md5 hmac-sha1 hmac-ripemd160 hmac-sha1-96 -syn keyword sshdconfigMAC hmac-md5-96 -syn keyword sshdconfigMAC hmac-sha2-256 hmac-sha256-96 hmac-sha2-512 -syn keyword sshdconfigMAC hmac-sha2-512-96 +syn keyword sshdconfigMAC hmac-sha1 +syn keyword sshdconfigMAC mac-sha1-96 +syn keyword sshdconfigMAC mac-sha2-256 +syn keyword sshdconfigMAC mac-sha2-512 +syn keyword sshdconfigMAC mac-md5 +syn keyword sshdconfigMAC mac-md5-96 +syn keyword sshdconfigMAC mac-ripemd160 +syn match sshdconfigMAC "\" syn match sshdconfigMAC "\" +syn match sshdconfigMAC "\" +syn match sshdconfigMAC "\" +syn match sshdconfigMAC "\" +syn match sshdconfigMAC "\" +syn match sshdconfigMAC "\" +syn match sshdconfigMAC "\" +syn match sshdconfigMAC "\" +syn match sshdconfigMAC "\" +syn match sshdconfigMAC "\" +syn match sshdconfigMAC "\" + +syn keyword sshdconfigHostKeyAlgo ssh-ed25519 +syn match sshdconfigHostKeyAlgo "\" +syn keyword sshdconfigHostKeyAlgo ssh-rsa +syn keyword sshdconfigHostKeyAlgo ssh-dss +syn keyword sshdconfigHostKeyAlgo ecdsa-sha2-nistp256 +syn keyword sshdconfigHostKeyAlgo ecdsa-sha2-nistp384 +syn keyword sshdconfigHostKeyAlgo ecdsa-sha2-nistp521 +syn match sshdconfigHostKeyAlgo "\" +syn match sshdconfigHostKeyAlgo "\" +syn match sshdconfigHostKeyAlgo "\" +syn match sshdconfigHostKeyAlgo "\" +syn match sshdconfigHostKeyAlgo "\" syn keyword sshdconfigRootLogin prohibit-password without-password forced-commands-only @@ -73,11 +113,14 @@ syn match sshdconfigIPQoS "af4[123]" syn match sshdconfigIPQoS "cs[0-7]" syn keyword sshdconfigIPQoS ef lowdelay throughput reliability -syn keyword sshdconfigKexAlgo ecdh-sha2-nistp256 ecdh-sha2-nistp384 ecdh-sha2-nistp521 -syn keyword sshdconfigKexAlgo diffie-hellman-group-exchange-sha256 -syn keyword sshdconfigKexAlgo diffie-hellman-group-exchange-sha1 -syn keyword sshdconfigKexAlgo diffie-hellman-group14-sha1 -syn keyword sshdconfigKexAlgo diffie-hellman-group1-sha1 +syn keyword sshdconfigKexAlgo diffie-hellman-group1-sha1 +syn keyword sshdconfigKexAlgo diffie-hellman-group14-sha1 +syn keyword sshdconfigKexAlgo diffie-hellman-group-exchange-sha1 +syn keyword sshdconfigKexAlgo diffie-hellman-group-exchange-sha256 +syn keyword sshdconfigKexAlgo ecdh-sha2-nistp256 +syn keyword sshdconfigKexAlgo ecdh-sha2-nistp384 +syn keyword sshdconfigKexAlgo ecdh-sha2-nistp521 +syn match sshdconfigKexAlgo "\" syn keyword sshdconfigTunnel point-to-point ethernet @@ -215,8 +258,9 @@ if version >= 508 || !exists("did_sshdconfig_syntax_inits") HiLink sshdconfigPrivilegeSeparation sshdconfigEnum HiLink sshdconfigTcpForwarding sshdconfigEnum HiLink sshdconfigRootLogin sshdconfigEnum - HiLink sshdconfigCipher sshdconfigEnum + HiLink sshdconfigCiphers sshdconfigEnum HiLink sshdconfigMAC sshdconfigEnum + HiLink sshdconfigHostKeyAlgo sshdconfigEnum HiLink sshdconfigRootLogin sshdconfigEnum HiLink sshdconfigLogLevel sshdconfigEnum HiLink sshdconfigSysLogFacility sshdconfigEnum From 85e539c99609cec0b5a0eab3aded394d0bbab555 Mon Sep 17 00:00:00 2001 From: James McCoy Date: Mon, 2 May 2016 21:15:57 -0400 Subject: [PATCH 11/34] 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 + test/functional/legacy/packadd_spec.lua | 64 ++++++++++++++++++++++++- 5 files changed, 113 insertions(+), 3 deletions(-) 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, }; diff --git a/test/functional/legacy/packadd_spec.lua b/test/functional/legacy/packadd_spec.lua index 94b5336b9f..9ca7c4e723 100644 --- a/test/functional/legacy/packadd_spec.lua +++ b/test/functional/legacy/packadd_spec.lua @@ -1,8 +1,9 @@ -- Tests for 'packpath' and :packadd local helpers = require('test.functional.helpers')(after_each) -local clear, source = helpers.clear, helpers.source +local clear, source, execute = helpers.clear, helpers.source, helpers.execute local call, eq, nvim = helpers.call, helpers.eq, helpers.meths +local feed = helpers.feed local function expected_empty() eq({}, nvim.get_vvar('errors')) @@ -85,4 +86,65 @@ describe('packadd', function() call('Test_packadd_noload') expected_empty() end) + + describe('command line completion', function() + local Screen = require('test.functional.ui.screen') + local screen + + before_each(function() + screen = Screen.new(30, 5) + screen:attach() + screen:set_default_attr_ids({ + [1] = { + foreground = Screen.colors.Black, + background = Screen.colors.Yellow, + }, + [2] = {bold = true, reverse = true} + }) + local NonText = Screen.colors.Blue + screen:set_default_attr_ignore({{}, {bold=true, foreground=NonText}}) + + execute([[let optdir1 = &packpath . '/pack/mine/opt']]) + execute([[let optdir2 = &packpath . '/pack/candidate/opt']]) + execute([[call mkdir(optdir1 . '/pluginA', 'p')]]) + execute([[call mkdir(optdir1 . '/pluginC', 'p')]]) + execute([[call mkdir(optdir2 . '/pluginB', 'p')]]) + execute([[call mkdir(optdir2 . '/pluginC', 'p')]]) + end) + + it('works', function() + feed(':packadd ') + screen:expect([=[ + | + ~ | + ~ | + {1:pluginA}{2: pluginB pluginC }| + :packadd pluginA^ | + ]=]) + feed('') + screen:expect([=[ + | + ~ | + ~ | + {2:pluginA }{1:pluginB}{2: pluginC }| + :packadd pluginB^ | + ]=]) + feed('') + screen:expect([=[ + | + ~ | + ~ | + {2:pluginA pluginB }{1:pluginC}{2: }| + :packadd pluginC^ | + ]=]) + feed('') + screen:expect([=[ + | + ~ | + ~ | + {2:pluginA pluginB pluginC }| + :packadd ^ | + ]=]) + end) + end) end) From 8ecdc571b0cf679c5195088d140f2988bcbe87e1 Mon Sep 17 00:00:00 2001 From: James McCoy Date: Mon, 20 Jun 2016 10:12:07 -0400 Subject: [PATCH 12/34] 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 --- runtime/doc/repeat.txt | 2 +- src/nvim/ex_cmds.lua | 2 +- src/nvim/ex_cmds2.c | 28 ++++++++++++++++++------- src/nvim/globals.h | 1 + src/nvim/version.c | 2 +- test/functional/legacy/packadd_spec.lua | 4 ++++ 6 files changed, 29 insertions(+), 10 deletions(-) diff --git a/runtime/doc/repeat.txt b/runtime/doc/repeat.txt index a7873ce002..122e995f0a 100644 --- a/runtime/doc/repeat.txt +++ b/runtime/doc/repeat.txt @@ -204,7 +204,7 @@ For writing a Vim script, see chapter 41 of the user manual |usr_41.txt|. When 'verbose' is two or higher, there is a message about each searched file. - *:pa* *:packadd* + *:pa* *:packadd* *E919* :pa[ckadd][!] {name} Search for an optional plugin directory in 'packpath' and source any plugin files found. The directory must match: 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 diff --git a/test/functional/legacy/packadd_spec.lua b/test/functional/legacy/packadd_spec.lua index 9ca7c4e723..e84a8e60d6 100644 --- a/test/functional/legacy/packadd_spec.lua +++ b/test/functional/legacy/packadd_spec.lua @@ -45,6 +45,10 @@ describe('packadd', function() call assert_true(17, g:ftdetect_works) call assert_true(len(&rtp) > len(rtp)) call assert_true(&rtp =~ (s:plugdir . '\($\|,\)')) + + " Check exception + call assert_fails("packadd directorynotfound", 'E919:') + call assert_fails("packadd", 'E471:') endfunc func Test_packadd_noload() From 4ca9e13637d9acfa9660103949062a2d5d9f5bde Mon Sep 17 00:00:00 2001 From: James McCoy Date: Mon, 20 Jun 2016 10:22:53 -0400 Subject: [PATCH 13/34] vim-patch:5f148ec Update runtime files. https://github.com/vim/vim/commit/5f148ec0b5a6cedd9129b3abac351034b83cc4f7 Ignore changes to * doc/channel.txt, doc/eval.txt: Channel related docs * doc/tags: Generated at build time * doc/todo.txt: Irrelevant to Neovim --- runtime/doc/eval.txt | 2 +- runtime/doc/os_win32.txt | 27 ++++++++++- runtime/doc/repeat.txt | 91 ++++++++++++++++++++++------------- runtime/doc/starting.txt | 3 +- runtime/syntax/vhdl.vim | 101 +++++++++++++++++++++++++-------------- 5 files changed, 150 insertions(+), 74 deletions(-) diff --git a/runtime/doc/eval.txt b/runtime/doc/eval.txt index 146f62c770..4122b27fd8 100644 --- a/runtime/doc/eval.txt +++ b/runtime/doc/eval.txt @@ -1,4 +1,4 @@ -*eval.txt* For Vim version 7.4. Last change: 2016 Mar 03 +*eval.txt* For Vim version 7.4. Last change: 2016 Mar 07 VIM REFERENCE MANUAL by Bram Moolenaar diff --git a/runtime/doc/os_win32.txt b/runtime/doc/os_win32.txt index 3c7ca4e36a..5dc276c9df 100644 --- a/runtime/doc/os_win32.txt +++ b/runtime/doc/os_win32.txt @@ -1,4 +1,4 @@ -*os_win32.txt* For Vim version 7.4. Last change: 2014 Sep 25 +*os_win32.txt* For Vim version 7.4. Last change: 2016 Mar 05 VIM REFERENCE MANUAL by George Reilly @@ -75,6 +75,31 @@ The directory of the Vim executable is appended to $PATH. This is mostly to make "!xxd" work, as it is in the Tools menu. And it also means that when executable() returns 1 the executable can actually be executed. +Quotes in file names *win32-quotes* + +Quotes inside a file name (or any other command line argument) can be escaped +with a backslash. E.g. > + vim -c "echo 'foo\"bar'" + +Alternatively use three quotes to get one: > + vim -c "echo 'foo"""bar'" + +The quotation rules are: + +1. A `"` starts quotation. +2. Another `"` or `""` ends quotation. If the quotation ends with `""`, a `"` + is produced at the end of the quoted string. + +Examples, with [] around an argument: + "foo" -> [foo] + "foo"" -> [foo"] + "foo"bar -> [foobar] + "foo" bar -> [foo], [bar] + "foo""bar -> [foo"bar] + "foo"" bar -> [foo"], [bar] + "foo"""bar" -> [foo"bar] + + ============================================================================== 3. Using the mouse *win32-mouse* diff --git a/runtime/doc/repeat.txt b/runtime/doc/repeat.txt index 122e995f0a..ea86be5bf7 100644 --- a/runtime/doc/repeat.txt +++ b/runtime/doc/repeat.txt @@ -1,4 +1,4 @@ -*repeat.txt* For Vim version 7.4. Last change: 2016 Mar 04 +*repeat.txt* For Vim version 7.4. Last change: 2016 Mar 07 VIM REFERENCE MANUAL by Bram Moolenaar @@ -405,57 +405,80 @@ Rationale: A Vim package is a directory that contains one or more plugins. The advantages over normal plugins: - A package can be downloaded as an archive and unpacked in its own directory. - That makes it easy to updated and/or remove. + Thus the files are not mixed with files of other plugins. That makes it + easy to update and remove. - A package can be a git, mercurial, etc. repository. That makes it really easy to update. - A package can contain multiple plugins that depend on each other. - A package can contain plugins that are automatically loaded on startup and - ones that are only loaded when needed with `:loadplugin`. + ones that are only loaded when needed with `:packadd`. + + +Using a package and loading automatically ~ Let's assume your Vim files are in the "~/.local/share/nvim/site" directory -and you want to add a package from a zip archive "/tmp/mypack.zip": - % mkdir -p ~/.local/share/nvim/site/pack/my - % cd ~/.local/share/nvim/site/pack/my - % unzip /tmp/mypack.zip +and you want to add a package from a zip archive "/tmp/foopack.zip": + % mkdir -p ~/.local/share/nvim/site/pack/foo + % cd ~/.local/share/nvim/site/pack/foo + % unzip /tmp/foopack.zip -The directory name "my" is arbitrary, you can pick anything you like. +The directory name "foo" is arbitrary, you can pick anything you like. You would now have these files under ~/.local/share/nvim/site: - pack/my/README.txt - pack/my/ever/always/plugin/always.vim - pack/my/ever/always/syntax/always.vim - pack/my/opt/mydebug/plugin/debugger.vim + pack/foo/README.txt + pack/foo/ever/foobar/plugin/foo.vim + pack/foo/ever/foobar/syntax/some.vim + pack/foo/opt/foodebug/plugin/debugger.vim -If you don't have a package but a single plugin, you need to create the extra -directory level: - % mkdir -p ~/.local/share/nvim/site/pack/my/ever/always - % cd ~/.local/share/nvim/site/pack/my/ever/always - % unzip /tmp/myplugin.zip +When Vim starts up, after processing your .vimrc, it scans all directories in +'packpath' for plugins under the "pack/*/ever" directory and loads them. The +directory is added to 'runtimepath'. -When Vim starts up it scans all directories in 'packpath' for plugins under the -"ever" directory and loads them. When found that directory is added to -'runtimepath'. +In the example Vim will find "pack/foo/ever/foobar/plugin/foo.vim" and adds +"~/.local/share/nvim/site/pack/foo/ever/foobar" to 'runtimepath'. -In the example Vim will find "my/ever/always/plugin/always.vim" and adds -"~/.local/share/nvim/site/pack/my/ever/always" to 'runtimepath'. +If the "foobar" plugin kicks in and sets the 'filetype' to "some", Vim will +find the syntax/some.vim file, because its directory is in 'runtimepath'. -If the "always" plugin kicks in and sets the 'filetype' to "always", Vim will -find the syntax/always.vim file, because its directory is in 'runtimepath'. +Vim will also load ftdetect files, if there are any. -Vim will also load ftdetect files, like with |:packadd|. - - *pack-add* -To load an optional plugin from a pack use the `:packadd` command: > - :packadd mydebug -This could be done inside always.vim, if some conditions are met. -Or you could add this command to your |.vimrc|. - -It is perfectly normal for a package to only have files in the "opt" -directory. You then need to load each plugin when you want to use it. +Note that the files under "pack/foo/opt" or not loaded automatically, only the +ones under "pack/foo/ever". See |pack-add| below for how the "opt" directory +is used. Loading packages will not happen if loading plugins is disabled, see |load-plugins|. + +Using a single plugin and loading it automatically ~ + +If you don't have a package but a single plugin, you need to create the extra +directory level: + % mkdir -p ~/.local/share/nvim/site/pack/foo/ever/foobar + % cd ~/.local/share/nvim/site/pack/foo/ever/foobar + % unzip /tmp/someplugin.zip + +You would now have these files: + pack/foo/ever/foobar/plugin/foo.vim + pack/foo/ever/foobar/syntax/some.vim + +From here it works like above. + + +Optional plugins ~ + *pack-add* +To load an optional plugin from a pack use the `:packadd` command: > + :packadd foodebug +This searches for "pack/*/opt/foodebug" in 'packpath' and will find +~/.local/share/nvim/site/pack/foo/opt/foodebug/plugin/debugger.vim and source +it. + +This could be done inside always.vim, if some conditions are met. Or you +could add this command to your |.vimrc|. + +It is perfectly normal for a package to only have files in the "opt" +directory. You then need to load each plugin when you want to use it. + ============================================================================== 6. Debugging scripts *debug-scripts* diff --git a/runtime/doc/starting.txt b/runtime/doc/starting.txt index bd02e21752..bda5254663 100644 --- a/runtime/doc/starting.txt +++ b/runtime/doc/starting.txt @@ -1,4 +1,4 @@ -*starting.txt* For Vim version 7.4. Last change: 2016 Mar 03 +*starting.txt* For Vim version 7.4. Last change: 2016 Mar 05 VIM REFERENCE MANUAL by Bram Moolenaar @@ -41,6 +41,7 @@ filename One or more file names. The first one will be the current nvim -- -filename < All arguments after the "--" will be interpreted as file names, no other options or "+command" argument can follow. + For behavior of quotes on MS-Windows, see |win32-quotes|. *--* - This argument can mean two things, depending on whether Ex diff --git a/runtime/syntax/vhdl.vim b/runtime/syntax/vhdl.vim index 916bd9635d..044ef83d17 100644 --- a/runtime/syntax/vhdl.vim +++ b/runtime/syntax/vhdl.vim @@ -1,14 +1,10 @@ " Vim syntax file -" Language: VHDL -" Maintainer: Daniel Kho +" Language: VHDL [VHSIC (Very High Speed Integrated Circuit) Hardware Description Language] +" Maintainer: Daniel Kho " Previous Maintainer: Czo -" Credits: Stephan Hegel -" Last Changed: 2015 Dec 4 by Daniel Kho +" Credits: Stephan Hegel +" Last Changed: 2016 Mar 05 by Daniel Kho -" VHSIC (Very High Speed Integrated Circuit) Hardware Description Language - -" For version 5.x: Clear all syntax items -" For version 6.x: Quit when a syntax file was already loaded if version < 600 syntax clear elseif exists("b:current_syntax") @@ -56,17 +52,40 @@ syn keyword vhdlStatement note warning error failure syn match vhdlStatement "\<\(if\|else\)\>" syn match vhdlError "\" -" Predefined VHDL types -syn keyword vhdlType bit bit_vector -syn keyword vhdlType character boolean integer real time -syn keyword vhdlType boolean_vector integer_vector real_vector time_vector -syn keyword vhdlType string severity_level -" Predefined standard ieee VHDL types -syn keyword vhdlType positive natural signed unsigned -syn keyword vhdlType unresolved_signed unresolved_unsigned u_signed u_unsigned -syn keyword vhdlType line text -syn keyword vhdlType std_logic std_logic_vector -syn keyword vhdlType std_ulogic std_ulogic_vector +" Types and type qualifiers +" Predefined standard VHDL types +syn match vhdlType "bit[\']*" +syn match vhdlType "boolean[\']*" +syn match vhdlType "natural[\']*" +syn match vhdlType "positive[\']*" +syn match vhdlType "integer[\']*" +syn match vhdlType "real[\']*" +syn match vhdlType "time[\']*" + +syn match vhdlType "bit_vector[\']*" +syn match vhdlType "boolean_vector[\']*" +syn match vhdlType "integer_vector[\']*" +syn match vhdlType "real_vector[\']*" +syn match vhdlType "time_vector[\']*" + +syn match vhdlType "character[\']*" +syn match vhdlType "string[\']*" +"syn keyword vhdlType severity_level +syn match vhdlType "line[\']*" +syn match vhdlType "text[\']*" + +" Predefined standard IEEE VHDL types +syn match vhdlType "std_ulogic[\']*" +syn match vhdlType "std_logic[\']*" +syn match vhdlType "std_ulogic_vector[\']*" +syn match vhdlType "std_logic_vector[\']*" +syn match vhdlType "unresolved_signed[\']*" +syn match vhdlType "unresolved_unsigned[\']*" +syn match vhdlType "u_signed[\']*" +syn match vhdlType "u_unsigned[\']*" +syn match vhdlType "signed[\']*" +syn match vhdlType "unsigned[\']*" + " array attributes syn match vhdlAttribute "\'high" @@ -191,15 +210,23 @@ syn case ignore syn region vhdlComment start="/\*" end="\*/" contains=vhdlTodo,vhdlFixme,@Spell syn match vhdlComment "\(^\|\s\)--.*" contains=vhdlTodo,vhdlFixme,@Spell +" Standard IEEE P1076.6 preprocessor directives (metacomments). +syn match vhdlPreProc "/\*\s*rtl_synthesis\s\+\(on\|off\)\s*\*/" +syn match vhdlPreProc "\(^\|\s\)--\s*rtl_synthesis\s\+\(on\|off\)\s*" +syn match vhdlPreProc "/\*\s*rtl_syn\s\+\(on\|off\)\s*\*/" +syn match vhdlPreProc "\(^\|\s\)--\s*rtl_syn\s\+\(on\|off\)\s*" + " Industry-standard directives. These are not standard VHDL, but are commonly " used in the industry. syn match vhdlPreProc "/\*\s*synthesis\s\+translate_\(on\|off\)\s*\*/" "syn match vhdlPreProc "/\*\s*simulation\s\+translate_\(on\|off\)\s*\*/" +syn match vhdlPreProc "/\*\s*pragma\s\+translate_\(on\|off\)\s*\*/" syn match vhdlPreProc "/\*\s*pragma\s\+synthesis_\(on\|off\)\s*\*/" syn match vhdlPreProc "/\*\s*synopsys\s\+translate_\(on\|off\)\s*\*/" syn match vhdlPreProc "\(^\|\s\)--\s*synthesis\s\+translate_\(on\|off\)\s*" "syn match vhdlPreProc "\(^\|\s\)--\s*simulation\s\+translate_\(on\|off\)\s*" +syn match vhdlPreProc "\(^\|\s\)--\s*pragma\s\+translate_\(on\|off\)\s*" syn match vhdlPreProc "\(^\|\s\)--\s*pragma\s\+synthesis_\(on\|off\)\s*" syn match vhdlPreProc "\(^\|\s\)--\s*synopsys\s\+translate_\(on\|off\)\s*" @@ -216,24 +243,24 @@ if version >= 508 || !exists("did_vhdl_syntax_inits") else command -nargs=+ HiLink hi def link endif - - HiLink vhdlSpecial Special - HiLink vhdlStatement Statement - HiLink vhdlCharacter Character - HiLink vhdlString String - HiLink vhdlVector Number - HiLink vhdlBoolean Number - HiLink vhdlTodo Todo - HiLink vhdlFixme Fixme - HiLink vhdlComment Comment - HiLink vhdlNumber Number - HiLink vhdlTime Number - HiLink vhdlType Type - HiLink vhdlOperator Operator - HiLink vhdlError Error - HiLink vhdlAttribute Special - HiLink vhdlPreProc PreProc - + + HiLink vhdlSpecial Special + HiLink vhdlStatement Statement + HiLink vhdlCharacter Character + HiLink vhdlString String + HiLink vhdlVector Number + HiLink vhdlBoolean Number + HiLink vhdlTodo Todo + HiLink vhdlFixme Fixme + HiLink vhdlComment Comment + HiLink vhdlNumber Number + HiLink vhdlTime Number + HiLink vhdlType Type + HiLink vhdlOperator Operator + HiLink vhdlError Error + HiLink vhdlAttribute Special + HiLink vhdlPreProc PreProc + delcommand HiLink endif From 1f54d253e169fbc483cc485f9b3092a8da1f62db Mon Sep 17 00:00:00 2001 From: James McCoy Date: Mon, 20 Jun 2016 10:35:38 -0400 Subject: [PATCH 14/34] 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 --- runtime/doc/repeat.txt | 22 +++++++++++----------- src/nvim/ex_cmds2.c | 4 ++-- src/nvim/version.c | 2 +- 3 files changed, 14 insertions(+), 14 deletions(-) diff --git a/runtime/doc/repeat.txt b/runtime/doc/repeat.txt index ea86be5bf7..8fcecfd5c0 100644 --- a/runtime/doc/repeat.txt +++ b/runtime/doc/repeat.txt @@ -1,4 +1,4 @@ -*repeat.txt* For Vim version 7.4. Last change: 2016 Mar 07 +*repeat.txt* For Vim version 7.4. Last change: 2016 Mar 09 VIM REFERENCE MANUAL by Bram Moolenaar @@ -426,16 +426,16 @@ The directory name "foo" is arbitrary, you can pick anything you like. You would now have these files under ~/.local/share/nvim/site: pack/foo/README.txt - pack/foo/ever/foobar/plugin/foo.vim - pack/foo/ever/foobar/syntax/some.vim + pack/foo/start/foobar/plugin/foo.vim + pack/foo/start/foobar/syntax/some.vim pack/foo/opt/foodebug/plugin/debugger.vim When Vim starts up, after processing your .vimrc, it scans all directories in -'packpath' for plugins under the "pack/*/ever" directory and loads them. The +'packpath' for plugins under the "pack/*/start" directory and loads them. The directory is added to 'runtimepath'. -In the example Vim will find "pack/foo/ever/foobar/plugin/foo.vim" and adds -"~/.local/share/nvim/site/pack/foo/ever/foobar" to 'runtimepath'. +In the example Vim will find "pack/foo/start/foobar/plugin/foo.vim" and adds +"~/.local/share/nvim/site/pack/foo/start/foobar" to 'runtimepath'. If the "foobar" plugin kicks in and sets the 'filetype' to "some", Vim will find the syntax/some.vim file, because its directory is in 'runtimepath'. @@ -443,7 +443,7 @@ find the syntax/some.vim file, because its directory is in 'runtimepath'. Vim will also load ftdetect files, if there are any. Note that the files under "pack/foo/opt" or not loaded automatically, only the -ones under "pack/foo/ever". See |pack-add| below for how the "opt" directory +ones under "pack/foo/start". See |pack-add| below for how the "opt" directory is used. Loading packages will not happen if loading plugins is disabled, see @@ -454,13 +454,13 @@ Using a single plugin and loading it automatically ~ If you don't have a package but a single plugin, you need to create the extra directory level: - % mkdir -p ~/.local/share/nvim/site/pack/foo/ever/foobar - % cd ~/.local/share/nvim/site/pack/foo/ever/foobar + % mkdir -p ~/.local/share/nvim/site/pack/foo/start/foobar + % cd ~/.local/share/nvim/site/pack/foo/start/foobar % unzip /tmp/someplugin.zip You would now have these files: - pack/foo/ever/foobar/plugin/foo.vim - pack/foo/ever/foobar/syntax/some.vim + pack/foo/start/foobar/plugin/foo.vim + pack/foo/start/foobar/syntax/some.vim From here it works like above. 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 From ea18b4a60f3b89d261c46b030d3d026ddad864bb Mon Sep 17 00:00:00 2001 From: James McCoy Date: Mon, 20 Jun 2016 10:37:19 -0400 Subject: [PATCH 15/34] vim-patch:77cdfd1 Updated runtime files. https://github.com/vim/vim/commit/77cdfd10382e01cc51f4ba1a9177032351843151 Ignore changes to: * doc/channel.txt, doc/eval.txt: Channel related docs * doc/options.txt: GUI related docs * doc/tags: Generated at build time * doc/todo.txt: Irrelevant for Neovim --- runtime/doc/change.txt | 6 +- runtime/doc/eval.txt | 2 +- runtime/doc/options.txt | 2 +- runtime/ftplugin/r.vim | 3 +- runtime/ftplugin/rhelp.vim | 3 +- runtime/ftplugin/rmd.vim | 3 +- runtime/ftplugin/rnoweb.vim | 3 +- runtime/ftplugin/rrst.vim | 3 +- runtime/indent/r.vim | 24 ++-- runtime/indent/rhelp.vim | 3 +- runtime/indent/rmd.vim | 3 +- runtime/indent/rnoweb.vim | 3 +- runtime/indent/rrst.vim | 3 +- runtime/syntax/python.vim | 4 +- runtime/syntax/r.vim | 58 +++++---- runtime/syntax/rhelp.vim | 246 ++++++++++++++++++++---------------- runtime/syntax/rmd.vim | 10 +- runtime/syntax/rnoweb.vim | 33 ++--- runtime/syntax/rrst.vim | 8 +- runtime/syntax/vhdl.vim | 52 ++++---- 20 files changed, 261 insertions(+), 211 deletions(-) diff --git a/runtime/doc/change.txt b/runtime/doc/change.txt index 4565cdf63e..2ccb9188a9 100644 --- a/runtime/doc/change.txt +++ b/runtime/doc/change.txt @@ -1,4 +1,4 @@ -*change.txt* For Vim version 7.4. Last change: 2016 Feb 10 +*change.txt* For Vim version 7.4. Last change: 2016 Mar 08 VIM REFERENCE MANUAL by Bram Moolenaar @@ -108,7 +108,9 @@ is an error when 'cpoptions' includes the 'E' flag. *J* J Join [count] lines, with a minimum of two lines. Remove the indent and insert up to two spaces (see - below). + below). Fails when on the last line of the buffer. + If [count] is too big it is reduce to the number of + lines available. *v_J* {Visual}J Join the highlighted lines, with a minimum of two diff --git a/runtime/doc/eval.txt b/runtime/doc/eval.txt index 4122b27fd8..712a0d7e5a 100644 --- a/runtime/doc/eval.txt +++ b/runtime/doc/eval.txt @@ -1,4 +1,4 @@ -*eval.txt* For Vim version 7.4. Last change: 2016 Mar 07 +*eval.txt* For Vim version 7.4. Last change: 2016 Mar 08 VIM REFERENCE MANUAL by Bram Moolenaar diff --git a/runtime/doc/options.txt b/runtime/doc/options.txt index 887cff0707..76ecb57e34 100644 --- a/runtime/doc/options.txt +++ b/runtime/doc/options.txt @@ -1,4 +1,4 @@ -*options.txt* For Vim version 7.4. Last change: 2016 Feb 24 +*options.txt* For Vim version 7.4. Last change: 2016 Mar 08 VIM REFERENCE MANUAL by Bram Moolenaar diff --git a/runtime/ftplugin/r.vim b/runtime/ftplugin/r.vim index 43b208b842..4ea3073922 100644 --- a/runtime/ftplugin/r.vim +++ b/runtime/ftplugin/r.vim @@ -1,7 +1,8 @@ " Vim filetype plugin file " Language: R " Maintainer: Jakson Alves de Aquino -" Last Change: Sun Feb 23, 2014 04:07PM +" Homepage: https://github.com/jalvesaq/R-Vim-runtime +" Last Change: Tue Apr 07, 2015 04:38PM " Only do this when not yet done for this buffer if exists("b:did_ftplugin") diff --git a/runtime/ftplugin/rhelp.vim b/runtime/ftplugin/rhelp.vim index 9b72fb42f9..fdac38f3e9 100644 --- a/runtime/ftplugin/rhelp.vim +++ b/runtime/ftplugin/rhelp.vim @@ -1,7 +1,8 @@ " Vim filetype plugin file " Language: R help file " Maintainer: Jakson Alves de Aquino -" Last Change: Wed Jul 09, 2014 06:23PM +" Homepage: https://github.com/jalvesaq/R-Vim-runtime +" Last Change: Tue Apr 07, 2015 04:37PM " Only do this when not yet done for this buffer if exists("b:did_ftplugin") diff --git a/runtime/ftplugin/rmd.vim b/runtime/ftplugin/rmd.vim index 55723ff396..ec64a07675 100644 --- a/runtime/ftplugin/rmd.vim +++ b/runtime/ftplugin/rmd.vim @@ -1,7 +1,8 @@ " Vim filetype plugin file " Language: R help file " Maintainer: Jakson Alves de Aquino -" Last Change: Wed Jul 09, 2014 06:23PM +" Homepage: https://github.com/jalvesaq/R-Vim-runtime +" Last Change: Tue Apr 07, 2015 04:37PM " Original work by Alex Zvoleff (adjusted for rmd by Michel Kuhlmann) " Only do this when not yet done for this buffer diff --git a/runtime/ftplugin/rnoweb.vim b/runtime/ftplugin/rnoweb.vim index baf53d0108..e184399dcb 100644 --- a/runtime/ftplugin/rnoweb.vim +++ b/runtime/ftplugin/rnoweb.vim @@ -1,7 +1,8 @@ " Vim filetype plugin file " Language: Rnoweb " Maintainer: Jakson Alves de Aquino -" Last Change: Wed Jul 09, 2014 06:23PM +" Homepage: https://github.com/jalvesaq/R-Vim-runtime +" Last Change: Tue Apr 07, 2015 04:37PM " Only do this when not yet done for this buffer if exists("b:did_ftplugin") diff --git a/runtime/ftplugin/rrst.vim b/runtime/ftplugin/rrst.vim index 8140169e61..ecfd6e87a1 100644 --- a/runtime/ftplugin/rrst.vim +++ b/runtime/ftplugin/rrst.vim @@ -1,7 +1,8 @@ " Vim filetype plugin file " Language: reStructuredText documentation format with R code " Maintainer: Jakson Alves de Aquino -" Last Change: Wed Jul 09, 2014 06:23PM +" Homepage: https://github.com/jalvesaq/R-Vim-runtime +" Last Change: Tue Apr 07, 2015 04:38PM " Original work by Alex Zvoleff " Only do this when not yet done for this buffer diff --git a/runtime/indent/r.vim b/runtime/indent/r.vim index 105f0cd7ad..01f3812ed2 100644 --- a/runtime/indent/r.vim +++ b/runtime/indent/r.vim @@ -1,7 +1,8 @@ " Vim indent file " Language: R " Author: Jakson Alves de Aquino -" Last Change: Thu Mar 26, 2015 05:36PM +" Homepage: https://github.com/jalvesaq/R-Vim-runtime +" Last Change: Thu Feb 18, 2016 06:32AM " Only load this indent file when no other was loaded. @@ -32,7 +33,7 @@ if ! exists("g:r_indent_ess_compatible") let g:r_indent_ess_compatible = 0 endif if ! exists("g:r_indent_op_pattern") - let g:r_indent_op_pattern = '\(+\|-\|\*\|/\|=\|\~\|%\)$' + let g:r_indent_op_pattern = '\(&\||\|+\|-\|\*\|/\|=\|\~\|%\|->\)\s*$' endif function s:RDelete_quotes(line) @@ -265,7 +266,7 @@ function GetRIndent() return 0 endif - if cline =~ '^\s*{' + if cline =~ '^\s*{' && s:Get_paren_balance(cline, '{', '}') > 0 if g:r_indent_ess_compatible && line =~ ')$' let nlnum = lnum let nline = line @@ -283,7 +284,7 @@ function GetRIndent() endif " line is an incomplete command: - if line =~ '\<\(if\|while\|for\|function\)\s*()$' || line =~ '\$' return indent(lnum) + &sw endif @@ -344,7 +345,7 @@ function GetRIndent() endif let post_block = 0 - if line =~ '}$' + if line =~ '}$' && s:Get_paren_balance(line, '{', '}') < 0 let lnum = s:Get_matching_brace(lnum, '{', '}', 0) let line = SanitizeRLine(getline(lnum)) if lnum > 0 && line =~ '^\s*{' @@ -359,14 +360,14 @@ function GetRIndent() let olnum = s:Get_prev_line(lnum) let oline = getline(olnum) if olnum > 0 - if line =~ g:r_indent_op_pattern - if oline =~ g:r_indent_op_pattern + if line =~ g:r_indent_op_pattern && s:Get_paren_balance(line, "(", ")") == 0 + if oline =~ g:r_indent_op_pattern && s:Get_paren_balance(line, "(", ")") == 0 return indent(lnum) else return indent(lnum) + &sw endif else - if oline =~ g:r_indent_op_pattern + if oline =~ g:r_indent_op_pattern && s:Get_paren_balance(line, "(", ")") == 0 return indent(lnum) - &sw endif endif @@ -471,7 +472,6 @@ function GetRIndent() endif let ind = indent(lnum) - let pind = indent(plnum) if g:r_indent_align_args == 0 && pb != 0 let ind += pb * &sw @@ -483,6 +483,12 @@ function GetRIndent() return ind endif + if plnum > 0 + let pind = indent(plnum) + else + let pind = 0 + endif + if ind == pind || (ind == (pind + &sw) && pline =~ '{$' && ppost_else == 0) return ind endif diff --git a/runtime/indent/rhelp.vim b/runtime/indent/rhelp.vim index 3b37128b2c..9dc2031cb6 100644 --- a/runtime/indent/rhelp.vim +++ b/runtime/indent/rhelp.vim @@ -1,7 +1,8 @@ " Vim indent file " Language: R Documentation (Help), *.Rd " Author: Jakson Alves de Aquino -" Last Change: Thu Oct 16, 2014 07:07AM +" Homepage: https://github.com/jalvesaq/R-Vim-runtime +" Last Change: Tue Apr 07, 2015 04:38PM " Only load this indent file when no other was loaded. diff --git a/runtime/indent/rmd.vim b/runtime/indent/rmd.vim index 9a8a3cb719..88904405e8 100644 --- a/runtime/indent/rmd.vim +++ b/runtime/indent/rmd.vim @@ -1,7 +1,8 @@ " Vim indent file " Language: Rmd " Author: Jakson Alves de Aquino -" Last Change: Thu Jul 10, 2014 07:11PM +" Homepage: https://github.com/jalvesaq/R-Vim-runtime +" Last Change: Tue Apr 07, 2015 04:38PM " Only load this indent file when no other was loaded. diff --git a/runtime/indent/rnoweb.vim b/runtime/indent/rnoweb.vim index d0cad3d8d9..29fa5bc78f 100644 --- a/runtime/indent/rnoweb.vim +++ b/runtime/indent/rnoweb.vim @@ -1,7 +1,8 @@ " Vim indent file " Language: Rnoweb " Author: Jakson Alves de Aquino -" Last Change: Sun Mar 22, 2015 09:28AM +" Homepage: https://github.com/jalvesaq/R-Vim-runtime +" Last Change: Tue Apr 07, 2015 04:38PM " Only load this indent file when no other was loaded. diff --git a/runtime/indent/rrst.vim b/runtime/indent/rrst.vim index 8bfa8344ce..f3ee53e7fb 100644 --- a/runtime/indent/rrst.vim +++ b/runtime/indent/rrst.vim @@ -1,7 +1,8 @@ " Vim indent file " Language: Rrst " Author: Jakson Alves de Aquino -" Last Change: Wed Jul 09, 2014 07:33PM +" Homepage: https://github.com/jalvesaq/R-Vim-runtime +" Last Change: Tue Apr 07, 2015 04:38PM " Only load this indent file when no other was loaded. diff --git a/runtime/syntax/python.vim b/runtime/syntax/python.vim index 78d35e4c15..2a0ea5de2b 100644 --- a/runtime/syntax/python.vim +++ b/runtime/syntax/python.vim @@ -1,7 +1,7 @@ " Vim syntax file " Language: Python " Maintainer: Zvezdan Petkovic -" Last Change: 2015 Sep 15 +" Last Change: 2016 Feb 20 " Credits: Neil Schemenauer " Dmitry Vasiliev " @@ -199,6 +199,8 @@ if !exists("python_no_builtin_highlight") syn keyword pythonBuiltin ascii bytes exec " non-essential built-in functions; Python 2 only syn keyword pythonBuiltin apply buffer coerce intern + " avoid highlighting attributes as builtins + syn match pythonAttribute /\.\h\w*/hs=s+1 contains=ALLBUT,pythonBuiltin transparent endif " From the 'Python Library Reference' class hierarchy at the bottom. diff --git a/runtime/syntax/r.vim b/runtime/syntax/r.vim index e48b6686cb..d96bf96acb 100644 --- a/runtime/syntax/r.vim +++ b/runtime/syntax/r.vim @@ -5,17 +5,21 @@ " Tom Payne " Contributor: Johannes Ranke " Homepage: https://github.com/jalvesaq/R-Vim-runtime -" Last Change: Wed Oct 21, 2015 06:33AM +" Last Change: Thu Mar 10, 2016 12:26PM " Filenames: *.R *.r *.Rhistory *.Rt " " NOTE: The highlighting of R functions is defined in " runtime files created by a filetype plugin, if installed. " " CONFIGURATION: -" syntax folding can be turned on by +" Syntax folding can be turned on by " " let r_syntax_folding = 1 " +" ROxygen highlighting can be turned off by +" +" let r_hl_roxygen = 0 +" " Some lines of code were borrowed from Zhuojun Chen. if exists("b:current_syntax") @@ -24,9 +28,12 @@ endif setlocal iskeyword=@,48-57,_,. -if exists("g:r_syntax_folding") +if exists("g:r_syntax_folding") && g:r_syntax_folding setlocal foldmethod=syntax endif +if !exists("g:r_hl_roxygen") + let g:r_hl_roxygen = 1 +endif syn case match @@ -35,18 +42,20 @@ syn match rCommentTodo contained "\(BUG\|FIXME\|NOTE\|TODO\):" syn match rComment contains=@Spell,rCommentTodo,rOBlock "#.*" " Roxygen -syn region rOBlock start="^\s*\n#\{1,2}' " start="\%^#\{1,2}' " end="^\(#\{1,2}'\)\@!" contains=rOTitle,rOKeyword,rOExamples,@Spell keepend -syn region rOTitle start="^\s*\n#\{1,2}' " start="\%^#\{1,2}' " end="^\(#\{1,2}'\s*$\)\@=" contained contains=rOCommentKey -syn match rOCommentKey "#\{1,2}'" containedin=rOTitle contained +if g:r_hl_roxygen + syn region rOBlock start="^\s*\n#\{1,2}' " start="\%^#\{1,2}' " end="^\(#\{1,2}'\)\@!" contains=rOTitle,rOKeyword,rOExamples,@Spell keepend + syn region rOTitle start="^\s*\n#\{1,2}' " start="\%^#\{1,2}' " end="^\(#\{1,2}'\s*$\)\@=" contained contains=rOCommentKey + syn match rOCommentKey "#\{1,2}'" containedin=rOTitle contained -syn region rOExamples start="^#\{1,2}' @examples.*"rs=e+1,hs=e+1 end="^\(#\{1,2}' @.*\)\@=" end="^\(#\{1,2}'\)\@!" contained contains=rOKeyword + syn region rOExamples start="^#\{1,2}' @examples.*"rs=e+1,hs=e+1 end="^\(#\{1,2}' @.*\)\@=" end="^\(#\{1,2}'\)\@!" contained contains=rOKeyword -syn match rOKeyword contained "@\(param\|return\|name\|rdname\|examples\|example\|include\|docType\)" -syn match rOKeyword contained "@\(S3method\|TODO\|aliases\|alias\|assignee\|author\|callGraphDepth\|callGraph\)" -syn match rOKeyword contained "@\(callGraphPrimitives\|concept\|exportClass\|exportMethod\|exportPattern\|export\|formals\)" -syn match rOKeyword contained "@\(format\|importClassesFrom\|importFrom\|importMethodsFrom\|import\|keywords\|useDynLib\)" -syn match rOKeyword contained "@\(method\|noRd\|note\|references\|seealso\|setClass\|slot\|source\|title\|usage\)" -syn match rOKeyword contained "@\(family\|template\|templateVar\|description\|details\|inheritParams\|field\)" + syn match rOKeyword contained "@\(param\|return\|name\|rdname\|examples\|example\|include\|docType\)" + syn match rOKeyword contained "@\(S3method\|TODO\|aliases\|alias\|assignee\|author\|callGraphDepth\|callGraph\)" + syn match rOKeyword contained "@\(callGraphPrimitives\|concept\|exportClass\|exportMethod\|exportPattern\|export\|formals\)" + syn match rOKeyword contained "@\(format\|importClassesFrom\|importFrom\|importMethodsFrom\|import\|keywords\|useDynLib\)" + syn match rOKeyword contained "@\(method\|noRd\|note\|references\|seealso\|setClass\|slot\|source\|title\|usage\)" + syn match rOKeyword contained "@\(family\|template\|templateVar\|description\|details\|inheritParams\|field\)" +endif if &filetype == "rhelp" @@ -159,12 +168,13 @@ syn match rBraceError "[)}]" contained syn match rCurlyError "[)\]]" contained syn match rParenError "[\]}]" contained -" Source list of R functions produced by a filetype plugin (if installed) -if has("nvim") - " Nvim-R +if !exists("g:R_hi_fun") + let g:R_hi_fun = 1 +endif +if g:R_hi_fun + " Nvim-R: runtime R/functions.vim -else - " Vim-R-plugin + " Vim-R-plugin: runtime r-plugin/functions.vim endif @@ -235,11 +245,13 @@ hi def link rStatement Statement hi def link rString String hi def link rStrError Error hi def link rType Type -hi def link rOKeyword Title -hi def link rOBlock Comment -hi def link rOTitle Title -hi def link rOCommentKey Comment -hi def link rOExamples SpecialComment +if g:r_hl_roxygen + hi def link rOKeyword Title + hi def link rOBlock Comment + hi def link rOTitle Title + hi def link rOCommentKey Comment + hi def link rOExamples SpecialComment +endif let b:current_syntax="r" diff --git a/runtime/syntax/rhelp.vim b/runtime/syntax/rhelp.vim index 32c91add48..47c764e296 100644 --- a/runtime/syntax/rhelp.vim +++ b/runtime/syntax/rhelp.vim @@ -2,25 +2,21 @@ " Language: R Help File " Maintainer: Jakson Aquino " Former Maintainer: Johannes Ranke -" Last Change: Wed Jul 09, 2014 10:28PM +" Homepage: https://github.com/jalvesaq/R-Vim-runtime +" Last Change: Sat Feb 06, 2016 11:34AM " Remarks: - Includes R syntax highlighting in the appropriate " sections if an r.vim file is in the same directory or in the " default debian location. " - There is no Latex markup in equations " - Thanks to Will Gray for finding and fixing a bug -" - No support for \if, \ifelse and \out as I don't understand -" them and have no examples at hand (help welcome). -" - No support for \var tag within quoted string (dito) +" - No support for \var tag within quoted string " Version Clears: {{{1 -" For version 5.x: Clear all syntax items -" For version 6.x and 7.x: Quit when a syntax file was already loaded -if version < 600 - syntax clear -elseif exists("b:current_syntax") +if exists("b:current_syntax") finish endif +scriptencoding utf-8 setlocal iskeyword=@,48-57,_,. syn case match @@ -29,9 +25,11 @@ syn case match syn region rhelpIdentifier matchgroup=rhelpSection start="\\name{" end="}" syn region rhelpIdentifier matchgroup=rhelpSection start="\\alias{" end="}" syn region rhelpIdentifier matchgroup=rhelpSection start="\\pkg{" end="}" contains=rhelpLink +syn region rhelpIdentifier matchgroup=rhelpSection start="\\CRANpkg{" end="}" contains=rhelpLink syn region rhelpIdentifier matchgroup=rhelpSection start="\\method{" end="}" contained syn region rhelpIdentifier matchgroup=rhelpSection start="\\Rdversion{" end="}" + " Highlighting of R code using an existing r.vim syntax file if available {{{1 syn include @R syntax/r.vim @@ -69,76 +67,115 @@ syn match rhelpDelimiter "\\cr" syn match rhelpDelimiter "\\tab " " Keywords {{{1 -syn match rhelpKeyword "\\R" -syn match rhelpKeyword "\\ldots" +syn match rhelpKeyword "\\R\>" +syn match rhelpKeyword "\\ldots\>" +syn match rhelpKeyword "\\sspace\>" syn match rhelpKeyword "--" syn match rhelpKeyword "---" -syn match rhelpKeyword "<" -syn match rhelpKeyword ">" -syn match rhelpKeyword "\\ge" -syn match rhelpKeyword "\\le" -syn match rhelpKeyword "\\alpha" -syn match rhelpKeyword "\\beta" -syn match rhelpKeyword "\\gamma" -syn match rhelpKeyword "\\delta" -syn match rhelpKeyword "\\epsilon" -syn match rhelpKeyword "\\zeta" -syn match rhelpKeyword "\\eta" -syn match rhelpKeyword "\\theta" -syn match rhelpKeyword "\\iota" -syn match rhelpKeyword "\\kappa" -syn match rhelpKeyword "\\lambda" -syn match rhelpKeyword "\\mu" -syn match rhelpKeyword "\\nu" -syn match rhelpKeyword "\\xi" -syn match rhelpKeyword "\\omicron" -syn match rhelpKeyword "\\pi" -syn match rhelpKeyword "\\rho" -syn match rhelpKeyword "\\sigma" -syn match rhelpKeyword "\\tau" -syn match rhelpKeyword "\\upsilon" -syn match rhelpKeyword "\\phi" -syn match rhelpKeyword "\\chi" -syn match rhelpKeyword "\\psi" -syn match rhelpKeyword "\\omega" -syn match rhelpKeyword "\\Alpha" -syn match rhelpKeyword "\\Beta" -syn match rhelpKeyword "\\Gamma" -syn match rhelpKeyword "\\Delta" -syn match rhelpKeyword "\\Epsilon" -syn match rhelpKeyword "\\Zeta" -syn match rhelpKeyword "\\Eta" -syn match rhelpKeyword "\\Theta" -syn match rhelpKeyword "\\Iota" -syn match rhelpKeyword "\\Kappa" -syn match rhelpKeyword "\\Lambda" -syn match rhelpKeyword "\\Mu" -syn match rhelpKeyword "\\Nu" -syn match rhelpKeyword "\\Xi" -syn match rhelpKeyword "\\Omicron" -syn match rhelpKeyword "\\Pi" -syn match rhelpKeyword "\\Rho" -syn match rhelpKeyword "\\Sigma" -syn match rhelpKeyword "\\Tau" -syn match rhelpKeyword "\\Upsilon" -syn match rhelpKeyword "\\Phi" -syn match rhelpKeyword "\\Chi" -syn match rhelpKeyword "\\Psi" -syn match rhelpKeyword "\\Omega" + +" Condition Keywords {{{2 +syn match rhelpKeyword "\\if\>" +syn match rhelpKeyword "\\ifelse\>" +syn match rhelpKeyword "\\out\>" +" Examples of usage: +" \ifelse{latex}{\eqn{p = 5 + 6 - 7 \times 8}}{\eqn{p = 5 + 6 - 7 * 8}} +" \ifelse{latex}{\out{$\alpha$}}{\ifelse{html}{\out{α}}{alpha}} + +" Keywords and operators valid only if in math mode {{{2 +syn match rhelpMathOp "<" contained +syn match rhelpMathOp ">" contained +syn match rhelpMathOp "+" contained +syn match rhelpMathOp "-" contained +syn match rhelpMathOp "=" contained + +" Conceal function based on syntax/tex.vim {{{2 +if exists("g:tex_conceal") + let s:tex_conceal = g:tex_conceal +else + let s:tex_conceal = 'gm' +endif +function s:HideSymbol(pat, cchar, hide) + if a:hide + exe "syn match rhelpMathSymb '" . a:pat . "' contained conceal cchar=" . a:cchar + else + exe "syn match rhelpMathSymb '" . a:pat . "' contained" + endif +endfunction + +" Math symbols {{{2 +if s:tex_conceal =~ 'm' + let s:hd = 1 +else + let s:hd = 0 +endif +call s:HideSymbol('\\infty\>', '∞', s:hd) +call s:HideSymbol('\\ge\>', '≥', s:hd) +call s:HideSymbol('\\le\>', '≤', s:hd) +call s:HideSymbol('\\prod\>', '∏', s:hd) +call s:HideSymbol('\\sum\>', '∑', s:hd) +syn match rhelpMathSymb "\\sqrt\>" contained + +" Greek letters {{{2 +if s:tex_conceal =~ 'g' + let s:hd = 1 +else + let s:hd = 0 +endif +call s:HideSymbol('\\alpha\>', 'α', s:hd) +call s:HideSymbol('\\beta\>', 'β', s:hd) +call s:HideSymbol('\\gamma\>', 'γ', s:hd) +call s:HideSymbol('\\delta\>', 'δ', s:hd) +call s:HideSymbol('\\epsilon\>', 'ϵ', s:hd) +call s:HideSymbol('\\zeta\>', 'ζ', s:hd) +call s:HideSymbol('\\eta\>', 'η', s:hd) +call s:HideSymbol('\\theta\>', 'θ', s:hd) +call s:HideSymbol('\\iota\>', 'ι', s:hd) +call s:HideSymbol('\\kappa\>', 'κ', s:hd) +call s:HideSymbol('\\lambda\>', 'λ', s:hd) +call s:HideSymbol('\\mu\>', 'μ', s:hd) +call s:HideSymbol('\\nu\>', 'ν', s:hd) +call s:HideSymbol('\\xi\>', 'ξ', s:hd) +call s:HideSymbol('\\pi\>', 'π', s:hd) +call s:HideSymbol('\\rho\>', 'ρ', s:hd) +call s:HideSymbol('\\sigma\>', 'σ', s:hd) +call s:HideSymbol('\\tau\>', 'τ', s:hd) +call s:HideSymbol('\\upsilon\>', 'υ', s:hd) +call s:HideSymbol('\\phi\>', 'ϕ', s:hd) +call s:HideSymbol('\\chi\>', 'χ', s:hd) +call s:HideSymbol('\\psi\>', 'ψ', s:hd) +call s:HideSymbol('\\omega\>', 'ω', s:hd) +call s:HideSymbol('\\Gamma\>', 'Γ', s:hd) +call s:HideSymbol('\\Delta\>', 'Δ', s:hd) +call s:HideSymbol('\\Theta\>', 'Θ', s:hd) +call s:HideSymbol('\\Lambda\>', 'Λ', s:hd) +call s:HideSymbol('\\Xi\>', 'Ξ', s:hd) +call s:HideSymbol('\\Pi\>', 'Π', s:hd) +call s:HideSymbol('\\Sigma\>', 'Σ', s:hd) +call s:HideSymbol('\\Upsilon\>', 'Υ', s:hd) +call s:HideSymbol('\\Phi\>', 'Φ', s:hd) +call s:HideSymbol('\\Psi\>', 'Ψ', s:hd) +call s:HideSymbol('\\Omega\>', 'Ω', s:hd) +delfunction s:HideSymbol +" Note: The letters 'omicron', 'Alpha', 'Beta', 'Epsilon', 'Zeta', 'Eta', +" 'Iota', 'Kappa', 'Mu', 'Nu', 'Omicron', 'Rho', 'Tau' and 'Chi' are listed +" at src/library/tools/R/Rd2txt.R because they are valid in HTML, although +" they do not make valid LaTeX code (e.g. Α versus \Alpha). " Links {{{1 -syn region rhelpLink matchgroup=rhelpSection start="\\link{" end="}" contained keepend extend -syn region rhelpLink matchgroup=rhelpSection start="\\link\[.\{-}\]{" end="}" contained keepend extend -syn region rhelpLink matchgroup=rhelpSection start="\\linkS4class{" end="}" contained keepend extend +syn region rhelpLink matchgroup=rhelpType start="\\link{" end="}" contained keepend extend +syn region rhelpLink matchgroup=rhelpType start="\\link\[.\{-}\]{" end="}" contained keepend extend +syn region rhelpLink matchgroup=rhelpType start="\\linkS4class{" end="}" contained keepend extend +syn region rhelpLink matchgroup=rhelpType start="\\url{" end="}" contained keepend extend +syn region rhelpLink matchgroup=rhelpType start="\\href{" end="}" contained keepend extend +syn region rhelpLink matchgroup=rhelpType start="\\figure{" end="}" contained keepend extend " Verbatim like {{{1 -if v:version > 703 - syn region rhelpVerbatim matchgroup=rhelpType start="\\samp{" skip='\\\@1" @@ -148,12 +185,9 @@ syn match rhelpType "\\sQuote\>" syn match rhelpType "\\dQuote\>" syn match rhelpType "\\preformatted\>" syn match rhelpType "\\kbd\>" -syn match rhelpType "\\eqn\>" -syn match rhelpType "\\deqn\>" syn match rhelpType "\\file\>" syn match rhelpType "\\email\>" -syn match rhelpType "\\url\>" -syn match rhelpType "\\href\>" +syn match rhelpType "\\enc\>" syn match rhelpType "\\var\>" syn match rhelpType "\\env\>" syn match rhelpType "\\option\>" @@ -163,6 +197,7 @@ syn match rhelpType "\\renewcommand\>" syn match rhelpType "\\dfn\>" syn match rhelpType "\\cite\>" syn match rhelpType "\\acronym\>" +syn match rhelpType "\\doi\>" " rhelp sections {{{1 syn match rhelpSection "\\encoding\>" @@ -202,9 +237,9 @@ syn match rhelpDelimiter "{\|\[\|(\|)\|\]\|}" syn match rhelpComment /%.*$/ " Error {{{1 -syn region rhelpRegion matchgroup=Delimiter start=/(/ matchgroup=Delimiter end=/)/ contains=@Spell,rhelpCodeSpecial,rhelpComment,rhelpDelimiter,rhelpDots,rhelpFreesec,rhelpFreesubsec,rhelpIdentifier,rhelpKeyword,rhelpLink,rhelpPreProc,rhelpRComment,rhelpRcode,rhelpRegion,rhelpS4method,rhelpSection,rhelpSexpr,rhelpSpecialChar,rhelpString,rhelpType,rhelpVerbatim -syn region rhelpRegion matchgroup=Delimiter start=/{/ matchgroup=Delimiter end=/}/ contains=@Spell,rhelpCodeSpecial,rhelpComment,rhelpDelimiter,rhelpDots,rhelpFreesec,rhelpFreesubsec,rhelpIdentifier,rhelpKeyword,rhelpLink,rhelpPreProc,rhelpRComment,rhelpRcode,rhelpRegion,rhelpS4method,rhelpSection,rhelpSexpr,rhelpSpecialChar,rhelpString,rhelpType,rhelpVerbatim -syn region rhelpRegion matchgroup=Delimiter start=/\[/ matchgroup=Delimiter end=/]/ contains=@Spell,rhelpCodeSpecial,rhelpComment,rhelpDelimiter,rhelpDots,rhelpFreesec,rhelpFreesubsec,rhelpIdentifier,rhelpKeyword,rhelpLink,rhelpPreProc,rhelpRComment,rhelpRcode,rhelpRegion,rhelpS4method,rhelpSection,rhelpSexpr,rhelpSpecialChar,rhelpString,rhelpType,rhelpVerbatim +syn region rhelpRegion matchgroup=Delimiter start=/(/ matchgroup=Delimiter end=/)/ contains=@Spell,rhelpCodeSpecial,rhelpComment,rhelpDelimiter,rhelpDots,rhelpFreesec,rhelpFreesubsec,rhelpIdentifier,rhelpKeyword,rhelpLink,rhelpPreProc,rhelpRComment,rhelpRcode,rhelpRegion,rhelpS4method,rhelpSection,rhelpSexpr,rhelpSpecialChar,rhelpString,rhelpType,rhelpVerbatim,rhelpEquation +syn region rhelpRegion matchgroup=Delimiter start=/{/ matchgroup=Delimiter end=/}/ contains=@Spell,rhelpCodeSpecial,rhelpComment,rhelpDelimiter,rhelpDots,rhelpFreesec,rhelpFreesubsec,rhelpIdentifier,rhelpKeyword,rhelpLink,rhelpPreProc,rhelpRComment,rhelpRcode,rhelpRegion,rhelpS4method,rhelpSection,rhelpSexpr,rhelpSpecialChar,rhelpString,rhelpType,rhelpVerbatim,rhelpEquation +syn region rhelpRegion matchgroup=Delimiter start=/\[/ matchgroup=Delimiter end=/]/ contains=@Spell,rhelpCodeSpecial,rhelpComment,rhelpDelimiter,rhelpDots,rhelpFreesec,rhelpFreesubsec,rhelpIdentifier,rhelpKeyword,rhelpLink,rhelpPreProc,rhelpRComment,rhelpRcode,rhelpRegion,rhelpS4method,rhelpSection,rhelpSexpr,rhelpSpecialChar,rhelpString,rhelpType,rhelpVerbatim,rhelpEquation syn match rhelpError /[)\]}]/ syn match rhelpBraceError /[)}]/ contained syn match rhelpCurlyError /[)\]]/ contained @@ -213,36 +248,27 @@ syn match rhelpParenError /[\]}]/ contained syntax sync match rhelpSyncRcode grouphere rhelpRcode "\\examples{" " Define the default highlighting {{{1 -" For version 5.7 and earlier: only when not done already -" For version 5.8 and later: only when an item doesn't have highlighting yet -if version >= 508 || !exists("did_rhelp_syntax_inits") - if version < 508 - let did_rhelp_syntax_inits = 1 - command -nargs=+ HiLink hi link - else - command -nargs=+ HiLink hi def link - endif - HiLink rhelpVerbatim String - HiLink rhelpDelimiter Delimiter - HiLink rhelpIdentifier Identifier - HiLink rhelpString String - HiLink rhelpCodeSpecial Special - HiLink rhelpKeyword Keyword - HiLink rhelpDots Keyword - HiLink rhelpLink Underlined - HiLink rhelpType Type - HiLink rhelpSection PreCondit - HiLink rhelpError Error - HiLink rhelpBraceError Error - HiLink rhelpCurlyError Error - HiLink rhelpParenError Error - HiLink rhelpPreProc PreProc - HiLink rhelpDelimiter Delimiter - HiLink rhelpComment Comment - HiLink rhelpRComment Comment - HiLink rhelpSpecialChar SpecialChar - delcommand HiLink -endif +hi def link rhelpVerbatim String +hi def link rhelpDelimiter Delimiter +hi def link rhelpIdentifier Identifier +hi def link rhelpString String +hi def link rhelpCodeSpecial Special +hi def link rhelpKeyword Keyword +hi def link rhelpDots Keyword +hi def link rhelpLink Underlined +hi def link rhelpType Type +hi def link rhelpSection PreCondit +hi def link rhelpError Error +hi def link rhelpBraceError Error +hi def link rhelpCurlyError Error +hi def link rhelpParenError Error +hi def link rhelpPreProc PreProc +hi def link rhelpDelimiter Delimiter +hi def link rhelpComment Comment +hi def link rhelpRComment Comment +hi def link rhelpSpecialChar SpecialChar +hi def link rhelpMathSymb Special +hi def link rhelpMathOp Operator let b:current_syntax = "rhelp" diff --git a/runtime/syntax/rmd.vim b/runtime/syntax/rmd.vim index 6f1b847453..4cde7441d3 100644 --- a/runtime/syntax/rmd.vim +++ b/runtime/syntax/rmd.vim @@ -1,15 +1,13 @@ " markdown Text with R statements " Language: markdown with R code chunks -" Last Change: Wed Jul 09, 2014 10:29PM +" Homepage: https://github.com/jalvesaq/R-Vim-runtime +" Last Change: Sat Feb 06, 2016 06:45AM " " CONFIGURATION: " To highlight chunk headers as R code, put in your vimrc: " let rmd_syn_hl_chunk = 1 -" for portability -if version < 600 - syntax clear -elseif exists("b:current_syntax") +if exists("b:current_syntax") finish endif @@ -58,6 +56,8 @@ if rmdIsPandoc == 0 if exists("b:current_syntax") unlet b:current_syntax endif + " Extend cluster + syn cluster texMathZoneGroup add=rmdrInline " Inline syntax match rmdLaTeXInlDelim "\$" syntax match rmdLaTeXInlDelim "\\\$" diff --git a/runtime/syntax/rnoweb.vim b/runtime/syntax/rnoweb.vim index 7d42395b5c..665acc53e2 100644 --- a/runtime/syntax/rnoweb.vim +++ b/runtime/syntax/rnoweb.vim @@ -1,20 +1,14 @@ " Vim syntax file " Language: R noweb Files " Maintainer: Johannes Ranke -" Last Change: 2009 May 05 -" Version: 0.9 -" SVN: $Id: rnoweb.vim 84 2009-05-03 19:52:47Z ranke $ +" Last Change: Sat Feb 06, 2016 06:47AM +" Version: 0.9.1 " Remarks: - This file is inspired by the proposal of -" Fernando Henrique Ferraz Pereira da Rosa -" http://www.ime.usp.br/~feferraz/en/sweavevim.html +" Fernando Henrique Ferraz Pereira da Rosa +" http://www.ime.usp.br/~feferraz/en/sweavevim.html " -" Version Clears: {{{1 -" For version 5.x: Clear all syntax items -" For version 6.x and 7.x: Quit when a syntax file was already loaded -if version < 600 - syntax clear -elseif exists("b:current_syntax") +if exists("b:current_syntax") finish endif @@ -26,21 +20,22 @@ unlet b:current_syntax syn cluster texMatchGroup add=@rnoweb syn cluster texMathMatchGroup add=rnowebSexpr +syn cluster texMathZoneGroup add=rnowebSexpr syn cluster texEnvGroup add=@rnoweb syn cluster texFoldGroup add=@rnoweb -syn cluster texDocGroup add=@rnoweb -syn cluster texPartGroup add=@rnoweb -syn cluster texChapterGroup add=@rnoweb -syn cluster texSectionGroup add=@rnoweb -syn cluster texSubSectionGroup add=@rnoweb -syn cluster texSubSubSectionGroup add=@rnoweb -syn cluster texParaGroup add=@rnoweb +syn cluster texDocGroup add=@rnoweb +syn cluster texPartGroup add=@rnoweb +syn cluster texChapterGroup add=@rnoweb +syn cluster texSectionGroup add=@rnoweb +syn cluster texSubSectionGroup add=@rnoweb +syn cluster texSubSubSectionGroup add=@rnoweb +syn cluster texParaGroup add=@rnoweb " Highlighting of R code using an existing r.vim syntax file if available {{{1 syn include @rnowebR syntax/r.vim syn region rnowebChunk matchgroup=rnowebDelimiter start="^<<.*>>=" matchgroup=rnowebDelimiter end="^@" contains=@rnowebR,rnowebChunkReference,rnowebChunk fold keepend syn match rnowebChunkReference "^<<.*>>$" contained -syn region rnowebSexpr matchgroup=Delimiter start="\\Sexpr{" matchgroup=Delimiter end="}" contains=@rnowebR +syn region rnowebSexpr matchgroup=Delimiter start="\\Sexpr{" matchgroup=Delimiter end="}" contains=@rnowebR contained " Sweave options command {{{1 syn region rnowebSweaveopts matchgroup=Delimiter start="\\SweaveOpts{" matchgroup=Delimiter end="}" diff --git a/runtime/syntax/rrst.vim b/runtime/syntax/rrst.vim index 4667b3a2c1..24d3844df0 100644 --- a/runtime/syntax/rrst.vim +++ b/runtime/syntax/rrst.vim @@ -1,16 +1,14 @@ " reStructured Text with R statements " Language: reST with R code chunks " Maintainer: Alex Zvoleff, azvoleff@mail.sdsu.edu -" Last Change: Wed Jul 09, 2014 10:29PM +" Homepage: https://github.com/jalvesaq/R-Vim-runtime +" Last Change: Sat Feb 06, 2016 06:45AM " " CONFIGURATION: " To highlight chunk headers as R code, put in your vimrc: " let rrst_syn_hl_chunk = 1 -" for portability -if version < 600 - syntax clear -elseif exists("b:current_syntax") +if exists("b:current_syntax") finish endif diff --git a/runtime/syntax/vhdl.vim b/runtime/syntax/vhdl.vim index 044ef83d17..32503823ee 100644 --- a/runtime/syntax/vhdl.vim +++ b/runtime/syntax/vhdl.vim @@ -54,37 +54,37 @@ syn match vhdlError "\" " Types and type qualifiers " Predefined standard VHDL types -syn match vhdlType "bit[\']*" -syn match vhdlType "boolean[\']*" -syn match vhdlType "natural[\']*" -syn match vhdlType "positive[\']*" -syn match vhdlType "integer[\']*" -syn match vhdlType "real[\']*" -syn match vhdlType "time[\']*" +syn match vhdlType "\\'\=" +syn match vhdlType "\\'\=" +syn match vhdlType "\\'\=" +syn match vhdlType "\\'\=" +syn match vhdlType "\\'\=" +syn match vhdlType "\\'\=" +syn match vhdlType "\\'\=" -syn match vhdlType "bit_vector[\']*" -syn match vhdlType "boolean_vector[\']*" -syn match vhdlType "integer_vector[\']*" -syn match vhdlType "real_vector[\']*" -syn match vhdlType "time_vector[\']*" +syn match vhdlType "\\'\=" +syn match vhdlType "\\'\=" +syn match vhdlType "\\'\=" +syn match vhdlType "\\'\=" +syn match vhdlType "\\'\=" -syn match vhdlType "character[\']*" -syn match vhdlType "string[\']*" +syn match vhdlType "\\'\=" +syn match vhdlType "\\'\=" "syn keyword vhdlType severity_level -syn match vhdlType "line[\']*" -syn match vhdlType "text[\']*" +syn keyword vhdlType line +syn keyword vhdlType text " Predefined standard IEEE VHDL types -syn match vhdlType "std_ulogic[\']*" -syn match vhdlType "std_logic[\']*" -syn match vhdlType "std_ulogic_vector[\']*" -syn match vhdlType "std_logic_vector[\']*" -syn match vhdlType "unresolved_signed[\']*" -syn match vhdlType "unresolved_unsigned[\']*" -syn match vhdlType "u_signed[\']*" -syn match vhdlType "u_unsigned[\']*" -syn match vhdlType "signed[\']*" -syn match vhdlType "unsigned[\']*" +syn match vhdlType "\\'\=" +syn match vhdlType "\\'\=" +syn match vhdlType "\\'\=" +syn match vhdlType "\\'\=" +syn match vhdlType "\\'\=" +syn match vhdlType "\\'\=" +syn match vhdlType "\\'\=" +syn match vhdlType "\\'\=" +syn match vhdlType "\\'\=" +syn match vhdlType "\\'\=" " array attributes From 26f74fdf61827f5afc6fe4e90b9e9497264cb039 Mon Sep 17 00:00:00 2001 From: James McCoy Date: Mon, 20 Jun 2016 20:24:13 -0400 Subject: [PATCH 16/34] 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 +- test/functional/legacy/packadd_spec.lua | 22 ++++++++++++++++++++++ 5 files changed, 39 insertions(+), 5 deletions(-) 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, diff --git a/test/functional/legacy/packadd_spec.lua b/test/functional/legacy/packadd_spec.lua index e84a8e60d6..5006981f8f 100644 --- a/test/functional/legacy/packadd_spec.lua +++ b/test/functional/legacy/packadd_spec.lua @@ -73,6 +73,23 @@ describe('packadd', function() packadd! mytest call assert_equal(new_rtp, &rtp) endfunc + + func Test_packloadall() + let plugindir = &packpath . '/pack/mine/start/foo/plugin' + call mkdir(plugindir, 'p') + call writefile(['let g:plugin_foo_number = 1234'], plugindir . '/bar.vim') + packloadall + call assert_equal(1234, g:plugin_foo_number) + + " only works once + call writefile(['let g:plugin_bar_number = 4321'], plugindir . '/bar2.vim') + packloadall + call assert_false(exists('g:plugin_bar_number')) + + " works when ! used + packloadall! + call assert_equal(4321, g:plugin_bar_number) + endfunc ]=]) call('SetUp') end) @@ -91,6 +108,11 @@ describe('packadd', function() expected_empty() end) + it('works with :packloadall', function() + call('Test_packloadall') + expected_empty() + end) + describe('command line completion', function() local Screen = require('test.functional.ui.screen') local screen From 55dcf0918c364dd58e700cde5f2efbf7da4b3051 Mon Sep 17 00:00:00 2001 From: James McCoy Date: Mon, 20 Jun 2016 21:04:08 -0400 Subject: [PATCH 17/34] 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 + test/functional/legacy/packadd_spec.lua | 22 +++ 5 files changed, 157 insertions(+), 116 deletions(-) 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 */ diff --git a/test/functional/legacy/packadd_spec.lua b/test/functional/legacy/packadd_spec.lua index 5006981f8f..296ec315a7 100644 --- a/test/functional/legacy/packadd_spec.lua +++ b/test/functional/legacy/packadd_spec.lua @@ -90,6 +90,23 @@ describe('packadd', function() packloadall! call assert_equal(4321, g:plugin_bar_number) endfunc + + func Test_helptags() + let docdir1 = &packpath . '/pack/mine/start/foo/doc' + let docdir2 = &packpath . '/pack/mine/start/bar/doc' + call mkdir(docdir1, 'p') + call mkdir(docdir2, 'p') + call writefile(['look here: *look-here*'], docdir1 . '/bar.txt') + call writefile(['look away: *look-away*'], docdir2 . '/foo.txt') + exe 'set rtp=' . &packpath . '/pack/mine/start/foo,' . &packpath . '/pack/mine/start/bar' + + helptags ALL + + let tags1 = readfile(docdir1 . '/tags') + call assert_true(tags1[0] =~ 'look-here') + let tags2 = readfile(docdir2 . '/tags') + call assert_true(tags2[0] =~ 'look-away') + endfunc ]=]) call('SetUp') end) @@ -113,6 +130,11 @@ describe('packadd', function() expected_empty() end) + it('works with helptags', function() + call('Test_helptags') + expected_empty() + end) + describe('command line completion', function() local Screen = require('test.functional.ui.screen') local screen From 080476882be32768a97e26af22133435ccb8fc2a Mon Sep 17 00:00:00 2001 From: James McCoy Date: Mon, 20 Jun 2016 20:34:24 -0400 Subject: [PATCH 18/34] 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 +++--- test/functional/legacy/packadd_spec.lua | 25 +++++++++++++++ 13 files changed, 85 insertions(+), 36 deletions(-) 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 */ diff --git a/test/functional/legacy/packadd_spec.lua b/test/functional/legacy/packadd_spec.lua index 296ec315a7..4def2130df 100644 --- a/test/functional/legacy/packadd_spec.lua +++ b/test/functional/legacy/packadd_spec.lua @@ -107,6 +107,26 @@ describe('packadd', function() let tags2 = readfile(docdir2 . '/tags') call assert_true(tags2[0] =~ 'look-away') endfunc + + func Test_colorscheme() + let colordirrun = &packpath . '/runtime/colors' + let colordirstart = &packpath . '/pack/mine/start/foo/colors' + let colordiropt = &packpath . '/pack/mine/opt/bar/colors' + call mkdir(colordirrun, 'p') + call mkdir(colordirstart, 'p') + call mkdir(colordiropt, 'p') + call writefile(['let g:found_one = 1'], colordirrun . '/one.vim') + call writefile(['let g:found_two = 1'], colordirstart . '/two.vim') + call writefile(['let g:found_three = 1'], colordiropt . '/three.vim') + exe 'set rtp=' . &packpath . '/runtime' + + colorscheme one + call assert_equal(1, g:found_one) + colorscheme two + call assert_equal(1, g:found_two) + colorscheme three + call assert_equal(1, g:found_three) + endfunc ]=]) call('SetUp') end) @@ -135,6 +155,11 @@ describe('packadd', function() expected_empty() end) + it('works with colorschemes', function() + call('Test_colorscheme') + expected_empty() + end) + describe('command line completion', function() local Screen = require('test.functional.ui.screen') local screen From 53613e7fcd27feda32844904f4ef88bf82841015 Mon Sep 17 00:00:00 2001 From: James McCoy Date: Tue, 21 Jun 2016 23:13:46 -0400 Subject: [PATCH 19/34] vim-patch:7.4.1553 Problem: ":runtime" does not use 'packpath'. Solution: Add "what" argument. https://github.com/vim/vim/commit/8dcf259d904cfb965d31841dc74a5cfaf5a351d9 --- runtime/doc/repeat.txt | 36 ++++++++++++++--- src/nvim/ex_cmds2.c | 33 +++++++++++++--- src/nvim/version.c | 2 +- src/nvim/vim.h | 1 + test/functional/legacy/packadd_spec.lua | 52 +++++++++++++++++++++++++ 5 files changed, 113 insertions(+), 11 deletions(-) diff --git a/runtime/doc/repeat.txt b/runtime/doc/repeat.txt index 8fcecfd5c0..5357090b1b 100644 --- a/runtime/doc/repeat.txt +++ b/runtime/doc/repeat.txt @@ -174,10 +174,12 @@ For writing a Vim script, see chapter 41 of the user manual |usr_41.txt|. commands. *:ru* *:runtime* -:ru[ntime][!] {file} .. +:ru[ntime][!] [where] {file} .. Read Ex commands from {file} in each directory given - by 'runtimepath'. There is no error for non-existing - files. Example: > + by 'runtimepath' and/or 'packpath'. There is no error + for non-existing files. + + Example: > :runtime syntax/c.vim < There can be multiple {file} arguments, separated by @@ -191,6 +193,15 @@ For writing a Vim script, see chapter 41 of the user manual |usr_41.txt|. When it is not included only the first found file is sourced. + When [where] is omitted only 'runtimepath' is used. + Other values: + START search under "start" in 'packpath' + OPT search under "opt" in 'packpath' + PACK search under "start" and "opt" in + 'packpath' + ALL first use 'runtimepath', then search + under "start" and "opt" in 'packpath' + When {file} contains wildcards it is expanded to all matching files. Example: > :runtime! plugin/*.vim @@ -229,6 +240,16 @@ For writing a Vim script, see chapter 41 of the user manual |usr_41.txt|. Also see |pack-add|. +:packloadall[!] Load all packages in the "start" directories under + 'packpath'. The directories found are added to + 'runtimepath'. + This normally done during startup, after loading your + .vimrc file. With this command it can be done + earlier. + Packages will be loaded only once. After this command + it won't happen again. When the optional ! is added + this command will load packages even when done before. + See |packages|. :scripte[ncoding] [encoding] *:scripte* *:scriptencoding* *E167* Specify the character encoding used in the script. @@ -446,8 +467,13 @@ Note that the files under "pack/foo/opt" or not loaded automatically, only the ones under "pack/foo/start". See |pack-add| below for how the "opt" directory is used. -Loading packages will not happen if loading plugins is disabled, see -|load-plugins|. +Loading packages automatically will not happen if loading plugins is disabled, +see |load-plugins|. + +To load packages earlier, so that 'runtimepath' gets updated: > + :packloadall +This also works when loading plugins is disabled. The automatic loading will +only happen once. Using a single plugin and loading it automatically ~ 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 (done == FAIL && (flags & DIP_START)) { + if ((flags & DIP_NORTP) == 0) { + done = do_in_path(p_rtp, name, flags, callback, cookie); + } + + if ((done == FAIL || (flags & DIP_ALL)) && (flags & DIP_START)) { char *start_dir = "pack/*/start/*/%s"; size_t len = STRLEN(start_dir) + STRLEN(name); char_u *s = xmallocz(len); @@ -2401,7 +2424,7 @@ int do_in_runtimepath(char_u *name, int flags, DoInRuntimepathCB callback, xfree(s); } - if (done == FAIL && (flags & DIP_OPT)) { + if ((done == FAIL || (flags & DIP_ALL)) && (flags & DIP_OPT)) { char *opt_dir = "pack/*/opt/*/%s"; size_t len = STRLEN(opt_dir) + STRLEN(name); char_u *s = xmallocz(len); 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 */ diff --git a/test/functional/legacy/packadd_spec.lua b/test/functional/legacy/packadd_spec.lua index 4def2130df..509d52123d 100644 --- a/test/functional/legacy/packadd_spec.lua +++ b/test/functional/legacy/packadd_spec.lua @@ -127,6 +127,53 @@ describe('packadd', function() colorscheme three call assert_equal(1, g:found_three) endfunc + + func Test_runtime() + let rundir = &packpath . '/runtime/extra' + let startdir = &packpath . '/pack/mine/start/foo/extra' + let optdir = &packpath . '/pack/mine/opt/bar/extra' + call mkdir(rundir, 'p') + call mkdir(startdir, 'p') + call mkdir(optdir, 'p') + call writefile(['let g:sequence .= "run"'], rundir . '/bar.vim') + call writefile(['let g:sequence .= "start"'], startdir . '/bar.vim') + call writefile(['let g:sequence .= "foostart"'], startdir . '/foo.vim') + call writefile(['let g:sequence .= "opt"'], optdir . '/bar.vim') + call writefile(['let g:sequence .= "xxxopt"'], optdir . '/xxx.vim') + exe 'set rtp=' . &packpath . '/runtime' + + let g:sequence = '' + runtime extra/bar.vim + call assert_equal('run', g:sequence) + let g:sequence = '' + runtime START extra/bar.vim + call assert_equal('start', g:sequence) + let g:sequence = '' + runtime OPT extra/bar.vim + call assert_equal('opt', g:sequence) + let g:sequence = '' + runtime PACK extra/bar.vim + call assert_equal('start', g:sequence) + let g:sequence = '' + runtime! PACK extra/bar.vim + call assert_equal('startopt', g:sequence) + let g:sequence = '' + runtime PACK extra/xxx.vim + call assert_equal('xxxopt', g:sequence) + + let g:sequence = '' + runtime ALL extra/bar.vim + call assert_equal('run', g:sequence) + let g:sequence = '' + runtime ALL extra/foo.vim + call assert_equal('foostart', g:sequence) + let g:sequence = '' + runtime! ALL extra/xxx.vim + call assert_equal('xxxopt', g:sequence) + let g:sequence = '' + runtime! ALL extra/bar.vim + call assert_equal('runstartopt', g:sequence) + endfunc ]=]) call('SetUp') end) @@ -160,6 +207,11 @@ describe('packadd', function() expected_empty() end) + it('works with :runtime [what]', function() + call('Test_runtime') + expected_empty() + end) + describe('command line completion', function() local Screen = require('test.functional.ui.screen') local screen From 443d335ce31929f0e1c3b2ad6e403f98067c9526 Mon Sep 17 00:00:00 2001 From: James McCoy Date: Wed, 22 Jun 2016 11:04:46 -0400 Subject: [PATCH 20/34] 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 +- test/functional/legacy/packadd_spec.lua | 47 +++++++++++++++++++++++++ 3 files changed, 82 insertions(+), 11 deletions(-) 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, diff --git a/test/functional/legacy/packadd_spec.lua b/test/functional/legacy/packadd_spec.lua index 509d52123d..d85467ced1 100644 --- a/test/functional/legacy/packadd_spec.lua +++ b/test/functional/legacy/packadd_spec.lua @@ -271,5 +271,52 @@ describe('packadd', function() :packadd ^ | ]=]) end) + + it('works for colorschemes', function() + source([[ + let colordirrun = &packpath . '/runtime/colors' + let colordirstart = &packpath . '/pack/mine/start/foo/colors' + let colordiropt = &packpath . '/pack/mine/opt/bar/colors' + call mkdir(colordirrun, 'p') + call mkdir(colordirstart, 'p') + call mkdir(colordiropt, 'p') + call writefile(['let g:found_one = 1'], colordirrun . '/one.vim') + call writefile(['let g:found_two = 1'], colordirstart . '/two.vim') + call writefile(['let g:found_three = 1'], colordiropt . '/three.vim') + exe 'set rtp=' . &packpath . '/runtime']]) + + feed(':colorscheme ') + screen:expect([=[ + | + ~ | + ~ | + {1:one}{2: three two }| + :colorscheme one^ | + ]=]) + feed('') + screen:expect([=[ + | + ~ | + ~ | + {2:one }{1:three}{2: two }| + :colorscheme three^ | + ]=]) + feed('') + screen:expect([=[ + | + ~ | + ~ | + {2:one three }{1:two}{2: }| + :colorscheme two^ | + ]=]) + feed('') + screen:expect([=[ + | + ~ | + ~ | + {2:one three two }| + :colorscheme ^ | + ]=]) + end) end) end) From 4bd14e921b7ac56560f53d54aba1380bc7bc0689 Mon Sep 17 00:00:00 2001 From: James McCoy Date: Wed, 22 Jun 2016 20:10:37 -0400 Subject: [PATCH 21/34] 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(-) 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 From 0b2633b1bb3a73dae7679bf9bec0dc9f5e75fe44 Mon Sep 17 00:00:00 2001 From: James McCoy Date: Wed, 22 Jun 2016 20:24:20 -0400 Subject: [PATCH 22/34] vim-patch:e18c0b3 Updated runtime files. https://github.com/vim/vim/commit/e18c0b39815c5a746887a509c2cd9f11fadaba07 Ignore changes to * doc/channel.txt, runtime/tools/demoserver.py: Channel related changes * doc/if_lua.txt, doc/if_perl.txt, doc/if_pyth.txt, doc/if_ruby.txt, doc/if_tcl.txt, doc/todo.txt: Irrelevant to Neovim * doc/tags: Generated at build time --- runtime/doc/helphelp.txt | 5 ++++- runtime/doc/index.txt | 3 ++- runtime/doc/quickfix.txt | 6 +++++- runtime/doc/repeat.txt | 11 +++++++---- runtime/doc/syntax.txt | 8 ++++---- runtime/doc/usr_41.txt | 6 ++++-- runtime/doc/various.txt | 3 ++- runtime/optwin.vim | 2 +- 8 files changed, 29 insertions(+), 15 deletions(-) diff --git a/runtime/doc/helphelp.txt b/runtime/doc/helphelp.txt index f3533b8815..2a098544c6 100644 --- a/runtime/doc/helphelp.txt +++ b/runtime/doc/helphelp.txt @@ -1,4 +1,4 @@ -*helphelp.txt* For Vim version 7.4. Last change: 2014 Sep 19 +*helphelp.txt* For Vim version 7.4. Last change: 2016 Mar 12 VIM REFERENCE MANUAL by Bram Moolenaar @@ -188,6 +188,9 @@ command: > *E154* *E150* *E151* *E152* *E153* *E670* :helpt[ags] [++t] {dir} Generate the help tags file(s) for directory {dir}. + When {dir} is ALL then all "doc" directories in + 'runtimepath' will be used. + All "*.txt" and "*.??x" files in the directory and sub-directories are scanned for a help tag definition in between stars. The "*.??x" files are for diff --git a/runtime/doc/index.txt b/runtime/doc/index.txt index eff03c8daf..bd2df5d1e5 100644 --- a/runtime/doc/index.txt +++ b/runtime/doc/index.txt @@ -1,4 +1,4 @@ -*index.txt* For Vim version 7.4. Last change: 2016 Mar 04 +*index.txt* For Vim version 7.4. Last change: 2016 Mar 12 VIM REFERENCE MANUAL by Bram Moolenaar @@ -1379,6 +1379,7 @@ tag command action ~ |:ounmenu| :ounme[nu] remove menu for Operator-pending mode |:ownsyntax| :ow[nsyntax] set new local syntax highlight for this window |:packadd| :pa[ckadd] add a plugin from 'packpath' +|:packloadall| :packl[oadall] load all packages under 'packpath' |:pclose| :pc[lose] close preview window |:pedit| :ped[it] edit file in the preview window |:print| :p[rint] print lines diff --git a/runtime/doc/quickfix.txt b/runtime/doc/quickfix.txt index 317226108f..3b54faf18e 100644 --- a/runtime/doc/quickfix.txt +++ b/runtime/doc/quickfix.txt @@ -1,4 +1,4 @@ -*quickfix.txt* For Vim version 7.4. Last change: 2016 Jan 21 +*quickfix.txt* For Vim version 7.4. Last change: 2016 Mar 19 VIM REFERENCE MANUAL by Bram Moolenaar @@ -49,6 +49,10 @@ The following quickfix commands can be used. The location list commands are similar to the quickfix commands, replacing the 'c' prefix in the quickfix command with 'l'. + *E924* +If the current window was closed by an |autocommand| while processing a +location list command, it will be aborted. + *:cc* :cc[!] [nr] Display error [nr]. If [nr] is omitted, the same error is displayed again. Without [!] this doesn't diff --git a/runtime/doc/repeat.txt b/runtime/doc/repeat.txt index 5357090b1b..2a20a42c16 100644 --- a/runtime/doc/repeat.txt +++ b/runtime/doc/repeat.txt @@ -1,4 +1,4 @@ -*repeat.txt* For Vim version 7.4. Last change: 2016 Mar 09 +*repeat.txt* For Vim version 7.4. Last change: 2016 Mar 15 VIM REFERENCE MANUAL by Bram Moolenaar @@ -240,15 +240,18 @@ For writing a Vim script, see chapter 41 of the user manual |usr_41.txt|. Also see |pack-add|. + *:packl* *:packloadall* :packloadall[!] Load all packages in the "start" directories under 'packpath'. The directories found are added to 'runtimepath'. - This normally done during startup, after loading your - .vimrc file. With this command it can be done - earlier. + This is normally done automatically during startup, + after loading your .vimrc file. With this command it + can be done earlier. Packages will be loaded only once. After this command it won't happen again. When the optional ! is added this command will load packages even when done before. + An Error only causes sourcing the script where it + happens to be aborted, further plugins will be loaded. See |packages|. :scripte[ncoding] [encoding] *:scripte* *:scriptencoding* *E167* diff --git a/runtime/doc/syntax.txt b/runtime/doc/syntax.txt index b6f1e4d856..9bec855190 100644 --- a/runtime/doc/syntax.txt +++ b/runtime/doc/syntax.txt @@ -1,4 +1,4 @@ -*syntax.txt* For Vim version 7.4. Last change: 2016 Feb 25 +*syntax.txt* For Vim version 7.4. Last change: 2016 Mar 12 VIM REFERENCE MANUAL by Bram Moolenaar @@ -4518,9 +4518,9 @@ in their own color. :colo[rscheme] {name} Load color scheme {name}. This searches 'runtimepath' for the file "colors/{name}.vim". The first one that is found is loaded. - To see the name of the currently active color scheme: > - :colo -< The name is also stored in the g:colors_name variable. + Also searches all plugins in 'packpath', first below + "start" and then under "opt". + Doesn't work recursively, thus you can't use ":colorscheme" in a color scheme script. After the color scheme has been loaded the diff --git a/runtime/doc/usr_41.txt b/runtime/doc/usr_41.txt index a14e722328..f57e237a01 100644 --- a/runtime/doc/usr_41.txt +++ b/runtime/doc/usr_41.txt @@ -1,4 +1,4 @@ -*usr_41.txt* For Vim version 7.4. Last change: 2016 Feb 14 +*usr_41.txt* For Vim version 7.4. Last change: 2016 Mar 15 VIM USER MANUAL - by Bram Moolenaar @@ -889,9 +889,11 @@ Mappings: *mapping-functions* wildmenumode() check if the wildmode is active Testing: *test-functions* - assert_equal() assert that two expressions values are equal + assert_equal() assert that two expressions values are equal assert_false() assert that an expression is false assert_true() assert that an expression is true + assert_exception() assert that a command throws an exception + assert_fails() assert that a function call fails Various: *various-functions* mode() get current editing mode diff --git a/runtime/doc/various.txt b/runtime/doc/various.txt index b3e5e2db03..eb813866da 100644 --- a/runtime/doc/various.txt +++ b/runtime/doc/various.txt @@ -1,4 +1,4 @@ -*various.txt* For Vim version 7.4. Last change: 2016 Feb 27 +*various.txt* For Vim version 7.4. Last change: 2016 Mar 20 VIM REFERENCE MANUAL by Bram Moolenaar @@ -375,6 +375,7 @@ B *+termguicolors* 24-bit color in xterm-compatible terminals support N *+termresponse* support for |t_RV| and |v:termresponse| N *+textobjects* |text-objects| selection *+tgetent* non-Unix only: able to use external termcap +N *+timers* the |timer_start()| function N *+title* Setting the window 'title' and 'icon' N *+toolbar* |gui-toolbar| N *+user_commands* User-defined commands. |user-commands| diff --git a/runtime/optwin.vim b/runtime/optwin.vim index 7e58c76ec4..bfcf4d5294 100644 --- a/runtime/optwin.vim +++ b/runtime/optwin.vim @@ -1,7 +1,7 @@ " These commands create the option window. " " Maintainer: Bram Moolenaar -" Last Change: 2016 Feb 21 +" Last Change: 2016 Mar 19 " If there already is an option window, jump to that one. if bufwinnr("option-window") > 0 From 5f471b24865755fc00017c0470dc987bccd4405b Mon Sep 17 00:00:00 2001 From: James McCoy Date: Wed, 22 Jun 2016 22:05:27 -0400 Subject: [PATCH 23/34] vim-patch:4f3f668 Updated runtime files. https://github.com/vim/vim/commit/4f3f668c8486444e53163c29d2fc79bf47eb3c82 Ignore changes to * doc/channel.txt: Channel related docs * doc/tags: Generated at build time * doc/todo.txt: Irrelevant to Neovim --- runtime/doc/autocmd.txt | 2 +- runtime/doc/eval.txt | 3 +- runtime/doc/helphelp.txt | 4 +- runtime/doc/options.txt | 7 +-- runtime/doc/repeat.txt | 103 ++++++++++++++++++++++++++++++++++----- runtime/doc/starting.txt | 9 ++-- 6 files changed, 105 insertions(+), 23 deletions(-) diff --git a/runtime/doc/autocmd.txt b/runtime/doc/autocmd.txt index 6641732679..dc37ff1d6d 100644 --- a/runtime/doc/autocmd.txt +++ b/runtime/doc/autocmd.txt @@ -1,4 +1,4 @@ -*autocmd.txt* For Vim version 7.4. Last change: 2015 Dec 05 +*autocmd.txt* For Vim version 7.4. Last change: 2016 Mar 26 VIM REFERENCE MANUAL by Bram Moolenaar diff --git a/runtime/doc/eval.txt b/runtime/doc/eval.txt index 712a0d7e5a..0bd5c04344 100644 --- a/runtime/doc/eval.txt +++ b/runtime/doc/eval.txt @@ -1,4 +1,4 @@ -*eval.txt* For Vim version 7.4. Last change: 2016 Mar 08 +*eval.txt* For Vim version 7.4. Last change: 2016 Mar 26 VIM REFERENCE MANUAL by Bram Moolenaar @@ -7408,6 +7408,7 @@ unix Unix version of Vim. user_commands User-defined commands. vertsplit Compiled with vertically split windows |:vsplit|. vim_starting True while initial source'ing takes place. |startup| + *vim_starting* virtualedit Compiled with 'virtualedit' option. visual Compiled with Visual mode. visualextra Compiled with extra Visual mode commands. diff --git a/runtime/doc/helphelp.txt b/runtime/doc/helphelp.txt index 2a098544c6..95d280c529 100644 --- a/runtime/doc/helphelp.txt +++ b/runtime/doc/helphelp.txt @@ -1,4 +1,4 @@ -*helphelp.txt* For Vim version 7.4. Last change: 2016 Mar 12 +*helphelp.txt* For Vim version 7.4. Last change: 2016 Mar 26 VIM REFERENCE MANUAL by Bram Moolenaar @@ -199,9 +199,11 @@ command: > sorted. When there are duplicates an error message is given. An existing tags file is silently overwritten. + The optional "++t" argument forces adding the "help-tags" tag. This is also done when the {dir} is equal to $VIMRUNTIME/doc. + To rebuild the help tags in the runtime directory (requires write permission there): > :helptags $VIMRUNTIME/doc diff --git a/runtime/doc/options.txt b/runtime/doc/options.txt index 76ecb57e34..669f74186c 100644 --- a/runtime/doc/options.txt +++ b/runtime/doc/options.txt @@ -1,4 +1,4 @@ -*options.txt* For Vim version 7.4. Last change: 2016 Mar 08 +*options.txt* For Vim version 7.4. Last change: 2016 Mar 24 VIM REFERENCE MANUAL by Bram Moolenaar @@ -2458,8 +2458,8 @@ A jump table for the options with a short description can be found at |Q_op|. file only, the option is not changed. When 'binary' is set, the value of 'fileformats' is not used. - Note that when Vim starts up with an empty buffer this option is not - used. Set 'fileformat' in your vimrc instead. + When Vim starts up with an empty buffer the first item is used. You + can overrule this by setting 'fileformat' in your .vimrc. For systems with a Dos-like (), when reading files that are ":source"ed and for vimrc files, automatic detection may be @@ -4238,6 +4238,7 @@ A jump table for the options with a short description can be found at |Q_op|. written. A ":set nomodified" command also resets the original values to the current values and the 'modified' option will be reset. + Similarly for 'eol' and 'bomb'. This option is not set when a change is made to the buffer as the result of a BufNewFile, BufRead/BufReadPost, BufWritePost, FileAppendPost or VimLeave autocommand event. See |gzip-example| for diff --git a/runtime/doc/repeat.txt b/runtime/doc/repeat.txt index 2a20a42c16..a5785fb714 100644 --- a/runtime/doc/repeat.txt +++ b/runtime/doc/repeat.txt @@ -1,4 +1,4 @@ -*repeat.txt* For Vim version 7.4. Last change: 2016 Mar 15 +*repeat.txt* For Vim version 7.4. Last change: 2016 Mar 26 VIM REFERENCE MANUAL by Bram Moolenaar @@ -8,13 +8,14 @@ Repeating commands, Vim scripts and debugging *repeating* Chapter 26 of the user manual introduces repeating |usr_26.txt|. -1. Single repeats |single-repeat| -2. Multiple repeats |multi-repeat| -3. Complex repeats |complex-repeat| -4. Using Vim scripts |using-scripts| -5. Using Vim packages |packages| -6. Debugging scripts |debug-scripts| -7. Profiling |profiling| +1. Single repeats |single-repeat| +2. Multiple repeats |multi-repeat| +3. Complex repeats |complex-repeat| +4. Using Vim scripts |using-scripts| +5. Using Vim packages |packages| +6. Creating Vim packages |package-create| +7. Debugging scripts |debug-scripts| +8. Profiling |profiling| ============================================================================== 1. Single repeats *single-repeat* @@ -466,7 +467,7 @@ find the syntax/some.vim file, because its directory is in 'runtimepath'. Vim will also load ftdetect files, if there are any. -Note that the files under "pack/foo/opt" or not loaded automatically, only the +Note that the files under "pack/foo/opt" are not loaded automatically, only the ones under "pack/foo/start". See |pack-add| below for how the "opt" directory is used. @@ -502,14 +503,90 @@ This searches for "pack/*/opt/foodebug" in 'packpath' and will find ~/.local/share/nvim/site/pack/foo/opt/foodebug/plugin/debugger.vim and source it. -This could be done inside always.vim, if some conditions are met. Or you -could add this command to your |.vimrc|. +This could be done if some conditions are met. For example, depending on +whether Vim supports a feature or a dependency is missing. + +You can also load an optional plugin at startup, by putting this command in +your |.vimrc|: > + :packadd! foodebug +The extra "!" is so that the plugin isn't loaded with Vim was started with +|--noplugin|. It is perfectly normal for a package to only have files in the "opt" directory. You then need to load each plugin when you want to use it. + +Where to put what ~ + +Since color schemes, loaded with `:colorscheme`, are found below +"pack/*/start" and "pack/*/opt", you could put them anywhere. We recommend +you put them below "pack/*/opt", for example +".vim/pack/mycolors/opt/dark/colors/very_dark.vim". + +Filetype plugins should go under "pack/*/start", so that they are always +found. Unless you have more than one plugin for a file type and want to +select which one to load with `:packadd`. E.g. depending on the compiler +version: > + if foo_compiler_version > 34 + packadd foo_new + else + packadd foo_old + endif + +The "after" directory is most likely not useful in a package. It's not +disallowed though. + ============================================================================== -6. Debugging scripts *debug-scripts* +6. Creating Vim packages *package-create* + +This assumes you write one or more plugins that you distribute as a package. + +If you have two unrelated plugins you would use two packages, so that Vim +users can chose what they include or not. Or you can decide to use one +package with optional plugins, and tell the user to add the ones he wants with +`:packadd`. + +Decide how you want to distribute the package. You can create an archive or +you could use a repository. An archive can be used by more users, but is a +bit harder to update to a new version. A repository can usually be kept +up-to-date easily, but it requires a program like "git" to be available. +You can do both, github can automatically create an archive for a release. + +Your directory layout would be like this: + start/foobar/plugin/foo.vim " always loaded, defines commands + start/foobar/plugin/bar.vim " always loaded, defines commands + start/foobar/autoload/foo.vim " loaded when foo command used + start/foobar/doc/foo.txt " help for foo.vim + start/foobar/doc/tags " help tags + opt/fooextra/plugin/extra.vim " optional plugin, defines commands + opt/fooextra/autoload/extra.vim " loaded when extra command used + opt/fooextra/doc/extra.txt " help for extra.vim + opt/fooextra/doc/tags " help tags + +This allows for the user to do: > + mkdir ~/.local/share/nvim/site/pack/myfoobar + cd ~/.local/share/nvim/site/pack/myfoobar + git clone https://github.com/you/foobar.git + +Here "myfoobar" is a name that the user can choose, the only condition is that +it differs from other packages. + +In your documentation you explain what the plugins do, and tell the user how +to load the optional plugin: > + :packadd! fooextra + +You could add this packadd command in one of your plugins, to be executed when +the optional plugin is needed. + +Run the `:helptags` command to generate the doc/tags file. Including this +generated file in the package means that the user can drop the package in his +pack directory and the help command works right away. Don't forget to re-run +the command after changing the plugin help: > + :helptags path/start/foobar/doc + :helptags path/opt/fooextra/doc + +============================================================================== +7. Debugging scripts *debug-scripts* Besides the obvious messages that you can add to your scripts to find out what they are doing, Vim offers a debug mode. This allows you to step through a @@ -733,7 +810,7 @@ OBSCURE user, don't use typeahead for debug commands. ============================================================================== -7. Profiling *profile* *profiling* +8. Profiling *profile* *profiling* Profiling means that Vim measures the time that is spent on executing functions and/or scripts. The |+profile| feature is required for this. diff --git a/runtime/doc/starting.txt b/runtime/doc/starting.txt index bda5254663..4829307706 100644 --- a/runtime/doc/starting.txt +++ b/runtime/doc/starting.txt @@ -1,4 +1,4 @@ -*starting.txt* For Vim version 7.4. Last change: 2016 Mar 05 +*starting.txt* For Vim version 7.4. Last change: 2016 Mar 26 VIM REFERENCE MANUAL by Bram Moolenaar @@ -465,8 +465,8 @@ accordingly. Vim proceeds in this order: use "--cmd 'set noloadplugins'" |--cmd|. Plugin packs are loaded. These are plugins, as above, but found in - 'packpath' directories. Every plugin directory found is added in - 'runtimepath'. See |packages|. + 'packpath' "start" directories. Every plugin directory found is added + in 'runtimepath'. See |packages|. 7. Set 'shellpipe' and 'shellredir' The 'shellpipe' and 'shellredir' options are set according to the @@ -503,8 +503,9 @@ accordingly. Vim proceeds in this order: 14. Execute startup commands If a "-t" flag was given to Vim, the tag is jumped to. The commands given with the |-c| and |+cmd| arguments are executed. - The starting flag is reset, has("vim_starting") will now return zero. If the 'insertmode' option is set, Insert mode is entered. + The starting flag is reset, has("vim_starting") will now return zero. + The |v:vim_did_enter| variable is set to 1. The |VimEnter| autocommands are executed. Some hints on using initializations: From 99e51b81e6ef4c62232429159e893bf748fc5fad Mon Sep 17 00:00:00 2001 From: James McCoy Date: Wed, 22 Jun 2016 22:39:30 -0400 Subject: [PATCH 24/34] 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. --- runtime/doc/usr_05.txt | 58 ++++++++++++++++++++++++++++++++++------- runtime/doc/usr_toc.txt | 11 ++++---- src/nvim/version.c | 1 + 3 files changed, 56 insertions(+), 14 deletions(-) diff --git a/runtime/doc/usr_05.txt b/runtime/doc/usr_05.txt index 5aecf33557..50aa8cc62f 100644 --- a/runtime/doc/usr_05.txt +++ b/runtime/doc/usr_05.txt @@ -1,4 +1,4 @@ -*usr_05.txt* For Vim version 7.4. Last change: 2012 Nov 20 +*usr_05.txt* For Vim version 7.4. Last change: 2016 Mar 25 VIM USER MANUAL - by Bram Moolenaar @@ -12,10 +12,11 @@ Vim's capabilities. Or define your own macros. |05.1| The vimrc file |05.2| The example vimrc file explained |05.3| Simple mappings -|05.4| Adding a plugin -|05.5| Adding a help file -|05.6| The option window -|05.7| Often used options +|05.4| Adding a package +|05.5| Adding a plugin +|05.6| Adding a help file +|05.7| The option window +|05.8| Often used options Next chapter: |usr_06.txt| Using syntax highlighting Previous chapter: |usr_04.txt| Making small changes @@ -245,7 +246,46 @@ The ":map" command (with no arguments) lists your current mappings. At least the ones for Normal mode. More about mappings in section |40.1|. ============================================================================== -*05.4* Adding a plugin *add-plugin* *plugin* +*05.4* Adding a package *add-package* *matchit-install* + +A package is a set of files that you can add to Vim. There are two kinds of +packages: optional and automatically loaded on startup. + +The Vim distribution comes with a few packages that you can optionally use. +For example, the matchit plugin. This plugin makes the "%" command jump to +matching HTML tags, if/else/endif in Vim scripts, etc. Very useful, although +it's not backwards compatible (that's why it is not enabled by default). + +To start using the matchit plugin, add one line to your vimrc file: > + packadd matchit + +That's all! You can also type the command to try it out. Now you can find +help about this plugin: > + :help matchit + +This works, because when `:packadd` loaded the plugin it also added the +package directory in 'runtimepath', so that the help file can be found. + +You can find packages on the Internet in various places. It usually comes as +an archive or as a repository. For an archive you can follow these steps: + 1. create the package directory: > + mkdir -p ~/.local/share/nvim/site/pack/fancy +< "fancy" can be any name of your liking. Use one that describes the + package. + 2. unpack the archive in that directory. This assumes the top + directory in the archive is "start": > + cd ~/.local/share/nvim/site/pack/fancy + unzip /tmp/fancy.zip +< If the archive layout is different make sure that you end up with a + path like this: + ~/.local/share/nvim/site/pack/fancy/start/fancytext/plugin/fancy.vim ~ + Here "fancytext" is the name of the package, it can be anything + else. + +More information about packages can be found here: |packages|. + +============================================================================== +*05.5* Adding a plugin *add-plugin* *plugin* Vim's functionality can be extended by adding plugins. A plugin is nothing more than a Vim script file that is loaded automatically when Vim starts. You @@ -384,7 +424,7 @@ Further reading: |new-filetype| How to detect a new file type. ============================================================================== -*05.5* Adding a help file *add-local-help* +*05.6* Adding a help file *add-local-help* If you are lucky, the plugin you installed also comes with a help file. We will explain how to install the help file, so that you can easily find help @@ -417,7 +457,7 @@ them through the tag. For writing a local help file, see |write-local-help|. ============================================================================== -*05.6* The option window +*05.7* The option window If you are looking for an option that does what you want, you can search in the help files here: |options|. Another way is by using this command: > @@ -456,7 +496,7 @@ border. This is what the 'scrolloff' option does, it specifies an offset from the window border where scrolling starts. ============================================================================== -*05.7* Often used options +*05.8* Often used options There are an awful lot of options. Most of them you will hardly ever use. Some of the more useful ones will be mentioned here. Don't forget you can diff --git a/runtime/doc/usr_toc.txt b/runtime/doc/usr_toc.txt index 77ea462a23..e021b806e3 100644 --- a/runtime/doc/usr_toc.txt +++ b/runtime/doc/usr_toc.txt @@ -1,4 +1,4 @@ -*usr_toc.txt* For Vim version 7.4. Last change: 2010 Jul 20 +*usr_toc.txt* For Vim version 7.4. Last change: 2016 Mar 25 VIM USER MANUAL - by Bram Moolenaar @@ -101,10 +101,11 @@ Read this from start to end to learn the essential commands. |05.1| The vimrc file |05.2| The example vimrc file explained |05.3| Simple mappings - |05.4| Adding a plugin - |05.5| Adding a help file - |05.6| The option window - |05.7| Often used options + |05.4| Adding a package + |05.5| Adding a plugin + |05.6| Adding a help file + |05.7| The option window + |05.8| Often used options |usr_06.txt| Using syntax highlighting |06.1| Switching it on 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 From b418f3d6f2f98b446b79b0a1f6cf151f7e26246c Mon Sep 17 00:00:00 2001 From: James McCoy Date: Sun, 26 Jun 2016 13:48:41 -0400 Subject: [PATCH 25/34] Move vimball plugin into an optional package --- runtime/{ => pack/dist/opt/vimball}/autoload/vimball.vim | 0 .../pi_vimball.txt => pack/dist/opt/vimball/doc/vimball.txt} | 2 +- runtime/{ => pack/dist/opt/vimball}/plugin/vimballPlugin.vim | 0 3 files changed, 1 insertion(+), 1 deletion(-) rename runtime/{ => pack/dist/opt/vimball}/autoload/vimball.vim (100%) rename runtime/{doc/pi_vimball.txt => pack/dist/opt/vimball/doc/vimball.txt} (99%) rename runtime/{ => pack/dist/opt/vimball}/plugin/vimballPlugin.vim (100%) diff --git a/runtime/autoload/vimball.vim b/runtime/pack/dist/opt/vimball/autoload/vimball.vim similarity index 100% rename from runtime/autoload/vimball.vim rename to runtime/pack/dist/opt/vimball/autoload/vimball.vim diff --git a/runtime/doc/pi_vimball.txt b/runtime/pack/dist/opt/vimball/doc/vimball.txt similarity index 99% rename from runtime/doc/pi_vimball.txt rename to runtime/pack/dist/opt/vimball/doc/vimball.txt index bbc74988ca..9965a216e4 100644 --- a/runtime/doc/pi_vimball.txt +++ b/runtime/pack/dist/opt/vimball/doc/vimball.txt @@ -1,4 +1,4 @@ -*pi_vimball.txt* For Vim version 7.4. Last change: 2012 Jan 17 +*vimball.txt* For Vim version 7.4. Last change: 2012 Jan 17 ---------------- Vimball Archiver diff --git a/runtime/plugin/vimballPlugin.vim b/runtime/pack/dist/opt/vimball/plugin/vimballPlugin.vim similarity index 100% rename from runtime/plugin/vimballPlugin.vim rename to runtime/pack/dist/opt/vimball/plugin/vimballPlugin.vim From d65563ae9ceebf1ff509e6d8c1638e808a32c002 Mon Sep 17 00:00:00 2001 From: James McCoy Date: Sun, 26 Jun 2016 13:59:41 -0400 Subject: [PATCH 26/34] =?UTF-8?q?Reword=20=C2=A705.4=20to=20describe=20usi?= =?UTF-8?q?ng=20the=20new=20vimball=20package?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- runtime/doc/usr_05.txt | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/runtime/doc/usr_05.txt b/runtime/doc/usr_05.txt index 50aa8cc62f..464ced72bf 100644 --- a/runtime/doc/usr_05.txt +++ b/runtime/doc/usr_05.txt @@ -246,25 +246,26 @@ The ":map" command (with no arguments) lists your current mappings. At least the ones for Normal mode. More about mappings in section |40.1|. ============================================================================== -*05.4* Adding a package *add-package* *matchit-install* +*05.4* Adding a package *add-package* *vimball-install* A package is a set of files that you can add to Vim. There are two kinds of packages: optional and automatically loaded on startup. The Vim distribution comes with a few packages that you can optionally use. -For example, the matchit plugin. This plugin makes the "%" command jump to -matching HTML tags, if/else/endif in Vim scripts, etc. Very useful, although -it's not backwards compatible (that's why it is not enabled by default). +For example, the vimball plugin. This plugin supports creating and using +vimballs (self-installing Vim plugin archives). -To start using the matchit plugin, add one line to your vimrc file: > - packadd matchit +To start using the vimball plugin, add one line to your vimrc file: > + packadd vimball That's all! You can also type the command to try it out. Now you can find help about this plugin: > - :help matchit + :help vimball This works, because when `:packadd` loaded the plugin it also added the -package directory in 'runtimepath', so that the help file can be found. +package directory in 'runtimepath', so that the help file can be found. The +tags for vimball's help are already created. If you need to generate the help +tags for a package, see the `:helptags` command. You can find packages on the Internet in various places. It usually comes as an archive or as a repository. For an archive you can follow these steps: From 31734c6ab0d743dad1c4f6fd9a86479ec2790a61 Mon Sep 17 00:00:00 2001 From: James McCoy Date: Sun, 26 Jun 2016 21:00:05 -0400 Subject: [PATCH 27/34] Generate tags and install docs for included packages --- runtime/CMakeLists.txt | 43 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) diff --git a/runtime/CMakeLists.txt b/runtime/CMakeLists.txt index a9de7557e4..66971eccb2 100644 --- a/runtime/CMakeLists.txt +++ b/runtime/CMakeLists.txt @@ -2,6 +2,7 @@ set(SYN_VIM_GENERATOR ${PROJECT_SOURCE_DIR}/scripts/genvimvim.lua) set(GENERATED_RUNTIME_DIR ${PROJECT_BINARY_DIR}/runtime) set(GENERATED_SYN_VIM ${GENERATED_RUNTIME_DIR}/syntax/vim/generated.vim) set(GENERATED_HELP_TAGS ${GENERATED_RUNTIME_DIR}/doc/tags) +set(GENERATED_PACKAGE_DIR ${GENERATED_RUNTIME_DIR}/pack/dist/opt) file(MAKE_DIRECTORY ${GENERATED_RUNTIME_DIR}) file(MAKE_DIRECTORY ${GENERATED_RUNTIME_DIR}/syntax) @@ -18,6 +19,47 @@ add_custom_command(OUTPUT ${GENERATED_SYN_VIM} ${PROJECT_SOURCE_DIR}/src/nvim/eval.c ) +if(POLICY CMP0054) + cmake_policy(SET CMP0054 OLD) +endif() + +file(GLOB PACKAGES ${PROJECT_SOURCE_DIR}/runtime/pack/dist/opt/*) + +set(GENERATED_PACKAGE_TAGS) +foreach(PACKAGE ${PACKAGES}) + get_filename_component(PACKNAME ${PACKAGE} NAME) + file(GLOB "${PACKNAME}_DOC_FILES" ${PACKAGE}/doc/*.txt) + if("${PACKNAME}_DOC_FILES") + file(MAKE_DIRECTORY ${GENERATED_PACKAGE_DIR}/${PACKNAME}) + add_custom_target("${PACKNAME}-tags" + COMMAND ${CMAKE_COMMAND} -E copy_directory + ${PACKAGE} ${GENERATED_PACKAGE_DIR}/${PACKNAME} + COMMAND "${PROJECT_BINARY_DIR}/bin/nvim" + -u NONE -i NONE -e --headless -c "helptags doc" -c quit + DEPENDS + nvim + WORKING_DIRECTORY "${GENERATED_PACKAGE_DIR}/${PACKNAME}" + ) + + add_custom_command(OUTPUT "${GENERATED_PACKAGE_DIR}/${PACKNAME}/doc/tags" + DEPENDS + "${PACKNAME}-tags" + ) + + set("${PACKNAME}_DOC_NAMES") + foreach(DF "${${PACKNAME}_DOC_FILES}") + get_filename_component(F ${DF} NAME) + list(APPEND "${PACKNAME}_DOC_NAMES" ${GENERATED_PACKAGE_DIR}/${PACKNAME}/doc/${F}) + endforeach() + + install_helper( + FILES ${GENERATED_PACKAGE_DIR}/${PACKNAME}/doc/tags "${${PACKNAME}_DOC_NAMES}" + DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/nvim/runtime/pack/dist/opt/${PACKNAME}/doc) + + list(APPEND GENERATED_PACKAGE_TAGS "${GENERATED_PACKAGE_DIR}/${PACKNAME}/doc/tags") + endif() +endforeach() + file(GLOB DOCFILES ${PROJECT_SOURCE_DIR}/runtime/doc/*.txt) set(BUILDDOCFILES) @@ -53,6 +95,7 @@ add_custom_target( DEPENDS ${GENERATED_SYN_VIM} ${GENERATED_HELP_TAGS} + ${GENERATED_PACKAGE_TAGS} ) # CMake is painful here. It will create the destination using the user's From 3f689ed327be0a391f8cdd15302583c02b04b4e2 Mon Sep 17 00:00:00 2001 From: James McCoy Date: Thu, 7 Jul 2016 23:02:08 -0400 Subject: [PATCH 28/34] vim-patch:7db8f6f Updated runtime files. https://github.com/vim/vim/commit/7db8f6f4f85e5d0526d23107b2a5e2334dc23354 Ignore changes to * doc/tags: Generated at build time * doc/channel.txt, doc/todo.txt: Irrelevant to Neovim * pack/dist/opt/matchit/doc/matchit.txt: matchit is enabled by default, so description of how to enable isn't needed. --- runtime/doc/editing.txt | 4 ++-- runtime/doc/eval.txt | 2 +- runtime/doc/helphelp.txt | 6 ++++-- runtime/doc/repeat.txt | 4 ++-- runtime/doc/usr_05.txt | 7 +++---- runtime/doc/usr_25.txt | 10 +++++++--- runtime/doc/usr_41.txt | 3 ++- runtime/syntax/sh.vim | 9 +++++---- runtime/syntax/tex.vim | 8 ++++---- 9 files changed, 30 insertions(+), 23 deletions(-) diff --git a/runtime/doc/editing.txt b/runtime/doc/editing.txt index 69f834b04d..6f85436ab4 100644 --- a/runtime/doc/editing.txt +++ b/runtime/doc/editing.txt @@ -1,4 +1,4 @@ -*editing.txt* For Vim version 7.4. Last change: 2016 Feb 16 +*editing.txt* For Vim version 7.4. Last change: 2016 Mar 28 VIM REFERENCE MANUAL by Bram Moolenaar @@ -358,7 +358,7 @@ These are the common ones: To avoid the special meaning of the wildcards prepend a backslash. However, on MS-Windows the backslash is a path separator and "path\[abc]" is still seen as a wildcard when "[" is in the 'isfname' option. A simple way to avoid this -is to use "path\[[]abc]". Then the file "path[abc]" literally. +is to use "path\[[]abc]", this matches the file "path\[abc]". *starstar-wildcard* Expanding "**" is possible on Unix, Win32, Mac OS/X and a few other systems. diff --git a/runtime/doc/eval.txt b/runtime/doc/eval.txt index 0bd5c04344..3495f9c004 100644 --- a/runtime/doc/eval.txt +++ b/runtime/doc/eval.txt @@ -1,4 +1,4 @@ -*eval.txt* For Vim version 7.4. Last change: 2016 Mar 26 +*eval.txt* For Vim version 7.4. Last change: 2016 Mar 29 VIM REFERENCE MANUAL by Bram Moolenaar diff --git a/runtime/doc/helphelp.txt b/runtime/doc/helphelp.txt index 95d280c529..9654f249fa 100644 --- a/runtime/doc/helphelp.txt +++ b/runtime/doc/helphelp.txt @@ -1,4 +1,4 @@ -*helphelp.txt* For Vim version 7.4. Last change: 2016 Mar 26 +*helphelp.txt* For Vim version 7.4. Last change: 2016 Mar 28 VIM REFERENCE MANUAL by Bram Moolenaar @@ -254,7 +254,9 @@ The second one finds the English user manual, even when 'helplang' is set to When using command-line completion for the ":help" command, the "@en" extension is only shown when a tag exists for multiple languages. When the -tag only exists for English "@en" is omitted. +tag only exists for English "@en" is omitted. When the first candidate has an +"@ab" extension and it matches the first language in 'helplang' "@ab" is also +omitted. When using |CTRL-]| or ":help!" in a non-English help file Vim will try to find the tag in the same language. If not found then 'helplang' will be used diff --git a/runtime/doc/repeat.txt b/runtime/doc/repeat.txt index a5785fb714..5a2396669e 100644 --- a/runtime/doc/repeat.txt +++ b/runtime/doc/repeat.txt @@ -1,4 +1,4 @@ -*repeat.txt* For Vim version 7.4. Last change: 2016 Mar 26 +*repeat.txt* For Vim version 7.4. Last change: 2016 Mar 27 VIM REFERENCE MANUAL by Bram Moolenaar @@ -251,7 +251,7 @@ For writing a Vim script, see chapter 41 of the user manual |usr_41.txt|. Packages will be loaded only once. After this command it won't happen again. When the optional ! is added this command will load packages even when done before. - An Error only causes sourcing the script where it + An error only causes sourcing the script where it happens to be aborted, further plugins will be loaded. See |packages|. diff --git a/runtime/doc/usr_05.txt b/runtime/doc/usr_05.txt index 464ced72bf..f920fd4591 100644 --- a/runtime/doc/usr_05.txt +++ b/runtime/doc/usr_05.txt @@ -1,4 +1,4 @@ -*usr_05.txt* For Vim version 7.4. Last change: 2016 Mar 25 +*usr_05.txt* For Vim version 7.4. Last change: 2016 Mar 28 VIM USER MANUAL - by Bram Moolenaar @@ -340,10 +340,9 @@ Then copy the file to your plugin directory: Example for Unix (assuming you didn't have a plugin directory yet): > mkdir -p ~/.local/share/nvim/site/plugin - cp /usr/local/share/vim/vim60/macros/justify.vim ~/.local/share/nvim/site/plugin + cp /tmp/yourplugin.vim ~/.local/share/nvim/site/plugin -That's all! Now you can use the commands defined in this plugin to justify -text. +That's all! Now you can use the commands defined in this plugin. Instead of putting plugins directly into the plugin/ directory, you may better organize them by putting them into subdirectories under plugin/. diff --git a/runtime/doc/usr_25.txt b/runtime/doc/usr_25.txt index 23d76a8b0f..24420353dd 100644 --- a/runtime/doc/usr_25.txt +++ b/runtime/doc/usr_25.txt @@ -1,4 +1,4 @@ -*usr_25.txt* For Vim version 7.4. Last change: 2014 Oct 29 +*usr_25.txt* For Vim version 7.4. Last change: 2016 Mar 28 VIM USER MANUAL - by Bram Moolenaar @@ -196,12 +196,16 @@ Vim has no built-in way of justifying text. However, there is a neat macro package that does the job. To use this package, execute the following command: > - :runtime macros/justify.vim + :packadd justify + +Or put this line in your |vimrc|: > + + packadd! justify This Vim script file defines a new visual command "_j". To justify a block of text, highlight the text in Visual mode and then execute "_j". Look in the file for more explanations. To go there, do "gf" on this name: -$VIMRUNTIME/macros/justify.vim. +$VIMRUNTIME/pack/dist/opt/justify/plugin/justify.vim. An alternative is to filter the text through an external program. Example: > diff --git a/runtime/doc/usr_41.txt b/runtime/doc/usr_41.txt index f57e237a01..f00f03bae8 100644 --- a/runtime/doc/usr_41.txt +++ b/runtime/doc/usr_41.txt @@ -1,4 +1,4 @@ -*usr_41.txt* For Vim version 7.4. Last change: 2016 Mar 15 +*usr_41.txt* For Vim version 7.4. Last change: 2016 Mar 27 VIM USER MANUAL - by Bram Moolenaar @@ -890,6 +890,7 @@ Mappings: *mapping-functions* Testing: *test-functions* assert_equal() assert that two expressions values are equal + assert_match() assert that a pattern matches the value assert_false() assert that an expression is false assert_true() assert that an expression is true assert_exception() assert that a command throws an exception diff --git a/runtime/syntax/sh.vim b/runtime/syntax/sh.vim index 3fc236f033..8b0a91f674 100644 --- a/runtime/syntax/sh.vim +++ b/runtime/syntax/sh.vim @@ -2,8 +2,8 @@ " Language: shell (sh) Korn shell (ksh) bash (sh) " Maintainer: Charles E. Campbell " Previous Maintainer: Lennart Schultz -" Last Change: Feb 18, 2016 -" Version: 145 +" Last Change: Mar 12, 2016 +" Version: 146 " URL: http://www.drchip.org/astronaut/vim/index.html#SYNTAX_SH " For options and settings, please use: :help ft-sh-syntax " This file includes many ideas from Eric Brunet (eric.brunet@ens.fr) @@ -185,7 +185,7 @@ endif " Options: {{{1 " ==================== -syn match shOption "\s\zs[-+][-_a-zA-Z0-9#]\+" +syn match shOption "\s\zs[-+][-_a-zA-Z#@]\+" syn match shOption "\s\zs--[^ \t$`'"|);]\+" " File Redirection Highlighted As Operators: {{{1 @@ -317,7 +317,8 @@ syn match shColon '^\s*\zs:' " String And Character Constants: {{{1 "================================ -syn match shNumber "-\=\<\d\+\>#\=" +syn match shNumber "\<\d\+\>#\=" +syn match shNumber "-\=\.\=\d\+\>#\=" syn match shCtrlSeq "\\\d\d\d\|\\[abcfnrtv0]" contained if exists("b:is_bash") syn match shSpecial "\\\o\o\o\|\\x\x\x\|\\c[^"]\|\\[abefnrtv]" contained diff --git a/runtime/syntax/tex.vim b/runtime/syntax/tex.vim index cef28d65ed..5af5882a56 100644 --- a/runtime/syntax/tex.vim +++ b/runtime/syntax/tex.vim @@ -1,8 +1,8 @@ " Vim syntax file " Language: TeX " Maintainer: Charles E. Campbell -" Last Change: Feb 18, 2016 -" Version: 92 +" Last Change: Mar 07, 2016 +" Version: 93 " URL: http://www.drchip.org/astronaut/vim/index.html#SYNTAX_TEX " " Notes: {{{1 @@ -296,7 +296,7 @@ syn match texTypeStyle "\\sc\>" syn match texTypeStyle "\\tt\>" " Type Styles: attributes, commands, families, etc (LaTeX2E): {{{1 -if s:tex_conceal !~ 'b' +if s:tex_conceal !~# 'b' syn match texTypeStyle "\\textbf\>" syn match texTypeStyle "\\textit\>" endif @@ -541,7 +541,7 @@ if !exists("g:tex_no_math") syn match texOnlyMath "[_^]" endif syn match texSpecialChar "\^\^[0-9a-f]\{2}\|\^\^\S" -if s:tex_conceal !~ 'S' +if s:tex_conceal !~# 'S' syn match texSpecialChar '\\glq\>' contained conceal cchar=‚ syn match texSpecialChar '\\grq\>' contained conceal cchar=‘ syn match texSpecialChar '\\glqq\>' contained conceal cchar=„ From 23b2ee077130182c60d6639d99b45546902c8f80 Mon Sep 17 00:00:00 2001 From: James McCoy Date: Thu, 7 Jul 2016 23:12:33 -0400 Subject: [PATCH 29/34] 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 + test/functional/legacy/packadd_spec.lua | 34 ++++++++++++++++++++++--- 3 files changed, 46 insertions(+), 9 deletions(-) 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, p_pp); + add_pack_plugin, &APP_ADD_DIR); + do_in_path(p_pp, (char_u *)"pack/*/start/*", DIP_ALL + DIP_DIR, + 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, diff --git a/test/functional/legacy/packadd_spec.lua b/test/functional/legacy/packadd_spec.lua index d85467ced1..8c680f24b4 100644 --- a/test/functional/legacy/packadd_spec.lua +++ b/test/functional/legacy/packadd_spec.lua @@ -75,14 +75,40 @@ describe('packadd', function() endfunc func Test_packloadall() - let plugindir = &packpath . '/pack/mine/start/foo/plugin' - call mkdir(plugindir, 'p') - call writefile(['let g:plugin_foo_number = 1234'], plugindir . '/bar.vim') + " plugin foo with an autoload directory + let fooplugindir = &packpath . '/pack/mine/start/foo/plugin' + call mkdir(fooplugindir, 'p') + call writefile(['let g:plugin_foo_number = 1234', + \ 'let g:plugin_foo_auto = bbb#value', + \ 'let g:plugin_extra_auto = extra#value'], fooplugindir . '/bar.vim') + let fooautodir = &packpath . '/pack/mine/start/foo/autoload' + call mkdir(fooautodir, 'p') + call writefile(['let bar#value = 77'], fooautodir . '/bar.vim') + + " plugin aaa with an autoload directory + let aaaplugindir = &packpath . '/pack/mine/start/aaa/plugin' + call mkdir(aaaplugindir, 'p') + call writefile(['let g:plugin_aaa_number = 333', + \ 'let g:plugin_aaa_auto = bar#value'], aaaplugindir . '/bbb.vim') + let aaaautodir = &packpath . '/pack/mine/start/aaa/autoload' + call mkdir(aaaautodir, 'p') + call writefile(['let bbb#value = 55'], aaaautodir . '/bbb.vim') + + " plugin extra with only an autoload directory + let extraautodir = &packpath . '/pack/mine/start/extra/autoload' + call mkdir(extraautodir, 'p') + call writefile(['let extra#value = 99'], extraautodir . '/extra.vim') + packloadall call assert_equal(1234, g:plugin_foo_number) + call assert_equal(55, g:plugin_foo_auto) + call assert_equal(99, g:plugin_extra_auto) + call assert_equal(333, g:plugin_aaa_number) + call assert_equal(77, g:plugin_aaa_auto) " only works once - call writefile(['let g:plugin_bar_number = 4321'], plugindir . '/bar2.vim') + call writefile(['let g:plugin_bar_number = 4321'], + \ fooplugindir . '/bar2.vim') packloadall call assert_false(exists('g:plugin_bar_number')) From e686b613ecd349265e17d9c1f481cafac4935aef Mon Sep 17 00:00:00 2001 From: James McCoy Date: Thu, 7 Jul 2016 23:26:00 -0400 Subject: [PATCH 30/34] vim-patch:03413f4 Updated runtime files. https://github.com/vim/vim/commit/03413f44167c4b5cd0012def9bb331e2518c83cf Ignore changes to * doc/Makefile, doc/help.txt: Related to Vim's version8 documentation * doc/gui_x11.txt, doc/todo.txt, doc/vim.1, gvim.desktop, vim.desktop: Irrelevant to Neovim * doc/quickref.txt, doc/options.txt: As of yet unported 'emoji' * doc/tags, syntax/vim.vim: Generated at build time --- runtime/doc/eval.txt | 15 ++++-- runtime/doc/help.txt | 2 +- runtime/doc/helphelp.txt | 6 ++- runtime/doc/options.txt | 2 +- runtime/doc/pattern.txt | 6 +-- runtime/doc/quickref.txt | 2 +- runtime/doc/repeat.txt | 50 +++++++++++++++---- runtime/doc/starting.txt | 9 ++-- runtime/doc/syntax.txt | 40 ++++++++------- runtime/doc/usr_41.txt | 5 +- .../dist/opt/vimball/autoload/vimball.vim | 32 ++++++------ .../dist/opt/vimball/plugin/vimballPlugin.vim | 29 ++++++----- runtime/syntax/c.vim | 6 ++- runtime/syntax/mysql.vim | 30 ++++++----- runtime/syntax/sh.vim | 21 +++++--- runtime/syntax/tex.vim | 14 ++++-- 16 files changed, 170 insertions(+), 99 deletions(-) diff --git a/runtime/doc/eval.txt b/runtime/doc/eval.txt index 3495f9c004..0ca41370e9 100644 --- a/runtime/doc/eval.txt +++ b/runtime/doc/eval.txt @@ -1,4 +1,4 @@ -*eval.txt* For Vim version 7.4. Last change: 2016 Mar 29 +*eval.txt* For Vim version 7.4. Last change: 2016 Apr 12 VIM REFERENCE MANUAL by Bram Moolenaar @@ -413,7 +413,8 @@ only appear once. Examples: > A key is always a String. You can use a Number, it will be converted to a String automatically. Thus the String '4' and the number 4 will find the same entry. Note that the String '04' and the Number 04 are different, since the -Number will be converted to the String '4'. +Number will be converted to the String '4'. The empty string can be used as a +key. A value can be any expression. Using a Dictionary for a value creates a nested Dictionary: > @@ -861,11 +862,12 @@ These three can be repeated and mixed. Examples: expr8 *expr8* ----- expr8[expr1] item of String or |List| *expr-[]* *E111* + *subscript* If expr8 is a Number or String this results in a String that contains the expr1'th single byte from expr8. expr8 is used as a String, expr1 as a Number. This doesn't recognize multi-byte encodings, see |byteidx()| for -an alternative. +an alternative, or use `split()` to turn the string into a list of characters. Index zero gives the first byte. This is like it works in C. Careful: text column numbers start with one! Example, to get the byte under the @@ -2155,6 +2157,7 @@ writefile({list}, {fname} [, {flags}]) Number write list of lines to file {fname} xor({expr}, {expr}) Number bitwise XOR + abs({expr}) *abs()* Return the absolute value of {expr}. When {expr} evaluates to a |Float| abs() returns a |Float|. When {expr} can be @@ -2779,6 +2782,7 @@ cursor({list}) When there is one argument {list} this is used as a |List| with two, three or four item: + [{lnum}, {col}] [{lnum}, {col}, {off}] [{lnum}, {col}, {off}, {curswant}] This is like the return value of |getpos()| or |getcurpos()|, @@ -3207,7 +3211,10 @@ feedkeys({string} [, {mode}]) *feedkeys()* similar to using ":normal!". You can call feedkeys() several times without 'x' and then one time with 'x' (possibly with an empty {string}) to execute all the - typeahead. + typeahead. Note that when Vim ends in Insert mode it + will behave as if is typed, to avoid getting + stuck, waiting for a character to be typed before the + script continues. Return value is always 0. filereadable({file}) *filereadable()* diff --git a/runtime/doc/help.txt b/runtime/doc/help.txt index 305eaea924..fc4816a6c8 100644 --- a/runtime/doc/help.txt +++ b/runtime/doc/help.txt @@ -1,4 +1,4 @@ -*help.txt* For Vim version 7.4. Last change: 2016 Feb 27 +*help.txt* For Vim version 7.4. Last change: 2016 Mar 31 VIM - main help file k diff --git a/runtime/doc/helphelp.txt b/runtime/doc/helphelp.txt index 9654f249fa..ca341af200 100644 --- a/runtime/doc/helphelp.txt +++ b/runtime/doc/helphelp.txt @@ -1,4 +1,4 @@ -*helphelp.txt* For Vim version 7.4. Last change: 2016 Mar 28 +*helphelp.txt* For Vim version 7.4. Last change: 2016 Apr 01 VIM REFERENCE MANUAL by Bram Moolenaar @@ -313,6 +313,10 @@ aligned on a line. When referring to an existing help tag and to create a hot-link, place the name between two bars (|) eg. |help-writing|. +When referring to a Vim command and to create a hot-link, place the +name between two backticks, eg. inside `:filetype`. You will see this is +highlighted as a command, like a code block (see below). + When referring to a Vim option in the help file, place the option name between two single quotes, eg. 'statusline' diff --git a/runtime/doc/options.txt b/runtime/doc/options.txt index 669f74186c..e00f27f9f0 100644 --- a/runtime/doc/options.txt +++ b/runtime/doc/options.txt @@ -1,4 +1,4 @@ -*options.txt* For Vim version 7.4. Last change: 2016 Mar 24 +*options.txt* For Vim version 7.4. Last change: 2016 Apr 12 VIM REFERENCE MANUAL by Bram Moolenaar diff --git a/runtime/doc/pattern.txt b/runtime/doc/pattern.txt index 5897f756d8..0fe6106ec5 100644 --- a/runtime/doc/pattern.txt +++ b/runtime/doc/pattern.txt @@ -1,4 +1,4 @@ -*pattern.txt* For Vim version 7.4. Last change: 2016 Jan 03 +*pattern.txt* For Vim version 7.4. Last change: 2016 Apr 03 VIM REFERENCE MANUAL by Bram Moolenaar @@ -1096,8 +1096,8 @@ x A single character, with no special meaning, matches itself '/', alphabetic, numeric, '_' or '~'. These items only work for 8-bit characters, except [:lower:] and [:upper:] also work for multi-byte characters when using the new - regexp engine. In the future these items may work for multi-byte - characters. + regexp engine. See |two-engines|. In the future these items may + work for multi-byte characters. */[[=* *[==]* - An equivalence class. This means that characters are matched that have almost the same meaning, e.g., when ignoring accents. This diff --git a/runtime/doc/quickref.txt b/runtime/doc/quickref.txt index b6ab33dd16..fcfecc02a1 100644 --- a/runtime/doc/quickref.txt +++ b/runtime/doc/quickref.txt @@ -1,4 +1,4 @@ -*quickref.txt* For Vim version 7.4. Last change: 2016 Feb 24 +*quickref.txt* For Vim version 7.4. Last change: 2016 Mar 30 VIM REFERENCE MANUAL by Bram Moolenaar diff --git a/runtime/doc/repeat.txt b/runtime/doc/repeat.txt index 5a2396669e..e84bbe5439 100644 --- a/runtime/doc/repeat.txt +++ b/runtime/doc/repeat.txt @@ -1,4 +1,4 @@ -*repeat.txt* For Vim version 7.4. Last change: 2016 Mar 27 +*repeat.txt* For Vim version 7.4. Last change: 2016 Apr 05 VIM REFERENCE MANUAL by Bram Moolenaar @@ -70,8 +70,8 @@ examples. The global commands work by first scanning through the [range] lines and marking each line where a match occurs (for a multi-line pattern, only the start of the match matters). -In a second scan the [cmd] is executed for each marked line with its line -number prepended. For ":v" and ":g!" the command is executed for each not +In a second scan the [cmd] is executed for each marked line, as if the cursor +was in that line. For ":v" and ":g!" the command is executed for each not marked line. If a line is deleted its mark disappears. The default for [range] is the whole buffer (1,$). Use "CTRL-C" to interrupt the command. If an error message is given for a line, the command for that @@ -225,8 +225,11 @@ For writing a Vim script, see chapter 41 of the user manual |usr_41.txt|. there yet. Note that {name} is the directory name, not the name - of the .vim file. If the "{name}/plugin" directory - contains more than one file they are all sourced. + of the .vim file. All the files matching the pattern + pack/*/opt/{name}/plugin/**/*.vim ~ + will be sourced. This allows for using subdirectories + below "plugin", just like with plugins in + 'runtimepath'. If the filetype detection was not enabled yet (this is usually done with a "syntax enable" or "filetype @@ -242,15 +245,24 @@ For writing a Vim script, see chapter 41 of the user manual |usr_41.txt|. Also see |pack-add|. *:packl* *:packloadall* -:packloadall[!] Load all packages in the "start" directories under - 'packpath'. The directories found are added to - 'runtimepath'. +:packl[oadall][!] Load all packages in the "start" directory under each + entry in 'packpath'. + + First all the directories found are added to + 'runtimepath', then the plugins found in the + directories are sourced. This allows for a plugin to + depend on something of another plugin, e.g. an + "autoload" directory. See |packload-two-steps| for + how this can be useful. + This is normally done automatically during startup, after loading your .vimrc file. With this command it can be done earlier. + Packages will be loaded only once. After this command it won't happen again. When the optional ! is added this command will load packages even when done before. + An error only causes sourcing the script where it happens to be aborted, further plugins will be loaded. See |packages|. @@ -456,8 +468,9 @@ You would now have these files under ~/.local/share/nvim/site: pack/foo/opt/foodebug/plugin/debugger.vim When Vim starts up, after processing your .vimrc, it scans all directories in -'packpath' for plugins under the "pack/*/start" directory and loads them. The -directory is added to 'runtimepath'. +'packpath' for plugins under the "pack/*/start" directory. First all those +directories are added to 'runtimepath'. Then all the plugins are loaded. +See |packload-two-steps| for how these two steps can be useful. In the example Vim will find "pack/foo/start/foobar/plugin/foo.vim" and adds "~/.local/share/nvim/site/pack/foo/start/foobar" to 'runtimepath'. @@ -585,6 +598,23 @@ the command after changing the plugin help: > :helptags path/start/foobar/doc :helptags path/opt/fooextra/doc + +Dependencies between plugins ~ + *packload-two-steps* +Suppose you have a two plugins that depend on the same functionality. You can +put the common functionality in an autoload directory, so that it will be +found automatically. Your package would have these files: + + pack/foo/start/one/plugin/one.vim > + call foolib#getit() +< pack/foo/start/two/plugin/two.vim > + call foolib#getit() +< pack/foo/start/lib/autoload/foolib.vim > + func foolib#getit() + +This works, because loading packages will first add all found directories to +'runtimepath' before sourcing the plugins. + ============================================================================== 7. Debugging scripts *debug-scripts* diff --git a/runtime/doc/starting.txt b/runtime/doc/starting.txt index 4829307706..236ed65f46 100644 --- a/runtime/doc/starting.txt +++ b/runtime/doc/starting.txt @@ -1,4 +1,4 @@ -*starting.txt* For Vim version 7.4. Last change: 2016 Mar 26 +*starting.txt* For Vim version 7.4. Last change: 2016 Apr 05 VIM REFERENCE MANUAL by Bram Moolenaar @@ -464,9 +464,10 @@ accordingly. Vim proceeds in this order: commands from the command line have not been executed yet. You can use "--cmd 'set noloadplugins'" |--cmd|. - Plugin packs are loaded. These are plugins, as above, but found in - 'packpath' "start" directories. Every plugin directory found is added - in 'runtimepath'. See |packages|. + Packages are loaded. These are plugins, as above, but found in the + "start" directory of each entry in 'packpath'. Every plugin directory + found is added in 'runtimepath' and then the plugins are sourced. See + |packages|. 7. Set 'shellpipe' and 'shellredir' The 'shellpipe' and 'shellredir' options are set according to the diff --git a/runtime/doc/syntax.txt b/runtime/doc/syntax.txt index 9bec855190..491e5801c8 100644 --- a/runtime/doc/syntax.txt +++ b/runtime/doc/syntax.txt @@ -1,4 +1,4 @@ -*syntax.txt* For Vim version 7.4. Last change: 2016 Mar 12 +*syntax.txt* For Vim version 7.4. Last change: 2016 Apr 10 VIM REFERENCE MANUAL by Bram Moolenaar @@ -936,26 +936,27 @@ To disable them use ":unlet". Example: > :unlet c_comment_strings Variable Highlight ~ -c_gnu GNU gcc specific items -c_comment_strings strings and numbers inside a comment -c_space_errors trailing white space and spaces before a -c_no_trail_space_error ... but no trailing spaces -c_no_tab_space_error ... but no spaces before a -c_no_bracket_error don't highlight {}; inside [] as errors -c_no_curly_error don't highlight {}; inside [] and () as errors; +*c_gnu* GNU gcc specific items +*c_comment_strings* strings and numbers inside a comment +*c_space_errors* trailing white space and spaces before a +*c_no_trail_space_error* ... but no trailing spaces +*c_no_tab_space_error* ... but no spaces before a +*c_no_bracket_error* don't highlight {}; inside [] as errors +*c_no_curly_error* don't highlight {}; inside [] and () as errors; except { and } in first column -c_curly_error highlight a missing }; this forces syncing from the +*c_curly_error* highlight a missing }; this forces syncing from the start of the file, can be slow -c_no_ansi don't do standard ANSI types and constants -c_ansi_typedefs ... but do standard ANSI types -c_ansi_constants ... but do standard ANSI constants -c_no_utf don't highlight \u and \U in strings -c_syntax_for_h for *.h files use C syntax instead of C++ and use objc +*c_no_ansi* don't do standard ANSI types and constants +*c_ansi_typedefs* ... but do standard ANSI types +*c_ansi_constants* ... but do standard ANSI constants +*c_no_utf* don't highlight \u and \U in strings +*c_syntax_for_h* for *.h files use C syntax instead of C++ and use objc syntax instead of objcpp -c_no_if0 don't highlight "#if 0" blocks as comments -c_no_cformat don't highlight %-formats in strings -c_no_c99 don't highlight C99 standard items -c_no_c11 don't highlight C11 standard items +*c_no_if0* don't highlight "#if 0" blocks as comments +*c_no_cformat* don't highlight %-formats in strings +*c_no_c99* don't highlight C99 standard items +*c_no_c11* don't highlight C11 standard items +*c_no_bsd* don't highlight BSD specific types When 'foldmethod' is set to "syntax" then /* */ comments and { } blocks will become a fold. If you don't want comments to become a fold use: > @@ -5026,6 +5027,9 @@ defaults back: > :syntax reset +It is a bit of a wrong name, since it does not reset any syntax items, it only +affects the highlighting. + This doesn't change the colors for the 'highlight' option. Note that the syntax colors that you set in your vimrc file will also be reset diff --git a/runtime/doc/usr_41.txt b/runtime/doc/usr_41.txt index f00f03bae8..4d3ad49f1f 100644 --- a/runtime/doc/usr_41.txt +++ b/runtime/doc/usr_41.txt @@ -1,4 +1,4 @@ -*usr_41.txt* For Vim version 7.4. Last change: 2016 Mar 27 +*usr_41.txt* For Vim version 7.4. Last change: 2016 Apr 12 VIM USER MANUAL - by Bram Moolenaar @@ -768,6 +768,7 @@ Date and Time: *date-functions* *time-functions* strftime() convert time to a string reltime() get the current or elapsed time accurately reltimestr() convert reltime() result to a string + reltimefloat() convert reltime() result to a Float *buffer-functions* *window-functions* *arg-functions* Buffers, windows and the argument list: @@ -890,7 +891,9 @@ Mappings: *mapping-functions* Testing: *test-functions* assert_equal() assert that two expressions values are equal + assert_notequal() assert that two expressions values are not equal assert_match() assert that a pattern matches the value + assert_notmatch() assert that a pattern does not match the value assert_false() assert that an expression is false assert_true() assert that an expression is true assert_exception() assert that a command throws an exception diff --git a/runtime/pack/dist/opt/vimball/autoload/vimball.vim b/runtime/pack/dist/opt/vimball/autoload/vimball.vim index 9a5a73c3c1..1af6b19c88 100644 --- a/runtime/pack/dist/opt/vimball/autoload/vimball.vim +++ b/runtime/pack/dist/opt/vimball/autoload/vimball.vim @@ -1,9 +1,9 @@ " vimball.vim : construct a file containing both paths and files -" Author: Charles E. Campbell, Jr. -" Date: Jan 17, 2012 -" Version: 35 +" Author: Charles E. Campbell +" Date: Apr 11, 2016 +" Version: 37 " GetLatestVimScripts: 1502 1 :AutoInstall: vimball.vim -" Copyright: (c) 2004-2011 by Charles E. Campbell, Jr. +" Copyright: (c) 2004-2011 by Charles E. Campbell " The VIM LICENSE applies to Vimball.vim, and Vimball.txt " (see |copyright|) except use "Vimball" instead of "Vim". " No warranty, express or implied. @@ -14,7 +14,7 @@ if &cp || exists("g:loaded_vimball") finish endif -let g:loaded_vimball = "v35" +let g:loaded_vimball = "v37" if v:version < 702 echohl WarningMsg echo "***warning*** this version of vimball needs vim 7.2" @@ -142,7 +142,7 @@ fun! vimball#MkVimball(line1,line2,writelevel,...) range let lastline= line("$") + 1 if lastline == 2 && getline("$") == "" - call setline(1,'" Vimball Archiver by Charles E. Campbell, Jr., Ph.D.') + call setline(1,'" Vimball Archiver by Charles E. Campbell') call setline(2,'UseVimball') call setline(3,'finish') let lastline= line("$") + 1 @@ -179,7 +179,7 @@ fun! vimball#MkVimball(line1,line2,writelevel,...) range " remove the evidence setlocal nomod bh=wipe exe "tabn ".curtabnr - exe "tabc ".vbtabnr + exe "tabc! ".vbtabnr " restore options call vimball#RestoreSettings() @@ -280,7 +280,7 @@ fun! vimball#Vimball(really,...) " when AsNeeded/filename is filereadable or was present in VimballRecord if fname =~ '\ instead of <".fname.">") let fname= anfname endif @@ -379,10 +379,10 @@ fun! vimball#Vimball(really,...) call s:RecordInFile(home) " restore events, delete tab and buffer - exe "tabn ".vbtabnr + exe "sil! tabn ".vbtabnr setlocal nomod bh=wipe - exe "tabn ".curtabnr - exe "tabc ".vbtabnr + exe "sil! tabn ".curtabnr + exe "sil! tabc! ".vbtabnr call vimball#RestoreSettings() call s:ChgDir(curdir) @@ -555,7 +555,7 @@ fun! vimball#ShowMesg(level,msg) set noruler noshowcmd redraw! - if &fo =~ '[ta]' + if &fo =~# '[ta]' echomsg "***vimball*** ".a:msg else if a:level == s:WARNING || a:level == s:USAGE @@ -715,7 +715,7 @@ fun! vimball#SaveSettings() " call Dfunc("SaveSettings()") let s:makeep = getpos("'a") let s:regakeep= @a - if exists("&acd") + if exists("+acd") let s:acdkeep = &acd endif let s:eikeep = &ei @@ -728,7 +728,7 @@ fun! vimball#SaveSettings() let s:vekeep = &ve let s:ffkeep = &l:ff let s:swfkeep = &l:swf - if exists("&acd") + if exists("+acd") setlocal ei=all ve=all noacd nofen noic report=999 nohid bt= ma lz pm= ff=unix noswf else setlocal ei=all ve=all nofen noic report=999 nohid bt= ma lz pm= ff=unix noswf @@ -743,7 +743,7 @@ endfun fun! vimball#RestoreSettings() " call Dfunc("RestoreSettings()") let @a = s:regakeep - if exists("&acd") + if exists("+acd") let &acd = s:acdkeep endif let &l:fen = s:fenkeep @@ -760,7 +760,7 @@ fun! vimball#RestoreSettings() " call Decho("restore mark-a: makeep=".string(makeep)) call setpos("'a",s:makeep) endif - if exists("&acd") + if exists("+acd") unlet s:acdkeep endif unlet s:regakeep s:eikeep s:fenkeep s:hidkeep s:ickeep s:repkeep s:vekeep s:makeep s:lzkeep s:pmkeep s:ffkeep diff --git a/runtime/pack/dist/opt/vimball/plugin/vimballPlugin.vim b/runtime/pack/dist/opt/vimball/plugin/vimballPlugin.vim index 59279774ca..d7473a0296 100644 --- a/runtime/pack/dist/opt/vimball/plugin/vimballPlugin.vim +++ b/runtime/pack/dist/opt/vimball/plugin/vimballPlugin.vim @@ -1,6 +1,6 @@ " vimballPlugin : construct a file containing both paths and files -" Author: Charles E. Campbell, Jr. -" Copyright: (c) 2004-2010 by Charles E. Campbell, Jr. +" Author: Charles E. Campbell +" Copyright: (c) 2004-2014 by Charles E. Campbell " The VIM LICENSE applies to Vimball.vim, and Vimball.txt " (see |copyright|) except use "Vimball" instead of "Vim". " No warranty, express or implied. @@ -16,22 +16,25 @@ if &cp || exists("g:loaded_vimballPlugin") finish endif -let g:loaded_vimballPlugin = "v35" +let g:loaded_vimballPlugin = "v37" let s:keepcpo = &cpo set cpo&vim " ------------------------------------------------------------------------------ " Public Interface: {{{1 -com! -ra -complete=file -na=+ -bang MkVimball call vimball#MkVimball(,,0,) -com! -na=? -complete=dir UseVimball call vimball#Vimball(1,) -com! -na=0 VimballList call vimball#Vimball(0) -com! -na=* -complete=dir RmVimball call vimball#SaveSettings()|call vimball#RmVimball()|call vimball#RestoreSettings() -au BufEnter *.vba,*.vba.gz,*.vba.bz2,*.vba.zip,*.vba.xz setlocal bt=nofile fmr=[[[,]]] fdm=marker|if &ff != 'unix'|setlocal ma ff=unix noma|endif|call vimball#ShowMesg(0,"Source this file to extract it! (:so %)") -au SourceCmd *.vba.gz,*.vba.bz2,*.vba.zip,*.vba.xz if expand("%")!=expand("") | exe "1sp" fnameescape(expand(""))|endif|call vimball#Decompress(expand(""))|so %|if expand("%")!=expand("")|close|endif -au SourceCmd *.vba if expand("%")!=expand("") | exe "1sp" fnameescape(expand(""))|call vimball#Vimball(1)|close|else|call vimball#Vimball(1)|endif -au BufEnter *.vmb,*.vmb.gz,*.vmb.bz2,*.vmb.zip,*.vmb.xz setlocal bt=nofile fmr=[[[,]]] fdm=marker|if &ff != 'unix'|setlocal ma ff=unix noma|endif|call vimball#ShowMesg(0,"Source this file to extract it! (:so %)") -au SourceCmd *.vmb.gz,*.vmb.bz2,*.vmb.zip,*.vmb.xz if expand("%")!=expand("") | exe "1sp" fnameescape(expand(""))|endif|call vimball#Decompress(expand(""))|so %|if expand("%")!=expand("")|close|endif -au SourceCmd *.vmb if expand("%")!=expand("") | exe "1sp" fnameescape(expand(""))|call vimball#Vimball(1)|close|else|call vimball#Vimball(1)|endif +com! -range -complete=file -nargs=+ -bang MkVimball call vimball#MkVimball(,,0,) +com! -nargs=? -complete=dir UseVimball call vimball#Vimball(1,) +com! -nargs=0 VimballList call vimball#Vimball(0) +com! -nargs=* -complete=dir RmVimball call vimball#SaveSettings()|call vimball#RmVimball()|call vimball#RestoreSettings() +augroup Vimball + au! + au BufEnter *.vba,*.vba.gz,*.vba.bz2,*.vba.zip,*.vba.xz setlocal bt=nofile fmr=[[[,]]] fdm=marker|if &ff != 'unix'|setlocal ma ff=unix noma|endif|if line('$') > 1|call vimball#ShowMesg(0,"Source this file to extract it! (:so %)")|endif + au SourceCmd *.vba.gz,*.vba.bz2,*.vba.zip,*.vba.xz let s:origfile=expand("%")|if expand("%")!=expand("") | exe "1sp" fnameescape(expand(""))|endif|call vimball#Decompress(expand(""))|so %|if s:origfile!=expand("")|close|endif + au SourceCmd *.vba if expand("%")!=expand("") | exe "1sp" fnameescape(expand(""))|call vimball#Vimball(1)|close|else|call vimball#Vimball(1)|endif + au BufEnter *.vmb,*.vmb.gz,*.vmb.bz2,*.vmb.zip,*.vmb.xz setlocal bt=nofile fmr=[[[,]]] fdm=marker|if &ff != 'unix'|setlocal ma ff=unix noma|endif|if line('$') > 1|call vimball#ShowMesg(0,"Source this file to extract it! (:so %)")|endif + au SourceCmd *.vmb.gz,*.vmb.bz2,*.vmb.zip,*.vmb.xz let s:origfile=expand("%")|if expand("%")!=expand("") | exe "1sp" fnameescape(expand(""))|endif|call vimball#Decompress(expand(""))|so %|if s:origfile!=expand("")|close|endif + au SourceCmd *.vmb if expand("%")!=expand("") | exe "1sp" fnameescape(expand(""))|call vimball#Vimball(1)|close|else|call vimball#Vimball(1)|endif +augroup END " ===================================================================== " Restoration And Modelines: {{{1 diff --git a/runtime/syntax/c.vim b/runtime/syntax/c.vim index 32b63e09e4..3fe3256059 100644 --- a/runtime/syntax/c.vim +++ b/runtime/syntax/c.vim @@ -1,7 +1,7 @@ " Vim syntax file " Language: C " Maintainer: Bram Moolenaar -" Last Change: 2016 Feb 08 +" Last Change: 2016 Apr 10 " Quit when a (custom) syntax file was already loaded if exists("b:current_syntax") @@ -248,6 +248,10 @@ if !exists("c_no_c99") " ISO C99 syn keyword cType _Bool bool _Complex complex _Imaginary imaginary syn keyword cType int8_t int16_t int32_t int64_t syn keyword cType uint8_t uint16_t uint32_t uint64_t + if !exists("c_no_bsd") + " These are BSD specific. + syn keyword cType u_int8_t u_int16_t u_int32_t u_int64_t + endif syn keyword cType int_least8_t int_least16_t int_least32_t int_least64_t syn keyword cType uint_least8_t uint_least16_t uint_least32_t uint_least64_t syn keyword cType int_fast8_t int_fast16_t int_fast32_t int_fast64_t diff --git a/runtime/syntax/mysql.vim b/runtime/syntax/mysql.vim index c01ecc192b..d7cf74710d 100644 --- a/runtime/syntax/mysql.vim +++ b/runtime/syntax/mysql.vim @@ -1,7 +1,7 @@ " Vim syntax file " Language: mysql " Maintainer: Kenneth J. Pronovici -" Last Change: $LastChangedDate: 2010-04-22 09:48:02 -0500 (Thu, 22 Apr 2010) $ +" Last Change: $LastChangedDate: 2016-04-11 10:31:04 -0500 (Mon, 11 Apr 2016) $ " Filenames: *.mysql " URL: ftp://cedar-solutions.com/software/mysql.vim " Note: The definitions below are taken from the mysql user manual as of April 2002, for version 3.23 @@ -18,7 +18,7 @@ endif syn case ignore " General keywords which don't fall into other categories -syn keyword mysqlKeyword action add after aggregate all alter as asc auto_increment avg avg_row_length +syn keyword mysqlKeyword action add after aggregate all alter as asc auto_increment avg_row_length syn keyword mysqlKeyword both by syn keyword mysqlKeyword cascade change character check checksum column columns comment constraint create cross syn keyword mysqlKeyword current_date current_time current_timestamp @@ -30,7 +30,7 @@ syn keyword mysqlKeyword global grant grants group syn keyword mysqlKeyword having heap high_priority hosts hour hour_minute hour_second syn keyword mysqlKeyword identified ignore index infile inner insert insert_id into isam syn keyword mysqlKeyword join -syn keyword mysqlKeyword key keys kill last_insert_id leading left limit lines load local lock logs long +syn keyword mysqlKeyword key keys kill last_insert_id leading left limit lines load local lock logs long syn keyword mysqlKeyword low_priority syn keyword mysqlKeyword match max_rows middleint min_rows minute minute_second modify month myisam syn keyword mysqlKeyword natural no @@ -64,6 +64,9 @@ syn match mysqlNumber "\<0x[abcdefABCDEF0-9]*\>" " User variables syn match mysqlVariable "@\a*[A-Za-z0-9]*\([._]*[A-Za-z0-9]\)*" +" Escaped column names +syn match mysqlEscaped "`[^`]*`" + " Comments (c-style, mysql-style and modified sql-style) syn region mysqlComment start="/\*" end="\*/" syn match mysqlComment "#.*" @@ -84,14 +87,14 @@ syn sync ccomment mysqlComment " The second problem is that some of these keywords are included in " function names. For instance, year() is part of the name of the " dayofyear() function, and the dec keyword (no parenthesis) is part of -" the name of the decode() function. +" the name of the decode() function. -syn keyword mysqlType tinyint smallint mediumint int integer bigint -syn keyword mysqlType date datetime time bit bool +syn keyword mysqlType tinyint smallint mediumint int integer bigint +syn keyword mysqlType date datetime time bit bool syn keyword mysqlType tinytext mediumtext longtext text syn keyword mysqlType tinyblob mediumblob longblob blob -syn region mysqlType start="float\W" end="."me=s-1 -syn region mysqlType start="float$" end="."me=s-1 +syn region mysqlType start="float\W" end="."me=s-1 +syn region mysqlType start="float$" end="."me=s-1 syn region mysqlType start="float(" end=")" contains=mysqlNumber,mysqlVariable syn region mysqlType start="double\W" end="."me=s-1 syn region mysqlType start="double$" end="."me=s-1 @@ -139,12 +142,12 @@ syn region mysqlFlow start="if(" end=")" contains=ALL " " I'm leery of just defining keywords for functions, since according to the MySQL manual: " -" Function names do not clash with table or column names. For example, ABS is a -" valid column name. The only restriction is that for a function call, no spaces -" are allowed between the function name and the `(' that follows it. +" Function names do not clash with table or column names. For example, ABS is a +" valid column name. The only restriction is that for a function call, no spaces +" are allowed between the function name and the `(' that follows it. " -" This means that if I want to highlight function names properly, I have to use a -" region to define them, not just a keyword. This will probably cause the syntax file +" This means that if I want to highlight function names properly, I have to use a +" region to define them, not just a keyword. This will probably cause the syntax file " to load more slowly, but at least it will be 'correct'. syn region mysqlFunction start="abs(" end=")" contains=ALL @@ -154,6 +157,7 @@ syn region mysqlFunction start="ascii(" end=")" contains=ALL syn region mysqlFunction start="asin(" end=")" contains=ALL syn region mysqlFunction start="atan(" end=")" contains=ALL syn region mysqlFunction start="atan2(" end=")" contains=ALL +syn region mysqlFunction start="avg(" end=")" contains=ALL syn region mysqlFunction start="benchmark(" end=")" contains=ALL syn region mysqlFunction start="bin(" end=")" contains=ALL syn region mysqlFunction start="bit_and(" end=")" contains=ALL diff --git a/runtime/syntax/sh.vim b/runtime/syntax/sh.vim index 8b0a91f674..6ef5bf0d16 100644 --- a/runtime/syntax/sh.vim +++ b/runtime/syntax/sh.vim @@ -2,8 +2,8 @@ " Language: shell (sh) Korn shell (ksh) bash (sh) " Maintainer: Charles E. Campbell " Previous Maintainer: Lennart Schultz -" Last Change: Mar 12, 2016 -" Version: 146 +" Last Change: Apr 11, 2016 +" Version: 147 " URL: http://www.drchip.org/astronaut/vim/index.html#SYNTAX_SH " For options and settings, please use: :help ft-sh-syntax " This file includes many ideas from Eric Brunet (eric.brunet@ens.fr) @@ -539,13 +539,20 @@ endif " Synchronization: {{{1 " ================ -if !exists("sh_minlines") - let sh_minlines = 200 +if !exists("g:sh_minlines") + let s:sh_minlines = 200 +else + let s:sh_minlines= g:sh_minlines endif -if !exists("sh_maxlines") - let sh_maxlines = 2 * sh_minlines +if !exists("g:sh_maxlines") + let s:sh_maxlines = 2*s:sh_minlines + if s:sh_maxlines < 25 + let s:sh_maxlines= 25 + endif +else + let s:sh_maxlines= g:sh_maxlines endif -exec "syn sync minlines=" . sh_minlines . " maxlines=" . sh_maxlines +exec "syn sync minlines=" . s:sh_minlines . " maxlines=" . s:sh_maxlines syn sync match shCaseEsacSync grouphere shCaseEsac "\" syn sync match shCaseEsacSync groupthere shCaseEsac "\" syn sync match shDoSync grouphere shDo "\" diff --git a/runtime/syntax/tex.vim b/runtime/syntax/tex.vim index 5af5882a56..d6d5dd81ee 100644 --- a/runtime/syntax/tex.vim +++ b/runtime/syntax/tex.vim @@ -1,8 +1,8 @@ " Vim syntax file " Language: TeX " Maintainer: Charles E. Campbell -" Last Change: Mar 07, 2016 -" Version: 93 +" Last Change: Apr 11, 2016 +" Version: 94 " URL: http://www.drchip.org/astronaut/vim/index.html#SYNTAX_TEX " " Notes: {{{1 @@ -83,10 +83,14 @@ else let s:tex_conceal= g:tex_conceal endif if !exists("g:tex_superscripts") - let g:tex_superscripts= "[0-9a-zA-W.,:;+-<>/()=]" + let s:tex_superscripts= "[0-9a-zA-W.,:;+-<>/()=]" +else + let s:tex_superscripts= g:tex_superscripts endif if !exists("g:tex_subscripts") - let g:tex_subscripts= "[0-9aehijklmnoprstuvx,+-/().]" + let s:tex_subscripts= "[0-9aehijklmnoprstuvx,+-/().]" +else + let s:tex_subscripts= g:tex_subscripts endif " Determine whether or not to use "*.sty" mode {{{1 @@ -1049,7 +1053,7 @@ if has("conceal") && &enc == 'utf-8' endif " s:SuperSub: fun! s:SuperSub(group,leader,pat,cchar) - if a:pat =~# '^\\' || (a:leader == '\^' && a:pat =~# g:tex_superscripts) || (a:leader == '_' && a:pat =~# g:tex_subscripts) + if a:pat =~# '^\\' || (a:leader == '\^' && a:pat =~# s:tex_superscripts) || (a:leader == '_' && a:pat =~# s:tex_subscripts) " call Decho("SuperSub: group<".a:group."> leader<".a:leader."> pat<".a:pat."> cchar<".a:cchar.">") exe 'syn match '.a:group." '".a:leader.a:pat."' contained conceal cchar=".a:cchar exe 'syn match '.a:group."s '".a:pat ."' contained conceal cchar=".a:cchar.' nextgroup='.a:group.'s' From 520a4f06e20c3917e75e3a413a290d9141cb0a0c Mon Sep 17 00:00:00 2001 From: James McCoy Date: Fri, 8 Jul 2016 00:05:35 -0400 Subject: [PATCH 31/34] 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 + test/functional/legacy/packadd_spec.lua | 2 ++ 3 files changed, 20 insertions(+), 5 deletions(-) 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, diff --git a/test/functional/legacy/packadd_spec.lua b/test/functional/legacy/packadd_spec.lua index 8c680f24b4..b2ed39f288 100644 --- a/test/functional/legacy/packadd_spec.lua +++ b/test/functional/legacy/packadd_spec.lua @@ -27,6 +27,7 @@ describe('packadd', function() func Test_packadd() call mkdir(s:plugdir . '/plugin', 'p') call mkdir(s:plugdir . '/ftdetect', 'p') + call mkdir(s:plugdir . '/after', 'p') set rtp& let rtp = &rtp filetype on @@ -45,6 +46,7 @@ describe('packadd', function() call assert_true(17, g:ftdetect_works) call assert_true(len(&rtp) > len(rtp)) call assert_true(&rtp =~ (s:plugdir . '\($\|,\)')) + call assert_true(&rtp =~ (s:plugdir . '/after$')) " Check exception call assert_fails("packadd directorynotfound", 'E919:') From c147766389a11df0bc6cf86bb1a6bd0e22a6026b Mon Sep 17 00:00:00 2001 From: James McCoy Date: Fri, 8 Jul 2016 00:27:05 -0400 Subject: [PATCH 32/34] 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(-) 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, From 86b4f6856b52b311137467af9a631f7e567dcfbf Mon Sep 17 00:00:00 2001 From: James McCoy Date: Fri, 8 Jul 2016 00:35:24 -0400 Subject: [PATCH 33/34] 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(-) 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) { From 059e9785dc2fea0a15344162de4a5a7c8da6f491 Mon Sep 17 00:00:00 2001 From: James McCoy Date: Fri, 8 Jul 2016 01:36:23 -0400 Subject: [PATCH 34/34] 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 | 148 ++++++++++++++++++++--------------------- src/nvim/spell.c | 6 +- src/nvim/syntax.c | 33 ++++----- 11 files changed, 173 insertions(+), 167 deletions(-) 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 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 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;