diff options
author | Bram Moolenaar <Bram@vim.org> | 2022-03-08 21:35:07 +0000 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2022-03-08 21:35:07 +0000 |
commit | 1588bc8ebee22f2855f27273fc2234fff370f86c (patch) | |
tree | 7ef17f0d3739007a97fbe09daa1f96757a8ac8f2 | |
parent | ed0c62e7b16b62655824df28cdd6bd75aadbb8fc (diff) |
Update runtime files
48 files changed, 634 insertions, 328 deletions
diff --git a/runtime/autoload/dist/ft.vim b/runtime/autoload/dist/ft.vim index 22974b6cc0..a36f615d61 100644 --- a/runtime/autoload/dist/ft.vim +++ b/runtime/autoload/dist/ft.vim @@ -3,7 +3,7 @@ vim9script # Vim functions for file type detection # # Maintainer: Bram Moolenaar <Bram@vim.org> -# Last Change: 2022 Feb 22 +# Last Change: 2022 Mar 05 # These functions are moved here from runtime/filetype.vim to make startup # faster. diff --git a/runtime/compiler/jest.vim b/runtime/compiler/jest.vim index fee70b7c55..a4bb549de1 100644 --- a/runtime/compiler/jest.vim +++ b/runtime/compiler/jest.vim @@ -1,7 +1,7 @@ " Vim compiler file " Compiler: Jest " Maintainer: Doug Kearns <dougkearns@gmail.com> -" Last Change: 2018 May 15 +" Last Change: 2021 Nov 20 if exists("current_compiler") finish @@ -15,12 +15,14 @@ endif let s:cpo_save = &cpo set cpo&vim -" CompilerSet makeprg=npx\ jest\ --no-colors +" CompilerSet makeprg=npx\ --no-install\ jest\ --no-colors CompilerSet makeprg=jest\ --no-colors -CompilerSet errorformat=%E\ \ ●\ %m, +CompilerSet errorformat=%-A\ \ ●\ Console, + \%E\ \ ●\ %m, \%Z\ %\\{4}%.%#Error:\ %f:\ %m\ (%l:%c):%\\=, \%Z\ %\\{6}at\ %\\S%#\ (%f:%l:%c), + \%Z\ %\\{6}at\ %\\S%#\ %f:%l:%c, \%+C\ %\\{4}%\\w%.%#, \%+C\ %\\{4}%[-+]%.%#, \%-C%.%#, diff --git a/runtime/compiler/sml.vim b/runtime/compiler/sml.vim index c7e1b1bf16..a0b13b6c8a 100644 --- a/runtime/compiler/sml.vim +++ b/runtime/compiler/sml.vim @@ -1,7 +1,7 @@ " Vim compiler file " Compiler: SML/NJ Compiler " Maintainer: Doug Kearns <dougkearns@gmail.com> -" Last Change: 2020 Feb 10 +" Last Change: 2022 Feb 09 if exists("current_compiler") finish @@ -16,10 +16,10 @@ let s:cpo_save = &cpo set cpo&vim CompilerSet makeprg=sml -CompilerSet errorformat=%f:%l.%c-%\\d%\\+.%\\d%\\+\ %trror:\ %m, +CompilerSet errorformat=%f:%l.%c-%e.%k\ %trror:\ %m, \%f:%l.%c\ %trror:\ %m, - \%trror:\ %m - \%f:%l.%c-%\\d%\\+.%\\d%\\+\ %tarning:\ %m, + \%trror:\ %m, + \%f:%l.%c-%e.%k\ %tarning:\ %m, \%f:%l.%c\ %tarning:\ %m, \%tarning:\ %m, \%-G%.%# diff --git a/runtime/defaults.vim b/runtime/defaults.vim index 4a44ebf955..f1d5cd1edf 100644 --- a/runtime/defaults.vim +++ b/runtime/defaults.vim @@ -1,7 +1,7 @@ " The default vimrc file. " " Maintainer: Bram Moolenaar <Bram@vim.org> -" Last change: 2021 Nov 17 +" Last change: 2022 Mar 03 " " This is loaded if no vimrc file was found. " Except when Vim is run with "-u NONE" or "-C". @@ -64,9 +64,10 @@ if has('win32') set guioptions-=t endif -" Don't use Ex mode, use Q for formatting. +" Don't use Q for Ex mode, use it for formatting. Except for Select mode. " Revert with ":unmap Q". map Q gq +sunmap Q " CTRL-U in insert mode deletes a lot. Use CTRL-G u to first break undo, " so that you can undo CTRL-U after inserting a line break. diff --git a/runtime/doc/autocmd.txt b/runtime/doc/autocmd.txt index 2a5f5fd732..b1120e9023 100644 --- a/runtime/doc/autocmd.txt +++ b/runtime/doc/autocmd.txt @@ -1,4 +1,4 @@ -*autocmd.txt* For Vim version 8.2. Last change: 2022 Feb 09 +*autocmd.txt* For Vim version 8.2. Last change: 2022 Mar 04 VIM REFERENCE MANUAL by Bram Moolenaar @@ -63,7 +63,7 @@ effects. Be careful not to destroy your text. they were given. See |autocmd-nested| for [++nested]. "nested" (without the ++) can also be used, for backwards - compatibility. + compatibility, but not in |Vim9| script. *E1078* *autocmd-once* If [++once] is supplied the command is executed once, then removed ("one shot"). @@ -365,6 +365,7 @@ Name triggered by ~ |InsertEnter| starting Insert mode |InsertChange| when typing <Insert> while in Insert or Replace mode |InsertLeave| when leaving Insert mode +|InsertLeavePre| just before leaving Insert mode |InsertCharPre| when a character was typed in Insert mode, before inserting it diff --git a/runtime/doc/builtin.txt b/runtime/doc/builtin.txt index 23756831be..922a2da3ba 100644 --- a/runtime/doc/builtin.txt +++ b/runtime/doc/builtin.txt @@ -1,4 +1,4 @@ -*builtin.txt* For Vim version 8.2. Last change: 2022 Feb 23 +*builtin.txt* For Vim version 8.2. Last change: 2022 Mar 08 VIM REFERENCE MANUAL by Bram Moolenaar @@ -5572,7 +5572,7 @@ matchfuzzy({list}, {str} [, {dict}]) *matchfuzzy()* empty list is returned. If length of {str} is greater than 256, then returns an empty list. - Refer to |fuzzy-match| for more information about fuzzy + Refer to |fuzzy-matching| for more information about fuzzy matching strings. Example: > @@ -8160,8 +8160,7 @@ sound_playfile({path} [, {callback}]) < Can also be used as a |method|: > GetSoundPath()->sound_playfile() -< There is no error *E538* , but can listen to 538.nl. - {only available when compiled with the |+sound| feature} +< {only available when compiled with the |+sound| feature} sound_stop({id}) *sound_stop()* diff --git a/runtime/doc/change.txt b/runtime/doc/change.txt index 04d536cad3..04bd238d11 100644 --- a/runtime/doc/change.txt +++ b/runtime/doc/change.txt @@ -1,4 +1,4 @@ -*change.txt* For Vim version 8.2. Last change: 2022 Feb 04 +*change.txt* For Vim version 8.2. Last change: 2022 Mar 05 VIM REFERENCE MANUAL by Bram Moolenaar @@ -778,8 +778,8 @@ matched pattern is deleted. The separator after {pattern} can also be left out then. Example: > :%s/TESTING This deletes "TESTING" from all lines, but only one per line. - -For compatibility with Vi these two exceptions are allowed: + *E1270* +For compatibility with Vi these two exceptions are allowed in legacy script: "\/{string}/" and "\?{string}?" do the same as "//{string}/r". "\&{string}&" does the same as "//{string}/". *pattern-delimiter* *E146* *E1241* *E1242* diff --git a/runtime/doc/channel.txt b/runtime/doc/channel.txt index 0e95cd233d..2182ae6974 100644 --- a/runtime/doc/channel.txt +++ b/runtime/doc/channel.txt @@ -1,4 +1,4 @@ -*channel.txt* For Vim version 8.2. Last change: 2021 Nov 28 +*channel.txt* For Vim version 8.2. Last change: 2022 Feb 27 VIM REFERENCE MANUAL by Bram Moolenaar @@ -1288,18 +1288,18 @@ prompt. > " Create a channel log so we can see what happens. call ch_logfile('logfile', 'w') - " Function handling a line of text has been typed. + " Function handling a line of text that has been typed. func TextEntered(text) " Send the text to a shell with Enter appended. call ch_sendraw(g:shell_job, a:text .. "\n") endfunc - " Function handling output from the shell: Added above the prompt. + " Function handling output from the shell: Add it above the prompt. func GotOutput(channel, msg) call append(line("$") - 1, "- " .. a:msg) endfunc - " Function handling the shell exist: close the window. + " Function handling the shell exits: close the window. func JobExit(job, status) quit! endfunc @@ -1310,7 +1310,6 @@ prompt. > \ err_cb: function('GotOutput'), \ exit_cb: function('JobExit'), \ }) - let shell_ch = job_getchannel(shell_job) new set buftype=prompt @@ -1321,6 +1320,46 @@ prompt. > " start accepting shell commands startinsert < +The same in |Vim9| script: > + + vim9script + + # Create a channel log so we can see what happens. + ch_logfile('logfile', 'w') + + var shell_job: job + + # Function handling a line of text that has been typed. + def TextEntered(text: string) + # Send the text to a shell with Enter appended. + ch_sendraw(shell_job, text .. "\n") + enddef + + # Function handling output from the shell: Add it above the prompt. + def GotOutput(channel: channel, msg: string) + append(line("$") - 1, "- " .. msg) + enddef + + # Function handling the shell exits: close the window. + def JobExit(job: job, status: number) + quit! + enddef + + # Start a shell in the background. + shell_job = job_start(["/bin/sh"], { + out_cb: GotOutput, + err_cb: GotOutput, + exit_cb: JobExit, + }) + + new + set buftype=prompt + var buf = bufnr('') + prompt_setcallback(buf, TextEntered) + prompt_setprompt(buf, "shell command: ") + + # start accepting shell commands + startinsert vim:tw=78:ts=8:noet:ft=help:norl: diff --git a/runtime/doc/eval.txt b/runtime/doc/eval.txt index 87edd49ece..48cef5c09f 100644 --- a/runtime/doc/eval.txt +++ b/runtime/doc/eval.txt @@ -1,4 +1,4 @@ -*eval.txt* For Vim version 8.2. Last change: 2022 Feb 21 +*eval.txt* For Vim version 8.2. Last change: 2022 Mar 05 VIM REFERENCE MANUAL by Bram Moolenaar @@ -1834,6 +1834,7 @@ Some variables can be set by the user, but the type cannot be changed. *v:argv* *argv-variable* v:argv The command line arguments Vim was invoked with. This is a list of strings. The first item is the Vim command. + See |v:progpath| for the command with full path. *v:beval_col* *beval_col-variable* v:beval_col The number of the column, over which the mouse pointer is. @@ -2215,6 +2216,8 @@ v:none An empty String. Used to put an empty item in JSON. See < v:none ~ That is so that eval() can parse the string back to the same value. Read-only. + Note that using `== v:none` and `!= v:none` will often give + an error. Instead, use `is v:none` and `isnot v:none` . *v:null* *null-variable* v:null An empty String. Used to put "null" in JSON. See @@ -2225,7 +2228,10 @@ v:null An empty String. Used to put "null" in JSON. See < v:null ~ That is so that eval() can parse the string back to the same value. Read-only. - In |Vim9| script "null" can be used without "v:". + In |Vim9| script `null` can be used without "v:". + In some places `v:null` and `null` can be used for a List, + Dict, Job, etc. that is not set. That is slightly different + than an empty List, Dict, etc. *v:numbermax* *numbermax-variable* v:numbermax Maximum value of a number. @@ -3423,16 +3429,17 @@ text... opposite of |:lockvar|. :if {expr1} *:if* *:end* *:endif* *:en* *E171* *E579* *E580* -:en[dif] Execute the commands until the next matching ":else" - or ":endif" if {expr1} evaluates to non-zero. +:en[dif] Execute the commands until the next matching `:else` + or `:endif` if {expr1} evaluates to non-zero. Although the short forms work, it is recommended to - always use `:endif` to avoid confusion. + always use `:endif` to avoid confusion and to make + auto-indenting work properly. From Vim version 4.5 until 5.0, every Ex command in - between the ":if" and ":endif" is ignored. These two + between the `:if` and `:endif` is ignored. These two commands were just to allow for future expansions in a backward compatible way. Nesting was allowed. Note - that any ":else" or ":elseif" was ignored, the "else" + that any `:else` or `:elseif` was ignored, the `else` part was not executed either. You can use this to remain compatible with older @@ -3441,32 +3448,38 @@ text... : version-5-specific-commands :endif < The commands still need to be parsed to find the - "endif". Sometimes an older Vim has a problem with a - new command. For example, ":silent" is recognized as - a ":substitute" command. In that case ":execute" can + `endif`. Sometimes an older Vim has a problem with a + new command. For example, `:silent` is recognized as + a `:substitute` command. In that case `:execute` can avoid problems: > :if version >= 600 : execute "silent 1,$delete" :endif < - NOTE: The ":append" and ":insert" commands don't work - properly in between ":if" and ":endif". + In |Vim9| script `:endif` cannot be shortened, to + improve script readability. + NOTE: The `:append` and `:insert` commands don't work + properly in between `:if` and `:endif`. *:else* *:el* *E581* *E583* -:el[se] Execute the commands until the next matching ":else" - or ":endif" if they previously were not being +:el[se] Execute the commands until the next matching `:else` + or `:endif` if they previously were not being executed. + In |Vim9| script `:else` cannot be shortened, to + improve script readability. *:elseif* *:elsei* *E582* *E584* -:elsei[f] {expr1} Short for ":else" ":if", with the addition that there - is no extra ":endif". +:elsei[f] {expr1} Short for `:else` `:if`, with the addition that there + is no extra `:endif`. + In |Vim9| script `:elseif` cannot be shortened, to + improve script readability. :wh[ile] {expr1} *:while* *:endwhile* *:wh* *:endw* *E170* *E585* *E588* *E733* -:endw[hile] Repeat the commands between ":while" and ":endwhile", +:endw[hile] Repeat the commands between `:while` and `:endwhile`, as long as {expr1} evaluates to non-zero. When an error is detected from a command inside the - loop, execution continues after the "endwhile". + loop, execution continues after the `endwhile`. Example: > :let lnum = 1 :while lnum <= line("$") @@ -3474,12 +3487,14 @@ text... :let lnum = lnum + 1 :endwhile < - NOTE: The ":append" and ":insert" commands don't work - properly inside a ":while" and ":for" loop. + In |Vim9| script `:while` and `:endwhile` cannot be + shortened, to improve script readability. + NOTE: The `:append` and `:insert` commands don't work + properly inside a `:while` and `:for` loop. :for {var} in {object} *:for* *E690* *E732* :endfo[r] *:endfo* *:endfor* - Repeat the commands between ":for" and ":endfor" for + Repeat the commands between `:for` and `:endfor` for each item in {object}. {object} can be a |List| or a |Blob|. *E1177* @@ -3489,7 +3504,7 @@ text... global/window/tab/buffer variable. When an error is detected for a command inside the - loop, execution continues after the "endfor". + loop, execution continues after the `endfor`. Changing {object} inside the loop affects what items are used. Make a copy if this is unwanted: > :for item in copy(mylist) @@ -3514,9 +3529,12 @@ text... iterate over. Unlike with |List|, modifying the |Blob| does not affect the iteration. + In |Vim9| script `:endfor` cannot be shortened, to + improve script readability. + :for [{var1}, {var2}, ...] in {listlist} :endfo[r] *E1140* - Like ":for" above, but each item in {listlist} must be + Like `:for` above, but each item in {listlist} must be a list, of which each item is assigned to {var1}, {var2}, etc. Example: > :for [lnum, col] in [[1, 3], [2, 5], [3, 8]] @@ -3524,39 +3542,44 @@ text... :endfor < *:continue* *:con* *E586* -:con[tinue] When used inside a ":while" or ":for" loop, jumps back +:con[tinue] When used inside a `:while` or `:for` loop, jumps back to the start of the loop. - If it is used after a |:try| inside the loop but - before the matching |:finally| (if present), the - commands following the ":finally" up to the matching - |:endtry| are executed first. This process applies to - all nested ":try"s inside the loop. The outermost - ":endtry" then jumps back to the start of the loop. - + If it is used after a `:try` inside the loop but + before the matching `:finally` (if present), the + commands following the `:finally` up to the matching + `:endtry` are executed first. This process applies to + all nested `:try`s inside the loop. The outermost + `:endtry` then jumps back to the start of the loop. + + In |Vim9| script `:cont` is the shortest form, to + improve script readability. *:break* *:brea* *E587* -:brea[k] When used inside a ":while" or ":for" loop, skips to - the command after the matching ":endwhile" or - ":endfor". - If it is used after a |:try| inside the loop but - before the matching |:finally| (if present), the - commands following the ":finally" up to the matching - |:endtry| are executed first. This process applies to - all nested ":try"s inside the loop. The outermost - ":endtry" then jumps to the command after the loop. +:brea[k] When used inside a `:while` or `:for` loop, skips to + the command after the matching `:endwhile` or + `:endfor`. + If it is used after a `:try` inside the loop but + before the matching `:finally` (if present), the + commands following the `:finally` up to the matching + `:endtry` are executed first. This process applies to + all nested `:try`s inside the loop. The outermost + `:endtry` then jumps to the command after the loop. + + In |Vim9| script `:break` cannot be shortened, to + improve script readability. :try *:try* *:endt* *:endtry* *E600* *E601* *E602* *E1032* :endt[ry] Change the error handling for the commands between - ":try" and ":endtry" including everything being - executed across ":source" commands, function calls, + `:try` and `:endtry` including everything being + executed across `:source` commands, function calls, or autocommand invocations. When an error or interrupt is detected and there is - a |:finally| command following, execution continues - after the ":finally". Otherwise, or when the - ":endtry" is reached thereafter, the next - (dynamically) surrounding ":try" is checked for - a corresponding ":finally" etc. Then the script + a `:finally` command following, execution continues + after the `:finally`. Otherwise, or when the + `:endtry` is reached thereafter, the next + (dynamically) surrounding `:try` is checked for + a corresponding `:finally` etc. Then the script processing is terminated. Whether a function definition has an "abort" argument does not matter. Example: > @@ -3564,9 +3587,9 @@ text... echomsg "not reached" < Moreover, an error or interrupt (dynamically) inside - ":try" and ":endtry" is converted to an exception. It - can be caught as if it were thrown by a |:throw| - command (see |:catch|). In this case, the script + `:try` and `:endtry` is converted to an exception. It + can be caught as if it were thrown by a `:throw` + command (see `:catch`). In this case, the script processing is not terminated. The value "Vim:Interrupt" is used for an interrupt @@ -3581,13 +3604,16 @@ text... try | sleep 100 | catch /^Vim:Interrupt$/ | endtry try | edit | catch /^Vim(edit):E\d\+/ | echo "error" | endtry < + In |Vim9| script `:endtry` cannot be shortened, to + improve script readability. + *:cat* *:catch* *E603* *E604* *E605* *E654* *E1033* -:cat[ch] /{pattern}/ The following commands until the next |:catch|, - |:finally|, or |:endtry| that belongs to the same - |:try| as the ":catch" are executed when an exception +:cat[ch] /{pattern}/ The following commands until the next `:catch`, + `:finally`, or `:endtry` that belongs to the same + `:try` as the `:catch` are executed when an exception matching {pattern} is being thrown and has not yet - been caught by a previous ":catch". Otherwise, these + been caught by a previous `:catch`. Otherwise, these commands are skipped. When {pattern} is omitted all errors are caught. Examples: > @@ -3609,29 +3635,35 @@ text... NOTE: It is not reliable to ":catch" the TEXT of an error message because it may vary in different locales. + In |Vim9| script `:catch` cannot be shortened, to + improve script readability. *:fina* *:finally* *E606* *E607* -:fina[lly] The following commands until the matching |:endtry| +:fina[lly] The following commands until the matching `:endtry` are executed whenever the part between the matching - |:try| and the ":finally" is left: either by falling - through to the ":finally" or by a |:continue|, - |:break|, |:finish|, or |:return|, or by an error or - interrupt or exception (see |:throw|). + `:try` and the `:finally` is left: either by falling + through to the `:finally` or by a `:continue`, + `:break`, `:finish`, or `:return`, or by an error or + interrupt or exception (see `:throw`). + + In |Vim9| script `:finally` cannot be shortened, to + improve script readability and avoid confusion with + `:final`. *:th* *:throw* *E608* *E1129* :th[row] {expr1} The {expr1} is evaluated and thrown as an exception. - If the ":throw" is used after a |:try| but before the - first corresponding |:catch|, commands are skipped - until the first ":catch" matching {expr1} is reached. - If there is no such ":catch" or if the ":throw" is - used after a ":catch" but before the |:finally|, the - commands following the ":finally" (if present) up to - the matching |:endtry| are executed. If the ":throw" - is after the ":finally", commands up to the ":endtry" + If the ":throw" is used after a `:try` but before the + first corresponding `:catch`, commands are skipped + until the first `:catch` matching {expr1} is reached. + If there is no such `:catch` or if the ":throw" is + used after a `:catch` but before the `:finally`, the + commands following the `:finally` (if present) up to + the matching `:endtry` are executed. If the `:throw` + is after the `:finally`, commands up to the `:endtry` are skipped. At the ":endtry", this process applies - again for the next dynamically surrounding ":try" + again for the next dynamically surrounding `:try` (which may be found in a calling function or sourcing - script), until a matching ":catch" has been found. + script), until a matching `:catch` has been found. If the exception is not caught, the command processing is terminated. Example: > @@ -3640,13 +3672,16 @@ text... for when an error causes the parsing to skip the whole line and not see the "|" that separates the commands. + In |Vim9| script `:throw` cannot be shortened, to + improve script readability. + *:ec* *:echo* :ec[ho] {expr1} .. Echoes each {expr1}, with a space in between. The first {expr1} starts on a new line. Also see |:comment|. Use "\n" to start a new line. Use "\r" to move the cursor to the first column. - Uses the highlighting set by the |:echohl| command. + Uses the highlighting set by the `:echohl` command. Cannot be followed by a comment. Example: > :echo "the value of 'shell' is" &shell @@ -3655,21 +3690,21 @@ text... And since Vim mostly postpones redrawing until it's finished with a sequence of commands this happens quite often. To avoid that a command from before the - ":echo" causes a redraw afterwards (redraws are often + `:echo` causes a redraw afterwards (redraws are often postponed until you type something), force a redraw - with the |:redraw| command. Example: > + with the `:redraw` command. Example: > :new | redraw | echo "there is a new window" < *:echon* :echon {expr1} .. Echoes each {expr1}, without anything added. Also see |:comment|. - Uses the highlighting set by the |:echohl| command. + Uses the highlighting set by the `:echohl` command. Cannot be followed by a comment. Example: > :echon "the value of 'shell' is " &shell < - Note the difference between using ":echo", which is a - Vim command, and ":!echo", which is an external shell + Note the difference between using `:echo`, which is a + Vim command, and `:!echo`, which is an external shell command: > :!echo % --> filename < The arguments of ":!" are expanded, see |:_%|. > @@ -3685,8 +3720,8 @@ text... *:echoh* *:echohl* :echoh[l] {name} Use the highlight group {name} for the following - |:echo|, |:echon| and |:echomsg| commands. Also used - for the |input()| prompt. Example: > + `:echo`, `:echon` and `:echomsg` commands. Also used + for the `input()` prompt. Example: > :echohl WarningMsg | echo "Don't panic!" | echohl None < Don't forget to set the group back to "None", otherwise all following echo's will be highlighted. @@ -3695,14 +3730,14 @@ text... :echom[sg] {expr1} .. Echo the expression(s) as a true message, saving the message in the |message-history|. Spaces are placed between the arguments as with the - |:echo| command. But unprintable characters are + `:echo` command. But unprintable characters are displayed, not interpreted. - The |