Vim 9 implementation of matchparen.vim

55 views
Skip to first unread message

Christian J. Robinson

unread,
Aug 22, 2022, 1:58:56 AM8/22/22
to vim_dev
I've attached a Vim 9 implementation of the matchparen.vim plugin.

There was a fair amount of logic to determine whether features existed, but since this is a Vim 9 implementation it is safe to assume those features will exist so that logic was removed.

If there's interest I am willing to do similar work on other distribution scripts.

--
Christian J. Robinson <hep...@gmail.com>
matchparen.vim

Christian J. Robinson

unread,
Aug 22, 2022, 2:07:09 AM8/22/22
to vim_dev
Somehow I missed a couple of bugs, so I've attached a fixed version.
matchparen.vim

Bram Moolenaar

unread,
Aug 22, 2022, 8:01:06 AM8/22/22
to vim...@googlegroups.com, Christian J. Robinson

Christian J. Robinson wrote:

> I've attached a Vim 9 implementation of the matchparen.vim plugin.
>
> There was a fair amount of logic to determine whether features existed, but
> since this is a Vim 9 implementation it is safe to assume those features
> will exist so that logic was removed.

Thank you for doing this. I hope several people try it out and let us
know how well it works. If everybody is happy I can include it in the
distribution.


--
If "R" is Reverse, how come "D" is FORWARD?

/// Bram Moolenaar -- Br...@Moolenaar.net -- http://www.Moolenaar.net \\\
/// \\\
\\\ sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ ///
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///

Christian J. Robinson

unread,
Aug 23, 2022, 3:32:36 PM8/23/22
to Bram Moolenaar, vim_dev
I've attached another bugfix version.
matchparen.vim

TJ DeVries

unread,
Aug 29, 2022, 11:07:44 PM8/29/22
to vim_dev
I was wondering if there was any particular reason that in the middle of the matchparen script,
an eval is used as the if condition instead of just running the code directly.

    s_skip = '!empty(filter(map(synstack(line("."), col(".")), ''synIDattr(v:val, "name")''), ' ..
      '''v:val =~? "string\\|character\\|singlequote\\|escape\\|symbol\\|comment"''))'
    # If executing the expression determines that the cursor is currently in...
    try
      if eval(s_skip)
        s_skip = "0"
      endif
    catch /^Vim\%((\a\+)\)\=:E363/
      # We won't find anything, so skip searching, should keep Vim responsive.
      return
    endtry

I was trying to understand why that couldn't just be executed directly in the if condition.

Thanks,

TJ
Reply all
Reply to author
Forward
0 new messages