diff options
author | Bram Moolenaar <Bram@vim.org> | 2021-12-24 13:18:38 +0000 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2021-12-24 13:18:38 +0000 |
commit | fa3b72348d88343390fbe212cfc230fec1602fc2 (patch) | |
tree | c0f27c44f2819613a4288bfc6ebc5c58f421d90d /runtime | |
parent | d3f00f54bf955bd01767db3a0af25866bc112ec7 (diff) |
Update runtime files
Diffstat (limited to 'runtime')
28 files changed, 389 insertions, 451 deletions
diff --git a/runtime/autoload/dist/ft.vim b/runtime/autoload/dist/ft.vim index 366d7b009d..9933ace8c2 100644 --- a/runtime/autoload/dist/ft.vim +++ b/runtime/autoload/dist/ft.vim @@ -1,7 +1,7 @@ " Vim functions for file type detection " " Maintainer: Bram Moolenaar <Bram@vim.org> -" Last Change: 2021 Nov 27 +" Last Change: 2021 Dec 17 " These functions are moved here from runtime/filetype.vim to make startup " faster. diff --git a/runtime/doc/eval.txt b/runtime/doc/eval.txt index db8e1002dc..fa8ce9fef1 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 Dec 15 +*eval.txt* For Vim version 8.2. Last change: 2021 Dec 24 VIM REFERENCE MANUAL by Bram Moolenaar @@ -2367,7 +2367,9 @@ v:termresponse The escape sequence returned by the terminal for the |t_RV| The response from a new xterm is: "<Esc>[> Pp ; Pv ; Pc c". Pp is the terminal type: 0 for vt100 and 1 for vt220. Pv is the patch level (since this was introduced in patch 95, it's - always 95 or bigger). Pc is always zero. + always 95 or higher). Pc is always zero. + If Pv is 141 or higher then Vim will try to request terminal + codes. This only works with xterm |xterm-codes|. {only when compiled with |+termresponse| feature} *v:termblinkresp* @@ -6190,8 +6192,9 @@ getreg([{regname} [, 1 [, {list}]]]) *getreg()* The result is a String, which is the contents of register {regname}. Example: > :let cliptext = getreg('*') -< When {regname} was not set the result is an empty string. - The {regname} argument is a string. +< When register {regname} was not set the result is an empty + string. + The {regname} argument must be a string. getreg('=') returns the last evaluated value of the expression register. (For use in maps.) diff --git a/runtime/doc/map.txt b/runtime/doc/map.txt index fc3f42584c..b8806d2cad 100644 --- a/runtime/doc/map.txt +++ b/runtime/doc/map.txt @@ -1,4 +1,4 @@ -*map.txt* For Vim version 8.2. Last change: 2021 Dec 15 +*map.txt* For Vim version 8.2. Last change: 2021 Dec 20 VIM REFERENCE MANUAL by Bram Moolenaar @@ -962,8 +962,7 @@ g@{motion} Call the function set by the 'operatorfunc' option. "line" {motion} was |linewise| "char" {motion} was |characterwise| "block" {motion} was |blockwise-visual| - Although "block" would rarely appear, since it can - only result from Visual mode where "g@" is not useful. + The type can be forced, see |forced-motion|. {not available when compiled without the |+eval| feature} @@ -974,35 +973,56 @@ Here is an example that counts the number of spaces with <F4>: > " doubling <F4> works on a line nnoremap <expr> <F4><F4> CountSpaces() .. '_' - function CountSpaces(virtualedit = '', irregular_block = v:false, type = '') abort + function CountSpaces(context = {}, type = '') abort if a:type == '' - let &operatorfunc = function('CountSpaces', [&virtualedit, v:false]) + let context = #{ + \ dot_command: v:false, + \ extend_block: '', + \ virtualedit: [&l:virtualedit, &g:virtualedit], + \ } + let &operatorfunc = function('CountSpaces', [context]) set virtualedit=block return 'g@' endif - let cb_save = &clipboard - let sel_save = &selection - let reg_save = getreginfo('"') - let visual_marks_save = [getpos("'<"), getpos("'>")] + let save = #{ + \ clipboard: &clipboard, + \ selection: &selection, + \ virtualedit: [&l:virtualedit, &g:virtualedit], + \ register: getreginfo('"'), + \ visual_marks: [getpos("'<"), getpos("'>")], + \ } try set clipboard= selection=inclusive virtualedit= - let commands = #{line: "'[V']", char: "`[v`]", block: "`[\<C-V>`]"}->get(a:type, 'v') - if getpos("']")[-1] != 0 || a:irregular_block - let commands ..= 'oO$' - let &operatorfunc = function('CountSpaces', [a:virtualedit, v:true]) + let commands = #{ + \ line: "'[V']", + \ char: "`[v`]", + \ block: "`[\<C-V>`]", + \ }[a:type] + let [_, _, col, off] = getpos("']") + if off != 0 + let vcol = getline("'[")->strpart(0, col + off)->strdisplaywidth() + if vcol >= [line("'["), '$']->virtcol() - 1 + let a:context.extend_block = '$' + else + let a:context.extend_block = vcol .. '|' + endif + endif + if a:context.extend_block != '' + let commands ..= 'oO' .. a:context.extend_block endif let commands ..= 'y' execute 'silent noautocmd keepjumps normal! ' .. commands echomsg getreg('"')->count(' ') finally - call setreg('"', reg_save) - call setpos("'<", visual_marks_save[0]) - call setpos("'>", visual_marks_save[1]) - let &clipboard = cb_save - let &selection = sel_save - let &virtualedit = a:virtualedit + call setreg('"', save.register) + call setpos("'<", save.visual_marks[0]) + call setpos("'>", save.visual_marks[1]) + let &clipboard = save.clipboard + let &selection = save.selection + let [&l:virtualedit, &g:virtualedit] = get(a:context.dot_command ? save : a:context, 'virtualedit') + let a:context.dot_command = v:true endtry endfunction diff --git a/runtime/doc/options.txt b/runtime/doc/options.txt index b4e7761659..845351d08f 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 Dec 11 +*options.txt* For Vim version 8.2. Last change: 2021 Dec 21 VIM REFERENCE MANUAL by Bram Moolenaar @@ -385,7 +385,7 @@ lambda it will be converted to the name, e.g. "<lambda>123". Examples: set opfunc={a\ ->\ MyOpFunc(a)} " set using a funcref variable let Fn = function('MyTagFunc') - let &tagfunc = string(Fn) + let &tagfunc = Fn " set using a lambda expression let &tagfunc = {t -> MyTagFunc(t)} " set using a variable with lambda expression @@ -9210,7 +9210,7 @@ A jump table for the options with a short description can be found at |Q_op|. 'xtermcodes' boolean (default on) global When detecting xterm patchlevel 141 or higher with the termresponse - mechanism and this option is set, Vim will request the actual termimal + mechanism and this option is set, Vim will request the actual terminal key codes and number of colors from the terminal. This takes care of various configuration options of the terminal that cannot be obtained from the termlib/terminfo entry, see |xterm-codes|. diff --git a/runtime/doc/quickref.txt b/runtime/doc/quickref.txt index aa5a36a331..e532942914 100644 --- a/runtime/doc/quickref.txt +++ b/runtime/doc/quickref.txt @@ -1,4 +1,4 @@ -*quickref.txt* For Vim version 8.2. Last change: 2021 Oct 17 +*quickref.txt* For Vim version 8.2. Last change: 2021 Dec 21 VIM REFERENCE MANUAL by Bram Moolenaar @@ -1010,6 +1010,7 @@ Short explanation of each option: *option-list* 'writeany' 'wa' write to file with no need for "!" override 'writebackup' 'wb' make a backup before overwriting a file 'writedelay' 'wd' delay this many msec for each char (for debug) +'xtermcodes' request terminal codes from an xterm ------------------------------------------------------------------------------ *Q_ur* Undo/Redo commands diff --git a/runtime/doc/syntax.txt b/runtime/doc/syntax.txt index 0101b51b64..35a4e3ad7a 100644 --- a/runtime/doc/syntax.txt +++ b/runtime/doc/syntax.txt @@ -4506,7 +4506,7 @@ it marks the "\(\I\i*\)" sub-expression as external; in the end pattern, it changes the \z1 back-reference into an external reference referring to the first external sub-expression in the start pattern. External references can also be used in skip patterns: > - :syn region foo start="start \(\I\i*\)" skip="not end \z1" end="end \z1" + :syn region foo start="start \z(\I\i*\)" skip="not end \z1" end="end \z1" Note that normal and external sub-expressions are completely orthogonal and indexed separately; for instance, if the pattern "\z(..\)\(..\)" is applied diff --git a/runtime/doc/tags b/runtime/doc/tags index fc5a0c9254..9b5fe38c12 100644 --- a/runtime/doc/tags +++ b/runtime/doc/tags @@ -751,6 +751,7 @@ $VIM_POSIX vi_diff.txt /*$VIM_POSIX* 'nowriteany' options.txt /*'nowriteany'* 'nowritebackup' options.txt /*'nowritebackup'* 'nows' options.txt /*'nows'* +'noxtermcodes' options.txt /*'noxtermcodes'* 'nrformats' options.txt /*'nrformats'* 'nu' options.txt /*'nu'* 'number' options.txt /*'number'* @@ -1262,6 +1263,7 @@ $VIM_POSIX vi_diff.txt /*$VIM_POSIX* 'writedelay' options.txt /*'writedelay'* 'ws' options.txt /*'ws'* 'ww' options.txt /*'ww'* +'xtermcodes' options.txt /*'xtermcodes'* '{ motion.txt /*'{* '} motion.txt /*'}* ( motion.txt /*(* @@ -5912,6 +5914,7 @@ collate-variable eval.txt /*collate-variable* color-xterm syntax.txt /*color-xterm* coloring syntax.txt /*coloring* colortest.vim syntax.txt /*colortest.vim* +command-block vim9.txt /*command-block* command-line-functions usr_41.txt /*command-line-functions* command-line-window cmdline.txt /*command-line-window* command-mode intro.txt /*command-mode* diff --git a/runtime/doc/term.txt b/runtime/doc/term.txt index 3e90cc0476..9e91c0e949 100644 --- a/runtime/doc/term.txt +++ b/runtime/doc/term.txt @@ -1,4 +1,4 @@ -*term.txt* For Vim version 8.2. Last change: 2021 Dec 08 +*term.txt* For Vim version 8.2. Last change: 2021 Dec 21 VIM REFERENCE MANUAL by Bram Moolenaar diff --git a/runtime/doc/terminal.txt b/runtime/doc/terminal.txt index d75015a3f0..ca28f1f330 100644 --- a/runtime/doc/terminal.txt +++ b/runtime/doc/terminal.txt @@ -1,4 +1,4 @@ -*terminal.txt* For Vim version 8.2. Last change: 2021 Nov 13 +*terminal.txt* For Vim version 8.2. Last change: 2021 Dec 21 VIM REFERENCE MANUAL by Bram Moolenaar @@ -1428,6 +1428,8 @@ GDB command *termdebug-customizing* To change the name of the gdb command, set the "g:termdebugger" variable before invoking `:Termdebug`: > let g:termdebugger = "mygdb" +If the command needs an argument use a List: > + let g:termdebugger = ['rr', 'replay', '--'] < *gdb-version* Only debuggers fully compatible with gdb will work. Vim uses the GDB/MI interface. The "new-ui" command requires gdb version 7.12 or later. if you diff --git a/runtime/doc/todo.txt b/runtime/doc/todo.txt index 80ea2a33e5..bd97d3a2bd 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 Dec 15 +*todo.txt* For Vim version 8.2. Last change: 2021 Dec 24 VIM REFERENCE MANUAL by Bram Moolenaar @@ -38,9 +38,14 @@ browser use: https://github.com/vim/vim/issues/1234 *known-bugs* -------------------- Known bugs and current work ----------------------- +type of v: vars should be more specific + v:completed_item is dict<string>, not dict<any> + +E1135 is used twice + +"z=" in German can take a very long time, CTRL-C should interrupt it. + Vim9 - Make everything work: -- Check TODO items in vim9execute.c -- use CheckLegacyAndVim9Success(lines) in many more places - For builtin functions using tv_get_string*() use check_for_string() to be more strict about the argument type (not a bool). done: balloon_() @@ -48,8 +53,6 @@ Vim9 - Make everything work: map() could check that the return type of the function argument matches the type of the list or dict member. (#8092) Same for other functions, such as searchpair(). -- Test try/catch and throw better, also nested. - Test that return inside try/finally jumps to finally and then returns. - Test that a function defined inside a :def function is local to that function, g: functions can be defined and script-local functions cannot be defined. @@ -89,6 +92,9 @@ Further Vim9 improvements, possibly after launch: has(featureName), len(someString) - Implement as part of an expression: ++expr, --expr, expr++, expr--. +Update list of features to vote on: +- multiple cursors +- built-in LSP support Popup windows: - Preview popup not properly updated when it overlaps with completion menu. @@ -131,8 +137,6 @@ Text properties: where property fits in. Or Should we let the textprop highlight overrule other (e.g. diff) highlight if the priority is above a certain value? (#7392) -- Popup attached to text property stays visible when text is no longer - visible. (#7736) - Popup attached to text property stays visible when text is deleted with "cc". (#7737) "C" works OK. "dd" also files in a buffer with a single line. @@ -249,6 +253,8 @@ Idea: when typing ":e /some/dir/" and "dir" does not exist, highlight in red. initialization to figure out the default value from 'shell'. Add a test for this. +Patch to add :argdedupe. (Nir Lichtman, #6235) + MS-Windows: did path modifier :p:8 stop working? #8600 test_arglist func Test_all_not_allowed_from_cmdwin() hangs on MS-Windows. @@ -415,8 +421,6 @@ Motif: Build on Ubuntu can't enter any text in dialog text fields. Running test_gui and test_gui_init with Motif sometimes kills the window manager. Problem with Motif? -Patch to add :argdedupe. (Nir Lichtman, #6235) - When editing a file with ":edit" the output of :swapname is relative, while editing it with "vim file" it is absolute. (#355) Which one should it be? diff --git a/runtime/doc/various.txt b/runtime/doc/various.txt index b82427ca18..5b8654b8a9 100644 --- a/runtime/doc/various.txt +++ b/runtime/doc/various.txt @@ -1,4 +1,4 @@ -*various.txt* For Vim version 8.2. Last change: 2021 Dec 13 +*various.txt* For Vim version 8.2. Last change: 2021 Dec 20 VIM REFERENCE MANUAL by Bram Moolenaar @@ -549,14 +549,17 @@ N *+X11* Unix only: can restore window title |X11| name can be omitted. :redi[r] @">> Append messages to the unnamed register. -:redi[r] => {var} Redirect messages to a variable. If the variable - doesn't exist, then it is created. If the variable - exists, then it is initialized to an empty string. +:redi[r] => {var} Redirect messages to a variable. + In legacy script: If the variable doesn't exist, then + it is created. If the variable exists, then it is + initialized to an empty string. After the redirection + starts, if the variable is removed or locked or the + variable type is changed, then further command output + messages will cause errors. + In Vim9 script: the variable must have been declared + as a string. The variable will remain empty until redirection ends. - Only string variables can be used. After the - redirection starts, if the variable is removed or - locked or the variable type is changed, then further - command output messages will cause errors. + Only string variables can be used. To get the output of one command the |execute()| function can be used instead of redirection. diff --git a/runtime/doc/vim9.txt b/runtime/doc/vim9.txt index 39affbfc2c..6c142a4b12 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 Dec 15 +*vim9.txt* For Vim version 8.2. Last change: 2021 Dec 22 VIM REFERENCE MANUAL by Bram Moolenaar @@ -169,8 +169,8 @@ created yet. In this case you can call `execute()` to invoke it at runtime. > `:def` has no options like `:function` does: "range", "abort", "dict" or "closure". A `:def` function always aborts on an error (unless `:silent!` was -used for the command or inside a `:try` block), does not get a range passed -cannot be a "dict" function, and can always be a closure. +used for the command or the error was caught a `:try` block), does not get a +range passed cannot be a "dict" function, and can always be a closure. *vim9-no-dict-function* Later classes will be added, which replaces the "dict function" mechanism. For now you will need to pass the dictionary explicitly: > @@ -509,7 +509,7 @@ The function must already have been defined. > When using `function()` the resulting type is "func", a function with any number of arguments and any return type (including void). The function can be -defined later. +defined later if the argument is in quotes. Lambda using => instead of -> ~ diff --git a/runtime/filetype.vim b/runtime/filetype.vim index c3d370d4eb..ef98589b5b 100644 --- a/runtime/filetype.vim +++ b/runtime/filetype.vim @@ -1,7 +1,7 @@ " Vim support file to detect file types " " Maintainer: Bram Moolenaar <Bram@vim.org> -" Last Change: 2021 Dec 14 +" Last Change: 2021 Dec 22 " Listen very carefully, I will say this only once if exists("did_load_filetypes") diff --git a/runtime/ftplugin/zsh.vim b/runtime/ftplugin/zsh.vim index 53ce1417dd..34410f1c62 100644 --- a/runtime/ftplugin/zsh.vim +++ b/runtime/ftplugin/zsh.vim @@ -18,13 +18,13 @@ setlocal comments=:# commentstring=#\ %s formatoptions-=t formatoptions+=croql let b:undo_ftplugin = "setl com< cms< fo< " -if executable('zsh') +if executable('zsh') && &shell !~# '/\%(nologin\|false\)$' if !has('gui_running') && executable('less') - command! -buffer -nargs=1 RunHelp silent exe '!MANPAGER= zsh -ic "autoload -Uz run-help; run-help <args> 2>/dev/null | LESS= less"' | redraw! + command! -buffer -nargs=1 RunHelp silent exe '!MANPAGER= zsh -c "autoload -Uz run-help; run-help <args> 2>/dev/null | LESS= less"' | redraw! elseif has('terminal') - command! -buffer -nargs=1 RunHelp silent exe ':term zsh -ic "autoload -Uz run-help; run-help <args>"' + command! -buffer -nargs=1 RunHelp silent exe ':term zsh -c "autoload -Uz run-help; run-help <args>"' else - command! -buffer -nargs=1 RunHelp echo system('zsh -ic "autoload -Uz run-help; run-help <args> 2>/dev/null"') + command! -buffer -nargs=1 RunHelp echo system('zsh -c "autoload -Uz run-help; run-help <args> 2>/dev/null"') endif if !exists('current_compiler') compiler zsh diff --git a/runtime/indent/sh.vim b/runtime/indent/sh.vim index d2fb1ba452..aa47c6d1bd 100644 --- a/runtime/indent/sh.vim +++ b/runtime/indent/sh.vim @@ -109,7 +109,7 @@ function! GetShIndent() let ind += s:indent_value('continuation-line') endif elseif s:end_block(line) && !s:start_block(line) - let ind -= s:indent_value('default') + let ind = indent(lnum) elseif pnum != 0 && \ s:is_continuation_line(pline) && \ !s:end_block(curline) && diff --git a/runtime/indent/xml.vim b/runtime/indent/xml.vim index da65417939..5bf53ad1f8 100644 --- a/runtime/indent/xml.vim +++ b/runtime/indent/xml.vim @@ -39,6 +39,8 @@ setlocal indentkeys=o,O,*<Return>,<>>,<<>,/,{,},!^F " autoindent: used when the indentexpr returns -1 setlocal autoindent +let b:undo_indent = "setl ai< inde< indk<" + if !exists('b:xml_indent_open') let b:xml_indent_open = '.\{-}<[:A-Z_a-z]' " pre tag, e.g. <address> @@ -51,6 +53,10 @@ if !exists('b:xml_indent_close') " let b:xml_indent_close = '.\{-}</\(address\)\@!' endif +if !exists('b:xml_indent_continuation_filetype') + let b:xml_indent_continuation_filetype = 'xml' +endif + let &cpo = s:keepcpo unlet s:keepcpo @@ -162,7 +168,7 @@ endfun func! <SID>IsXMLContinuation(line) " Checks, whether or not the line matches a start-of-tag - return a:line !~ '^\s*<' && &ft is# 'xml' + return a:line !~ '^\s*<' && &ft =~# b:xml_indent_continuation_filetype endfunc func! <SID>HasNoTagEnd(line) diff --git a/runtime/menu.vim b/runtime/menu.vim index e17652432d..5f4e395e12 100644 --- a/runtime/menu.vim +++ b/runtime/menu.vim @@ -2,7 +2,7 @@ " You can also use this as a start for your own set of menus. " " Maintainer: Bram Moolenaar <Bram@vim.org> -" Last Change: 2020 Sep 28 +" Last Change: 2021 Dec 22 " Note that ":an" (short for ":anoremenu") is often used to make a menu work " in all modes and avoid side effects from mappings defined by the user. @@ -717,6 +717,11 @@ func s:BMCanAdd(name, num) return 0 endif + " no name with control characters + if a:name =~ '[\x01-\x1f]' + return 0 + endif + " no special buffer, such as terminal or popup let buftype = getbufvar(a:num, '&buftype') if buftype != '' && buftype != 'nofile' && buftype != 'nowrite' diff --git a/runtime/optwin.vim b/runtime/optwin.vim index 9aa2db26f4..d138ab1d17 100644 --- a/runtime/optwin.vim +++ b/runtime/optwin.vim @@ -1,7 +1,7 @@ " These commands create the option window. " " Maintainer: Bram Moolenaar <Bram@vim.org> -" Last Change: 2021 Dec 12 +" Last Change: 2021 Dec 21 " If there already is an option window, jump to that one. let buf = bufnr('option-window') diff --git a/runtime/pack/dist/opt/matchit/autoload/matchit.vim b/runtime/pack/dist/opt/matchit/autoload/matchit.vim index 4f3dd8ff9e..e8689980ae 100644 --- a/runtime/pack/dist/opt/matchit/autoload/matchit.vim +++ b/runtime/pack/dist/opt/matchit/autoload/matchit.vim @@ -1,6 +1,11 @@ " matchit.vim: (global plugin) Extended "%" matching " autload script of matchit plugin, see ../plugin/matchit.vim -" Last Change: Mar 01, 2020 +" Last Change: Jun 10, 2021 + +" Neovim does not support scriptversion +if has("vimscript-4") + scriptversion 4 +endif let s:last_mps = "" let s:last_words = ":" @@ -30,11 +35,11 @@ function s:RestoreOptions() " In s:CleanUp(), :execute "set" restore_options . let restore_options = "" if get(b:, 'match_ignorecase', &ic) != &ic - let restore_options .= (&ic ? " " : " no") . "ignorecase" + let restore_options ..= (&ic ? " " : " no") .. "ignorecase" let &ignorecase = b:match_ignorecase endif if &ve != '' - let restore_options = " ve=" . &ve . restore_options + let restore_options = " ve=" .. &ve .. restore_options set ve= endif return restore_options @@ -42,22 +47,23 @@ endfunction function matchit#Match_wrapper(word, forward, mode) range let restore_options = s:RestoreOptions() - " If this function was called from Visual mode, make sure that the cursor - " is at the correct end of the Visual range: - if a:mode == "v" - execute "normal! gv\<Esc>" - elseif a:mode == "o" && mode(1) !~# '[vV]' - exe "norm! v" - elseif a:mode == "n" && mode(1) =~# 'ni' - exe "norm! v" - endif " In s:CleanUp(), we may need to check whether the cursor moved forward. let startpos = [line("."), col(".")] - " Use default behavior if called with a count. + " if a count has been applied, use the default [count]% mode (see :h N%) if v:count - exe "normal! " . v:count . "%" + exe "normal! " .. v:count .. "%" return s:CleanUp(restore_options, a:mode, startpos) end + if a:mode =~# "v" && mode(1) =~# 'ni' + exe "norm! gv" + elseif a:mode == "o" && mode(1) !~# '[vV]' + exe "norm! v" + " If this function was called from Visual mode, make sure that the cursor + " is at the correct end of the Visual range: + elseif a:mode == "v" + execute "normal! gv\<Esc>" + let startpos = [line("."), col(".")] + endif " First step: if not already done, set the script variables " s:do_BR flag for whether there are backrefs @@ -78,30 +84,30 @@ function matchit#Match_wrapper(word, forward, mode) range " quote the special chars in 'matchpairs', replace [,:] with \| and then " append the builtin pairs (/*, */, #if, #ifdef, #ifndef, #else, #elif, " #endif) - let default = escape(&mps, '[$^.*~\\/?]') . (strlen(&mps) ? "," : "") . + let default = escape(&mps, '[$^.*~\\/?]') .. (strlen(&mps) ? "," : "") .. \ '\/\*:\*\/,#\s*if\%(n\=def\)\=:#\s*else\>:#\s*elif\>:#\s*endif\>' " s:all = pattern with all the keywords - let match_words = match_words . (strlen(match_words) ? "," : "") . default + let match_words = match_words .. (strlen(match_words) ? "," : "") .. default let s:last_words = match_words - if match_words !~ s:notslash . '\\\d' + if match_words !~ s:notslash .. '\\\d' let s:do_BR = 0 let s:pat = match_words else let s:do_BR = 1 let s:pat = s:ParseWords(match_words) endif - let s:all = substitute(s:pat, s:notslash . '\zs[,:]\+', '\\|', 'g') + let s:all = substitute(s:pat, s:notslash .. '\zs[,:]\+', '\\|', 'g') " Just in case there are too many '\(...)' groups inside the pattern, make " sure to use \%(...) groups, so that error E872 can be avoided let s:all = substitute(s:all, '\\(', '\\%(', 'g') - let s:all = '\%(' . s:all . '\)' + let s:all = '\%(' .. s:all .. '\)' if exists("b:match_debug") let b:match_pat = s:pat endif " Reconstruct the version with unresolved backrefs. - let s:patBR = substitute(match_words.',', - \ s:notslash.'\zs[,:]*,[,:]*', ',', 'g') - let s:patBR = substitute(s:patBR, s:notslash.'\zs:\{2,}', ':', 'g') + let s:patBR = substitute(match_words .. ',', + \ s:notslash .. '\zs[,:]*,[,:]*', ',', 'g') + let s:patBR = substitute(s:patBR, s:notslash .. '\zs:\{2,}', ':', 'g') endif " Second step: set the following local variables: @@ -128,12 +134,15 @@ function matchit#Match_wrapper(word, forward, mode) range let curcol = match(matchline, regexp) " If there is no match, give up. if curcol == -1 + " Make sure macros abort properly + "exe "norm! \<esc>" + call feedkeys("\e", 'tni') return s:CleanUp(restore_options, a:mode, startpos) endif let endcol = matchend(matchline, regexp) let suf = strlen(matchline) - endcol - let prefix = (curcol ? '^.*\%' . (curcol + 1) . 'c\%(' : '^\%(') - let suffix = (suf ? '\)\%' . (endcol + 1) . 'c.*$' : '\)$') + let prefix = (curcol ? '^.*\%' .. (curcol + 1) .. 'c\%(' : '^\%(') + let suffix = (suf ? '\)\%' .. (endcol + 1) .. 'c.*$' : '\)$') endif if exists("b:match_debug") let b:match_match = matchstr(matchline, regexp) @@ -150,7 +159,7 @@ function matchit#Match_wrapper(word, forward, mode) range " 'while:endwhile' or whatever. A bit of a kluge: s:Choose() returns " group . "," . groupBR, and we pick it apart. let group = s:Choose(s:pat, matchline, ",", ":", prefix, suffix, s:patBR) - let i = matchend(group, s:notslash . ",") + let i = matchend(group, s:notslash .. ",") let groupBR = strpart(group, i) let group = strpart(group, 0, i-1) " Now, matchline =~ prefix . substitute(group,':','\|','g') . suffix @@ -159,32 +168,32 @@ function matchit#Match_wrapper(word, forward, mode) range endif if exists("b:match_debug") let b:match_wholeBR = groupBR - let i = matchend(groupBR, s:notslash . ":") + let i = matchend(groupBR, s:notslash .. ":") let b:match_iniBR = strpart(groupBR, 0, i-1) endif " Fourth step: Set the arguments for searchpair(). - let i = matchend(group, s:notslash . ":") - let j = matchend(group, '.*' . s:notslash . ":") + let i = matchend(group, s:notslash .. ":") + let j = matchend(group, '.*' .. s:notslash .. ":") let ini = strpart(group, 0, i-1) - let mid = substitute(strpart(group, i,j-i-1), s:notslash.'\zs:', '\\|', 'g') + let mid = substitute(strpart(group, i,j-i-1), s:notslash .. '\zs:', '\\|', 'g') let fin = strpart(group, j) "Un-escape the remaining , and : characters. - let ini = substitute(ini, s:notslash . '\zs\\\(:\|,\)', '\1', 'g') - let mid = substitute(mid, s:notslash . '\zs\\\(:\|,\)', '\1', 'g') - let fin = substitute(fin, s:notslash . '\zs\\\(:\|,\)', '\1', 'g') + let ini = substitute(ini, s:notslash .. '\zs\\\(:\|,\)', '\1', 'g') + let mid = substitute(mid, s:notslash .. '\zs\\\(:\|,\)', '\1', 'g') + let fin = substitute(fin, s:notslash .. '\zs\\\(:\|,\)', '\1', 'g') " searchpair() requires that these patterns avoid \(\) groups. - let ini = substitute(ini, s:notslash . '\zs\\(', '\\%(', 'g') - let mid = substitute(mid, s:notslash . '\zs\\(', '\\%(', 'g') - let fin = substitute(fin, s:notslash . '\zs\\(', '\\%(', 'g') + let ini = substitute(ini, s:notslash .. '\zs\\(', '\\%(', 'g') + let mid = substitute(mid, s:notslash .. '\zs\\(', '\\%(', 'g') + let fin = substitute(fin, s:notslash .. '\zs\\(', '\\%(', 'g') " Set mid. This is optimized for readability, not micro-efficiency! - if a:forward && matchline =~ prefix . fin . suffix - \ || !a:forward && matchline =~ prefix . ini . suffix + if a:forward && matchline =~ prefix .. fin .. suffix + \ || !a:forward && matchline =~ prefix .. ini .. suffix let mid = "" endif " Set flag. This is optimized for readability, not micro-efficiency! - if a:forward && matchline =~ prefix . fin . suffix - \ || !a:forward && matchline !~ prefix . ini . suffix + if a:forward && matchline =~ prefix .. fin .. suffix + \ || !a:forward && matchline !~ prefix .. ini .. suffix |