# HG changeset patch # User Bram Moolenaar # Date 1664817304 -7200 # Node ID f68f43043842aee2a9051e891d006d61631e8ee1 # Parent a7462ca00059aac3903e46db7f2bb317172e3928 Update runtime files Commit: https://github.com/vim/vim/commit/f269eabc6c4f5bdcef989cd5b4b95ba8ccaa4d8a Author: Bram Moolenaar Date: Mon Oct 3 18:04:35 2022 +0100 Update runtime files diff --git a/runtime/autoload/dist/vimindent.vim b/runtime/autoload/dist/vimindent.vim --- a/runtime/autoload/dist/vimindent.vim +++ b/runtime/autoload/dist/vimindent.vim @@ -4,6 +4,11 @@ vim9script # Maintainer: github user lacygoill # Last Change: 2022 Sep 24 +# NOTE: Whenever you change the code, make sure the tests are still passing: +# +# $ cd runtime/indent/ +# $ make clean; make test || vimdiff testdir/vim.{fail,ok} + # Config {{{1 const TIMEOUT: number = get(g:, 'vim_indent', {}) @@ -293,7 +298,7 @@ const START_MIDDLE_END: dictCacheBracketBlock() endif if line_A.lnum->IsInside('BracketBlock') - && !b:vimindent.block_stack[0].is_curly_block for block: dict in b:vimindent.block_stack - # Can't call `BracketBlockIndent()` before we're indenting a line *after* the start of the block.{{{ - # - # That's because it might need the correct indentation of the start - # of the block. But if we're still *on* the start, we haven't yet - # computed that indentation. - #}}} - if line_A.lnum > block.startlnum - && !block.is_curly_block + if line_A.lnum <= block.startlnum + continue + endif + if !block->has_key('startindent') + block.startindent = Indent(block.startlnum) + endif + if !block.is_curly_block + && !b:vimindent.block_stack[0].is_curly_block return BracketBlockIndent(line_A, block) endif endfor @@ -481,7 +485,7 @@ export def Expr(lnum: number): number # cursor(line_A.lnum, 1) var [start: string, middle: string, end: string] = START_MIDDLE_END[kwd] - var block_start = SearchPairStart(start, middle, end) + var block_start: number = SearchPairStart(start, middle, end) if block_start > 0 return Indent(block_start) else @@ -535,10 +539,10 @@ def Offset( # {{{2 # Indent twice for a line continuation in the block header itself, so that # we can easily distinguish the end of the block header from the start of # the block body. - elseif line_B->EndsWithLineContinuation() - && !line_A.isfirst - || line_A.text =~ LINE_CONTINUATION_AT_SOL - && line_A.text !~ PLUS_MINUS_COMMAND + elseif (line_B->EndsWithLineContinuation() + && !line_A.isfirst) + || (line_A.text =~ LINE_CONTINUATION_AT_SOL + && line_A.text !~ PLUS_MINUS_COMMAND) || line_A.text->Is_IN_KeywordForLoop(line_B.text) return 2 * shiftwidth() else @@ -646,10 +650,6 @@ def CommentIndent(): number # {{{2 enddef def BracketBlockIndent(line_A: dict, block: dict): number # {{{2 - if !block->has_key('startindent') - block.startindent = block.startlnum->Indent() - endif - var ind: number = block.startindent if line_A.text =~ CLOSING_BRACKET_AT_SOL diff --git a/runtime/doc/builtin.txt b/runtime/doc/builtin.txt --- a/runtime/doc/builtin.txt +++ b/runtime/doc/builtin.txt @@ -1,4 +1,4 @@ -*builtin.txt* For Vim version 9.0. Last change: 2022 Sep 17 +*builtin.txt* For Vim version 9.0. Last change: 2022 Sep 30 VIM REFERENCE MANUAL by Bram Moolenaar @@ -6,9 +6,10 @@ Builtin functions *builtin-functions* -Note: Expression evaluation can be disabled at compile time. If this has been -done, the builtin functions are not available. See |+eval| and -|no-eval-feature|. +Note: Expression evaluation can be disabled at compile time, the builtin +functions are not available then. See |+eval| and |no-eval-feature|. + +For functions grouped by what they are used for see |function-list|. 1. Overview |builtin-function-list| 2. Details |builtin-function-details| @@ -7035,13 +7036,19 @@ reg_recording() *reg_recording()* Returns the single letter name of the register being recorded. Returns an empty string when not recording. See |q|. -reltime([{start} [, {end}]]) *reltime()* +reltime() +reltime({start}) +reltime({start}, {end}) *reltime()* Return an item that represents a time value. The item is a list with items that depend on the system. In Vim 9 script list can be used. The item can be passed to |reltimestr()| to convert it to a - string or |reltimefloat()| to convert to a Float. - + string or |reltimefloat()| to convert to a Float. For + example, to see the time spent in function Work(): > + var startTime = reltime() + Work() + echo startTime->reltime()->reltimestr() +< Without an argument reltime() returns the current time (the representation is system-dependent, it can not be used as the wall-clock time, see |localtime()| for that). @@ -7162,8 +7169,8 @@ remote_peek({serverid} [, {retvar}]) *r This function is not available in the |sandbox|. {only available when compiled with the |+clientserver| feature} Examples: > - :let repl = "" - :echo "PEEK: " .. remote_peek(id, "repl") .. ": " .. repl + :let repl = "" + :echo "PEEK: " .. remote_peek(id, "repl") .. ": " .. repl < Can also be used as a |method|: > ServerId()->remote_peek() @@ -7223,7 +7230,8 @@ remote_startserver({name}) < {only available when compiled with the |+clientserver| feature} -remove({list}, {idx} [, {end}]) *remove()* +remove({list}, {idx}) +remove({list}, {idx}, {end}) *remove()* Without {end}: Remove the item at {idx} from |List| {list} and return the item. With {end}: Remove items from {idx} to {end} (inclusive) and @@ -7241,7 +7249,8 @@ remove({list}, {idx} [, {end}]) *remo Can also be used as a |method|: > mylist->remove(idx) -remove({blob}, {idx} [, {end}]) +remove({blob}, {idx}) +remove({blob}, {idx}, {end}) Without {end}: Remove the byte at {idx} from |Blob| {blob} and return the byte. With {end}: Remove bytes from {idx} to {end} (inclusive) and diff --git a/runtime/doc/diff.txt b/runtime/doc/diff.txt --- a/runtime/doc/diff.txt +++ b/runtime/doc/diff.txt @@ -1,4 +1,4 @@ -*diff.txt* For Vim version 9.0. Last change: 2022 Jan 22 +*diff.txt* For Vim version 9.0. Last change: 2022 Oct 01 VIM REFERENCE MANUAL by Bram Moolenaar diff --git a/runtime/doc/fold.txt b/runtime/doc/fold.txt --- a/runtime/doc/fold.txt +++ b/runtime/doc/fold.txt @@ -1,4 +1,4 @@ -*fold.txt* For Vim version 9.0. Last change: 2022 Jan 22 +*fold.txt* For Vim version 9.0. Last change: 2022 Oct 01 VIM REFERENCE MANUAL by Bram Moolenaar @@ -503,7 +503,7 @@ is evaluated to obtain the text displaye This shows the first line of the fold, with "/*", "*/" and "{{{" removed. Note the use of backslashes to avoid some characters to be interpreted by the -":set" command. It's simpler to define a function and call that: > +":set" command. It is much simpler to define a function and call it: > :set foldtext=MyFoldText() :function MyFoldText() @@ -512,6 +512,9 @@ Note the use of backslashes to avoid som : return v:folddashes .. sub :endfunction +The advantage of using a function call without arguments is that it is faster, +see |expr-option-function|. + Evaluating 'foldtext' is done in the |sandbox|. The current window is set to the window that displays the line. The context is set to the script where the option was last set. diff --git a/runtime/doc/insert.txt b/runtime/doc/insert.txt --- a/runtime/doc/insert.txt +++ b/runtime/doc/insert.txt @@ -1,4 +1,4 @@ -*insert.txt* For Vim version 9.0. Last change: 2022 Apr 06 +*insert.txt* For Vim version 9.0. Last change: 2022 Sep 30 VIM REFERENCE MANUAL by Bram Moolenaar @@ -667,7 +667,7 @@ When the popup menu is displayed there a |popupmenu-keys|. Note: The keys that are valid in CTRL-X mode are not mapped. This allows for -":map ^F ^X^F" to work (where ^F is CTRL-F and ^X is CTRL-X). The key that +`:map ` to work (assuming "<" is not in 'cpo'). The key that ends CTRL-X mode (any key that is not a valid CTRL-X mode command) is mapped. Also, when doing completion with 'complete' mappings apply as usual. @@ -677,11 +677,12 @@ buffer text cannot be changed. Mappings will generate an E565 error. The following mappings are suggested to make typing the completion commands -a bit easier (although they will hide other commands): > - :inoremap ^] ^X^] - :inoremap ^F ^X^F - :inoremap ^D ^X^D - :inoremap ^L ^X^L +a bit easier (although they will hide other commands; this requires "<" is not +in 'cpo'): > + :inoremap + :inoremap + :inoremap + :inoremap As a special case, typing CTRL-R to perform register insertion (see |i_CTRL-R|) will not exit CTRL-X mode. This is primarily to allow the use of diff --git a/runtime/doc/options.txt b/runtime/doc/options.txt --- a/runtime/doc/options.txt +++ b/runtime/doc/options.txt @@ -1,4 +1,4 @@ -*options.txt* For Vim version 9.0. Last change: 2022 Sep 27 +*options.txt* For Vim version 9.0. Last change: 2022 Oct 03 VIM REFERENCE MANUAL by Bram Moolenaar @@ -2942,7 +2942,7 @@ A jump table for the options with a shor 'display' 'dy' string (default "", set to "truncate" in |defaults.vim|) global - Change the way text is displayed. This is comma-separated list of + Change the way text is displayed. This is a comma-separated list of flags: lastline When included, as much as possible of the last line in a window will be displayed. "@@@" is put in the @@ -7307,8 +7307,10 @@ A jump table for the options with a shor local to window Scrolling works with screen lines. When 'wrap' is set and the first line in the window wraps part of it may not be visible, as if it is - above the window. - NOTE: only partly implemented, works with CTRL-E and CTRL-Y. + above the window. "<<<" is displayed at the start of the first line, + highlighted with |hl-NonText|. + NOTE: only partly implemented, currently works with CTRL-E, CTRL-Y + and scrolling with the mouse. *'softtabstop'* *'sts'* 'softtabstop' 'sts' number (default 0) diff --git a/runtime/doc/os_vms.txt b/runtime/doc/os_vms.txt --- a/runtime/doc/os_vms.txt +++ b/runtime/doc/os_vms.txt @@ -1,4 +1,4 @@ -*os_vms.txt* For Vim version 9.0. Last change: 2021 Jan 04 +*os_vms.txt* For Vim version 9.0. Last change: 2022 Sep 30 VIM REFERENCE MANUAL @@ -331,10 +331,10 @@ 8.16 Common VIM directory - different ar 8.1 Backspace/delete There are backspace/delete key inconsistencies with VMS. -:fixdel doesn't do the trick, but the solution is: > +:fixdel doesn't do the trick, but the solution is (without "<" in 'cpo'): > - :inoremap ^? ^H " for terminal mode - :inoremap ^H " for gui mode + :inoremap " for terminal mode + :inoremap " for gui mode Read more in ch: 8.6 (Terminal problems). (Bruce Hunsaker Vim 5.3) diff --git a/runtime/doc/print.txt b/runtime/doc/print.txt --- a/runtime/doc/print.txt +++ b/runtime/doc/print.txt @@ -1,4 +1,4 @@ -*print.txt* For Vim version 9.0. Last change: 2022 Jan 23 +*print.txt* For Vim version 9.0. Last change: 2022 Oct 01 VIM REFERENCE MANUAL by Bram Moolenaar diff --git a/runtime/doc/quickref.txt b/runtime/doc/quickref.txt --- a/runtime/doc/quickref.txt +++ b/runtime/doc/quickref.txt @@ -1,4 +1,4 @@ -*quickref.txt* For Vim version 9.0. Last change: 2022 Sep 14 +*quickref.txt* For Vim version 9.0. Last change: 2022 Oct 02 VIM REFERENCE MANUAL by Bram Moolenaar diff --git a/runtime/doc/syntax.txt b/runtime/doc/syntax.txt --- a/runtime/doc/syntax.txt +++ b/runtime/doc/syntax.txt @@ -1,4 +1,4 @@ -*syntax.txt* For Vim version 9.0. Last change: 2022 Sep 26 +*syntax.txt* For Vim version 9.0. Last change: 2022 Oct 03 VIM REFERENCE MANUAL by Bram Moolenaar @@ -5376,10 +5376,11 @@ ModeMsg 'showmode' message (e.g., "-- I *hl-MoreMsg* MoreMsg |more-prompt| *hl-NonText* -NonText '@' at the end of the window, characters from 'showbreak' - and other characters that do not really exist in the text - (e.g., ">" displayed when a double-wide character doesn't - fit at the end of the line). +NonText '@' at the end of the window, "<<<" at the start of the window + for 'smoothscroll', characters from 'showbreak' and other + characters that do not really exist in the text, such as the + ">" displayed when a double-wide character doesn't fit at the + end of the line. *hl-Normal* Normal Normal text. *hl-Pmenu* diff --git a/runtime/doc/tags b/runtime/doc/tags --- a/runtime/doc/tags +++ b/runtime/doc/tags @@ -714,14 +714,14 @@ 'nosmartindent' options.txt /*'nosmartindent'* 'nosmarttab' options.txt /*'nosmarttab'* 'nosmd' options.txt /*'nosmd'* +'nosmoothscroll' options.txt /*'nosmoothscroll'* +'nosms' options.txt /*'nosms'* 'nosn' options.txt /*'nosn'* 'nosol' options.txt /*'nosol'* 'nospell' options.txt /*'nospell'* 'nosplitbelow' options.txt /*'nosplitbelow'* 'nosplitright' options.txt /*'nosplitright'* -'nosplitscroll' options.txt /*'nosplitscroll'* 'nospr' options.txt /*'nospr'* -'nospsc' options.txt /*'nospsc'* 'nosr' options.txt /*'nosr'* 'nossl' options.txt /*'nossl'* 'nosta' options.txt /*'nosta'* @@ -938,6 +938,8 @@ 'smarttab' options.txt /*'smarttab'* 'smc' options.txt /*'smc'* 'smd' options.txt /*'smd'* +'smoothscroll' options.txt /*'smoothscroll'* +'sms' options.txt /*'sms'* 'sn' options.txt /*'sn'* 'so' options.txt /*'so'* 'softtabstop' options.txt /*'softtabstop'* @@ -954,12 +956,11 @@ 'spf' options.txt /*'spf'* 'spl' options.txt /*'spl'* 'splitbelow' options.txt /*'splitbelow'* +'splitkeep' options.txt /*'splitkeep'* 'splitright' options.txt /*'splitright'* -'splitscroll' options.txt /*'splitscroll'* 'spo' options.txt /*'spo'* 'spr' options.txt /*'spr'* 'sps' options.txt /*'sps'* -'spsc' options.txt /*'spsc'* 'sr' options.txt /*'sr'* 'srr' options.txt /*'srr'* 'ss' options.txt /*'ss'* @@ -4345,6 +4346,7 @@ E1303 map.txt /*E1303* E1304 vim9.txt /*E1304* E1305 textprop.txt /*E1305* E1306 vim9.txt /*E1306* +E1307 vim9.txt /*E1307* E131 userfunc.txt /*E131* E132 userfunc.txt /*E132* E133 userfunc.txt /*E133* @@ -6777,6 +6779,7 @@ expr-lambda eval.txt /*expr-lambda* expr-nesting eval.txt /*expr-nesting* expr-number eval.txt /*expr-number* expr-option eval.txt /*expr-option* +expr-option-function vim9.txt /*expr-option-function* expr-quote eval.txt /*expr-quote* expr-register eval.txt /*expr-register* expr-star eval.txt /*expr-star* diff --git a/runtime/doc/todo.txt b/runtime/doc/todo.txt --- a/runtime/doc/todo.txt +++ b/runtime/doc/todo.txt @@ -1,4 +1,4 @@ -*todo.txt* For Vim version 9.0. Last change: 2022 Sep 27 +*todo.txt* For Vim version 9.0. Last change: 2022 Oct 03 VIM REFERENCE MANUAL by Bram Moolenaar @@ -38,55 +38,40 @@ browser use: https://github.com/vim/vim/ *known-bugs* -------------------- Known bugs and current work ----------------------- -From test_global - Found errors in Test_interrupt_global(): - Run 1, 02:16:22 - 02:16:27: - command line..script /home/mool/vim/vim90/src/testdir/runtest.vim[469]..function RunTheTest[44]..Test_interrupt_global[13]..WaitForAssert[2]..7_WaitForCommon[11]..20 line 1: Pattern 'Interrupted' does not match 'Type :qa! and press...l changes and exit Vim 1,1 All' - command line..script /home/mool/vim/vim90/src/testdir/runtest.vim[469]..function RunTheTest[44]..Test_interrupt_global[20]..WaitForAssert[2]..7_WaitForCommon[11]..21 line 1: Pattern 'Interrupted' does not match 'Entering Ex mode. Type "visual" to go to Normal mode.' +'smoothscroll': +- computing 'scrolloff' position row use w_skipcol + +Add a string to the 'display' option ("smoothscroll" ?) to make CTRL-E and +CTRL-Y scroll one screen line, also if this means the first line doesn't start +with the first character (like what happens with a last line that doesn't +fit). Display "<<<" at the start of the first visible line (like "@@@" is +displayed in the last line). (Arseny Nasokin, #5154) +Neovim PR: https://github.com/neovim/neovim/pull/11014 Use :defer command: - Use "D" flag of writefile() and mkdir() in tests. - (testdir/test_e*.vim done) - -New Vim indent script: #11079 OK? + (testdir/test_p*.vim done) + +Fix for powershell: #11257 + +Change boolean 'splitscroll' into string 'splitkeep'. #11258 + Further Vim9 improvements, possibly after launch: -- For map(), reduce() and filter() use a specific implementation if the second - argument is a compiled function. #11163 - Use Vim9 for more runtime files. -- Check performance with callgrind and kcachegrind. - getline()/substitute()/setline() in #5632 -- Better implementation for partial and tests for that. -- when using "const" mark the variable type as const with TTFLAG_CONST, so - that an error is given at compile time when trying to change it. E.g. for a - const list and trying to call add(). -- Compile options that are an expression, e.g. "expr:" in 'spellsuggest', - 'foldexpr', 'foldtext', 'printexpr', 'diffexpr', 'patchexpr', 'charconvert', - 'balloonexpr', 'includeexpr', 'indentexpr', 'formatexpr'. - Give an error if compilation fails. (#7625) - Alternatively: Detect a compiled function call and skip the expression - evaluation. - Use the location where the option was set for deciding whether it's to be - evaluated in Vim9 script context. - implement :type - implement :enum - implement :class and :interface: See |vim9-classes| -- For range: make table of first ASCII character with flag to quickly check if - it can be a Vim9 command. E.g. "+" can, but "." can't. - Inline call to map() and filter(), better type checking. -- Make accessing varargs faster: arg[expr] - EVAL expr - LOADVARARG (varargs idx) - When evaluating constants for script variables, some functions could work: has(featureName), len(someString) - Implement as part of an expression: ++expr, --expr, expr++, expr--. Popup windows: -- Preview popup not properly updated when it overlaps with completion menu. - (Yegappan Lakshmanan, 2021 May 22) -- Scrollbar thumb sometimes not visible #10492 - Add a function to redraw a specific popup window. Esp. to be used when editing the command line, when screen updating doesn't happen. (Shougo) + #10210 Probably need to update all popup windows (they may overlap) + If the display is scrolled need to redraw everything later. - Add a flag to make a popup window focusable? CTRL-W P cycle over any preview window or focusable popup, end up back in current window. @@ -113,8 +98,6 @@ Popup windows: - put popup menu also in popup_mask? - Match does not have right BG color if line length equals popup width. (#5658) -- Any other commands to disable in a popup window? - Use ERROR_IF_POPUP_WINDOW for these. - Figure out the size and position better if wrapping inserts indent 'incsearch' with :s: @@ -203,13 +186,6 @@ Add BufDeletePost. #11041 Test property disappears when using CR twice in a row. OK when some text was entered. (#11151) -Add a string to the 'display' option ("smoothscroll" ?) to make CTRL-E and -CTRL-Y scroll one screen line, also if this means the first line doesn't start -with the first character (like what happens with a last line that doesn't -fit). Display "<<<" at the start of the first visible line (like "@@@" is -displayed in the last line). (Arseny Nasokin, #5154) -Neovim PR: https://github.com/neovim/neovim/pull/11014 - NFA regexp does not handle composing characters well: #10286 [ɔ̃] matches both ɔ and ɔ̃ \(ɔ\|ɔ̃\) matches ɔ and not ɔ̃ @@ -681,9 +657,6 @@ when possible. (Dylan Lloyd, #3973) Make ":interactive !cmd" stop termcap mode, also when used in an autocommand. (#3692) -matchaddpos() gets slow with many matches. Proposal by Rick Howe, 2018 Jul -19. - Add something like 'fillchars' local to window, but allow for specifying a highlight name. Esp. for the statusline. And "extends" and "precedes" are also useful without 'list' set. Also in diff --git a/runtime/doc/vim9.txt b/runtime/doc/vim9.txt --- a/runtime/doc/vim9.txt +++ b/runtime/doc/vim9.txt @@ -1,4 +1,4 @@ -*vim9.txt* For Vim version 9.0. Last change: 2022 Sep 19 +*vim9.txt* For Vim version 9.0. Last change: 2022 Oct 03 VIM REFERENCE MANUAL by Bram Moolenaar @@ -502,7 +502,7 @@ How constants work varies between langua can't be assigned another value a constant. JavaScript is an example. Others also make the value immutable, thus when a constant uses a list, the list cannot be changed. In Vim9 we can use both. - *E1021* + *E1021* *E1307* `:const` is used for making both the variable and the value a constant. Use this for composite structures that you want to make sure will not be modified. Example: > @@ -1413,11 +1413,11 @@ to a Vim9 function: Calling a function in an expr option ~ *expr-option-function* -A few options, such as 'foldexpr', are an expresison that is evaluated to get -a value. The evaluation can have quite a bit of overhead. One way to -minimize the overhead, and also to keep the option value very simple, is to -defined a compiled function and set the option to call it without arguments. -Example: > +The value of a few options, such as 'foldexpr', is an expression that is +evaluated to get a value. The evaluation can have quite a bit of overhead. +One way to minimize the overhead, and also to keep the option value very +simple, is to define a compiled function and set the option to call it +without arguments. Example: > vim9script def MyFoldFunc(): any ... compute fold level for line v:lnum diff --git a/runtime/ftplugin/erlang.vim b/runtime/ftplugin/erlang.vim --- a/runtime/ftplugin/erlang.vim +++ b/runtime/ftplugin/erlang.vim @@ -5,7 +5,7 @@ " Contributors: Ricardo Catalinas Jiménez " Eduardo Lopez (http://github.com/tapichu) " Arvid Bjurklint (http://github.com/slarwise) -" Last Update: 2021-Jan-08 +" Last Update: 2021-Nov-22 " License: Vim license " URL: https://github.com/vim-erlang/vim-erlang-runtime @@ -30,6 +30,28 @@ setlocal commentstring=%%s setlocal formatoptions+=ro +if get(g:, 'erlang_extend_path', 1) + " typical erlang.mk paths + let &l:path = join([ + \ 'deps/*/include', + \ 'deps/*/src', + \ 'deps/*/test', + \ 'deps/*/apps/*/include', + \ 'deps/*/apps/*/src', + \ &g:path], ',') + " typical rebar3 paths + let &l:path = join([ + \ 'apps/*/include', + \ 'apps/*/src', + \ '_build/default/lib/*/src', + \ '_build/default/*/include', + \ &l:path], ',') + " typical erlang paths + let &l:path = join(['include', 'src', 'test', &l:path], ',') + + set wildignore+=*/.erlang.mk/*,*.beam +endif + setlocal suffixesadd=.erl,.hrl let &l:include = '^\s*-\%(include\|include_lib\)\s*("\zs\f*\ze")' diff --git a/runtime/ftplugin/man.vim b/runtime/ftplugin/man.vim --- a/runtime/ftplugin/man.vim +++ b/runtime/ftplugin/man.vim @@ -3,7 +3,7 @@ " Maintainer: Jason Franklin " Maintainer: SungHyun Nam " Autoload Split: Bram Moolenaar -" Last Change: 2022 Jun 18 +" Last Change: 2022 Sep 30 " To make the ":Man" command available before editing a manual page, source " this script from your startup vimrc file. @@ -23,8 +23,9 @@ let s:cpo_save = &cpo set cpo-=C if &filetype == "man" - " allow dot and dash in manual page name. - setlocal iskeyword+=\.,- + " Allow hyphen, plus, colon, dot, and commercial at in manual page name. + " Allow parentheses for references. + setlocal iskeyword=48-57,_,a-z,A-Z,-,+,:,.,@-@,(,) let b:undo_ftplugin = "setlocal iskeyword<" " Add mappings, unless the user didn't want this. diff --git a/runtime/indent/erlang.vim b/runtime/indent/erlang.vim --- a/runtime/indent/erlang.vim +++ b/runtime/indent/erlang.vim @@ -4,7 +4,7 @@ " Contributors: Edwin Fine " Pawel 'kTT' Salata " Ricardo Catalinas Jiménez -" Last Update: 2020-Jun-11 +" Last Update: 2022-Sep-06 " License: Vim license " URL: https://github.com/vim-erlang/vim-erlang-runtime @@ -30,7 +30,9 @@ else endif setlocal indentexpr=ErlangIndent() -setlocal indentkeys+=0=end,0=of,0=catch,0=after,0=when,0=),0=],0=},0=>> +setlocal indentkeys+=0=end,0=of,0=catch,0=after,0=else,0=when,0=),0=],0=},0=>> + +let b:undo_indent = "setl inde< indk<" " Only define the functions once if exists("*ErlangIndent") @@ -235,8 +237,8 @@ function! s:GetTokensFromLine(line, stri " Two-character tokens elseif i + 1 < linelen && - \ index(['->', '<<', '>>', '||', '==', '/=', '=<', '>=', '++', '--', - \ '::'], + \ index(['->', '<<', '>>', '||', '==', '/=', '=<', '>=', '?=', '++', + \ '--', '::'], \ a:line[i : i + 1]) != -1 call add(indtokens, [a:line[i : i + 1], vcol, i]) let next_i = i + 2 @@ -558,8 +560,8 @@ function! s:IsCatchStandalone(lnum, i) let is_standalone = 0 elseif prev_token =~# '[a-z]' if index(['after', 'and', 'andalso', 'band', 'begin', 'bnot', 'bor', 'bsl', - \ 'bsr', 'bxor', 'case', 'catch', 'div', 'not', 'or', 'orelse', - \ 'rem', 'try', 'xor'], prev_token) != -1 + \ 'bsr', 'bxor', 'case', 'catch', 'div', 'maybe', 'not', 'or', + \ 'orelse', 'rem', 'try', 'xor'], prev_token) != -1 " If catch is after these keywords, it is standalone let is_standalone = 1 else @@ -568,7 +570,7 @@ function! s:IsCatchStandalone(lnum, i) " " Keywords: " - may precede 'catch': end - " - may not precede 'catch': fun if of receive when + " - may not precede 'catch': else fun if of receive when " - unused: cond let query let is_standalone = 0 endif @@ -577,7 +579,7 @@ function! s:IsCatchStandalone(lnum, i) let is_standalone = 0 else " This 'else' branch includes the following tokens: - " -> == /= =< < >= > =:= =/= + - * / ++ -- :: < > ; ( [ { ? = ! . | + " -> == /= =< < >= > ?= =:= =/= + - * / ++ -- :: < > ; ( [ { ? = ! . | let is_standalone = 1 endif @@ -590,6 +592,7 @@ endfunction " Purpose: " This function is called when a begin-type element ('begin', 'case', " '[', '<<', etc.) is found. It asks the caller to return if the stack +" if already empty. " Parameters: " stack: [token] " token: string @@ -758,7 +761,7 @@ endfunction function! s:SearchEndPair(lnum, curr_col) return s:SearchPair( \ a:lnum, a:curr_col, - \ '\C\<\%(case\|try\|begin\|receive\|if\)\>\|' . + \ '\C\<\%(case\|try\|begin\|receive\|if\|maybe\)\>\|' . \ '\\%(\s\|\n\|%.*$\|[A-Z_@][a-zA-Z_@]*\)*(', \ '', \ '\') @@ -847,6 +850,7 @@ function! s:ErlangCalcIndent2(lnum, stac if ret | return res | endif " case EXPR of BRANCHES end + " if BRANCHES end " try EXPR catch BRANCHES end " try EXPR after BODY end " try EXPR catch BRANCHES after BODY end @@ -855,15 +859,17 @@ function! s:ErlangCalcIndent2(lnum, stac " try EXPR of BRANCHES catch BRANCHES after BODY end " receive BRANCHES end " receive BRANCHES after BRANCHES end + " maybe EXPR end + " maybe EXPR else BRANCHES end " This branch is not Emacs-compatible - elseif (index(['of', 'receive', 'after', 'if'], token) != -1 || + elseif (index(['of', 'receive', 'after', 'if', 'else'], token) != -1 || \ (token ==# 'catch' && !s:IsCatchStandalone(lnum, i))) && \ !last_token_of_line && \ (empty(stack) || stack ==# ['when'] || stack ==# ['->'] || \ stack ==# ['->', ';']) - " If we are after of/receive, but these are not the last + " If we are after of/receive/etc, but these are not the last " tokens of the line, we want to indent like this: " " % stack == [] @@ -889,21 +895,21 @@ function! s:ErlangCalcIndent2(lnum, stac " stack = ['when'] => LTI is a guard if empty(stack) || stack == ['->', ';'] call s:Log(' LTI is in a condition after ' . - \'"of/receive/after/if/catch" -> return') + \'"of/receive/after/if/else/catch" -> return') return stored_vcol elseif stack == ['->'] call s:Log(' LTI is in a branch after ' . - \'"of/receive/after/if/catch" -> return') + \'"of/receive/after/if/else/catch" -> return') return stored_vcol + shiftwidth() elseif stack == ['when'] call s:Log(' LTI is in a guard after ' . - \'"of/receive/after/if/catch" -> return') + \'"of/receive/after/if/else/catch" -> return') return stored_vcol + shiftwidth() else return s:UnexpectedToken(token, stack) endif - elseif index(['case', 'if', 'try', 'receive'], token) != -1 + elseif index(['case', 'if', 'try', 'receive', 'maybe'], token) != -1 " stack = [] => LTI is a condition " stack = ['->'] => LTI is a branch @@ -913,45 +919,47 @@ function! s:ErlangCalcIndent2(lnum, stac " pass elseif (token ==# 'case' && stack[0] ==# 'of') || \ (token ==# 'if') || + \ (token ==# 'maybe' && stack[0] ==# 'else') || \ (token ==# 'try' && (stack[0] ==# 'of' || \ stack[0] ==# 'catch' || \ stack[0] ==# 'after')) || \ (token ==# 'receive') " From the indentation point of view, the keyword - " (of/catch/after/end) before the LTI is what counts, so + " (of/catch/after/else/end) before the LTI is what counts, so " when we reached these tokens, and the stack already had - " a catch/after/end, we didn't modify it. + " a catch/after/else/end, we didn't modify it. " - " This way when we reach case/try/receive (i.e. now), - " there is at most one of/catch/after/end token in the + " This way when we reach case/try/receive/maybe (i.e. now), + " there is at most one of/catch/after/else/end token in the " stack. if token ==# 'case' || token ==# 'try' || - \ (token ==# 'receive' && stack[0] ==# 'after') + \ (token ==# 'receive' && stack[0] ==# 'after') || + \ (token ==# 'maybe' && stack[0] ==# 'else') call s:Pop(stack) endif if empty(stack) call s:Log(' LTI is in a condition; matching ' . - \'"case/if/try/receive" found') + \'"case/if/try/receive/maybe" found') let stored_vcol = curr_vcol + shiftwidth() elseif stack[0] ==# 'align_to_begin_element' call s:Pop(stack) let stored_vcol = curr_vcol elseif len(stack) > 1 && stack[0] ==# '->' && stack[1] ==# ';' call s:Log(' LTI is in a condition; matching ' . - \'"case/if/try/receive" found') + \'"case/if/try/receive/maybe" found') call s:Pop(stack) call s:Pop(stack) let stored_vcol = curr_vcol + shiftwidth() elseif stack[0] ==# '->' call s:Log(' LTI is in a branch; matching ' . - \'"case/if/try/receive" found') + \'"case/if/try/receive/maybe" found') call s:Pop(stack) let stored_vcol = curr_vcol + 2 * shiftwidth() elseif stack[0] ==# 'when' call s:Log(' LTI is in a guard; matching ' . - \'"case/if/try/receive" found') + \'"case/if/try/receive/maybe" found') call s:Pop(stack) let stored_vcol = curr_vcol + 2 * shiftwidth() + 2 endif @@ -1213,7 +1221,7 @@ function! s:ErlangCalcIndent2(lnum, stac if empty(stack) call s:Push(stack, ';') - elseif index([';', '->', 'when', 'end', 'after', 'catch'], + elseif index([';', '->', 'when', 'end', 'after', 'catch', 'else'], \stack[0]) != -1 " Pass: " @@ -1223,10 +1231,10 @@ function! s:ErlangCalcIndent2(lnum, stac " should keep that, because they signify the type of the " LTI (branch, condition or guard). " - From the indentation point of view, the keyword - " (of/catch/after/end) before the LTI is what counts, so - " if the stack already has a catch/after/end, we don't - " modify it. This way when we reach case/try/receive, - " there will be at most one of/catch/after/end token in + " (of/catch/after/else/end) before the LTI is what counts, so + " if the stack already has a catch/after/else/end, we don't + " modify it. This way when we reach case/try/receive/maybe, + " there will be at most one of/catch/after/else/end token in " the stack. else return s:UnexpectedToken(token, stack) @@ -1242,7 +1250,8 @@ function! s:ErlangCalcIndent2(lnum, stac " stack = ['->'] -> LTI is a condition " stack = ['->', ';'] -> LTI is a branch call s:Push(stack, '->') - elseif index(['->', 'when', 'end', 'after', 'catch'], stack[0]) != -1 + elseif index(['->', 'when', 'end', 'after', 'catch', 'else'], + \stack[0]) != -1 " Pass: " " - If the stack top is another '->', then one '->' is @@ -1250,10 +1259,10 @@ function! s:ErlangCalcIndent2(lnum, stac " - If the stack top is a 'when', then we should keep " that, because this signifies that LTI is a in a guard. " - From the indentation point of view, the keyword - " (of/catch/after/end) before the LTI is what counts, so - " if the stack already has a catch/after/end, we don't - " modify it. This way when we reach case/try/receive, - " there will be at most one of/catch/after/end token in + " (of/catch/after/else/end) before the LTI is what counts, so + " if the stack already has a catch/after/else/end, we don't + " modify it. This way when we reach case/try/receive/maybe, + " there will be at most one of/catch/after/else/end token in " the stack. else return s:UnexpectedToken(token, stack) @@ -1283,7 +1292,8 @@ function! s:ErlangCalcIndent2(lnum, stac " LTI call s:Push(stack, token) endif - elseif index(['->', 'when', 'end', 'after', 'catch'], stack[0]) != -1 + elseif index(['->', 'when', 'end', 'after', 'catch', 'else'], + \stack[0]) != -1 " Pass: " - If the stack top is another 'when', then one 'when' is " enough. @@ -1291,21 +1301,63 @@ function! s:ErlangCalcIndent2(lnum, stac " should keep that, because they signify the type of the " LTI (branch, condition or guard). " - From the indentation point of view, the keyword - " (of/catch/after/end) before the LTI is what counts, so - " if the stack already has a catch/after/end, we don't - " modify it. This way when we reach case/try/receive, - " there will be at most one of/catch/after/end token in + " (of/catch/after/else/end) before the LTI is what counts, so + " if the stack already has a catch/after/else/end, we don't + " modify it. This way when we reach case/try/receive/maybe, + " there will be at most one of/catch/after/else/end token in " the stack. else return s:UnexpectedToken(token, stack) endif - elseif token ==# 'of' || token ==# 'after' || + elseif token ==# 'of' || token ==# 'after' || token ==# 'else' || \ (token ==# 'catch' && !s:IsCatchStandalone(lnum, i)) - if token ==# 'after' - " If LTI is between an 'after' and the corresponding - " 'end', then let's return + if token ==# 'after' || token ==# 'else' + " If LTI is between an after/else and the corresponding 'end', then + " let's return because calculating the indentation based on + " after/else is enough. + " + " Example: + " receive A after + " LTI + " maybe A else + " LTI + " + " Note about Emacs compabitility {{{ + " + " It would be fine to indent the examples above the following way: + " + " receive A after + " LTI + " maybe A else + " LTI + " + " We intend it the way above because that is how Emacs does it. + " Also, this is a bit faster. + " + " We are still not 100% Emacs compatible because of placing the + " 'end' after the indented blocks. + " + " Emacs example: + " + " receive A after + " LTI + " end, + " maybe A else + " LTI + " end % Yes, it's here (in OTP 25.0, might change + " % later) + " + " vim-erlang example: + " + " receive A after + " LTI + " end, + " maybe A else + " LTI + " end + " }}} let [ret, res] = s:BeginElementFoundIfEmpty(stack, token, curr_vcol, \stored_vcol, shiftwidth()) if ret | return res | endif @@ -1313,7 +1365,8 @@ function! s:ErlangCalcIndent2(lnum, stac if empty(stack) || stack[0] ==# '->' || stack[0] ==# 'when' call s:Push(stack, token) - elseif stack[0] ==# 'catch' || stack[0] ==# 'after' || stack[0] ==# 'end' + elseif stack[0] ==# 'catch' || stack[0] ==# 'after' || + \stack[0] ==# 'else' || stack[0] ==# 'end' " Pass: From the indentation point of view, the keyword " (of/catch/after/end) before the LTI is what counts, so " if the stack already has a catch/after/end, we don't @@ -1403,7 +1456,7 @@ function! ErlangIndent() endif let ml = matchlist(currline, - \'^\(\s*\)\(\%(end\|of\|catch\|after\)\>\|[)\]}]\|>>\)') + \'^\(\s*\)\(\%(end\|of\|catch\|after\|else\)\>\|[)\]}]\|>>\)') " If the line has a special beginning, but not a standalone catch if !empty(ml) && !(ml[2] ==# 'catch' && s:IsCatchStandalone(v:lnum, 0)) diff --git a/runtime/indent/testdir/vim.in b/runtime/indent/testdir/vim.in --- a/runtime/indent/testdir/vim.in +++ b/runtime/indent/testdir/vim.in @@ -857,3 +857,15 @@ b: 2}] silent! argdel * edit file " END_INDENT + +" START_INDENT +def Foo() +Bar(1, +[]->filter((_, v) => { +return true +}), +() => { +echo +}) +enddef +" END_INDENT diff --git a/runtime/indent/testdir/vim.ok b/runtime/indent/testdir/vim.ok --- a/runtime/indent/testdir/vim.ok +++ b/runtime/indent/testdir/vim.ok @@ -857,3 +857,15 @@ endfor silent! argdel * edit file " END_INDENT + +" START_INDENT +def Foo() + Bar(1, + []->filter((_, v) => { + return true + }), + () => { + echo + }) +enddef +" END_INDENT diff --git a/runtime/optwin.vim b/runtime/optwin.vim --- a/runtime/optwin.vim +++ b/runtime/optwin.vim @@ -1,7 +1,7 @@ " These commands create the option window. " " Maintainer: Bram Moolenaar -" Last Change: 2022 Sep 11 +" Last Change: 2022 Oct 02 " If there already is an option window, jump to that one. let buf = bufnr('option-window') diff --git a/runtime/plugin/manpager.vim b/runtime/plugin/manpager.vim --- a/runtime/plugin/manpager.vim +++ b/runtime/plugin/manpager.vim @@ -1,6 +1,6 @@ " Vim plugin for using Vim as manpager. " Maintainer: Enno Nagel -" Last Change: 2022 Jun 17 +" Last Change: 2022 Sep 30 " Set up the current buffer (likely read from stdin) as a manpage command MANPAGER call s:ManPager() @@ -18,9 +18,6 @@ function s:ManPager() " Make this an unlisted, readonly scratch buffer setlocal buftype=nofile noswapfile bufhidden=hide nobuflisted readonly - " Is this useful? Should allow for using K on word with a colon. - setlocal iskeyword+=: - " Ensure text width matches window width setlocal foldcolumn& nofoldenable nonumber norelativenumber @@ -44,6 +41,6 @@ function s:ManPager() setlocal nomodified nomodifiable " Set filetype to man even if ftplugin is disabled - setlocal iskeyword+=: filetype=man + setlocal filetype=man runtime ftplugin/man.vim endfunction diff --git a/runtime/syntax/erlang.vim b/runtime/syntax/erlang.vim --- a/runtime/syntax/erlang.vim +++ b/runtime/syntax/erlang.vim @@ -2,7 +2,7 @@ " Language: Erlang (http://www.erlang.org) " Maintainer: Csaba Hoch " Contributor: Adam Rutkowski -" Last Update: 2020-May-26 +" Last Update: 2022-Sep-06 " License: Vim license " URL: https://github.com/vim-erlang/vim-erlang-runtime @@ -61,7 +61,8 @@ syn match erlangQuotedAtomModifier '\\\% syn match erlangModifier '\$\%([^\\]\|\\\%(\o\{1,3}\|x\x\x\|x{\x\+}\|\^.\|.\)\)' " Operators, separators -syn match erlangOperator '==\|=:=\|/=\|=/=\|<\|=<\|>\|>=\|=>\|:=\|++\|--\|=\|!\|<-\|+\|-\|\*\|\/' +syn match erlangOperator '==\|=:=\|/=\|=/=\|<\|=<\|>\|>=\|=>\|:=\|?=\|++\|--\|=\|!\|<-\|+\|-\|\*\|\/' +syn match erlangEqualsBinary '=<<\%(<\)\@!' syn keyword erlangOperator div rem or xor bor bxor bsl bsr and band not bnot andalso orelse syn match erlangBracket '{\|}\|\[\|]\||\|||' syn match erlangPipe '|' @@ -76,7 +77,8 @@ syn match erlangGlobalFuncCall '\<\%(\a[ syn match erlangGlobalFuncRef '\<\%(\a[[:alnum:]_@]*\%(\s\|\n\|%.*\n\)*\.\%(\s\|\n\|%.*\n\)*\)*\a[[:alnum:]_@]*\%(\s\|\n\|%.*\n\)*:\%(\s\|\n\|%.*\n\)*\a[[:alnum:]_@]*\>\%(\%(\s\|\n\|%.*\n\)*/\)\@=' contains=erlangComment,erlangVariable " Variables, macros, records, maps -syn match erlangVariable '\<[A-Z_][[:alnum:]_@]*' +syn match erlangVariable '\<[A-Z][[:alnum:]_@]*' +syn match erlangAnonymousVariable '\<_[[:alnum:]_@]*' syn match erlangMacro '??\=[[:alnum:]_@]\+' syn match erlangMacro '\%(-define(\)\@<=[[:alnum:]_@]\+' syn region erlangQuotedMacro start=/??\=\s*'/ end=/'/ contains=erlangQuotedAtomModifier @@ -92,7 +94,7 @@ syn match erlangBitType '\%(\/\%(\s\|\n\ " Constants and Directives syn match erlangUnknownAttribute '^\s*-\%(\s\|\n\|%.*\n\)*\l[[:alnum:]_@]*' contains=erlangComment -syn match erlangAttribute '^\s*-\%(\s\|\n\|%.*\n\)*\%(behaviou\=r\|compile\|export\(_type\)\=\|file\|import\|module\|author\|copyright\|doc\|vsn\|on_load\|optional_callbacks\)\>' contains=erlangComment +syn match erlangAttribute '^\s*-\%(\s\|\n\|%.*\n\)*\%(behaviou\=r\|compile\|export\(_type\)\=\|file\|import\|module\|author\|copyright\|doc\|vsn\|on_load\|optional_callbacks\|feature\)\>' contains=erlangComment syn match erlangInclude '^\s*-\%(\s\|\n\|%.*\n\)*\%(include\|include_lib\)\>' contains=erlangComment syn match erlangRecordDef '^\s*-\%(\s\|\n\|%.*\n\)*record\>' contains=erlangComment syn match erlangDefine '^\s*-\%(\s\|\n\|%.*\n\)*\%(define\|undef\)\>' contains=erlangComment @@ -100,8 +102,8 @@ syn match erlangPreCondit '^\s*-\%(\s\|\ syn match erlangType '^\s*-\%(\s\|\n\|%.*\n\)*\%(spec\|type\|opaque\|callback\)\>' contains=erlangComment " Keywords -syn keyword erlangKeyword after begin case catch cond end fun if let of -syn keyword erlangKeyword receive when try +syn keyword erlangKeyword after begin case catch cond end fun if let of else +syn keyword erlangKeyword receive when try maybe " Build-in-functions (BIFs) syn keyword erlangBIF abs alive apply atom_to_binary atom_to_list contained @@ -174,6 +176,7 @@ hi def link erlangModifier Special " Operators, separators hi def link erlangOperator Operator +hi def link erlangEqualsBinary ErrorMsg hi def link erlangRightArrow Operator if s:old_style hi def link erlangBracket Normal @@ -191,6 +194,7 @@ hi def link erlangLocalFuncRef Normal hi def link erlangGlobalFuncCall Function hi def link erlangGlobalFuncRef Function hi def link erlangVariable Normal +hi def link erlangAnonymousVariable erlangVariable hi def link erlangMacro Normal hi def link erlangQuotedMacro Normal hi def link erlangRecord Normal @@ -203,6 +207,7 @@ hi def link erlangLocalFuncRef Normal hi def link erlangGlobalFuncCall Normal hi def link erlangGlobalFuncRef Normal hi def link erlangVariable Identifier +hi def link erlangAnonymousVariable erlangVariable hi def link erlangMacro Macro hi def link erlangQuotedMacro Macro hi def link erlangRecord Structure diff --git a/runtime/syntax/vim.vim b/runtime/syntax/vim.vim --- a/runtime/syntax/vim.vim +++ b/runtime/syntax/vim.vim @@ -1,8 +1,8 @@ " Vim syntax file " Language: Vim 9.0 script " Maintainer: Charles E. Campbell -" Last Change: September 14, 2022 -" Version: 9.0-05 +" Last Change: October 03, 2022 +" Version: 9.0-07 " URL: http://www.drchip.org/astronaut/vim/index.html#SYNTAX_VIM " Automatically generated keyword lists: {{{1 @@ -30,23 +30,23 @@ syn match vimCommand contained "\