Mercurial > vim
comparison runtime/plugin/matchparen.vim @ 1334:f3abb6aec8c8 v7.1.048
updated for version 7.1-048
author | vimboss |
---|---|
date | Thu, 02 Aug 2007 21:00:50 +0000 |
parents | b5c914e467f7 |
children | 048f26eb43a3 |
comparison
equal
deleted
inserted
replaced
1333:01762f635bab | 1334:f3abb6aec8c8 |
---|---|
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: 2006 Oct 12 | 3 " Last Change: 2007 Jul 30 |
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 availble. | 8 " - the "CursorMoved" autocmd event is not availble. |
60 endif | 60 endif |
61 | 61 |
62 " Figure out the arguments for searchpairpos(). | 62 " Figure out the arguments for searchpairpos(). |
63 " Restrict the search to visible lines with "stopline". | 63 " Restrict the search to visible lines with "stopline". |
64 " And avoid searching very far (e.g., for closed folds and long lines) | 64 " And avoid searching very far (e.g., for closed folds and long lines) |
65 " The "viewable" variables give a range in which we can scroll while keeping | |
66 " the cursor at the same position | |
67 " adjustedScrolloff accounts for very large numbers of scrolloff | |
68 let adjustedScrolloff = min([&scrolloff, (line('w$') - line('w0')) / 2]) | |
69 let bottom_viewable = min([line('$'), c_lnum + &lines - adjustedScrolloff - 2]) | |
70 let top_viewable = max([1, c_lnum-&lines+adjustedScrolloff + 2]) | |
71 " one of these stoplines will be adjusted below, but the current values are | |
72 " minimal boundaries within the current window | |
73 let stoplinebottom = line('w$') | |
74 let stoplinetop = line('w0') | |
65 if i % 2 == 0 | 75 if i % 2 == 0 |
66 let s_flags = 'nW' | 76 let s_flags = 'nW' |
67 let c2 = plist[i + 1] | 77 let c2 = plist[i + 1] |
68 if has("byte_offset") && has("syntax_items") && &smc > 0 | 78 if has("byte_offset") && has("syntax_items") && &smc > 0 |
69 let stopbyte = min([line2byte("$"), line2byte(".") + col(".") + &smc * 2]) | 79 let stopbyte = min([line2byte("$"), line2byte(".") + col(".") + &smc * 2]) |
70 let stopline = min([line('w$'), byte2line(stopbyte)]) | 80 let stopline = min([bottom_viewable, byte2line(stopbyte)]) |
71 else | 81 else |
72 let stopline = min([line('w$'), c_lnum + 100]) | 82 let stopline = min([bottom_viewable, c_lnum + 100]) |
73 endif | 83 endif |
84 let stoplinebottom = stopline | |
74 else | 85 else |
75 let s_flags = 'nbW' | 86 let s_flags = 'nbW' |
76 let c2 = c | 87 let c2 = c |
77 let c = plist[i - 1] | 88 let c = plist[i - 1] |
78 if has("byte_offset") && has("syntax_items") && &smc > 0 | 89 if has("byte_offset") && has("syntax_items") && &smc > 0 |
79 let stopbyte = max([1, line2byte(".") + col(".") - &smc * 2]) | 90 let stopbyte = max([1, line2byte(".") + col(".") - &smc * 2]) |
80 let stopline = max([line('w0'), byte2line(stopbyte)]) | 91 let stopline = max([top_viewable, byte2line(stopbyte)]) |
81 else | 92 else |
82 let stopline = max([line('w0'), c_lnum - 100]) | 93 let stopline = max([top_viewable, c_lnum - 100]) |
83 endif | 94 endif |
95 let stoplinetop = stopline | |
84 endif | 96 endif |
85 if c == '[' | 97 if c == '[' |
86 let c = '\[' | 98 let c = '\[' |
87 let c2 = '\]' | 99 let c2 = '\]' |
88 endif | 100 endif |
104 if before > 0 | 116 if before > 0 |
105 call winrestview(save_cursor) | 117 call winrestview(save_cursor) |
106 endif | 118 endif |
107 | 119 |
108 " If a match is found setup match highlighting. | 120 " If a match is found setup match highlighting. |
109 if m_lnum > 0 && m_lnum >= line('w0') && m_lnum <= line('w$') | 121 if m_lnum > 0 && m_lnum >= stoplinetop && m_lnum <= stoplinebottom |
110 exe '3match MatchParen /\(\%' . c_lnum . 'l\%' . (c_col - before) . | 122 exe '3match MatchParen /\(\%' . c_lnum . 'l\%' . (c_col - before) . |
111 \ 'c\)\|\(\%' . m_lnum . 'l\%' . m_col . 'c\)/' | 123 \ 'c\)\|\(\%' . m_lnum . 'l\%' . m_col . 'c\)/' |
112 let w:paren_hl_on = 1 | 124 let w:paren_hl_on = 1 |
113 endif | 125 endif |
114 endfunction | 126 endfunction |