From 86cdb8a4bd1abff40b5f80c3c4149b33cbaab990 Mon Sep 17 00:00:00 2001 From: Bram Moolenaar Date: Tue, 6 Apr 2021 19:01:03 +0200 Subject: [PATCH 01/14] patch 8.2.2726: confusing error message with white space before comma Problem: Confusing error message with white space before comma in the arguments of a function declaration. Solution: Give a specific error message. (closes #2235) --- src/testdir/test_vim9_func.vim | 9 +++++++++ src/userfunc.c | 11 +++++++++++ src/version.c | 2 ++ 3 files changed, 22 insertions(+) diff --git a/src/testdir/test_vim9_func.vim b/src/testdir/test_vim9_func.vim index 8085e5cf22..730cf40aaa 100644 --- a/src/testdir/test_vim9_func.vim +++ b/src/testdir/test_vim9_func.vim @@ -1263,6 +1263,15 @@ def Test_arg_type_wrong() CheckScriptFailure(['def Func5(items)', 'echo "a"'], 'E1077:') enddef +def Test_white_space_before_comma() + var lines =<< trim END + vim9script + def Func(a: number , b: number) + enddef + END + CheckScriptFailure(lines, 'E1068:') +enddef + def Test_white_space_after_comma() var lines =<< trim END vim9script diff --git a/src/userfunc.c b/src/userfunc.c index 1139573c63..af107b0db6 100644 --- a/src/userfunc.c +++ b/src/userfunc.c @@ -307,6 +307,17 @@ get_function_args( emsg(_("E989: Non-default argument follows default argument")); goto err_ret; } + + if (VIM_ISWHITE(*p) && *skipwhite(p) == ',') + { + // Be tolerant when skipping + if (!skip) + { + semsg(_(e_no_white_space_allowed_before_str_str), ",", p); + goto err_ret; + } + p = skipwhite(p); + } if (*p == ',') { ++p; diff --git a/src/version.c b/src/version.c index 4318b71eb7..9b356bd267 100644 --- a/src/version.c +++ b/src/version.c @@ -750,6 +750,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ +/**/ + 2726, /**/ 2725, /**/ From e9b8b78e046b40b877c999432c4698edb3413d5d Mon Sep 17 00:00:00 2001 From: Bram Moolenaar Date: Tue, 6 Apr 2021 20:18:29 +0200 Subject: [PATCH 02/14] patch 8.2.2727: function test fails Problem: Function test fails. Solution: Adjust expected error number. --- src/testdir/test_user_func.vim | 2 +- src/version.c | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/testdir/test_user_func.vim b/src/testdir/test_user_func.vim index 2db558931d..a58aa64b9d 100644 --- a/src/testdir/test_user_func.vim +++ b/src/testdir/test_user_func.vim @@ -150,7 +150,7 @@ func Test_default_arg() call assert_equal(res['0'], 1) call assert_fails("call MakeBadFunc()", 'E989:') - call assert_fails("fu F(a=1 ,) | endf", 'E475:') + call assert_fails("fu F(a=1 ,) | endf", 'E1068:') let d = Args2(7, v:none, 9) call assert_equal([7, 2, 9], [d.a, d.b, d.c]) diff --git a/src/version.c b/src/version.c index 9b356bd267..0abdbe50c1 100644 --- a/src/version.c +++ b/src/version.c @@ -750,6 +750,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ +/**/ + 2727, /**/ 2726, /**/ From e3d1f4c982bd0fe05496448d7868268c75ff7bfb Mon Sep 17 00:00:00 2001 From: Bram Moolenaar Date: Tue, 6 Apr 2021 20:21:59 +0200 Subject: [PATCH 03/14] patch 8.2.2728: special key names don't work if 'isident' is cleared Problem: Special key names don't work if 'isident' is cleared. Solution: Add vim_isNormalIDc() and use it for special key names. (closes #2389) --- src/charset.c | 10 ++++++++++ src/misc2.c | 6 +++--- src/proto/charset.pro | 1 + src/testdir/test_mapping.vim | 5 ++++- src/version.c | 2 ++ 5 files changed, 20 insertions(+), 4 deletions(-) diff --git a/src/charset.c b/src/charset.c index db0c146f88..10aa2e8e52 100644 --- a/src/charset.c +++ b/src/charset.c @@ -834,6 +834,16 @@ vim_isIDc(int c) return (c > 0 && c < 0x100 && (g_chartab[c] & CT_ID_CHAR)); } +/* + * Like vim_isIDc() but not using the 'isident' option: letters, numbers and + * underscore. + */ + int +vim_isNormalIDc(int c) +{ + return ASCII_ISALNUM(c) || c == '_'; +} + /* * return TRUE if 'c' is a keyword character: Letters and characters from * 'iskeyword' option for the current buffer. diff --git a/src/misc2.c b/src/misc2.c index 90b8b5893d..08e6ed9368 100644 --- a/src/misc2.c +++ b/src/misc2.c @@ -2826,7 +2826,7 @@ find_special_key( // Find end of modifier list last_dash = src; - for (bp = src + 1; *bp == '-' || vim_isIDc(*bp); bp++) + for (bp = src + 1; *bp == '-' || vim_isNormalIDc(*bp); bp++) { if (*bp == '-') { @@ -3121,10 +3121,10 @@ get_special_key_code(char_u *name) for (i = 0; key_names_table[i].name != NULL; i++) { table_name = key_names_table[i].name; - for (j = 0; vim_isIDc(name[j]) && table_name[j] != NUL; j++) + for (j = 0; vim_isNormalIDc(name[j]) && table_name[j] != NUL; j++) if (TOLOWER_ASC(table_name[j]) != TOLOWER_ASC(name[j])) break; - if (!vim_isIDc(name[j]) && table_name[j] == NUL) + if (!vim_isNormalIDc(name[j]) && table_name[j] == NUL) return key_names_table[i].key; } return 0; diff --git a/src/proto/charset.pro b/src/proto/charset.pro index d364b8e49d..883f39300d 100644 --- a/src/proto/charset.pro +++ b/src/proto/charset.pro @@ -19,6 +19,7 @@ int linetabsize(char_u *s); int linetabsize_col(int startcol, char_u *s); int win_linetabsize(win_T *wp, char_u *line, colnr_T len); int vim_isIDc(int c); +int vim_isNormalIDc(int c); int vim_iswordc(int c); int vim_iswordc_buf(int c, buf_T *buf); int vim_iswordp(char_u *p); diff --git a/src/testdir/test_mapping.vim b/src/testdir/test_mapping.vim index d7e4caa911..c93562b071 100644 --- a/src/testdir/test_mapping.vim +++ b/src/testdir/test_mapping.vim @@ -445,9 +445,12 @@ func Test_list_mappings() " Remove default mappings imapclear - inoremap CtrlM + " reset 'isident' to check it isn't used + set isident= + inoremap CtrlM inoremap AltS inoremap ShiftSlash + set isident& call assert_equal([ \ 'i * ShiftSlash', \ 'i * AltS', diff --git a/src/version.c b/src/version.c index 0abdbe50c1..f041987844 100644 --- a/src/version.c +++ b/src/version.c @@ -750,6 +750,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ +/**/ + 2728, /**/ 2727, /**/ From 643ce6c0c694667a2afd24bb39d8e9d36d94d7a9 Mon Sep 17 00:00:00 2001 From: Bram Moolenaar Date: Tue, 6 Apr 2021 21:17:27 +0200 Subject: [PATCH 04/14] patch 8.2.2729: Vim9: wrong error message for referring to legacy script var Problem: Vim9: wrong error message for referring to legacy script variable. Solution: Do allow referring to a variable in legacy script without "s:" if it exists at compile time. (closes #8076) --- src/testdir/test_vim9_assign.vim | 35 ++++++++++++++++++++++++++++++++ src/version.c | 2 ++ src/vim9compile.c | 14 +++---------- 3 files changed, 40 insertions(+), 11 deletions(-) diff --git a/src/testdir/test_vim9_assign.vim b/src/testdir/test_vim9_assign.vim index 73351b44f4..c35084d550 100644 --- a/src/testdir/test_vim9_assign.vim +++ b/src/testdir/test_vim9_assign.vim @@ -1476,6 +1476,41 @@ def Test_var_declaration_fails() CheckDefFailure(['const foo: number'], 'E1021:') enddef +def Test_script_local_in_legacy() + # OK to define script-local later when prefixed with s: + var lines =<< trim END + def SetLater() + s:legacy = 'two' + enddef + defcompile + let s:legacy = 'one' + call SetLater() + call assert_equal('two', s:legacy) + END + CheckScriptSuccess(lines) + + # OK to leave out s: prefix when script-local already defined + lines =<< trim END + let s:legacy = 'one' + def SetNoPrefix() + legacy = 'two' + enddef + call SetNoPrefix() + call assert_equal('two', s:legacy) + END + CheckScriptSuccess(lines) + + # Not OK to leave out s: prefix when script-local defined later + lines =<< trim END + def SetLaterNoPrefix() + legacy = 'two' + enddef + defcompile + let s:legacy = 'one' + END + CheckScriptFailure(lines, 'E476:', 1) +enddef + def Test_var_type_check() var lines =<< trim END vim9script diff --git a/src/version.c b/src/version.c index f041987844..8d44824a19 100644 --- a/src/version.c +++ b/src/version.c @@ -750,6 +750,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ +/**/ + 2729, /**/ 2728, /**/ diff --git a/src/vim9compile.c b/src/vim9compile.c index 6ff00f7d49..c9ca5953fc 100644 --- a/src/vim9compile.c +++ b/src/vim9compile.c @@ -5708,17 +5708,9 @@ generate_store_var( return generate_STORE(cctx, ISN_STOREV, vimvaridx, NULL); case dest_script: if (scriptvar_idx < 0) - { - char_u *name_s = name; - int r; - - // "s:" is included in the name. - r = generate_OLDSCRIPT(cctx, ISN_STORES, name_s, + // "s:" may be included in the name. + return generate_OLDSCRIPT(cctx, ISN_STORES, name, scriptvar_sid, type); - if (name_s != name) - vim_free(name_s); - return r; - } return generate_VIM9SCRIPT(cctx, ISN_STORESCRIPT, scriptvar_sid, scriptvar_idx, type); case dest_local: @@ -5854,7 +5846,7 @@ compile_lhs( ? script_var_exists(var_start + 2, lhs->lhs_varlen - 2, FALSE, cctx) : script_var_exists(var_start, lhs->lhs_varlen, - TRUE, cctx)) == OK; + FALSE, cctx)) == OK; imported_T *import = find_imported(var_start, lhs->lhs_varlen, cctx); From c9605f0595173bca0f158f2782de950ac6bed147 Mon Sep 17 00:00:00 2001 From: Bram Moolenaar Date: Tue, 6 Apr 2021 21:29:32 +0200 Subject: [PATCH 05/14] patch 8.2.2730: Coverity complains about not restoring character Problem: Coverity complains about not restoring character. Solution: Also restore the character in case of an error. --- src/version.c | 2 ++ src/vim9compile.c | 1 + 2 files changed, 3 insertions(+) diff --git a/src/version.c b/src/version.c index 8d44824a19..5850872fbf 100644 --- a/src/version.c +++ b/src/version.c @@ -750,6 +750,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ +/**/ + 2730, /**/ 2729, /**/ diff --git a/src/vim9compile.c b/src/vim9compile.c index c9ca5953fc..feb1838b7b 100644 --- a/src/vim9compile.c +++ b/src/vim9compile.c @@ -6108,6 +6108,7 @@ compile_load_lhs( { // this should not happen emsg(_(e_missbrac)); + var_start[varlen] = c; return FAIL; } var_start[varlen] = c; From 8dddc1f0e2e9eeb29fc59477b515bcd6bb1243ec Mon Sep 17 00:00:00 2001 From: Bram Moolenaar Date: Wed, 7 Apr 2021 19:00:25 +0200 Subject: [PATCH 06/14] patch 8.2.2731: Mac: SF symbols are not displayed properly Problem: Mac: SF symbols are not displayed properly. Solution: Add custom range to list of double-width characters. (Yee Cheng Chin, closes #8077) --- src/mbyte.c | 9 +++++++++ src/version.c | 2 ++ 2 files changed, 11 insertions(+) diff --git a/src/mbyte.c b/src/mbyte.c index 079e0d2b43..e3d64ba01b 100644 --- a/src/mbyte.c +++ b/src/mbyte.c @@ -1545,6 +1545,15 @@ utf_char2cells(int c) {0x1f6e9, 0x1f6e9}, {0x1f6f0, 0x1f6f0}, {0x1f6f3, 0x1f6f3} + +#ifdef MACOS_X + // Include SF Symbols characters, which should be rendered as + // double-width. All of them are in the Supplementary Private Use + // Area-B range. The exact range was determined by downloading the "SF + // Symbols" app from Apple, and then selecting all symbols, copying + // them out, and inspecting the unicode values of them. + , {0x100000, 0x100d7f} +#endif }; if (c >= 0x100) diff --git a/src/version.c b/src/version.c index 5850872fbf..7a865de2a1 100644 --- a/src/version.c +++ b/src/version.c @@ -750,6 +750,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ +/**/ + 2731, /**/ 2730, /**/ From e5b0b98a90acf420bb611fc99534982c98d0645b Mon Sep 17 00:00:00 2001 From: Bram Moolenaar Date: Wed, 7 Apr 2021 19:42:57 +0200 Subject: [PATCH 07/14] patch 8.2.2732: prompt for s///c in Ex mode can be wrong Problem: Prompt for s///c in Ex mode can be wrong. Solution: Position the cursor before showing the prompt. (closes #8073) --- src/ex_cmds.c | 1 + src/testdir/test_ex_mode.vim | 3 +++ src/version.c | 2 ++ 3 files changed, 6 insertions(+) diff --git a/src/ex_cmds.c b/src/ex_cmds.c index 90a9403ff3..6cd54d20ce 100644 --- a/src/ex_cmds.c +++ b/src/ex_cmds.c @@ -4153,6 +4153,7 @@ ex_substitute(exarg_T *eap) if (curwin->w_cursor.col < 0) curwin->w_cursor.col = 0; getvcol(curwin, &curwin->w_cursor, NULL, NULL, &ec); + curwin->w_cursor.col = regmatch.startpos[0].col; if (subflags.do_number || curwin->w_p_nu) { int numw = number_width(curwin) + 1; diff --git a/src/testdir/test_ex_mode.vim b/src/testdir/test_ex_mode.vim index ffde11e3e9..a761cbf8b4 100644 --- a/src/testdir/test_ex_mode.vim +++ b/src/testdir/test_ex_mode.vim @@ -77,6 +77,9 @@ func Test_Ex_substitute() call WaitForAssert({-> assert_match(' 1 foo foo', term_getline(buf, 5))}, \ 1000) call WaitForAssert({-> assert_match(' ^^^', term_getline(buf, 6))}, 1000) + call term_sendkeys(buf, "N\") + call term_wait(buf) + call WaitForAssert({-> assert_match(' ^^^', term_getline(buf, 6))}, 1000) call term_sendkeys(buf, "n\") call WaitForAssert({-> assert_match(' ^^^', term_getline(buf, 6))}, \ 1000) diff --git a/src/version.c b/src/version.c index 7a865de2a1..0bf907354c 100644 --- a/src/version.c +++ b/src/version.c @@ -750,6 +750,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ +/**/ + 2732, /**/ 2731, /**/ From 125ed2745c0a0570c1f81f249aebb023b2deef1b Mon Sep 17 00:00:00 2001 From: Bram Moolenaar Date: Wed, 7 Apr 2021 20:11:12 +0200 Subject: [PATCH 08/14] patch 8.2.2733: detecting Lua version is not reliable Problem: Detecting Lua version is not reliable. Solution: Add "vim.lua_version". (Ozaki Kiichi, closes #8080) --- ci/if_ver-1.vim | 2 +- runtime/doc/if_lua.txt | 2 ++ src/if_lua.c | 23 +++++++++++++++++++++++ src/testdir/test_lua.vim | 13 +------------ src/version.c | 2 ++ 5 files changed, 29 insertions(+), 13 deletions(-) diff --git a/ci/if_ver-1.vim b/ci/if_ver-1.vim index d5b2bb68c1..adc40a7cb0 100644 --- a/ci/if_ver-1.vim +++ b/ci/if_ver-1.vim @@ -6,7 +6,7 @@ if 1 echo "*** Interface versions ***\n" echo 'Lua:' - PrintVer lua print(_VERSION) + PrintVer lua print(vim.lua_version, jit and "(LuaJIT)" or "") echo 'MzScheme:' PrintVer mzscheme (display (version)) diff --git a/runtime/doc/if_lua.txt b/runtime/doc/if_lua.txt index b556996985..b7ccb04c53 100644 --- a/runtime/doc/if_lua.txt +++ b/runtime/doc/if_lua.txt @@ -208,6 +208,8 @@ Vim evaluation and command execution, and others. created on demand. Example: > :lua print(vim.fn.has('timers')) < + vim.lua_version The Lua version Vim was compiled with, in the + form {major}.{minor}.{patch}, e.g. "5.1.4". ============================================================================== 3. List userdata *lua-list* diff --git a/src/if_lua.c b/src/if_lua.c index abcd850b3d..c19244fae5 100644 --- a/src/if_lua.c +++ b/src/if_lua.c @@ -24,6 +24,12 @@ #define LUAVIM_EVALNAME "luaeval" #define LUAVIM_EVALHEADER "local _A=select(1,...) return " +#ifdef LUA_RELEASE +# define LUAVIM_VERSION LUA_RELEASE +#else +# define LUAVIM_VERSION LUA_VERSION +#endif + typedef buf_T *luaV_Buffer; typedef win_T *luaV_Window; typedef dict_T *luaV_Dict; @@ -2087,6 +2093,7 @@ static const luaL_Reg luaV_module[] = { {"open", luaV_open}, {"type", luaV_type}, {"call", luaV_call}, + {"lua_version", NULL}, {NULL, NULL} }; @@ -2168,6 +2175,20 @@ luaV_setref(lua_State *L) return 1; } + static int +luaV_pushversion(lua_State *L) +{ + int major = 0; + int minor = 0; + int patch = 0; + char s[16]; + + sscanf(LUAVIM_VERSION, "Lua %d.%d.%d", &major, &minor, &patch); + vim_snprintf(s, sizeof(s), "%d.%d.%d", major, minor, patch); + lua_pushstring(L, s); + return 0; +} + #define LUA_VIM_FN_CODE \ "vim.fn = setmetatable({}, {\n"\ " __index = function (t, key)\n"\ @@ -2298,6 +2319,8 @@ luaopen_vim(lua_State *L) lua_newtable(L); // vim table lua_pushvalue(L, 1); // cache table luaV_openlib(L, luaV_module, 1); + luaV_pushversion(L); + lua_setfield(L, -2, "lua_version"); lua_setglobal(L, LUAVIM_NAME); // custom code (void)luaL_dostring(L, LUA_VIM_FN_CODE); diff --git a/src/testdir/test_lua.vim b/src/testdir/test_lua.vim index b9ef0d2364..c330563190 100644 --- a/src/testdir/test_lua.vim +++ b/src/testdir/test_lua.vim @@ -13,18 +13,7 @@ CheckFeature lua CheckFeature float " Depending on the lua version, the error messages are different. -let s:luaver = split(split(systemlist('lua -v')[0], ' ')[1], '\.') -if len(s:luaver) < 3 - " Didn't get something that looks like a version, use _VERSION. - let s:luaver = split(split(luaeval('_VERSION'), ' ')[1], '\.') -endif -let s:major = str2nr(s:luaver[0]) -let s:minor = str2nr(s:luaver[1]) -if len(s:luaver) >= 3 - let s:patch = str2nr(s:luaver[2]) -else - let s:patch = 0 -endif +let [s:major, s:minor, s:patch] = luaeval('vim.lua_version')->split('\.')->map({-> str2nr(v:val)}) let s:lua_53_or_later = 0 let s:lua_543_or_later = 0 if (s:major == 5 && s:minor >= 3) || s:major > 5 diff --git a/src/version.c b/src/version.c index 0bf907354c..58d6d9f172 100644 --- a/src/version.c +++ b/src/version.c @@ -750,6 +750,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ +/**/ + 2733, /**/ 2732, /**/ From 130cbfc31235c6cb52ffe718ea0a5bb50fbbc9fd Mon Sep 17 00:00:00 2001 From: Bram Moolenaar Date: Wed, 7 Apr 2021 21:07:20 +0200 Subject: [PATCH 09/14] Update runtime files --- .github/CODEOWNERS | 7 ++ runtime/compiler/powershell.vim | 84 +++++++++++++++ runtime/doc/Makefile | 2 + runtime/doc/cmdline.txt | 4 +- runtime/doc/editing.txt | 4 +- runtime/doc/eval.txt | 13 ++- runtime/doc/ft_ps1.txt | 64 +++++++++++ runtime/doc/gui_w32.txt | 4 +- runtime/doc/if_lua.txt | 2 +- runtime/doc/mbyte.txt | 4 +- runtime/doc/options.txt | 28 +++-- runtime/doc/os_win32.txt | 4 +- runtime/doc/syntax.txt | 2 +- runtime/doc/tags | 9 ++ runtime/doc/testing.txt | 2 +- runtime/doc/todo.txt | 15 +-- runtime/doc/usr_02.txt | 2 +- runtime/doc/version5.txt | 6 +- runtime/doc/version6.txt | 4 +- runtime/doc/vim9.txt | 36 +++++-- runtime/ftplugin/fortran.vim | 15 ++- runtime/ftplugin/ps1.vim | 59 +++++++++++ runtime/ftplugin/ps1xml.vim | 34 ++++++ runtime/indent/ps1.vim | 17 +++ runtime/plugin/matchparen.vim | 7 +- runtime/syntax/fortran.vim | 19 ++-- runtime/syntax/nasm.vim | 5 +- runtime/syntax/ps1.vim | 182 ++++++++++++++++++++++++++++++++ runtime/syntax/ps1xml.vim | 51 +++++++++ src/po/fr.po | 2 +- 30 files changed, 619 insertions(+), 68 deletions(-) create mode 100644 runtime/compiler/powershell.vim create mode 100644 runtime/doc/ft_ps1.txt create mode 100644 runtime/ftplugin/ps1.vim create mode 100644 runtime/ftplugin/ps1xml.vim create mode 100644 runtime/indent/ps1.vim create mode 100644 runtime/syntax/ps1.vim create mode 100644 runtime/syntax/ps1xml.vim diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS index 4972e38bc5..79b62e93e9 100644 --- a/.github/CODEOWNERS +++ b/.github/CODEOWNERS @@ -42,6 +42,7 @@ runtime/compiler/jshint.vim @dkearns runtime/compiler/jsonlint.vim @dkearns runtime/compiler/lazbuild.vim @dkearns runtime/compiler/php.vim @dkearns +runtime/compiler/powershell.vim @heaths runtime/compiler/rake.vim @tpope @dkearns runtime/compiler/rhino.vim @dkearns runtime/compiler/rspec.vim @tpope @dkearns @@ -67,6 +68,7 @@ runtime/doc/pi_netrw.txt @cecamp runtime/doc/pi_tar.txt @cecamp runtime/doc/pi_vimball.txt @cecamp runtime/doc/pi_zip.txt @cecamp +runtime/doc/ps1.txt @heaths runtime/ftplugin/awk.vim @dkearns runtime/ftplugin/basic.vim @dkearns runtime/ftplugin/bst.vim @tpope @@ -93,6 +95,8 @@ runtime/ftplugin/matlab.vim @cecamp runtime/ftplugin/nroff.vim @a-vrma runtime/ftplugin/nsis.vim @k-takata runtime/ftplugin/pdf.vim @tpope +runtime/ftplugin/ps1.vim @heaths +runtime/ftplugin/ps1xml.vim @heaths runtime/ftplugin/ruby.vim @tpope @dkearns runtime/ftplugin/sass.vim @tpope runtime/ftplugin/scss.vim @tpope @@ -111,6 +115,7 @@ runtime/indent/gitconfig.vim @tpope runtime/indent/haml.vim @tpope runtime/indent/liquid.vim @tpope runtime/indent/nsis.vim @k-takata +runtime/indent/ps1.vim @heaths runtime/indent/ruby.vim @AndrewRadev @dkearns runtime/indent/sass.vim @tpope runtime/indent/scss.vim @tpope @@ -173,6 +178,8 @@ runtime/syntax/pdf.vim @tpope runtime/syntax/php.vim @TysonAndre runtime/syntax/privoxy.vim @dkearns runtime/syntax/prolog.vim @XVilka +runtime/syntax/ps1.vim @heaths +runtime/syntax/ps1xml.vim @heaths runtime/syntax/rc.vim @chrisbra runtime/syntax/rpcgen.vim @cecamp runtime/syntax/ruby.vim @dkearns diff --git a/runtime/compiler/powershell.vim b/runtime/compiler/powershell.vim new file mode 100644 index 0000000000..45d5ec2191 --- /dev/null +++ b/runtime/compiler/powershell.vim @@ -0,0 +1,84 @@ +" Vim compiler file +" Compiler: powershell +" URL: https://github.com/PProvost/vim-ps1 +" Last Change: 2020 Mar 30 + +if exists("current_compiler") + finish +endif +let current_compiler = "powershell" + +if exists(":CompilerSet") != 2 " older Vim always used :setlocal + command -nargs=* CompilerSet setlocal +endif + +let s:cpo_save = &cpo +set cpo-=C + +if !exists("g:ps1_makeprg_cmd") + if executable('pwsh') + " pwsh is the future + let g:ps1_makeprg_cmd = 'pwsh' + elseif executable('pwsh.exe') + let g:ps1_makeprg_cmd = 'pwsh.exe' + elseif executable('powershell.exe') + let g:ps1_makeprg_cmd = 'powershell.exe' + else + let g:ps1_makeprg_cmd = '' + endif +endif + +if !executable(g:ps1_makeprg_cmd) + echoerr "To use the powershell compiler, please set g:ps1_makeprg_cmd to the powershell executable!" +endif + +" Show CategoryInfo, FullyQualifiedErrorId, etc? +let g:ps1_efm_show_error_categories = get(g:, 'ps1_efm_show_error_categories', 0) + +" Use absolute path because powershell requires explicit relative paths +" (./file.ps1 is okay, but # expands to file.ps1) +let &l:makeprg = g:ps1_makeprg_cmd .' %:p:S' + +" Parse file, line, char from callstacks: +" Write-Ouput : The term 'Write-Ouput' is not recognized as the name of a +" cmdlet, function, script file, or operable program. Check the spelling +" of the name, or if a path was included, verify that the path is correct +" and try again. +" At C:\script.ps1:11 char:5 +" + Write-Ouput $content +" + ~~~~~~~~~~~ +" + CategoryInfo : ObjectNotFound: (Write-Ouput:String) [], CommandNotFoundException +" + FullyQualifiedErrorId : CommandNotFoundException + +" Showing error in context with underlining. +CompilerSet errorformat=%+G+%m +" Error summary. +CompilerSet errorformat+=%E%*\\S\ :\ %m +" Error location. +CompilerSet errorformat+=%CAt\ %f:%l\ char:%c +" Errors that span multiple lines (may be wrapped to width of terminal). +CompilerSet errorformat+=%C%m +" Ignore blank/whitespace-only lines. +CompilerSet errorformat+=%Z\\s%# + +if g:ps1_efm_show_error_categories + CompilerSet errorformat^=%+G\ \ \ \ +\ %.%#\\s%#:\ %m +else + CompilerSet errorformat^=%-G\ \ \ \ +\ %.%#\\s%#:\ %m +endif + + +" Parse file, line, char from of parse errors: +" At C:\script.ps1:22 char:16 +" + Stop-Process -Name "invalidprocess +" + ~~~~~~~~~~~~~~~ +" The string is missing the terminator: ". +" + CategoryInfo : ParserError: (:) [], ParseException +" + FullyQualifiedErrorId : TerminatorExpectedAtEndOfString +CompilerSet errorformat+=At\ %f:%l\ char:%c + + +let &cpo = s:cpo_save +unlet s:cpo_save + +" vim:set sw=2 sts=2: diff --git a/runtime/doc/Makefile b/runtime/doc/Makefile index fcbcdc5bd6..e5ff1646ce 100644 --- a/runtime/doc/Makefile +++ b/runtime/doc/Makefile @@ -30,6 +30,7 @@ DOCS = \ filetype.txt \ fold.txt \ ft_ada.txt \ + ft_ps1.txt \ ft_rust.txt \ ft_sql.txt \ gui.txt \ @@ -173,6 +174,7 @@ HTMLS = \ filetype.html \ fold.html \ ft_ada.html \ + ft_ps1.html \ ft_rust.html \ ft_sql.html \ gui.html \ diff --git a/runtime/doc/cmdline.txt b/runtime/doc/cmdline.txt index 92560216ee..68cb04000e 100644 --- a/runtime/doc/cmdline.txt +++ b/runtime/doc/cmdline.txt @@ -1,4 +1,4 @@ -*cmdline.txt* For Vim version 8.2. Last change: 2021 Jan 26 +*cmdline.txt* For Vim version 8.2. Last change: 2021 Apr 05 VIM REFERENCE MANUAL by Bram Moolenaar @@ -597,9 +597,11 @@ followed by another Vim command: :global :help :helpfind + :helpgrep :lcscope :ldo :lfdo + :lhelpgrep :make :normal :perl diff --git a/runtime/doc/editing.txt b/runtime/doc/editing.txt index 4c4de79ee3..1351d4e96e 100644 --- a/runtime/doc/editing.txt +++ b/runtime/doc/editing.txt @@ -1,4 +1,4 @@ -*editing.txt* For Vim version 8.2. Last change: 2021 Jan 08 +*editing.txt* For Vim version 8.2. Last change: 2021 Apr 05 VIM REFERENCE MANUAL by Bram Moolenaar @@ -1253,7 +1253,7 @@ For versions of Vim where browsing is not supported, the command is executed unmodified. *browsefilter* -For MS Windows and GTK, you can modify the filters that are used in the browse +For MS-Windows and GTK, you can modify the filters that are used in the browse dialog. By setting the g:browsefilter or b:browsefilter variables, you can change the filters globally or locally to the buffer. The variable is set to a string in the format "{filter label}\t{pattern};{pattern}\n" where {filter diff --git a/runtime/doc/eval.txt b/runtime/doc/eval.txt index 97c968c748..798f58da54 100644 --- a/runtime/doc/eval.txt +++ b/runtime/doc/eval.txt @@ -1,4 +1,4 @@ -*eval.txt* For Vim version 8.2. Last change: 2021 Mar 28 +*eval.txt* For Vim version 8.2. Last change: 2021 Apr 07 VIM REFERENCE MANUAL by Bram Moolenaar @@ -1550,8 +1550,11 @@ the following ways: The arguments are optional. Example: > :let F = {-> 'error function'} - :echo F() + :echo F('ignored') < error function + +Note that in Vim9 script another kind of lambda can be used: |vim9-lambda|. + *closure* Lambda expressions can access outer scope variables and arguments. This is often called a closure. Example where "i" and "a:arg" are used in a lambda @@ -1586,7 +1589,7 @@ The lambda expression is also useful for Channel, Job and timer: > Handler called Note how execute() is used to execute an Ex command. That's ugly though. - +In Vim9 script you can use a command block, see |inline-function|. Lambda expressions have internal names like '42'. If you get an error for a lambda expression, you can find what it is with the following command: > @@ -6087,7 +6090,7 @@ getwininfo([{winid}]) *getwininfo()* tab pages is returned. Each List item is a |Dictionary| with the following entries: - botline last displayed buffer line + botline last complete displayed buffer line bufnr number of buffer in the window height window height (excluding winbar) loclist 1 if showing a location list @@ -11866,7 +11869,7 @@ gui_mac Compiled with Macintosh GUI. gui_motif Compiled with Motif GUI. gui_photon Compiled with Photon GUI. gui_running Vim is running in the GUI, or it will start soon. -gui_win32 Compiled with MS Windows Win32 GUI. +gui_win32 Compiled with MS-Windows Win32 GUI. gui_win32s idem, and Win32s system being used (Windows 3.1) haiku Haiku version of Vim. hangul_input Compiled with Hangul input support. |hangul| diff --git a/runtime/doc/ft_ps1.txt b/runtime/doc/ft_ps1.txt new file mode 100644 index 0000000000..df1480b929 --- /dev/null +++ b/runtime/doc/ft_ps1.txt @@ -0,0 +1,64 @@ +*ps1.txt* A Windows PowerShell syntax plugin for Vim + +Author: Peter Provost +License: Apache 2.0 +URL: https://github.com/PProvost/vim-ps1 + +INTRODUCTION *ps1-syntax* + +This plugin provides Vim syntax, indent and filetype detection for Windows +PowerShell scripts, modules, and XML configuration files. + + +ABOUT *ps1-about* + +Grab the latest version or report a bug on GitHub: + +https://github.com/PProvost/vim-ps1 + + +FOLDING *ps1-folding* + +The ps1 syntax file provides syntax folding (see |:syn-fold|) for script blocks +and digital signatures in scripts. + +When 'foldmethod' is set to "syntax" then function script blocks will be +folded unless you use the following in your .vimrc or before opening a script: > + + :let g:ps1_nofold_blocks = 1 +< +Digital signatures in scripts will also be folded unless you use: > + + :let g:ps1_nofold_sig = 1 +< +Note: syntax folding might slow down syntax highlighting significantly, +especially for large files. + + +COMPILER *ps1-compiler* + +The powershell `:compiler` script configures |:make| to execute the script in +PowerShell. + +It tries to pick a smart default PowerShell command: `pwsh` if available and +`powershell` otherwise, but you can customize the command: > + + :let g:ps1_makeprg_cmd = '/path/to/pwsh' +< +To configure whether to show the exception type information: > + + :let g:ps1_efm_show_error_categories = 1 +< + +KEYWORD LOOKUP *ps1-keyword* + +To look up keywords using PowerShell's Get-Help, press the |K| key. For more +convenient paging, the pager `less` should be installed, which is included in +many Linux distributions and in macOS. + +Many other distributions are available for Windows like +https://chocolatey.org/packages/less/. Make sure `less` is in a directory +listed in the `PATH` environment variable, which chocolatey above does. + +------------------------------------------------------------------------------ + vim:ft=help: diff --git a/runtime/doc/gui_w32.txt b/runtime/doc/gui_w32.txt index c0f8867739..b83df1b98b 100644 --- a/runtime/doc/gui_w32.txt +++ b/runtime/doc/gui_w32.txt @@ -1,4 +1,4 @@ -*gui_w32.txt* For Vim version 8.2. Last change: 2020 Mar 25 +*gui_w32.txt* For Vim version 8.2. Last change: 2021 Apr 05 VIM REFERENCE MANUAL by Bram Moolenaar @@ -403,7 +403,7 @@ The "File/Print" menu prints the text with syntax highlighting, see printer installed this should also work: > :w >>prn -Vim supports a number of standard MS Windows features. Some of these are +Vim supports a number of standard MS-Windows features. Some of these are detailed elsewhere: see |'mouse'|, |win32-hidden-menus|. *drag-n-drop-win32* diff --git a/runtime/doc/if_lua.txt b/runtime/doc/if_lua.txt index b7ccb04c53..48b42e65db 100644 --- a/runtime/doc/if_lua.txt +++ b/runtime/doc/if_lua.txt @@ -1,4 +1,4 @@ -*if_lua.txt* For Vim version 8.2. Last change: 2020 Jun 28 +*if_lua.txt* For Vim version 8.2. Last change: 2021 Apr 07 VIM REFERENCE MANUAL by Luis Carvalho diff --git a/runtime/doc/mbyte.txt b/runtime/doc/mbyte.txt index 41e42a2aec..7a5cca3ac9 100644 --- a/runtime/doc/mbyte.txt +++ b/runtime/doc/mbyte.txt @@ -1,4 +1,4 @@ -*mbyte.txt* For Vim version 8.2. Last change: 2020 Aug 15 +*mbyte.txt* For Vim version 8.2. Last change: 2021 Apr 05 VIM REFERENCE MANUAL by Bram Moolenaar et al. @@ -770,7 +770,7 @@ is suitable for complex input, such as CJK. of the two ways: FrontEnd system and BackEnd system. In the FrontEnd system, input events are snatched by the |IM-server| first, then |IM-server| give the application the result of input. On the other hand, the BackEnd - system works reverse order. MS Windows adopt BackEnd system. In X, most of + system works reverse order. MS-Windows adopt BackEnd system. In X, most of |IM-server|s adopt FrontEnd system. The demerit of BackEnd system is the large overhead in communication, but it provides safe synchronization with no restrictions on applications. diff --git a/runtime/doc/options.txt b/runtime/doc/options.txt index 0f628c0397..eb607d9cd9 100644 --- a/runtime/doc/options.txt +++ b/runtime/doc/options.txt @@ -1,4 +1,4 @@ -*options.txt* For Vim version 8.2. Last change: 2021 Mar 29 +*options.txt* For Vim version 8.2. Last change: 2021 Apr 07 VIM REFERENCE MANUAL by Bram Moolenaar @@ -4148,7 +4148,7 @@ A jump table for the options with a short description can be found at |Q_op|. the window. This happens only when the 'icon' option is on. Only works if the terminal supports setting window icon text (currently only X11 GUI and terminals with a non-empty 't_IS' option). - Does not work for MS Windows. + Does not work for MS-Windows. When Vim was compiled with HAVE_X11 defined, the original icon will be restored if possible |X11|. When this option contains printf-style '%' items, they will be @@ -5036,7 +5036,7 @@ A jump table for the options with a short description can be found at |Q_op|. jump between two double quotes. The characters must be separated by a colon. The pairs must be separated by a comma. Example for including '<' and - '>' (HTML): > + '>' (for HTML): > :set mps+=<:> < A more exotic example, to jump between the '=' and ';' in an @@ -8790,23 +8790,31 @@ A jump table for the options with a short description can be found at |Q_op|. part specifies what to do for each consecutive use of 'wildchar'. The first part specifies the behavior for the first use of 'wildchar', The second part for the second use, etc. - These are the possible values for each part: + + Each part consists of a colon separated list consisting of the + following possible values: "" Complete only the first match. "full" Complete the next full match. After the last match, the original string is used and then the first match - again. + again. Will also start 'wildmenu' if it is enabled. "longest" Complete till longest common string. If this doesn't result in a longer string, use the next part. - "longest:full" Like "longest", but also start 'wildmenu' if it is - enabled. "list" When more than one match, list all matches. + "lastused" When completing buffer names and more than one buffer + matches, sort buffers by time last used (other than + the current buffer). + When there is only a single match, it is fully completed in all cases. + + Examples of useful colon-separated values: + "longest:full" Like "longest", but also start 'wildmenu' if it is + enabled. Will not complete to the next full match. "list:full" When more than one match, list all matches and complete first match. "list:longest" When more than one match, list all matches and complete till longest common string. - "list:lastused" When more than one buffer matches, sort buffers - by time last used (other than the current buffer). - When there is only a single match, it is fully completed in all cases. + "list:lastused" When more than one buffer matches, list all matches + and sort buffers by time last used (other than the + current buffer). Examples: > :set wildmode=full diff --git a/runtime/doc/os_win32.txt b/runtime/doc/os_win32.txt index 1017d4d261..6c366083f6 100644 --- a/runtime/doc/os_win32.txt +++ b/runtime/doc/os_win32.txt @@ -1,4 +1,4 @@ -*os_win32.txt* For Vim version 8.2. Last change: 2017 Mar 21 +*os_win32.txt* For Vim version 8.2. Last change: 2021 Apr 05 VIM REFERENCE MANUAL by George Reilly @@ -83,7 +83,7 @@ executable() returns 1 the executable can actually be executed. Command line arguments *win32-cmdargs* -Analysis of a command line into parameters is not standardised in MS Windows. +Analysis of a command line into parameters is not standardised in MS-Windows. Vim and gvim used to use different logic to parse it (before 7.4.432), and the logic was also depended on what it was compiled with. Now Vim and gvim both use the CommandLineToArgvW() Win32 API, so they behave in the same way. diff --git a/runtime/doc/syntax.txt b/runtime/doc/syntax.txt index a165e83d64..685485d035 100644 --- a/runtime/doc/syntax.txt +++ b/runtime/doc/syntax.txt @@ -1,4 +1,4 @@ -*syntax.txt* For Vim version 8.2. Last change: 2021 Mar 06 +*syntax.txt* For Vim version 8.2. Last change: 2021 Apr 02 VIM REFERENCE MANUAL by Bram Moolenaar diff --git a/runtime/doc/tags b/runtime/doc/tags index c070a126a3..b28f644e66 100644 --- a/runtime/doc/tags +++ b/runtime/doc/tags @@ -5434,6 +5434,7 @@ assert_fails() testing.txt /*assert_fails()* assert_false() testing.txt /*assert_false()* assert_inrange() testing.txt /*assert_inrange()* assert_match() testing.txt /*assert_match()* +assert_nobeep() testing.txt /*assert_nobeep()* assert_notequal() testing.txt /*assert_notequal()* assert_notmatch() testing.txt /*assert_notmatch()* assert_report() testing.txt /*assert_report()* @@ -7507,6 +7508,7 @@ info-message starting.txt /*info-message* inform.vim syntax.txt /*inform.vim* informix ft_sql.txt /*informix* initialization starting.txt /*initialization* +inline-function vim9.txt /*inline-function* input() eval.txt /*input()* inputdialog() eval.txt /*inputdialog()* inputlist() eval.txt /*inputlist()* @@ -8582,6 +8584,12 @@ prop_type_change() textprop.txt /*prop_type_change()* prop_type_delete() textprop.txt /*prop_type_delete()* prop_type_get() textprop.txt /*prop_type_get()* prop_type_list() textprop.txt /*prop_type_list()* +ps1-about ft_ps1.txt /*ps1-about* +ps1-compiler ft_ps1.txt /*ps1-compiler* +ps1-folding ft_ps1.txt /*ps1-folding* +ps1-keyword ft_ps1.txt /*ps1-keyword* +ps1-syntax ft_ps1.txt /*ps1-syntax* +ps1.txt ft_ps1.txt /*ps1.txt* psql ft_sql.txt /*psql* ptcap.vim syntax.txt /*ptcap.vim* pterm-mouse options.txt /*pterm-mouse* @@ -10137,6 +10145,7 @@ vim9-export vim9.txt /*vim9-export* vim9-final vim9.txt /*vim9-final* vim9-gotchas vim9.txt /*vim9-gotchas* vim9-import vim9.txt /*vim9-import* +vim9-lambda vim9.txt /*vim9-lambda* vim9-mix vim9.txt /*vim9-mix* vim9-namespace vim9.txt /*vim9-namespace* vim9-rationale vim9.txt /*vim9-rationale* diff --git a/runtime/doc/testing.txt b/runtime/doc/testing.txt index 5d85358d71..6fd2d45887 100644 --- a/runtime/doc/testing.txt +++ b/runtime/doc/testing.txt @@ -1,4 +1,4 @@ -*testing.txt* For Vim version 8.2. Last change: 2021 Mar 10 +*testing.txt* For Vim version 8.2. Last change: 2021 Apr 02 VIM REFERENCE MANUAL by Bram Moolenaar diff --git a/runtime/doc/todo.txt b/runtime/doc/todo.txt index 8e70f36e86..1a3f4cc57d 100644 --- a/runtime/doc/todo.txt +++ b/runtime/doc/todo.txt @@ -1,4 +1,4 @@ -*todo.txt* For Vim version 8.2. Last change: 2021 Mar 29 +*todo.txt* For Vim version 8.2. Last change: 2021 Apr 05 VIM REFERENCE MANUAL by Bram Moolenaar @@ -42,17 +42,12 @@ Vim9 - Make everything work: - For builtin functions using tv_get_string*() use check_for_string() to be more strict about the argument type (not a bool). done: balloon_() -- Run the same tests in :def and Vim9 script, like in Test_expr7_not() - Check many more builtin function arguments at compile time. -- make 0 == 'string' fail on the script level, like inside :def. -- Check that when using a user function name without prefix, it does not find - a global function. Prefixing g: is required. -- Appending to dict item doesn't work in a :def function: - var d: dict = {a: 'x'} - d['a'] ..= 'y' - d.a ..= 'y' - Test to be extended: Test_assign_dict_with_op() - Using ".." at script level doesn't convert arguments to a string. +- This fails in a :def function but not at the script level: + var s = 'asdf'->((a) => a)('x') + Disallow passing more arguments to lambda than expected? +- Implement blob index and slice, also with assignment? - Compile replacement of :s command: s/pat/\=expr/ - Compile redir to local variable: var_redir_start(). - Implement type cast at the script level. diff --git a/runtime/doc/usr_02.txt b/runtime/doc/usr_02.txt index a866b7abbf..53d6cb5485 100644 --- a/runtime/doc/usr_02.txt +++ b/runtime/doc/usr_02.txt @@ -43,7 +43,7 @@ like: |~ | |"file.txt" [New file] | +---------------------------------------+ - ('#" is the cursor position.) + ('#' is the cursor position.) The tilde (~) lines indicate lines not in the file. In other words, when Vim runs out of file to display, it displays tilde lines. At the bottom of the diff --git a/runtime/doc/version5.txt b/runtime/doc/version5.txt index 2b44cbda77..d74f5a7377 100644 --- a/runtime/doc/version5.txt +++ b/runtime/doc/version5.txt @@ -1,4 +1,4 @@ -*version5.txt* For Vim version 8.2. Last change: 2020 Dec 19 +*version5.txt* For Vim version 8.2. Last change: 2021 Apr 05 VIM REFERENCE MANUAL by Bram Moolenaar @@ -405,7 +405,7 @@ Both of these are only available when enabled at compile time. Win32 GUI version *added-win32-GUI* ----------------- -The GUI has been ported to MS Windows 95 and NT. All the features of the X11 +The GUI has been ported to MS-Windows 95 and NT. All the features of the X11 GUI are available to Windows users now. |gui-w32| This also fixes problems with running the Win32 console version under Windows 95, where console support has always been bad. @@ -4403,7 +4403,7 @@ the last char of the line, "<<" moved an extra line. Also for other operators that always work on lines. link.sh changed "-lnsl_s" to "_s" when looking for "nsl" to be removed. -Now it only remove whole words. +Now it only removes whole words. When jumped to a mark or using "fz", and there is an error, the current column was lost. E.g. when using "$fzj". diff --git a/runtime/doc/version6.txt b/runtime/doc/version6.txt index ca1800fe35..de364d64a3 100644 --- a/runtime/doc/version6.txt +++ b/runtime/doc/version6.txt @@ -1,4 +1,4 @@ -*version6.txt* For Vim version 8.2. Last change: 2021 Jan 17 +*version6.txt* For Vim version 8.2. Last change: 2021 Apr 05 VIM REFERENCE MANUAL by Bram Moolenaar @@ -1025,7 +1025,7 @@ Port to OS/390 Unix (Ralf Schandl) Included jsbmouse support. (Darren Garth) Support for dec mouse in Unix. (Steve Wall) -Port to 16-bit MS Windows (Windows 3.1x) (Vince Negri) +Port to 16-bit MS-Windows (Windows 3.1x) (Vince Negri) Port to QNX. Supports the Photon GUI, mouse, etc. (Julian Kinraid) diff --git a/runtime/doc/vim9.txt b/runtime/doc/vim9.txt index 974ee6af6b..e693cba1df 100644 --- a/runtime/doc/vim9.txt +++ b/runtime/doc/vim9.txt @@ -1,4 +1,4 @@ -*vim9.txt* For Vim version 8.2. Last change: 2021 Mar 30 +*vim9.txt* For Vim version 8.2. Last change: 2021 Apr 06 VIM REFERENCE MANUAL by Bram Moolenaar @@ -305,13 +305,21 @@ Variables, functions and function arguments cannot shadow previously defined or imported variables and functions in the same script file. Variables may shadow Ex commands, rename the variable if needed. -Global variables and user defined functions must be prefixed with "g:", also -at the script level. > +Global variables must be prefixed with "g:", also at the script level. > vim9script var script_local = 'text' g:global = 'value' var Funcref = g:ThatFunction +Global functions must be prefixed with "g:" when defining them, but can be +called without "g:". > + vim9script + def g:GlobalFunc(): string + return 'text' + enddef + echo GlobalFunc() +The "g:" prefix is not needed for auto-load functions. + Since `&opt = value` is now assigning a value to option "opt", ":&" cannot be used to repeat a `:substitute` command. @@ -401,7 +409,7 @@ number of arguments and any return type. The function can be defined later. Lambda using => instead of -> ~ - + *vim9-lambda* In legacy script there can be confusion between using "->" for a method call and for a lambda. Also, when a "{" is found the parser needs to figure out if it is the start of a lambda or a dictionary, which is now more complicated @@ -425,12 +433,19 @@ But you can use a backslash to concatenate the lines before parsing: > filter(list, (k, \ v) \ => v > 0) - +< *inline-function* Additionally, a lambda can contain statements in {}: > var Lambda = (arg) => { g:was_called = 'yes' return expression } +This can be useful for a timer, for example: > + var count = 0 + var timer = timer_start(500, (_) => { + count += 1 + echom 'Handler called ' .. count + }, {repeat: 3}) + The ending "}" must be at the start of a line. It can be followed by other characters, e.g.: > @@ -836,7 +851,7 @@ Patterns are used like 'magic' is set, unless explicitly overruled. The 'edcompatible' option value is not used. The 'gdefault' option value is not used. -You may also find this wiki useful. It was written by an early adoptor of +You may also find this wiki useful. It was written by an early adopter of Vim9 script: https://github.com/lacygoill/wiki/blob/master/vim/vim9.md ============================================================================== @@ -881,14 +896,14 @@ THIS IS STILL UNDER DEVELOPMENT - ANYTHING CAN BREAK - ANYTHING CAN CHANGE :enddef End of a function defined with `:def`. It should be on a line by its own. -You may also find this wiki useful. It was written by an early adoptor of +You may also find this wiki useful. It was written by an early adopter of Vim9 script: https://github.com/lacygoill/wiki/blob/master/vim/vim9.md If the script the function is defined in is Vim9 script, then script-local variables can be accessed without the "s:" prefix. They must be defined before the function is compiled. If the script the function is defined in is legacy script, then script-local variables must be accessed with the "s:" -prefix and they do not need to exist (they can be deleted any time). +prefix if they do not exist at the time of compiling. *:defc* *:defcompile* :defc[ompile] Compile functions defined in the current script that @@ -1073,12 +1088,15 @@ dictionary. If there is a mix of types, the "any" type is used. > ['a', 'b', 'c'] list [1, 'x', 3] list +For script-local variables in Vim9 script the type is checked, also when the +variable was declared in a legacy function. + Stricter type checking ~ *type-checking* In legacy Vim script, where a number was expected, a string would be automatically converted to a number. This was convenient for an actual number -such as "123", but leads to unexpected problems (but no error message) if the +such as "123", but leads to unexpected problems (and no error message) if the string doesn't start with a number. Quite often this leads to hard-to-find bugs. diff --git a/runtime/ftplugin/fortran.vim b/runtime/ftplugin/fortran.vim index b9ba3c4722..26dc90a184 100644 --- a/runtime/ftplugin/fortran.vim +++ b/runtime/ftplugin/fortran.vim @@ -1,13 +1,13 @@ " Vim settings file " Language: Fortran 2008 (and older: Fortran 2003, 95, 90, 77, 66) -" Version: (v52) 2020 October 07 +" Version: (v53) 2021 April 06 " Maintainer: Ajit J. Thakkar ; " Usage: For instructions, do :help fortran-plugin from Vim " Credits: " Version 0.1 was created in September 2000 by Ajit Thakkar. " Since then, useful suggestions and contributions have been made, in order, by: " Stefano Zacchiroli, Hendrik Merx, Ben Fritz, David Barnett, Eisuke Kawashima, -" and Doug Kearns. +" Doug Kearns, and Fritz Reese. " Only do these settings when not done yet for this buffer if exists("b:did_ftplugin") @@ -66,12 +66,19 @@ endif " Set comments and textwidth according to source type if (b:fortran_fixed_source == 1) setlocal comments=:!,:*,:C - " Fixed format requires a textwidth of 72 for code - setlocal tw=72 + " Fixed format requires a textwidth of 72 for code, + " but some vendor extensions allow longer lines + if exists("fortran_extended_line_length") + setlocal tw=132 + elseif exists("fortran_cardimage_line_length") + setlocal tw=80 + else + setlocal tw=72 " If you need to add "&" on continued lines so that the code is " compatible with both free and fixed format, then you should do so " in column 73 and uncomment the next line " setlocal tw=73 + endif else setlocal comments=:! " Free format allows a textwidth of 132 diff --git a/runtime/ftplugin/ps1.vim b/runtime/ftplugin/ps1.vim new file mode 100644 index 0000000000..aac3bc9903 --- /dev/null +++ b/runtime/ftplugin/ps1.vim @@ -0,0 +1,59 @@ +" Vim filetype plugin file +" Language: Windows PowerShell +" URL: https://github.com/PProvost/vim-ps1 +" Last Change: 2021 Apr 02 + +" Only do this when not done yet for this buffer +if exists("b:did_ftplugin") | finish | endif + +" Don't load another plug-in for this buffer +let b:did_ftplugin = 1 + +let s:cpo_save = &cpo +set cpo&vim + +setlocal tw=0 +setlocal commentstring=#%s +setlocal formatoptions=tcqro +" Enable autocompletion of hyphenated PowerShell commands, +" e.g. Get-Content or Get-ADUser +setlocal iskeyword+=- + +" Change the browse dialog on Win32 to show mainly PowerShell-related files +if has("gui_win32") + let b:browsefilter = + \ "All PowerShell Files (*.ps1, *.psd1, *.psm1, *.ps1xml)\t*.ps1;*.psd1;*.psm1;*.ps1xml\n" . + \ "PowerShell Script Files (*.ps1)\t*.ps1\n" . + \ "PowerShell Module Files (*.psd1, *.psm1)\t*.psd1;*.psm1\n" . + \ "PowerShell XML Files (*.ps1xml)\t*.ps1xml\n" . + \ "All Files (*.*)\t*.*\n" +endif + +" Look up keywords by Get-Help: +" check for PowerShell Core in Windows, Linux or MacOS +if executable('pwsh') | let s:pwsh_cmd = 'pwsh' + " on Windows Subsystem for Linux, check for PowerShell Core in Windows +elseif exists('$WSLENV') && executable('pwsh.exe') | let s:pwsh_cmd = 'pwsh.exe' + " check for PowerShell <= 5.1 in Windows +elseif executable('powershell.exe') | let s:pwsh_cmd = 'powershell.exe' +endif + +if exists('s:pwsh_cmd') + if !has('gui_running') && executable('less') && + \ !(exists('$ConEmuBuild') && &term =~? '^xterm') + " For exclusion of ConEmu, see https://github.com/Maximus5/ConEmu/issues/2048 + command! -buffer -nargs=1 GetHelp silent exe '!' . s:pwsh_cmd . ' -NoLogo -NoProfile -NonInteractive -ExecutionPolicy RemoteSigned -Command Get-Help -Full "" | ' . (has('unix') ? 'LESS= less' : 'less') | redraw! + elseif has('terminal') + command! -buffer -nargs=1 GetHelp silent exe 'term ' . s:pwsh_cmd . ' -NoLogo -NoProfile -NonInteractive -ExecutionPolicy RemoteSigned -Command Get-Help -Full ""' . (executable('less') ? ' | less' : '') + else + command! -buffer -nargs=1 GetHelp echo system(s:pwsh_cmd . ' -NoLogo -NoProfile -NonInteractive -ExecutionPolicy RemoteSigned -Command Get-Help -Full ') + endif +endif +setlocal keywordprg=:GetHelp + +" Undo the stuff we changed +let b:undo_ftplugin = "setlocal tw< cms< fo< iskeyword< keywordprg<" . + \ " | unlet! b:browsefilter" + +let &cpo = s:cpo_save +unlet s:cpo_save diff --git a/runtime/ftplugin/ps1xml.vim b/runtime/ftplugin/ps1xml.vim new file mode 100644 index 0000000000..837a3309b4 --- /dev/null +++ b/runtime/ftplugin/ps1xml.vim @@ -0,0 +1,34 @@ +" Vim filetype plugin file +" Language: Windows PowerShell +" URL: https://github.com/PProvost/vim-ps1 +" Last Change: 2021 Apr 02 + +" Only do this when not done yet for this buffer +if exists("b:did_ftplugin") | finish | endif + +" Don't load another plug-in for this buffer +let b:did_ftplugin = 1 + +let s:cpo_save = &cpo +set cpo&vim + +setlocal tw=0 +setlocal commentstring=#%s +setlocal formatoptions=tcqro + +" Change the browse dialog on Win32 to show mainly PowerShell-related files +if has("gui_win32") + let b:browsefilter = + \ "All PowerShell Files (*.ps1, *.psd1, *.psm1, *.ps1xml)\t*.ps1;*.psd1;*.psm1;*.ps1xml\n" . + \ "PowerShell Script Files (*.ps1)\t*.ps1\n" . + \ "PowerShell Module Files (*.psd1, *.psm1)\t*.psd1;*.psm1\n" . + \ "PowerShell XML Files (*.ps1xml)\t*.ps1xml\n" . + \ "All Files (*.*)\t*.*\n" +endif + +" Undo the stuff we changed +let b:undo_ftplugin = "setlocal tw< cms< fo<" . + \ " | unlet! b:browsefilter" + +let &cpo = s:cpo_save +unlet s:cpo_save diff --git a/runtime/indent/ps1.vim b/runtime/indent/ps1.vim new file mode 100644 index 0000000000..0f794db83b --- /dev/null +++ b/runtime/indent/ps1.vim @@ -0,0 +1,17 @@ +" Vim indent file +" Language: Windows PowerShell +" URL: https://github.com/PProvost/vim-ps1 +" Last Change: 2017 Oct 19 + +" Only load this indent file when no other was loaded. +if exists("b:did_indent") + finish +endif +let b:did_indent = 1 + +" smartindent is good enough for powershell +setlocal smartindent +" disable the indent removal for # marks +inoremap # X# + +let b:undo_indent = "setl si<" diff --git a/runtime/plugin/matchparen.vim b/runtime/plugin/matchparen.vim index 162430ecd0..0dad0ac0ea 100644 --- a/runtime/plugin/matchparen.vim +++ b/runtime/plugin/matchparen.vim @@ -1,6 +1,6 @@ " Vim plugin for showing matching parens " Maintainer: Bram Moolenaar -" Last Change: 2020 Jun 18 +" Last Change: 2021 Apr 07 " Exit quickly when: " - this plugin was already loaded (or disabled) @@ -107,9 +107,10 @@ func s:Highlight_Matching_Pair() " Build an expression that detects whether the current cursor position is " in certain syntax types (string, comment, etc.), for use as " searchpairpos()'s skip argument. - " We match "escape" for special items, such as lispEscapeSpecial. + " We match "escape" for special items, such as lispEscapeSpecial, and + " match "symbol" for lispBarSymbol. let s_skip = '!empty(filter(map(synstack(line("."), col(".")), ''synIDattr(v:val, "name")''), ' . - \ '''v:val =~? "string\\|character\\|singlequote\\|escape\\|comment"''))' + \ '''v:val =~? "string\\|character\\|singlequote\\|escape\\symbol\\|comment"''))' " If executing the expression determines that the cursor is currently in " one of the syntax types, then we want searchpairpos() to find the pair " within those syntax types (i.e., not skip). Otherwise, the cursor is diff --git a/runtime/syntax/fortran.vim b/runtime/syntax/fortran.vim index 8ebd120226..b5c9b1ef8d 100644 --- a/runtime/syntax/fortran.vim +++ b/runtime/syntax/fortran.vim @@ -1,6 +1,6 @@ " Vim syntax file " Language: Fortran 2008 (and older: Fortran 2003, 95, 90, and 77) -" Version: (v103) 2020 October 07 +" Version: (v104) 2021 April 06 " Maintainer: Ajit J. Thakkar ; " Usage: For instructions, do :help fortran-syntax from Vim " Credits: @@ -8,10 +8,10 @@ " older Fortran 77 syntax file by Mario Eusebio and Preben Guldberg. " Since then, useful suggestions and contributions have been made, in order, by: " Andrej Panjkov, Bram Moolenaar, Thomas Olsen, Michael Sternberg, Christian Reile, -" Walter Dieudonné, Alexander Wagner, Roman Bertle, Charles Rendleman, +" Walter Dieudonne, Alexander Wagner, Roman Bertle, Charles Rendleman, " Andrew Griffiths, Joe Krahn, Hendrik Merx, Matt Thompson, Jan Hermann, -" Stefano Zaghi, Vishnu V. Krishnan, Judicaël Grasset, Takuma Yoshida, -" Eisuke Kawashima, and André Chalella.` +" Stefano Zaghi, Vishnu V. Krishnan, Judicael Grasset, Takuma Yoshida, +" Eisuke Kawashima, Andre Chalella, and Fritz Reese. if exists("b:current_syntax") finish @@ -360,8 +360,15 @@ syn cluster fortranCommentGroup contains=fortranTodo if (b:fortran_fixed_source == 1) if !exists("fortran_have_tabs") - "Flag items beyond column 72 - syn match fortranSerialNumber excludenl "^.\{73,}$"lc=72 + " Fixed format requires a textwidth of 72 for code, + " but some vendor extensions allow longer lines + if exists("fortran_extended_line_length") + syn match fortranSerialNumber excludenl "^.\{133,}$"lc=132 + elseif exists("fortran_cardimage_line_length") + syn match fortranSerialNumber excludenl "^.\{81,}$"lc=80 + else + syn match fortranSerialNumber excludenl "^.\{73,}$"lc=72 + endif "Flag left margin errors syn match fortranLabelError "^.\{-,4}[^0-9 ]" contains=fortranTab syn match fortranLabelError "^.\{4}\d\S" diff --git a/runtime/syntax/nasm.vim b/runtime/syntax/nasm.vim index 4f70a0f334..d763033225 100644 --- a/runtime/syntax/nasm.vim +++ b/runtime/syntax/nasm.vim @@ -3,7 +3,7 @@ " Maintainer: Andrii Sokolov " Original Author: Manuel M.H. Stol " Former Maintainer: Manuel M.H. Stol -" Contributors: Leonard König (C string highlighting) +" Contributors: Leonard König (C string highlighting), Peter Stanhope (Add missing 64-bit mode registers) " Last Change: 2017 Jan 23 " NASM Home: http://www.nasm.us/ @@ -240,7 +240,8 @@ syn cluster nasmGrpPreProcs contains=nasmMacroDef,@nasmGrpInMacros,@nasmGrpPreCo syn match nasmGen08Register "\<[A-D][HL]\>" syn match nasmGen16Register "\<\([A-D]X\|[DS]I\|[BS]P\)\>" syn match nasmGen32Register "\" -syn match nasmGen64Register "\" +syn match nasmGen64Register "\" +syn match nasmExtRegister "\<\([SB]PL\|[SD]IL\)\>" syn match nasmSegRegister "\<[C-GS]S\>" syn match nasmSpcRegister "\" syn match nasmFpuRegister "\" diff --git a/runtime/syntax/ps1.vim b/runtime/syntax/ps1.vim new file mode 100644 index 0000000000..e8f6b2f8ed --- /dev/null +++ b/runtime/syntax/ps1.vim @@ -0,0 +1,182 @@ +" Vim syntax file +" Language: Windows PowerShell +" URL: https://github.com/PProvost/vim-ps1 +" Last Change: 2020 Nov 24 +" +" The following settings are available for tuning syntax highlighting: +" let ps1_nofold_blocks = 1 +" let ps1_nofold_sig = 1 +" let ps1_nofold_region = 1 + +if exists("b:current_syntax") + finish +endif + +" Operators contain dashes +setlocal iskeyword+=- + +" PowerShell doesn't care about case +syn case ignore + +" Sync-ing method +syn sync minlines=100 + +" Certain tokens can't appear at the top level of the document +syn cluster ps1NotTop contains=@ps1Comment,ps1CDocParam,ps1FunctionDeclaration + +" Comments and special comment words +syn keyword ps1CommentTodo TODO FIXME XXX TBD HACK NOTE contained +syn match ps1CDocParam /.*/ contained +syn match ps1CommentDoc /^\s*\zs\.\w\+\>/ nextgroup=ps1CDocParam contained +syn match ps1CommentDoc /#\s*\zs\.\w\+\>/ nextgroup=ps1CDocParam contained +syn match ps1Comment /#.*/ contains=ps1CommentTodo,ps1CommentDoc,@Spell +syn region ps1Comment start="<#" end="#>" contains=ps1CommentTodo,ps1CommentDoc,@Spell + +" Language keywords and elements +syn keyword ps1Conditional if else elseif switch default +syn keyword ps1Repeat while for do until break continue foreach in +syn match ps1Repeat /\/ nextgroup=ps1Block skipwhite +syn match ps1Keyword /\/ nextgroup=ps1Block skipwhite +syn match ps1Keyword /\/ nextgroup=ps1Block skipwhite + +syn keyword ps1Exception begin process end exit inlinescript parallel sequence +syn keyword ps1Keyword try catch finally throw +syn keyword ps1Keyword return filter in trap param data dynamicparam +syn keyword ps1Constant $true $false $null +syn match ps1Constant +\$?+ +syn match ps1Constant +\$_+ +syn match ps1Constant +\$\$+ +syn match ps1Constant +\$^+ + +" Keywords reserved for future use +syn keyword ps1Keyword class define from using var + +" Function declarations +syn keyword ps1Keyword function nextgroup=ps1Function skipwhite +syn keyword ps1Keyword filter nextgroup=ps1Function skipwhite +syn keyword ps1Keyword workflow nextgroup=ps1Function skipwhite +syn keyword ps1Keyword configuration nextgroup=ps1Function skipwhite +syn keyword ps1Keyword class nextgroup=ps1Function skipwhite +syn keyword ps1Keyword enum nextgroup=ps1Function skipwhite + +" Function declarations and invocations +syn match ps1Cmdlet /\v(add|clear|close|copy|enter|exit|find|format|get|hide|join|lock|move|new|open|optimize|pop|push|redo|remove|rename|reset|search|select|Set|show|skip|split|step|switch|undo|unlock|watch)(-\w+)+/ contained +syn match ps1Cmdlet /\v(connect|disconnect|read|receive|send|write)(-\w+)+/ contained +syn match ps1Cmdlet /\v(backup|checkpoint|compare|compress|convert|convertfrom|convertto|dismount|edit|expand|export|group|import|initialize|limit|merge|mount|out|publish|restore|save|sync|unpublish|update)(-\w+)+/ contained +syn match ps1Cmdlet /\v(debug|measure|ping|repair|resolve|test|trace)(-\w+)+/ contained +syn match ps1Cmdlet /\v(approve|assert|build|complete|confirm|deny|deploy|disable|enable|install|invoke|register|request|restart|resume|start|stop|submit|suspend|uninstall|unregister|wait)(-\w+)+/ contained +syn match ps1Cmdlet /\v(block|grant|protect|revoke|unblock|unprotect)(-\w+)+/ contained +syn match ps1Cmdlet /\v(use)(-\w+)+/ contained + +" Other functions +syn match ps1Function /\w\+\(-\w\+\)\+/ contains=ps1Cmdlet + +" Type declarations +syn match ps1Type /\[[a-z_][a-z0-9_.,\[\]]\+\]/ + +" Variable references +syn match ps1ScopeModifier /\(global:\|local:\|private:\|script:\)/ contained +syn match ps1Variable /\$\w\+\(:\w\+\)\?/ contains=ps1ScopeModifier +syn match ps1Variable /\${\w\+\(:\?[[:alnum:]_()]\+\)\?}/ contains=ps1ScopeModifier + +" Operators +syn keyword ps1Operator -eq -ne -ge -gt -lt -le -like -notlike -match -notmatch -replace -split -contains -notcontains +syn keyword ps1Operator -ieq -ine -ige -igt -ile -ilt -ilike -inotlike -imatch -inotmatch -ireplace -isplit -icontains -inotcontains +syn keyword ps1Operator -ceq -cne -cge -cgt -clt -cle -clike -cnotlike -cmatch -cnotmatch -creplace -csplit -ccontains -cnotcontains +syn keyword ps1Operator -in -notin +syn keyword ps1Operator -is -isnot -as -join +syn keyword ps1Operator -and -or -not -xor -band -bor -bnot -bxor +syn keyword ps1Operator -f +syn match ps1Operator /!/ +syn match ps1Operator /=/ +syn match ps1Operator /+=/ +syn match ps1Operator /-=/ +syn match ps1Operator /\*=/ +syn match ps1Operator /\/=/ +syn match ps1Operator /%=/ +syn match ps1Operator /+/ +syn match ps1Operator /-\(\s\|\d\|\.\|\$\|(\)\@=/ +syn match ps1Operator /\*/ +syn match ps1Operator /\// +syn match ps1Operator /|/ +syn match ps1Operator /%/ +syn match ps1Operator /&/ +syn match ps1Operator /::/ +syn match ps1Operator /,/ +syn match ps1Operator /\(^\|\s\)\@<=\. \@=/ + +" Regular Strings +" These aren't precisely correct and could use some work +syn region ps1String start=/"/ skip=/`"/ end=/"/ contains=@ps1StringSpecial,@Spell +syn region ps1String start=/'/ skip=/''/ end=/'/ + +" Here-Strings +syn region ps1String start=/@"$/ end=/^"@/ contains=@ps1StringSpecial,@Spell +syn region ps1String start=/@'$/ end=/^'@/ + +" Interpolation +syn match ps1Escape /`./ +syn region ps1Interpolation matchgroup=ps1InterpolationDelimiter start="$(" end=")" contained contains=ALLBUT,@ps1NotTop +syn region ps1NestedParentheses start="(" skip="\\\\\|\\)" matchgroup=ps1Interpolation end=")" transparent contained +syn cluster ps1StringSpecial contains=ps1Escape,ps1Interpolation,ps1Variable,ps1Boolean,ps1Constant,ps1BuiltIn,@Spell + +" Numbers +syn match ps1Number "\(\<\|-\)\@<=\(0[xX]\x\+\|\d\+\)\([KMGTP][B]\)\=\(\>\|-\)\@=" +syn match ps1Number "\(\(\<\|-\)\@<=\d\+\.\d*\|\.\d\+\)\([eE][-+]\=\d\+\)\=[dD]\=" +syn match ps1Number "\<\d\+[eE][-+]\=\d\+[dD]\=\>" +syn match ps1Number "\<\d\+\([eE][-+]\=\d\+\)\=[dD]\>" + +" Constants +syn match ps1Boolean "$\%(true\|false\)\>" +syn match ps1Constant /\$null\>/ +syn match ps1BuiltIn "$^\|$?\|$_\|$\$" +syn match ps1BuiltIn "$\%(args\|error\|foreach\|home\|input\)\>" +syn match ps1BuiltIn "$\%(match\(es\)\?\|myinvocation\|host\|lastexitcode\)\>" +syn match ps1BuiltIn "$\%(ofs\|shellid\|stacktrace\)\>" + +" Named Switch +syn match ps1Label /\s-\w\+/ + +" Folding blocks +if !exists('g:ps1_nofold_blocks') + syn region ps1Block start=/{/ end=/}/ transparent fold +endif + +if !exists('g:ps1_nofold_region') + syn region ps1Region start=/#region/ end=/#endregion/ transparent fold keepend extend +endif + +if !exists('g:ps1_nofold_sig') + syn region ps1Signature start=/# SIG # Begin signature block/ end=/# SIG # End signature block/ transparent fold +endif + +" Setup default color highlighting +hi def link ps1Number Number +hi def link ps1Block Block +hi def link ps1Region Region +hi def link ps1Exception Exception +hi def link ps1Constant Constant +hi def link ps1String String +hi def link ps1Escape SpecialChar +hi def link ps1InterpolationDelimiter Delimiter +hi def link ps1Conditional Conditional +hi def link ps1Cmdlet Function +hi def link ps1Function Identifier +hi def link ps1Variable Identifier +hi def link ps1Boolean Boolean +hi def link ps1Constant Constant +hi def link ps1BuiltIn StorageClass +hi def link ps1Type Type +hi def link ps1ScopeModifier StorageClass +hi def link ps1Comment Comment +hi def link ps1CommentTodo Todo +hi def link ps1CommentDoc Tag +hi def link ps1CDocParam Identifier +hi def link ps1Operator Operator +hi def link ps1Repeat Repeat +hi def link ps1RepeatAndCmdlet Repeat +hi def link ps1Keyword Keyword +hi def link ps1KeywordAndCmdlet Keyword +hi def link ps1Label Label + +let b:current_syntax = "ps1" diff --git a/runtime/syntax/ps1xml.vim b/runtime/syntax/ps1xml.vim new file mode 100644 index 0000000000..6ca9ed0d1b --- /dev/null +++ b/runtime/syntax/ps1xml.vim @@ -0,0 +1,51 @@ +" Vim syntax file +" Language: Windows PowerShell +" URL: https://github.com/PProvost/vim-ps1 +" Last Change: 2013 Jun 24 + +if exists("b:current_syntax") + finish +endif + +let s:ps1xml_cpo_save = &cpo +set cpo&vim + +doau syntax xml +unlet b:current_syntax + +syn case ignore +syn include @ps1xmlScriptBlock :p:h/ps1.vim +unlet b:current_syntax + +syn region ps1xmlScriptBlock + \ matchgroup=xmlTag start="" + \ fold + \ contains=@ps1xmlScriptBlock + \ keepend +syn region ps1xmlScriptBlock + \ matchgroup=xmlTag start="" + \ matchgroup=xmlEndTag end="" + \ fold + \ contains=@ps1xmlScriptBlock + \ keepend +syn region ps1xmlScriptBlock + \ matchgroup=xmlTag start="" + \ matchgroup=xmlEndTag end="" + \ fold + \ contains=@ps1xmlScriptBlock + \ keepend +syn region ps1xmlScriptBlock + \ matchgroup=xmlTag start="" + \ matchgroup=xmlEndTag end="" + \ fold + \ contains=@ps1xmlScriptBlock + \ keepend + +syn cluster xmlRegionHook add=ps1xmlScriptBlock + +let b:current_syntax = "ps1xml" + +let &cpo = s:ps1xml_cpo_save +unlet s:ps1xml_cpo_save + diff --git a/src/po/fr.po b/src/po/fr.po index a5e7c48a4b..a650ebc93c 100644 --- a/src/po/fr.po +++ b/src/po/fr.po @@ -3049,7 +3049,7 @@ msgstr "-T \tR msgid "--not-a-term\t\tSkip warning for input/output not being a terminal" msgstr "" -"--no-a-term\t\tAucun avertissement si l'entrée/sortie n'est pas un terminal" +"--not-a-term\t\tAucun avertissement si l'entrée/sortie n'est pas un terminal" msgid "--ttyfail\t\tExit if input or output is not a terminal" msgstr "--ttyfail\t\tQuitte si l'entrée ou la sortie ne sont pas un terminal" From 15e5e53ef29a457126f7c699931ab5842431f2ea Mon Sep 17 00:00:00 2001 From: Bram Moolenaar Date: Wed, 7 Apr 2021 21:21:13 +0200 Subject: [PATCH 10/14] patch 8.2.2734: Vim9: cannot use legacy script-local var from :def function Problem: Vim9: cannot use legacy script-local var from :def function. Solution: Do not insist on using "s:" prefix. (closes #8076) --- src/proto/vim9compile.pro | 1 - src/testdir/test_vim9_expr.vim | 15 +++++++++++++++ src/version.c | 2 ++ src/vim9compile.c | 23 ++++++++--------------- 4 files changed, 25 insertions(+), 16 deletions(-) diff --git a/src/proto/vim9compile.pro b/src/proto/vim9compile.pro index 05d399867b..39624aef19 100644 --- a/src/proto/vim9compile.pro +++ b/src/proto/vim9compile.pro @@ -1,5 +1,4 @@ /* vim9compile.c */ -int script_var_exists(char_u *name, size_t len, int vim9script, cctx_T *cctx); int check_defined(char_u *p, size_t len, cctx_T *cctx, int is_arg); int check_compare_types(exprtype_T type, typval_T *tv1, typval_T *tv2); int use_typecheck(type_T *actual, type_T *expected); diff --git a/src/testdir/test_vim9_expr.vim b/src/testdir/test_vim9_expr.vim index 4e1e3d7fae..c86379eb1a 100644 --- a/src/testdir/test_vim9_expr.vim +++ b/src/testdir/test_vim9_expr.vim @@ -2714,6 +2714,21 @@ def Test_expr7_negate_add() CheckDefAndScriptFailure(lines, 'E1050:') enddef +def Test_expr7_legacy_script() + var lines =<< trim END + let s:legacy = 'legacy' + def GetLocal(): string + return legacy + enddef + def GetLocalPrefix(): string + return s:legacy + enddef + call assert_equal('legacy', GetLocal()) + call assert_equal('legacy', GetLocalPrefix()) + END + CheckScriptSuccess(lines) +enddef + def Echo(arg: any): string return arg enddef diff --git a/src/version.c b/src/version.c index 58d6d9f172..4eea2f1855 100644 --- a/src/version.c +++ b/src/version.c @@ -750,6 +750,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ +/**/ + 2734, /**/ 2733, /**/ diff --git a/src/vim9compile.c b/src/vim9compile.c index feb1838b7b..c4b5d3c1c0 100644 --- a/src/vim9compile.c +++ b/src/vim9compile.c @@ -332,22 +332,15 @@ script_is_vim9() /* * Lookup a variable (without s: prefix) in the current script. - * If "vim9script" is TRUE the script must be Vim9 script. Used for "var" - * without "s:". * "cctx" is NULL at the script level. * Returns OK or FAIL. */ - int -script_var_exists(char_u *name, size_t len, int vim9script, cctx_T *cctx) + static int +script_var_exists(char_u *name, size_t len, cctx_T *cctx) { - int is_vim9_script; - if (current_sctx.sc_sid <= 0) return FAIL; - is_vim9_script = script_is_vim9(); - if (vim9script && !is_vim9_script) - return FAIL; - if (is_vim9_script) + if (script_is_vim9()) { // Check script variables that were visible where the function was // defined. @@ -382,7 +375,7 @@ variable_exists(char_u *name, size_t len, cctx_T *cctx) return (cctx != NULL && (lookup_local(name, len, NULL, cctx) == OK || arg_exists(name, len, NULL, NULL, NULL, cctx) == OK)) - || script_var_exists(name, len, FALSE, cctx) == OK + || script_var_exists(name, len, cctx) == OK || find_imported(name, len, cctx) != NULL; } @@ -429,7 +422,7 @@ check_defined(char_u *p, size_t len, cctx_T *cctx, int is_arg) int c = p[len]; ufunc_T *ufunc = NULL; - if (script_var_exists(p, len, FALSE, cctx) == OK) + if (script_var_exists(p, len, cctx) == OK) { if (is_arg) semsg(_(e_argument_already_declared_in_script_str), p); @@ -2990,7 +2983,7 @@ compile_load( { // "var" can be script-local even without using "s:" if it // already exists in a Vim9 script or when it's imported. - if (script_var_exists(*arg, len, TRUE, cctx) == OK + if (script_var_exists(*arg, len, cctx) == OK || find_imported(name, 0, cctx) != NULL) res = compile_load_scriptvar(cctx, name, *arg, &end, FALSE); @@ -5844,9 +5837,9 @@ compile_lhs( && STRNCMP(var_start, "s:", 2) == 0; int script_var = (script_namespace ? script_var_exists(var_start + 2, lhs->lhs_varlen - 2, - FALSE, cctx) + cctx) : script_var_exists(var_start, lhs->lhs_varlen, - FALSE, cctx)) == OK; + cctx)) == OK; imported_T *import = find_imported(var_start, lhs->lhs_varlen, cctx); From fa5963880df1d11613594ab78c0a68f894d34aa3 Mon Sep 17 00:00:00 2001 From: Bram Moolenaar Date: Wed, 7 Apr 2021 21:58:16 +0200 Subject: [PATCH 11/14] patch 8.2.2735: Vim9: function reference found with prefix, not without Problem: Vim9: function reference found with prefix, not without. Solution: Also find function reference without prefix. --- src/testdir/test_vim9_expr.vim | 23 +++++++++++++++++++++++ src/version.c | 2 ++ src/vim9compile.c | 26 ++++++++++++++++++-------- 3 files changed, 43 insertions(+), 8 deletions(-) diff --git a/src/testdir/test_vim9_expr.vim b/src/testdir/test_vim9_expr.vim index c86379eb1a..44ff105c62 100644 --- a/src/testdir/test_vim9_expr.vim +++ b/src/testdir/test_vim9_expr.vim @@ -2102,6 +2102,29 @@ def Test_expr7_funcref() assert_equal(123, FuncRef()) END CheckDefAndScriptSuccess(lines) + + lines =<< trim END + vim9script + func g:GlobalFunc() + return 'global' + endfunc + func s:ScriptFunc() + return 'script' + endfunc + def Test() + var Ref = g:GlobalFunc + assert_equal('global', Ref()) + Ref = GlobalFunc + assert_equal('global', Ref()) + + Ref = s:ScriptFunc + assert_equal('script', Ref()) + Ref = ScriptFunc + assert_equal('script', Ref()) + enddef + Test() + END + CheckScriptSuccess(lines) enddef let g:test_space_dict = {'': 'empty', ' ': 'space'} diff --git a/src/version.c b/src/version.c index 4eea2f1855..f1534f1284 100644 --- a/src/version.c +++ b/src/version.c @@ -750,6 +750,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ +/**/ + 2735, /**/ 2734, /**/ diff --git a/src/vim9compile.c b/src/vim9compile.c index c4b5d3c1c0..00a8f56469 100644 --- a/src/vim9compile.c +++ b/src/vim9compile.c @@ -2889,11 +2889,11 @@ compile_load( if (*(*arg + 1) == ':') { - // load namespaced variable if (end <= *arg + 2) { isntype_T isn_type; + // load dictionary of namespace switch (**arg) { case 'g': isn_type = ISN_LOADGDICT; break; @@ -2912,6 +2912,7 @@ compile_load( { isntype_T isn_type = ISN_DROP; + // load namespaced variable name = vim_strnsave(*arg + 2, end - (*arg + 2)); if (name == NULL) return FAIL; @@ -2920,11 +2921,21 @@ compile_load( { case 'v': res = generate_LOADV(cctx, name, error); break; - case 's': res = compile_load_scriptvar(cctx, name, + case 's': if (is_expr && ASCII_ISUPPER(*name) + && find_func(name, FALSE, cctx) != NULL) + res = generate_funcref(cctx, name); + else + res = compile_load_scriptvar(cctx, name, NULL, &end, error); break; case 'g': if (vim_strchr(name, AUTOLOAD_CHAR) == NULL) - isn_type = ISN_LOADG; + { + if (is_expr && ASCII_ISUPPER(*name) + && find_func(name, FALSE, cctx) != NULL) + res = generate_funcref(cctx, name); + else + isn_type = ISN_LOADG; + } else { isn_type = ISN_LOADAUTO; @@ -2945,7 +2956,7 @@ compile_load( { // Global, Buffer-local, Window-local and Tabpage-local // variables can be defined later, thus we don't check if it - // exists, give error at runtime. + // exists, give an error at runtime. res = generate_LOAD(cctx, isn_type, 0, name, &t_any); } } @@ -2988,10 +2999,9 @@ compile_load( res = compile_load_scriptvar(cctx, name, *arg, &end, FALSE); // When evaluating an expression and the name starts with an - // uppercase letter or "x:" it can be a user defined function. - // TODO: this is just guessing - if (res == FAIL && is_expr - && (ASCII_ISUPPER(*name) || name[1] == ':')) + // uppercase letter it can be a user defined function. + // generate_funcref() will fail if the function can't be found. + if (res == FAIL && is_expr && ASCII_ISUPPER(*name)) res = generate_funcref(cctx, name); } } From 175a41c13f3e27e30c662f2f418c5a347dbc645d Mon Sep 17 00:00:00 2001 From: Bram Moolenaar Date: Thu, 8 Apr 2021 18:05:03 +0200 Subject: [PATCH 12/14] patch 8.2.2736: Vim9: for loop over string is a bit slow Problem: Vim9: for loop over string is a bit slow. Solution: Avoid using strlen(). --- src/version.c | 2 ++ src/vim9execute.c | 3 +-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/version.c b/src/version.c index f1534f1284..4e6435c31d 100644 --- a/src/version.c +++ b/src/version.c @@ -750,6 +750,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ +/**/ + 2736, /**/ 2735, /**/ diff --git a/src/vim9execute.c b/src/vim9execute.c index d3e2af772a..d6c4764882 100644 --- a/src/vim9execute.c +++ b/src/vim9execute.c @@ -2792,12 +2792,11 @@ call_def_function( else if (ltv->v_type == VAR_STRING) { char_u *str = ltv->vval.v_string; - int len = str == NULL ? 0 : (int)STRLEN(str); // Push the next character from the string. The index // is for the last byte of the previous character. ++idxtv->vval.v_number; - if (idxtv->vval.v_number >= len) + if (str == NULL || str[idxtv->vval.v_number] == NUL) { // past the end of the string, jump to "endfor" ectx.ec_iidx = iptr->isn_arg.forloop.for_end; From d8db8383926cb8729417d9515cbfaf455dbbd8d1 Mon Sep 17 00:00:00 2001 From: Bram Moolenaar Date: Thu, 8 Apr 2021 18:27:53 +0200 Subject: [PATCH 13/14] patch 8.2.2737: status line not updated when local 'statusline' option set Problem: Status line not updated when local 'statusline' option set. Solution: Check the 'statusline' option of each window. --- src/ex_getln.c | 15 ++++++++++++--- src/testdir/dumps/Test_statusline_mode_1.dump | 6 ++++-- src/testdir/dumps/Test_statusline_mode_2.dump | 6 ++++-- src/testdir/test_statusline.vim | 9 +++++---- src/version.c | 2 ++ 5 files changed, 27 insertions(+), 11 deletions(-) diff --git a/src/ex_getln.c b/src/ex_getln.c index b61761b608..a9f33e6ec2 100644 --- a/src/ex_getln.c +++ b/src/ex_getln.c @@ -1710,10 +1710,19 @@ getcmdline_int( #ifdef FEAT_STL_OPT // Redraw the statusline in case it uses the current mode using the mode() // function. - if (!cmd_silent && msg_scrolled == 0 && *p_stl != NUL) + if (!cmd_silent && msg_scrolled == 0) { - curwin->w_redr_status = TRUE; - redraw_statuslines(); + int found_one = FALSE; + win_T *wp; + + FOR_ALL_WINDOWS(wp) + if (*p_stl != NUL || *wp->w_p_stl != NUL) + { + wp->w_redr_status = TRUE; + found_one = TRUE; + } + if (found_one) + redraw_statuslines(); } #endif diff --git a/src/testdir/dumps/Test_statusline_mode_1.dump b/src/testdir/dumps/Test_statusline_mode_1.dump index 476fb7363d..9d111c9ed4 100644 --- a/src/testdir/dumps/Test_statusline_mode_1.dump +++ b/src/testdir/dumps/Test_statusline_mode_1.dump @@ -1,5 +1,7 @@ > +0&#ffffff0@49 |~+0#4040ff13&| @48 -|~| @48 -|-+3#0000000&|n|-| @46 +|++3#0000000&|n|+| @46 +| +0&&@49 +|~+0#4040ff13&| @48 +|-+1#0000000&|n|-| @46 | +0&&@49 diff --git a/src/testdir/dumps/Test_statusline_mode_2.dump b/src/testdir/dumps/Test_statusline_mode_2.dump index e4fe764ad9..f195543b0c 100644 --- a/src/testdir/dumps/Test_statusline_mode_2.dump +++ b/src/testdir/dumps/Test_statusline_mode_2.dump @@ -1,5 +1,7 @@ | +0&#ffffff0@49 |~+0#4040ff13&| @48 -|~| @48 -|-+3#0000000&|c|-| @46 +|++3#0000000&|c|+| @46 +| +0&&@49 +|~+0#4040ff13&| @48 +|-+1#0000000&|c|-| @46 |:+0&&> @48 diff --git a/src/testdir/test_statusline.vim b/src/testdir/test_statusline.vim index bbf7ddf194..ca28379f5d 100644 --- a/src/testdir/test_statusline.vim +++ b/src/testdir/test_statusline.vim @@ -452,19 +452,20 @@ func Test_statusline_using_mode() CheckScreendump let lines =<< trim END - set laststatus=2 - let &statusline = '-%{mode()}-' + setlocal statusline=-%{mode()}- + split + setlocal statusline=+%{mode()}+ END call writefile(lines, 'XTest_statusline') - let buf = RunVimInTerminal('-S XTest_statusline', {'rows': 5, 'cols': 50}) + let buf = RunVimInTerminal('-S XTest_statusline', {'rows': 7, 'cols': 50}) call VerifyScreenDump(buf, 'Test_statusline_mode_1', {}) call term_sendkeys(buf, ":") call VerifyScreenDump(buf, 'Test_statusline_mode_2', {}) " clean up - call term_sendkeys(buf, "\") + call term_sendkeys(buf, "close\") call StopVimInTerminal(buf) call delete('XTest_statusline') endfunc diff --git a/src/version.c b/src/version.c index 4e6435c31d..1a1f237843 100644 --- a/src/version.c +++ b/src/version.c @@ -750,6 +750,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ +/**/ + 2737, /**/ 2736, /**/ From dcae51facc4d6de1edd62f0242b40972be841103 Mon Sep 17 00:00:00 2001 From: Bram Moolenaar Date: Thu, 8 Apr 2021 20:10:10 +0200 Subject: [PATCH 14/14] patch 8.2.2738: extending a list with itself can give wrong result Problem: Extending a list with itself can give wrong result. Solution: Remember the item before where the insertion happens and skip to after the already inserted items. (closes #1112) --- src/list.c | 9 ++++++++- src/testdir/test_listdict.vim | 14 ++++++++++++++ src/version.c | 2 ++ 3 files changed, 24 insertions(+), 1 deletion(-) diff --git a/src/list.c b/src/list.c index 873f9e63de..76327abc87 100644 --- a/src/list.c +++ b/src/list.c @@ -894,6 +894,7 @@ list_extend(list_T *l1, list_T *l2, listitem_T *bef) { listitem_T *item; int todo; + listitem_T *bef_prev; // NULL list is equivalent to an empty list: nothing to do. if (l2 == NULL || l2->lv_len == 0) @@ -903,9 +904,15 @@ list_extend(list_T *l1, list_T *l2, listitem_T *bef) CHECK_LIST_MATERIALIZE(l1); CHECK_LIST_MATERIALIZE(l2); + // When exending a list with itself, at some point we run into the item + // that was before "bef" and need to skip over the already inserted items + // to "bef". + bef_prev = bef == NULL ? NULL : bef->li_prev; + // We also quit the loop when we have inserted the original item count of // the list, avoid a hang when we extend a list with itself. - for (item = l2->lv_first; item != NULL && --todo >= 0; item = item->li_next) + for (item = l2->lv_first; item != NULL && --todo >= 0; + item = item == bef_prev ? bef : item->li_next) if (list_insert_tv(l1, &item->li_tv, bef) == FAIL) return FAIL; return OK; diff --git a/src/testdir/test_listdict.vim b/src/testdir/test_listdict.vim index 051a37c3a5..1b0796d816 100644 --- a/src/testdir/test_listdict.vim +++ b/src/testdir/test_listdict.vim @@ -862,6 +862,20 @@ func Test_listdict_extend() " Extend g: dictionary with an invalid variable name call assert_fails("call extend(g:, {'-!' : 10})", 'E461:') + + " Extend a list with itself. + let l = [1, 5, 7] + call extend(l, l, 0) + call assert_equal([1, 5, 7, 1, 5, 7], l) + let l = [1, 5, 7] + call extend(l, l, 1) + call assert_equal([1, 1, 5, 7, 5, 7], l) + let l = [1, 5, 7] + call extend(l, l, 2) + call assert_equal([1, 5, 1, 5, 7, 7], l) + let l = [1, 5, 7] + call extend(l, l, 3) + call assert_equal([1, 5, 7, 1, 5, 7], l) endfunc func Test_listdict_extendnew() diff --git a/src/version.c b/src/version.c index 1a1f237843..452565c1f2 100644 --- a/src/version.c +++ b/src/version.c @@ -750,6 +750,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ +/**/ + 2738, /**/ 2737, /**/