Not sure how easy this will be to fix; I just noticed it. Also not sure of whether the problem is in matchit.vim, in $VIMRUNTIME/ftplugin/vim.vim, or in both.
Software in use: Vim or gvim, Big version, 8.2.1296 $VIMRUNTIME/pack/dist/opt/matchit/plugin/matchit.vim version 1.17 dated 2019 Oct 24 $VIMRUNTIME/pack/dist/opt/matchit/autoload/matchit.vim (Last change Mar 01, 2020) $VIMRUNTIME/ftplugin/vim.vim (Last change 2020 Jul 06) The bug is exhibited, for example, when viewing the CSApprox.vim plugin version 4.00 dated 14 Sep 2012; this is the latest version at vim.org: https://www.vim.org/scripts/script.php?script_id=2390 On my installation: ~/.vim/plugin/CSApprox.vim line 437 With matchit enabled, when viewing a Vim script where the function() function is used within the range of a function definition (between :function and :endfunction), hiting % on that :endfunction statement goes to the function() invocation and vice-versa; hitting % on that :function command does nothing. The problem is of course due to the fact that b:match_words (for the "vim" filetype) recognises "function" but does not skip "function(". I'm attaching a proposed patch. Please check it, I haven't written complex regular expressions in a long time. Best regards, Tony. -- -- You received this message from the "vim_dev" maillist. Do not top-post! Type your reply below the text you are replying to. For more information, visit http://www.vim.org/maillist.php --- You received this message because you are subscribed to the Google Groups "vim_dev" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/vim_dev/CAJkCKXvpJJmWDWfhaQ7cTVHO8v642Z5YLpLLruxoJws004UToQ%40mail.gmail.com.
# HG changeset patch # User Tony Mechelynck <[email protected]> # Parent 5d927b1aca7c85b6fe30a9077046e681445e4025 Avoid confusing function( with the start of a function definition when using matchit on Vim script diff --git a/runtime/ftplugin/vim.vim b/runtime/ftplugin/vim.vim --- a/runtime/ftplugin/vim.vim +++ b/runtime/ftplugin/vim.vim @@ -78,18 +78,18 @@ if !exists("no_plugin_maps") && !exists( nnoremap <silent><buffer> [" :call search('\%(^\s*".*\n\)\%(^\s*"\)\@!', "bW")<CR> vnoremap <silent><buffer> [" :<C-U>exe "normal! gv"<Bar>call search('\%(^\s*".*\n\)\%(^\s*"\)\@!', "bW")<CR> endif " Let the matchit plugin know what items can be matched. if exists("loaded_matchit") let b:match_ignorecase = 0 let b:match_words = - \ '\<\%(fu\%[nction]\|def\)\>:\<retu\%[rn]\>:\<\%(endf\%[unction]\|enddef\)\>,' . - \ '\<\(wh\%[ile]\|for\)\>:\<brea\%[k]\>:\<con\%[tinue]\>:\<end\(w\%[hile]\|fo\%[r]\)\>,' . + \ '\<\%(fu\%[nction](\@!\|def\)\>:\<retu\%[rn]\>:\<\%(endf\%[unction]\|enddef\)\>,' . + \ '\<\(wh\%[ile]\|for\)\>:\<brea\%[k]\>:\<con\%[tinue]\>:\<end\(w\%[hile]\|fo\%[r]\)\>,' . \ '\<if\>:\<el\%[seif]\>:\<en\%[dif]\>,' . \ '{:},' . \ '\<try\>:\<cat\%[ch]\>:\<fina\%[lly]\>:\<endt\%[ry]\>,' . \ '\<aug\%[roup]\s\+\%(END\>\)\@!\S:\<aug\%[roup]\s\+END\>,' " Ignore syntax region commands and settings, any 'en*' would clobber " if-endif. " - set spl=de,en " - au! FileType javascript syntax region foldBraces start=/{/ end=/}/ …
