annotate runtime/plugin/matchparen.vim @ 24924:0d411646a366 v8.2.2999

patch 8.2.2999: balloon sometimes does not hide with GTK 3 Commit: https://github.com/vim/vim/commit/47f6db90895c01259e90108caae9517e894e1f95 Author: Bram Moolenaar <Bram@vim.org> Date: Mon Jun 14 22:08:46 2021 +0200 patch 8.2.2999: balloon sometimes does not hide with GTK 3 Problem: Balloon sometimes does not hide with GTK 3. Solution: Also listen to GDK_LEAVE_NOTIFY. (Johannes Stezenbach)
author Bram Moolenaar <Bram@vim.org>
date Mon, 14 Jun 2021 22:15:02 +0200
parents 9f41bfdbc6fc
children b15334beeaa4
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
694
07d199fe02ed updated for version 7.0209
vimboss
parents:
diff changeset
1 " Vim plugin for showing matching parens
07d199fe02ed updated for version 7.0209
vimboss
parents:
diff changeset
2 " Maintainer: Bram Moolenaar <Bram@vim.org>
24468
9f41bfdbc6fc Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 24387
diff changeset
3 " Last Change: 2021 Apr 08
694
07d199fe02ed updated for version 7.0209
vimboss
parents:
diff changeset
4
07d199fe02ed updated for version 7.0209
vimboss
parents:
diff changeset
5 " Exit quickly when:
07d199fe02ed updated for version 7.0209
vimboss
parents:
diff changeset
6 " - this plugin was already loaded (or disabled)
07d199fe02ed updated for version 7.0209
vimboss
parents:
diff changeset
7 " - when 'compatible' is set
4352
04736b4030ec updated for version 7.3.925
Bram Moolenaar <bram@vim.org>
parents: 4242
diff changeset
8 " - the "CursorMoved" autocmd event is not available.
694
07d199fe02ed updated for version 7.0209
vimboss
parents:
diff changeset
9 if exists("g:loaded_matchparen") || &cp || !exists("##CursorMoved")
07d199fe02ed updated for version 7.0209
vimboss
parents:
diff changeset
10 finish
07d199fe02ed updated for version 7.0209
vimboss
parents:
diff changeset
11 endif
07d199fe02ed updated for version 7.0209
vimboss
parents:
diff changeset
12 let g:loaded_matchparen = 1
07d199fe02ed updated for version 7.0209
vimboss
parents:
diff changeset
13
4437
eb6ab7e78925 Update runtime files.
Bram Moolenaar <bram@vim.org>
parents: 4352
diff changeset
14 if !exists("g:matchparen_timeout")
eb6ab7e78925 Update runtime files.
Bram Moolenaar <bram@vim.org>
parents: 4352
diff changeset
15 let g:matchparen_timeout = 300
eb6ab7e78925 Update runtime files.
Bram Moolenaar <bram@vim.org>
parents: 4352
diff changeset
16 endif
eb6ab7e78925 Update runtime files.
Bram Moolenaar <bram@vim.org>
parents: 4352
diff changeset
17 if !exists("g:matchparen_insert_timeout")
eb6ab7e78925 Update runtime files.
Bram Moolenaar <bram@vim.org>
parents: 4352
diff changeset
18 let g:matchparen_insert_timeout = 60
eb6ab7e78925 Update runtime files.
Bram Moolenaar <bram@vim.org>
parents: 4352
diff changeset
19 endif
eb6ab7e78925 Update runtime files.
Bram Moolenaar <bram@vim.org>
parents: 4352
diff changeset
20
694
07d199fe02ed updated for version 7.0209
vimboss
parents:
diff changeset
21 augroup matchparen
07d199fe02ed updated for version 7.0209
vimboss
parents:
diff changeset
22 " Replace all matchparen autocommands
1368
048f26eb43a3 updated for version 7.1-082
vimboss
parents: 1334
diff changeset
23 autocmd! CursorMoved,CursorMovedI,WinEnter * call s:Highlight_Matching_Pair()
20965
59f93c2d2551 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 18489
diff changeset
24 autocmd! WinLeave * call s:Remove_Matches()
4232
0fcb050fd79d updated for version 7.3.867
Bram Moolenaar <bram@vim.org>
parents: 3082
diff changeset
25 if exists('##TextChanged')
0fcb050fd79d updated for version 7.3.867
Bram Moolenaar <bram@vim.org>
parents: 3082
diff changeset
26 autocmd! TextChanged,TextChangedI * call s:Highlight_Matching_Pair()
0fcb050fd79d updated for version 7.3.867
Bram Moolenaar <bram@vim.org>
parents: 3082
diff changeset
27 endif
694
07d199fe02ed updated for version 7.0209
vimboss
parents:
diff changeset
28 augroup END
07d199fe02ed updated for version 7.0209
vimboss
parents:
diff changeset
29
07d199fe02ed updated for version 7.0209
vimboss
parents:
diff changeset
30 " Skip the rest if it was already done.
07d199fe02ed updated for version 7.0209
vimboss
parents:
diff changeset
31 if exists("*s:Highlight_Matching_Pair")
07d199fe02ed updated for version 7.0209
vimboss
parents:
diff changeset
32 finish
07d199fe02ed updated for version 7.0209
vimboss
parents:
diff changeset
33 endif
07d199fe02ed updated for version 7.0209
vimboss
parents:
diff changeset
34
2034
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1556
diff changeset
35 let s:cpo_save = &cpo
757
8b0484fd9119 updated for version 7.0224
vimboss
parents: 711
diff changeset
36 set cpo-=C
8b0484fd9119 updated for version 7.0224
vimboss
parents: 711
diff changeset
37
694
07d199fe02ed updated for version 7.0209
vimboss
parents:
diff changeset
38 " The function that is invoked (very often) to define a ":match" highlighting
07d199fe02ed updated for version 7.0209
vimboss
parents:
diff changeset
39 " for any matching paren.
18489
1cd44535be32 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14254
diff changeset
40 func s:Highlight_Matching_Pair()
694
07d199fe02ed updated for version 7.0209
vimboss
parents:
diff changeset
41 " Remove any previous match.
20965
59f93c2d2551 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 18489
diff changeset
42 call s:Remove_Matches()
694
07d199fe02ed updated for version 7.0209
vimboss
parents:
diff changeset
43
711
1babf94e0b24 updated for version 7.0214
vimboss
parents: 706
diff changeset
44 " Avoid that we remove the popup menu.
1556
1c597397f006 updated for version 7.1-269
vimboss
parents: 1496
diff changeset
45 " Return when there are no colors (looks like the cursor jumps).
1c597397f006 updated for version 7.1-269
vimboss
parents: 1496
diff changeset
46 if pumvisible() || (&t_Co < 8 && !has("gui_running"))
711
1babf94e0b24 updated for version 7.0214
vimboss
parents: 706
diff changeset
47 return
1babf94e0b24 updated for version 7.0214
vimboss
parents: 706
diff changeset
48 endif
1babf94e0b24 updated for version 7.0214
vimboss
parents: 706
diff changeset
49
694
07d199fe02ed updated for version 7.0209
vimboss
parents:
diff changeset
50 " Get the character under the cursor and check if it's in 'matchpairs'.
07d199fe02ed updated for version 7.0209
vimboss
parents:
diff changeset
51 let c_lnum = line('.')
07d199fe02ed updated for version 7.0209
vimboss
parents:
diff changeset
52 let c_col = col('.')
07d199fe02ed updated for version 7.0209
vimboss
parents:
diff changeset
53 let before = 0
07d199fe02ed updated for version 7.0209
vimboss
parents:
diff changeset
54
6051
0efec12f52ac Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 5979
diff changeset
55 let text = getline(c_lnum)
7422
35af1e06696b commit https://github.com/vim/vim/commit/c21d67e33c1b42a492e04788cbb14a23a6724e39
Christian Brabandt <cb@256bit.org>
parents: 7384
diff changeset
56 let matches = matchlist(text, '\(.\)\=\%'.c_col.'c\(.\=\)')
7384
aea5ebf352c4 commit https://github.com/vim/vim/commit/256972a9849b5d575b62a6a71be5b6934b5b0e8b
Christian Brabandt <cb@256bit.org>
parents: 6118
diff changeset
57 if empty(matches)
aea5ebf352c4 commit https://github.com/vim/vim/commit/256972a9849b5d575b62a6a71be5b6934b5b0e8b
Christian Brabandt <cb@256bit.org>
parents: 6118
diff changeset
58 let [c_before, c] = ['', '']
aea5ebf352c4 commit https://github.com/vim/vim/commit/256972a9849b5d575b62a6a71be5b6934b5b0e8b
Christian Brabandt <cb@256bit.org>
parents: 6118
diff changeset
59 else
aea5ebf352c4 commit https://github.com/vim/vim/commit/256972a9849b5d575b62a6a71be5b6934b5b0e8b
Christian Brabandt <cb@256bit.org>
parents: 6118
diff changeset
60 let [c_before, c] = matches[1:2]
aea5ebf352c4 commit https://github.com/vim/vim/commit/256972a9849b5d575b62a6a71be5b6934b5b0e8b
Christian Brabandt <cb@256bit.org>
parents: 6118
diff changeset
61 endif
967
daa1e34570ff updated for version 7.0-093
vimboss
parents: 920
diff changeset
62 let plist = split(&matchpairs, '.\zs[:,]')
694
07d199fe02ed updated for version 7.0209
vimboss
parents:
diff changeset
63 let i = index(plist, c)
07d199fe02ed updated for version 7.0209
vimboss
parents:
diff changeset
64 if i < 0
07d199fe02ed updated for version 7.0209
vimboss
parents:
diff changeset
65 " not found, in Insert mode try character before the cursor
07d199fe02ed updated for version 7.0209
vimboss
parents:
diff changeset
66 if c_col > 1 && (mode() == 'i' || mode() == 'R')
7384
aea5ebf352c4 commit https://github.com/vim/vim/commit/256972a9849b5d575b62a6a71be5b6934b5b0e8b
Christian Brabandt <cb@256bit.org>
parents: 6118
diff changeset
67 let before = strlen(c_before)
aea5ebf352c4 commit https://github.com/vim/vim/commit/256972a9849b5d575b62a6a71be5b6934b5b0e8b
Christian Brabandt <cb@256bit.org>
parents: 6118
diff changeset
68 let c = c_before
694
07d199fe02ed updated for version 7.0209
vimboss
parents:
diff changeset
69 let i = index(plist, c)
07d199fe02ed updated for version 7.0209
vimboss
parents:
diff changeset
70 endif
07d199fe02ed updated for version 7.0209
vimboss
parents:
diff changeset
71 if i < 0
07d199fe02ed updated for version 7.0209
vimboss
parents:
diff changeset
72 " not found, nothing to do
07d199fe02ed updated for version 7.0209
vimboss
parents:
diff changeset
73 return
07d199fe02ed updated for version 7.0209
vimboss
parents:
diff changeset
74 endif
07d199fe02ed updated for version 7.0209
vimboss
parents:
diff changeset
75 endif
07d199fe02ed updated for version 7.0209
vimboss
parents:
diff changeset
76
07d199fe02ed updated for version 7.0209
vimboss
parents:
diff changeset
77 " Figure out the arguments for searchpairpos().
07d199fe02ed updated for version 7.0209
vimboss
parents:
diff changeset
78 if i % 2 == 0
07d199fe02ed updated for version 7.0209
vimboss
parents:
diff changeset
79 let s_flags = 'nW'
07d199fe02ed updated for version 7.0209
vimboss
parents:
diff changeset
80 let c2 = plist[i + 1]
07d199fe02ed updated for version 7.0209
vimboss
parents:
diff changeset
81 else
07d199fe02ed updated for version 7.0209
vimboss
parents:
diff changeset
82 let s_flags = 'nbW'
07d199fe02ed updated for version 7.0209
vimboss
parents:
diff changeset
83 let c2 = c
07d199fe02ed updated for version 7.0209
vimboss
parents:
diff changeset
84 let c = plist[i - 1]
07d199fe02ed updated for version 7.0209
vimboss
parents:
diff changeset
85 endif
07d199fe02ed updated for version 7.0209
vimboss
parents:
diff changeset
86 if c == '['
07d199fe02ed updated for version 7.0209
vimboss
parents:
diff changeset
87 let c = '\['
07d199fe02ed updated for version 7.0209
vimboss
parents:
diff changeset
88 let c2 = '\]'
07d199fe02ed updated for version 7.0209
vimboss
parents:
diff changeset
89 endif
07d199fe02ed updated for version 7.0209
vimboss
parents:
diff changeset
90
07d199fe02ed updated for version 7.0209
vimboss
parents:
diff changeset
91 " Find the match. When it was just before the cursor move it there for a
702
8a99b25de218 updated for version 7.0212
vimboss
parents: 698
diff changeset
92 " moment.
694
07d199fe02ed updated for version 7.0209
vimboss
parents:
diff changeset
93 if before > 0
6070
32a77cc160d9 Update runtime files. Make matchparen plugin backwards compatible.
Bram Moolenaar <bram@vim.org>
parents: 6051
diff changeset
94 let has_getcurpos = exists("*getcurpos")
32a77cc160d9 Update runtime files. Make matchparen plugin backwards compatible.
Bram Moolenaar <bram@vim.org>
parents: 6051
diff changeset
95 if has_getcurpos
32a77cc160d9 Update runtime files. Make matchparen plugin backwards compatible.
Bram Moolenaar <bram@vim.org>
parents: 6051
diff changeset
96 " getcurpos() is more efficient but doesn't exist before 7.4.313.
32a77cc160d9 Update runtime files. Make matchparen plugin backwards compatible.
Bram Moolenaar <bram@vim.org>
parents: 6051
diff changeset
97 let save_cursor = getcurpos()
32a77cc160d9 Update runtime files. Make matchparen plugin backwards compatible.
Bram Moolenaar <bram@vim.org>
parents: 6051
diff changeset
98 else
32a77cc160d9 Update runtime files. Make matchparen plugin backwards compatible.
Bram Moolenaar <bram@vim.org>
parents: 6051
diff changeset
99 let save_cursor = winsaveview()
32a77cc160d9 Update runtime files. Make matchparen plugin backwards compatible.
Bram Moolenaar <bram@vim.org>
parents: 6051
diff changeset
100 endif
694
07d199fe02ed updated for version 7.0209
vimboss
parents:
diff changeset
101 call cursor(c_lnum, c_col - before)
07d199fe02ed updated for version 7.0209
vimboss
parents:
diff changeset
102 endif
845
0fe7765dcb8e updated for version 7.0f03
vimboss
parents: 819
diff changeset
103
14254
1cfeee3ba4cd patch 8.1.0143: matchit and matchparen don't handle E363
Christian Brabandt <cb@256bit.org>
parents: 14249
diff changeset
104 if !has("syntax") || !exists("g:syntax_on")
1cfeee3ba4cd patch 8.1.0143: matchit and matchparen don't handle E363
Christian Brabandt <cb@256bit.org>
parents: 14249
diff changeset
105 let s_skip = "0"
1cfeee3ba4cd patch 8.1.0143: matchit and matchparen don't handle E363
Christian Brabandt <cb@256bit.org>
parents: 14249
diff changeset
106 else
1cfeee3ba4cd patch 8.1.0143: matchit and matchparen don't handle E363
Christian Brabandt <cb@256bit.org>
parents: 14249
diff changeset
107 " Build an expression that detects whether the current cursor position is
1cfeee3ba4cd patch 8.1.0143: matchit and matchparen don't handle E363
Christian Brabandt <cb@256bit.org>
parents: 14249
diff changeset
108 " in certain syntax types (string, comment, etc.), for use as
1cfeee3ba4cd patch 8.1.0143: matchit and matchparen don't handle E363
Christian Brabandt <cb@256bit.org>
parents: 14249
diff changeset
109 " searchpairpos()'s skip argument.
24387
5c98ea5f5d6e Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 20965
diff changeset
110 " We match "escape" for special items, such as lispEscapeSpecial, and
5c98ea5f5d6e Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 20965
diff changeset
111 " match "symbol" for lispBarSymbol.
14254
1cfeee3ba4cd patch 8.1.0143: matchit and matchparen don't handle E363
Christian Brabandt <cb@256bit.org>
parents: 14249
diff changeset
112 let s_skip = '!empty(filter(map(synstack(line("."), col(".")), ''synIDattr(v:val, "name")''), ' .
24468
9f41bfdbc6fc Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 24387
diff changeset
113 \ '''v:val =~? "string\\|character\\|singlequote\\|escape\\|symbol\\|comment"''))'
14254
1cfeee3ba4cd patch 8.1.0143: matchit and matchparen don't handle E363
Christian Brabandt <cb@256bit.org>
parents: 14249
diff changeset
114 " If executing the expression determines that the cursor is currently in
1cfeee3ba4cd patch 8.1.0143: matchit and matchparen don't handle E363
Christian Brabandt <cb@256bit.org>
parents: 14249
diff changeset
115 " one of the syntax types, then we want searchpairpos() to find the pair
1cfeee3ba4cd patch 8.1.0143: matchit and matchparen don't handle E363
Christian Brabandt <cb@256bit.org>
parents: 14249
diff changeset
116 " within those syntax types (i.e., not skip). Otherwise, the cursor is
1cfeee3ba4cd patch 8.1.0143: matchit and matchparen don't handle E363
Christian Brabandt <cb@256bit.org>
parents: 14249
diff changeset
117 " outside of the syntax types and s_skip should keep its value so we skip
1cfeee3ba4cd patch 8.1.0143: matchit and matchparen don't handle E363
Christian Brabandt <cb@256bit.org>
parents: 14249
diff changeset
118 " any matching pair inside the syntax types.
1cfeee3ba4cd patch 8.1.0143: matchit and matchparen don't handle E363
Christian Brabandt <cb@256bit.org>
parents: 14249
diff changeset
119 " Catch if this throws E363: pattern uses more memory than 'maxmempattern'.
1cfeee3ba4cd patch 8.1.0143: matchit and matchparen don't handle E363
Christian Brabandt <cb@256bit.org>
parents: 14249
diff changeset
120 try
1cfeee3ba4cd patch 8.1.0143: matchit and matchparen don't handle E363
Christian Brabandt <cb@256bit.org>
parents: 14249
diff changeset
121 execute 'if ' . s_skip . ' | let s_skip = "0" | endif'
1cfeee3ba4cd patch 8.1.0143: matchit and matchparen don't handle E363
Christian Brabandt <cb@256bit.org>
parents: 14249
diff changeset
122 catch /^Vim\%((\a\+)\)\=:E363/
1cfeee3ba4cd patch 8.1.0143: matchit and matchparen don't handle E363
Christian Brabandt <cb@256bit.org>
parents: 14249
diff changeset
123 " We won't find anything, so skip searching, should keep Vim responsive.
1cfeee3ba4cd patch 8.1.0143: matchit and matchparen don't handle E363
Christian Brabandt <cb@256bit.org>
parents: 14249
diff changeset
124 return
1cfeee3ba4cd patch 8.1.0143: matchit and matchparen don't handle E363
Christian Brabandt <cb@256bit.org>
parents: 14249
diff changeset
125 endtry
1cfeee3ba4cd patch 8.1.0143: matchit and matchparen don't handle E363
Christian Brabandt <cb@256bit.org>
parents: 14249
diff changeset
126 endif
845
0fe7765dcb8e updated for version 7.0f03
vimboss
parents: 819
diff changeset
127
1556
1c597397f006 updated for version 7.1-269
vimboss
parents: 1496
diff changeset
128 " Limit the search to lines visible in the window.
1c597397f006 updated for version 7.1-269
vimboss
parents: 1496
diff changeset
129 let stoplinebottom = line('w$')
1c597397f006 updated for version 7.1-269
vimboss
parents: 1496
diff changeset
130 let stoplinetop = line('w0')
1c597397f006 updated for version 7.1-269
vimboss
parents: 1496
diff changeset
131 if i % 2 == 0
1c597397f006 updated for version 7.1-269
vimboss
parents: 1496
diff changeset
132 let stopline = stoplinebottom
1c597397f006 updated for version 7.1-269
vimboss
parents: 1496
diff changeset
133 else
1c597397f006 updated for version 7.1-269
vimboss
parents: 1496
diff changeset
134 let stopline = stoplinetop
1c597397f006 updated for version 7.1-269
vimboss
parents: 1496
diff changeset
135 endif
1c597397f006 updated for version 7.1-269
vimboss
parents: 1496
diff changeset
136
4437
eb6ab7e78925 Update runtime files.
Bram Moolenaar <bram@vim.org>
parents: 4352
diff changeset
137 " Limit the search time to 300 msec to avoid a hang on very long lines.
eb6ab7e78925 Update runtime files.
Bram Moolenaar <bram@vim.org>
parents: 4352
diff changeset
138 " This fails when a timeout is not supported.
eb6ab7e78925 Update runtime files.
Bram Moolenaar <bram@vim.org>
parents: 4352
diff changeset
139 if mode() == 'i' || mode() == 'R'
eb6ab7e78925 Update runtime files.
Bram Moolenaar <bram@vim.org>
parents: 4352
diff changeset
140 let timeout = exists("b:matchparen_insert_timeout") ? b:matchparen_insert_timeout : g:matchparen_insert_timeout
eb6ab7e78925 Update runtime files.
Bram Moolenaar <bram@vim.org>
parents: 4352
diff changeset
141 else
eb6ab7e78925 Update runtime files.
Bram Moolenaar <bram@vim.org>
parents: 4352
diff changeset
142 let timeout = exists("b:matchparen_timeout") ? b:matchparen_timeout : g:matchparen_timeout
eb6ab7e78925 Update runtime files.
Bram Moolenaar <bram@vim.org>
parents: 4352
diff changeset
143 endif
1496
29c09fa57168 updated for version 7.1-211
vimboss
parents: 1368
diff changeset
144 try
4437
eb6ab7e78925 Update runtime files.
Bram Moolenaar <bram@vim.org>
parents: 4352
diff changeset
145 let [m_lnum, m_col] = searchpairpos(c, '', c2, s_flags, s_skip, stopline, timeout)
1496
29c09fa57168 updated for version 7.1-211
vimboss
parents: 1368
diff changeset
146 catch /E118/
1556
1c597397f006 updated for version 7.1-269
vimboss
parents: 1496
diff changeset
147 " Can't use the timeout, restrict the stopline a bit more to avoid taking
1c597397f006 updated for version 7.1-269
vimboss
parents: 1496
diff changeset
148 " a long time on closed folds and long lines.
1c597397f006 updated for version 7.1-269
vimboss
parents: 1496
diff changeset
149 " The "viewable" variables give a range in which we can scroll while
1c597397f006 updated for version 7.1-269
vimboss
parents: 1496
diff changeset
150 " keeping the cursor at the same position.
1c597397f006 updated for version 7.1-269
vimboss
parents: 1496
diff changeset
151 " adjustedScrolloff accounts for very large numbers of scrolloff.
1c597397f006 updated for version 7.1-269
vimboss
parents: 1496
diff changeset
152 let adjustedScrolloff = min([&scrolloff, (line('w$') - line('w0')) / 2])
1c597397f006 updated for version 7.1-269
vimboss
parents: 1496
diff changeset
153 let bottom_viewable = min([line('$'), c_lnum + &lines - adjustedScrolloff - 2])
1c597397f006 updated for version 7.1-269
vimboss
parents: 1496
diff changeset
154 let top_viewable = max([1, c_lnum-&lines+adjustedScrolloff + 2])
1c597397f006 updated for version 7.1-269
vimboss
parents: 1496
diff changeset
155 " one of these stoplines will be adjusted below, but the current values are
1c597397f006 updated for version 7.1-269
vimboss
parents: 1496
diff changeset
156 " minimal boundaries within the current window
1c597397f006 updated for version 7.1-269
vimboss
parents: 1496
diff changeset
157 if i % 2 == 0
1c597397f006 updated for version 7.1-269
vimboss
parents: 1496
diff changeset
158 if has("byte_offset") && has("syntax_items") && &smc > 0
1c597397f006 updated for version 7.1-269
vimboss
parents: 1496
diff changeset
159 let stopbyte = min([line2byte("$"), line2byte(".") + col(".") + &smc * 2])
1c597397f006 updated for version 7.1-269
vimboss
parents: 1496
diff changeset
160 let stopline = min([bottom_viewable, byte2line(stopbyte)])
1c597397f006 updated for version 7.1-269
vimboss
parents: 1496
diff changeset
161 else
1c597397f006 updated for version 7.1-269
vimboss
parents: 1496
diff changeset
162 let stopline = min([bottom_viewable, c_lnum + 100])
1c597397f006 updated for version 7.1-269
vimboss
parents: 1496
diff changeset
163 endif
1c597397f006 updated for version 7.1-269
vimboss
parents: 1496
diff changeset
164 let stoplinebottom = stopline
1c597397f006 updated for version 7.1-269
vimboss
parents: 1496
diff changeset
165 else
1c597397f006 updated for version 7.1-269
vimboss
parents: 1496
diff changeset
166 if has("byte_offset") && has("syntax_items") && &smc > 0
1c597397f006 updated for version 7.1-269
vimboss
parents: 1496
diff changeset
167 let stopbyte = max([1, line2byte(".") + col(".") - &smc * 2])
1c597397f006 updated for version 7.1-269
vimboss
parents: 1496
diff changeset
168 let stopline = max([top_viewable, byte2line(stopbyte)])
1c597397f006 updated for version 7.1-269
vimboss
parents: 1496
diff changeset
169 else
1c597397f006 updated for version 7.1-269
vimboss
parents: 1496
diff changeset
170 let stopline = max([top_viewable, c_lnum - 100])
1c597397f006 updated for version 7.1-269
vimboss
parents: 1496
diff changeset
171 endif
1c597397f006 updated for version 7.1-269
vimboss
parents: 1496
diff changeset
172 let stoplinetop = stopline
1c597397f006 updated for version 7.1-269
vimboss
parents: 1496
diff changeset
173 endif
1496
29c09fa57168 updated for version 7.1-211
vimboss
parents: 1368
diff changeset
174 let [m_lnum, m_col] = searchpairpos(c, '', c2, s_flags, s_skip, stopline)
29c09fa57168 updated for version 7.1-211
vimboss
parents: 1368
diff changeset
175 endtry
845
0fe7765dcb8e updated for version 7.0f03
vimboss
parents: 819
diff changeset
176
694
07d199fe02ed updated for version 7.0209
vimboss
parents:
diff changeset
177 if before > 0
6070
32a77cc160d9 Update runtime files. Make matchparen plugin backwards compatible.
Bram Moolenaar <bram@vim.org>
parents: 6051
diff changeset
178 if has_getcurpos
32a77cc160d9 Update runtime files. Make matchparen plugin backwards compatible.
Bram Moolenaar <bram@vim.org>
parents: 6051
diff changeset
179 call setpos('.', save_cursor)
32a77cc160d9 Update runtime files. Make matchparen plugin backwards compatible.
Bram Moolenaar <bram@vim.org>
parents: 6051
diff changeset
180 else
32a77cc160d9 Update runtime files. Make matchparen plugin backwards compatible.
Bram Moolenaar <bram@vim.org>
parents: 6051
diff changeset
181 call winrestview(save_cursor)
32a77cc160d9 Update runtime files. Make matchparen plugin backwards compatible.
Bram Moolenaar <bram@vim.org>
parents: 6051
diff changeset
182 endif
694
07d199fe02ed updated for version 7.0209
vimboss
parents:
diff changeset
183 endif
07d199fe02ed updated for version 7.0209
vimboss
parents:
diff changeset
184
07d199fe02ed updated for version 7.0209
vimboss
parents:
diff changeset
185 " If a match is found setup match highlighting.
1334
f3abb6aec8c8 updated for version 7.1-048
vimboss
parents: 1136
diff changeset
186 if m_lnum > 0 && m_lnum >= stoplinetop && m_lnum <= stoplinebottom
5979
f9fa2e506b9f updated for version 7.4.330
Bram Moolenaar <bram@vim.org>
parents: 4437
diff changeset
187 if exists('*matchaddpos')
f9fa2e506b9f updated for version 7.4.330
Bram Moolenaar <bram@vim.org>
parents: 4437
diff changeset
188 call matchaddpos('MatchParen', [[c_lnum, c_col - before], [m_lnum, m_col]], 10, 3)
f9fa2e506b9f updated for version 7.4.330
Bram Moolenaar <bram@vim.org>
parents: 4437
diff changeset
189 else
f9fa2e506b9f updated for version 7.4.330
Bram Moolenaar <bram@vim.org>
parents: 4437
diff changeset
190 exe '3match MatchParen /\(\%' . c_lnum . 'l\%' . (c_col - before) .
f9fa2e506b9f updated for version 7.4.330
Bram Moolenaar <bram@vim.org>
parents: 4437
diff changeset
191 \ 'c\)\|\(\%' . m_lnum . 'l\%' . m_col . 'c\)/'
f9fa2e506b9f updated for version 7.4.330
Bram Moolenaar <bram@vim.org>
parents: 4437
diff changeset
192 endif
819
23f82b5d2814 updated for version 7.0c10
vimboss
parents: 818
diff changeset
193 let w:paren_hl_on = 1
694
07d199fe02ed updated for version 7.0209
vimboss
parents:
diff changeset
194 endif
07d199fe02ed updated for version 7.0209
vimboss
parents:
diff changeset
195 endfunction
07d199fe02ed updated for version 7.0209
vimboss
parents:
diff changeset
196
20965
59f93c2d2551 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 18489
diff changeset
197 func s:Remove_Matches()
59f93c2d2551 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 18489
diff changeset
198 if exists('w:paren_hl_on') && w:paren_hl_on
59f93c2d2551 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 18489
diff changeset
199 silent! call matchdelete(3)
59f93c2d2551 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 18489
diff changeset
200 let w:paren_hl_on = 0
59f93c2d2551 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 18489
diff changeset
201 endif
59f93c2d2551 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 18489
diff changeset
202 endfunc
59f93c2d2551 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 18489
diff changeset
203
59f93c2d2551 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 18489
diff changeset
204
694
07d199fe02ed updated for version 7.0209
vimboss
parents:
diff changeset
205 " Define commands that will disable and enable the plugin.
18489
1cd44535be32 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14254
diff changeset
206 command DoMatchParen call s:DoMatchParen()
1cd44535be32 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14254
diff changeset
207 command NoMatchParen call s:NoMatchParen()
12756
3b26420fc639 Long overdue runtime update.
Christian Brabandt <cb@256bit.org>
parents: 8148
diff changeset
208
18489
1cd44535be32 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14254
diff changeset
209 func s:NoMatchParen()
12756
3b26420fc639 Long overdue runtime update.
Christian Brabandt <cb@256bit.org>
parents: 8148
diff changeset
210 let w = winnr()
3b26420fc639 Long overdue runtime update.
Christian Brabandt <cb@256bit.org>
parents: 8148
diff changeset
211 noau windo silent! call matchdelete(3)
3b26420fc639 Long overdue runtime update.
Christian Brabandt <cb@256bit.org>
parents: 8148
diff changeset
212 unlet! g:loaded_matchparen
3b26420fc639 Long overdue runtime update.
Christian Brabandt <cb@256bit.org>
parents: 8148
diff changeset
213 exe "noau ". w . "wincmd w"
3b26420fc639 Long overdue runtime update.
Christian Brabandt <cb@256bit.org>
parents: 8148
diff changeset
214 au! matchparen
3b26420fc639 Long overdue runtime update.
Christian Brabandt <cb@256bit.org>
parents: 8148
diff changeset
215 endfunc
3b26420fc639 Long overdue runtime update.
Christian Brabandt <cb@256bit.org>
parents: 8148
diff changeset
216
18489
1cd44535be32 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14254
diff changeset
217 func s:DoMatchParen()
12756
3b26420fc639 Long overdue runtime update.
Christian Brabandt <cb@256bit.org>
parents: 8148
diff changeset
218 runtime plugin/matchparen.vim
3b26420fc639 Long overdue runtime update.
Christian Brabandt <cb@256bit.org>
parents: 8148
diff changeset
219 let w = winnr()
3b26420fc639 Long overdue runtime update.
Christian Brabandt <cb@256bit.org>
parents: 8148
diff changeset
220 silent windo doau CursorMoved
3b26420fc639 Long overdue runtime update.
Christian Brabandt <cb@256bit.org>
parents: 8148
diff changeset
221 exe "noau ". w . "wincmd w"
3b26420fc639 Long overdue runtime update.
Christian Brabandt <cb@256bit.org>
parents: 8148
diff changeset
222 endfunc
757
8b0484fd9119 updated for version 7.0224
vimboss
parents: 711
diff changeset
223
2034
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1556
diff changeset
224 let &cpo = s:cpo_save
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1556
diff changeset
225 unlet s:cpo_save