comparison runtime/plugin/matchparen.vim @ 20965:59f93c2d2551

Update runtime files Commit: https://github.com/vim/vim/commit/73fef33014dbf21fc59e7e47fb091117868d82fb Author: Bram Moolenaar <Bram@vim.org> Date: Sun Jun 21 22:12:03 2020 +0200 Update runtime files
author Bram Moolenaar <Bram@vim.org>
date Sun, 21 Jun 2020 22:15:04 +0200
parents 1cd44535be32
children 5c98ea5f5d6e
comparison
equal deleted inserted replaced
20964:be672fa6d129 20965:59f93c2d2551
1 " Vim plugin for showing matching parens 1 " Vim plugin for showing matching parens
2 " Maintainer: Bram Moolenaar <Bram@vim.org> 2 " Maintainer: Bram Moolenaar <Bram@vim.org>
3 " Last Change: 2019 Oct 28 3 " Last Change: 2020 Jun 18
4 4
5 " Exit quickly when: 5 " Exit quickly when:
6 " - this plugin was already loaded (or disabled) 6 " - this plugin was already loaded (or disabled)
7 " - when 'compatible' is set 7 " - when 'compatible' is set
8 " - the "CursorMoved" autocmd event is not available. 8 " - the "CursorMoved" autocmd event is not available.
19 endif 19 endif
20 20
21 augroup matchparen 21 augroup matchparen
22 " Replace all matchparen autocommands 22 " Replace all matchparen autocommands
23 autocmd! CursorMoved,CursorMovedI,WinEnter * call s:Highlight_Matching_Pair() 23 autocmd! CursorMoved,CursorMovedI,WinEnter * call s:Highlight_Matching_Pair()
24 autocmd! WinLeave * call s:Remove_Matches()
24 if exists('##TextChanged') 25 if exists('##TextChanged')
25 autocmd! TextChanged,TextChangedI * call s:Highlight_Matching_Pair() 26 autocmd! TextChanged,TextChangedI * call s:Highlight_Matching_Pair()
26 endif 27 endif
27 augroup END 28 augroup END
28 29
36 37
37 " The function that is invoked (very often) to define a ":match" highlighting 38 " The function that is invoked (very often) to define a ":match" highlighting
38 " for any matching paren. 39 " for any matching paren.
39 func s:Highlight_Matching_Pair() 40 func s:Highlight_Matching_Pair()
40 " Remove any previous match. 41 " Remove any previous match.
41 if exists('w:paren_hl_on') && w:paren_hl_on 42 call s:Remove_Matches()
42 silent! call matchdelete(3)
43 let w:paren_hl_on = 0
44 endif
45 43
46 " Avoid that we remove the popup menu. 44 " Avoid that we remove the popup menu.
47 " Return when there are no colors (looks like the cursor jumps). 45 " Return when there are no colors (looks like the cursor jumps).
48 if pumvisible() || (&t_Co < 8 && !has("gui_running")) 46 if pumvisible() || (&t_Co < 8 && !has("gui_running"))
49 return 47 return
193 endif 191 endif
194 let w:paren_hl_on = 1 192 let w:paren_hl_on = 1
195 endif 193 endif
196 endfunction 194 endfunction
197 195
196 func s:Remove_Matches()
197 if exists('w:paren_hl_on') && w:paren_hl_on
198 silent! call matchdelete(3)
199 let w:paren_hl_on = 0
200 endif
201 endfunc
202
203
198 " Define commands that will disable and enable the plugin. 204 " Define commands that will disable and enable the plugin.
199 command DoMatchParen call s:DoMatchParen() 205 command DoMatchParen call s:DoMatchParen()
200 command NoMatchParen call s:NoMatchParen() 206 command NoMatchParen call s:NoMatchParen()
201 207
202 func s:NoMatchParen() 208 func s:NoMatchParen()