diff options
author | Jan Edmund Lazo <jan.lazo@mail.utoronto.ca> | 2021-05-04 19:18:16 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-05-04 19:18:16 -0400 |
commit | 4ad30f775e5564c539324b4818886f067d2ecd99 (patch) | |
tree | 97a554379bda7e5fc77e58c690db3f5a72db8c74 /runtime/plugin/matchparen.vim | |
parent | 63d8a8f4e8b02e524d85aed08aa16c5d9815598c (diff) | |
parent | d5b063aec1db95704b37a77fdbd968cb6b48cc3b (diff) | |
download | rneovim-4ad30f775e5564c539324b4818886f067d2ecd99.tar.gz rneovim-4ad30f775e5564c539324b4818886f067d2ecd99.tar.bz2 rneovim-4ad30f775e5564c539324b4818886f067d2ecd99.zip |
Merge pull request #14424 from janlazo/vim-8.1.1726
vim-patch:8.1.1726,8.2.{296,860,1827,2388,2788,2790,2801}
Diffstat (limited to 'runtime/plugin/matchparen.vim')
-rw-r--r-- | runtime/plugin/matchparen.vim | 31 |
1 files changed, 19 insertions, 12 deletions
diff --git a/runtime/plugin/matchparen.vim b/runtime/plugin/matchparen.vim index 65b9fe57bf..cc4f38f669 100644 --- a/runtime/plugin/matchparen.vim +++ b/runtime/plugin/matchparen.vim @@ -1,6 +1,6 @@ " Vim plugin for showing matching parens " Maintainer: Bram Moolenaar <Bram@vim.org> -" Last Change: 2018 Jul 3 +" Last Change: 2021 Apr 08 " Exit quickly when: " - this plugin was already loaded (or disabled) @@ -21,6 +21,7 @@ endif augroup matchparen " Replace all matchparen autocommands autocmd! CursorMoved,CursorMovedI,WinEnter * call s:Highlight_Matching_Pair() + autocmd! WinLeave * call s:Remove_Matches() if exists('##TextChanged') autocmd! TextChanged,TextChangedI * call s:Highlight_Matching_Pair() endif @@ -36,12 +37,9 @@ set cpo-=C " The function that is invoked (very often) to define a ":match" highlighting " for any matching paren. -function! s:Highlight_Matching_Pair() +func s:Highlight_Matching_Pair() " Remove any previous match. - if exists('w:paren_hl_on') && w:paren_hl_on - silent! call matchdelete(3) - let w:paren_hl_on = 0 - endif + call s:Remove_Matches() " Avoid that we remove the popup menu. " Return when there are no colors (looks like the cursor jumps). @@ -109,9 +107,10 @@ function! s:Highlight_Matching_Pair() " Build an expression that detects whether the current cursor position is " in certain syntax types (string, comment, etc.), for use as " searchpairpos()'s skip argument. - " We match "escape" for special items, such as lispEscapeSpecial. + " We match "escape" for special items, such as lispEscapeSpecial, and + " match "symbol" for lispBarSymbol. let s_skip = '!empty(filter(map(synstack(line("."), col(".")), ''synIDattr(v:val, "name")''), ' . - \ '''v:val =~? "string\\|character\\|singlequote\\|escape\\|comment"''))' + \ '''v:val =~? "string\\|character\\|singlequote\\|escape\\|symbol\\|comment"''))' " If executing the expression determines that the cursor is currently in " one of the syntax types, then we want searchpairpos() to find the pair " within those syntax types (i.e., not skip). Otherwise, the cursor is @@ -195,11 +194,19 @@ function! s:Highlight_Matching_Pair() endif endfunction +func s:Remove_Matches() + if exists('w:paren_hl_on') && w:paren_hl_on + silent! call matchdelete(3) + let w:paren_hl_on = 0 + endif +endfunc + + " Define commands that will disable and enable the plugin. -command! DoMatchParen call s:DoMatchParen() -command! NoMatchParen call s:NoMatchParen() +command DoMatchParen call s:DoMatchParen() +command NoMatchParen call s:NoMatchParen() -func! s:NoMatchParen() +func s:NoMatchParen() let w = winnr() noau windo silent! call matchdelete(3) unlet! g:loaded_matchparen @@ -207,7 +214,7 @@ func! s:NoMatchParen() au! matchparen endfunc -func! s:DoMatchParen() +func s:DoMatchParen() runtime plugin/matchparen.vim let w = winnr() silent windo doau CursorMoved |