comparison runtime/plugin/matchparen.vim @ 6051:0efec12f52ac

Updated runtime files.
author Bram Moolenaar <bram@vim.org>
date Thu, 10 Jul 2014 22:01:47 +0200
parents f9fa2e506b9f
children 32a77cc160d9
comparison
equal deleted inserted replaced
6050:f5c7483cbbb4 6051:0efec12f52ac
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: 2014 Jun 17 3 " Last Change: 2014 Jul 09
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.
52 " Get the character under the cursor and check if it's in 'matchpairs'. 52 " Get the character under the cursor and check if it's in 'matchpairs'.
53 let c_lnum = line('.') 53 let c_lnum = line('.')
54 let c_col = col('.') 54 let c_col = col('.')
55 let before = 0 55 let before = 0
56 56
57 let c = getline(c_lnum)[c_col - 1] 57 let text = getline(c_lnum)
58 let c = text[c_col - 1]
58 let plist = split(&matchpairs, '.\zs[:,]') 59 let plist = split(&matchpairs, '.\zs[:,]')
59 let i = index(plist, c) 60 let i = index(plist, c)
60 if i < 0 61 if i < 0
61 " not found, in Insert mode try character before the cursor 62 " not found, in Insert mode try character before the cursor
62 if c_col > 1 && (mode() == 'i' || mode() == 'R') 63 if c_col > 1 && (mode() == 'i' || mode() == 'R')
63 let before = 1 64 let before = 1
64 let c = getline(c_lnum)[c_col - 2] 65 let c = text[c_col - 2]
65 let i = index(plist, c) 66 let i = index(plist, c)
66 endif 67 endif
67 if i < 0 68 if i < 0
68 " not found, nothing to do 69 " not found, nothing to do
69 return 70 return
85 endif 86 endif
86 87
87 " Find the match. When it was just before the cursor move it there for a 88 " Find the match. When it was just before the cursor move it there for a
88 " moment. 89 " moment.
89 if before > 0 90 if before > 0
90 let save_cursor = winsaveview() 91 let save_cursor = getcurpos()
91 call cursor(c_lnum, c_col - before) 92 call cursor(c_lnum, c_col - before)
92 endif 93 endif
93 94
94 " When not in a string or comment ignore matches inside them. 95 " When not in a string or comment ignore matches inside them.
95 " We match "escape" for special items, such as lispEscapeSpecial. 96 " We match "escape" for special items, such as lispEscapeSpecial.
145 endif 146 endif
146 let [m_lnum, m_col] = searchpairpos(c, '', c2, s_flags, s_skip, stopline) 147 let [m_lnum, m_col] = searchpairpos(c, '', c2, s_flags, s_skip, stopline)
147 endtry 148 endtry
148 149
149 if before > 0 150 if before > 0
150 call winrestview(save_cursor) 151 call setpos('.', save_cursor)
151 endif 152 endif
152 153
153 " If a match is found setup match highlighting. 154 " If a match is found setup match highlighting.
154 if m_lnum > 0 && m_lnum >= stoplinetop && m_lnum <= stoplinebottom 155 if m_lnum > 0 && m_lnum >= stoplinetop && m_lnum <= stoplinebottom
155 if exists('*matchaddpos') 156 if exists('*matchaddpos')