Mercurial > vim
comparison runtime/pack/dist/opt/matchit/plugin/matchit.vim @ 9975:03fa8a51e9dc
commit https://github.com/vim/vim/commit/e4a3bcf28d92d0bde9ca227ccb40d401038185e5
Author: Bram Moolenaar <Bram@vim.org>
Date: Fri Aug 26 19:52:37 2016 +0200
Updated runtime files. Add Scala files.
author | Christian Brabandt <cb@256bit.org> |
---|---|
date | Fri, 26 Aug 2016 20:00:12 +0200 |
parents | 071f9da012fb |
children | 214f228718cf |
comparison
equal
deleted
inserted
replaced
9974:cb480e05fb5f | 9975:03fa8a51e9dc |
---|---|
1 " matchit.vim: (global plugin) Extended "%" matching | 1 " matchit.vim: (global plugin) Extended "%" matching |
2 " Last Change: Fri Jan 25 10:00 AM 2008 EST | 2 " Last Change: 2016 Aug 21 |
3 " Maintainer: Benji Fisher PhD <benji@member.AMS.org> | 3 " Maintainer: Benji Fisher PhD <benji@member.AMS.org> |
4 " Version: 1.13.2, for Vim 6.3+ | 4 " Version: 1.13.2, for Vim 6.3+ |
5 " Fix from Fernando Torres included. | 5 " Fix from Fernando Torres included. |
6 " Improvement from Ken Takata included. | |
6 " URL: http://www.vim.org/script.php?script_id=39 | 7 " URL: http://www.vim.org/script.php?script_id=39 |
7 | 8 |
8 " Documentation: | 9 " Documentation: |
9 " The documentation is in a separate file, matchit.txt . | 10 " The documentation is in a separate file, matchit.txt . |
10 | 11 |
42 finish | 43 finish |
43 endif | 44 endif |
44 let loaded_matchit = 1 | 45 let loaded_matchit = 1 |
45 let s:last_mps = "" | 46 let s:last_mps = "" |
46 let s:last_words = ":" | 47 let s:last_words = ":" |
48 let s:patBR = "" | |
47 | 49 |
48 let s:save_cpo = &cpo | 50 let s:save_cpo = &cpo |
49 set cpo&vim | 51 set cpo&vim |
50 | 52 |
51 nnoremap <silent> % :<C-U>call <SID>Match_wrapper('',1,'n') <CR> | 53 nnoremap <silent> % :<C-U>call <SID>Match_wrapper('',1,'n') <CR> |
119 let match_words = b:match_words | 121 let match_words = b:match_words |
120 else | 122 else |
121 execute "let match_words =" b:match_words | 123 execute "let match_words =" b:match_words |
122 endif | 124 endif |
123 " Thanks to Preben "Peppe" Guldberg and Bram Moolenaar for this suggestion! | 125 " Thanks to Preben "Peppe" Guldberg and Bram Moolenaar for this suggestion! |
124 if (match_words != s:last_words) || (&mps != s:last_mps) || | 126 if (match_words != s:last_words) || (&mps != s:last_mps) |
125 \ exists("b:match_debug") | 127 \ || exists("b:match_debug") |
126 let s:last_mps = &mps | 128 let s:last_mps = &mps |
127 " The next several lines were here before | 129 " The next several lines were here before |
128 " BF started messing with this script. | 130 " BF started messing with this script. |
129 " quote the special chars in 'matchpairs', replace [,:] with \| and then | 131 " quote the special chars in 'matchpairs', replace [,:] with \| and then |
130 " append the builtin pairs (/*, */, #if, #ifdef, #else, #elif, #endif) | 132 " append the builtin pairs (/*, */, #if, #ifdef, #else, #elif, #endif) |
146 let s:all = '\%(' . s:all . '\)' | 148 let s:all = '\%(' . s:all . '\)' |
147 " let s:all = '\%(' . substitute(s:all, '\\\ze[,:]', '', 'g') . '\)' | 149 " let s:all = '\%(' . substitute(s:all, '\\\ze[,:]', '', 'g') . '\)' |
148 if exists("b:match_debug") | 150 if exists("b:match_debug") |
149 let b:match_pat = s:pat | 151 let b:match_pat = s:pat |
150 endif | 152 endif |
153 " Reconstruct the version with unresolved backrefs. | |
154 let s:patBR = substitute(match_words.',', | |
155 \ s:notslash.'\zs[,:]*,[,:]*', ',', 'g') | |
156 let s:patBR = substitute(s:patBR, s:notslash.'\zs:\{2,}', ':', 'g') | |
151 endif | 157 endif |
152 | 158 |
153 " Second step: set the following local variables: | 159 " Second step: set the following local variables: |
154 " matchline = line on which the cursor started | 160 " matchline = line on which the cursor started |
155 " curcol = number of characters before match | 161 " curcol = number of characters before match |
190 " (backref) versions of these. Then, resolve the backrefs. | 196 " (backref) versions of these. Then, resolve the backrefs. |
191 " Set the following local variable: | 197 " Set the following local variable: |
192 " group = colon-separated list of patterns, one of which matches | 198 " group = colon-separated list of patterns, one of which matches |
193 " = ini:mid:fin or ini:fin | 199 " = ini:mid:fin or ini:fin |
194 " | 200 " |
195 " Reconstruct the version with unresolved backrefs. | |
196 let patBR = substitute(match_words.',', | |
197 \ s:notslash.'\zs[,:]*,[,:]*', ',', 'g') | |
198 let patBR = substitute(patBR, s:notslash.'\zs:\{2,}', ':', 'g') | |
199 " Now, set group and groupBR to the matching group: 'if:endif' or | 201 " Now, set group and groupBR to the matching group: 'if:endif' or |
200 " 'while:endwhile' or whatever. A bit of a kluge: s:Choose() returns | 202 " 'while:endwhile' or whatever. A bit of a kluge: s:Choose() returns |
201 " group . "," . groupBR, and we pick it apart. | 203 " group . "," . groupBR, and we pick it apart. |
202 let group = s:Choose(s:pat, matchline, ",", ":", prefix, suffix, patBR) | 204 let group = s:Choose(s:pat, matchline, ",", ":", prefix, suffix, s:patBR) |
203 let i = matchend(group, s:notslash . ",") | 205 let i = matchend(group, s:notslash . ",") |
204 let groupBR = strpart(group, i) | 206 let groupBR = strpart(group, i) |
205 let group = strpart(group, 0, i-1) | 207 let group = strpart(group, 0, i-1) |
206 " Now, matchline =~ prefix . substitute(group,':','\|','g') . suffix | 208 " Now, matchline =~ prefix . substitute(group,':','\|','g') . suffix |
207 if s:do_BR " Do the hard part: resolve those backrefs! | 209 if s:do_BR " Do the hard part: resolve those backrefs! |
659 endif | 661 endif |
660 if (match_words != s:last_words) || (&mps != s:last_mps) || | 662 if (match_words != s:last_words) || (&mps != s:last_mps) || |
661 \ exists("b:match_debug") | 663 \ exists("b:match_debug") |
662 let s:last_words = match_words | 664 let s:last_words = match_words |
663 let s:last_mps = &mps | 665 let s:last_mps = &mps |
666 let match_words = match_words . (strlen(match_words) ? "," : "") . default | |
664 if match_words !~ s:notslash . '\\\d' | 667 if match_words !~ s:notslash . '\\\d' |
665 let s:do_BR = 0 | 668 let s:do_BR = 0 |
666 let s:pat = match_words | 669 let s:pat = match_words |
667 else | 670 else |
668 let s:do_BR = 1 | 671 let s:do_BR = 1 |
669 let s:pat = s:ParseWords(match_words) | 672 let s:pat = s:ParseWords(match_words) |
670 endif | 673 endif |
671 let s:all = '\%(' . substitute(s:pat . (strlen(s:pat)?",":"") . default, | 674 let s:all = '\%(' . substitute(s:pat . (strlen(s:pat) ? "," : "") . default, |
672 \ '[,:]\+','\\|','g') . '\)' | 675 \ '[,:]\+', '\\|', 'g') . '\)' |
673 if exists("b:match_debug") | 676 if exists("b:match_debug") |
674 let b:match_pat = s:pat | 677 let b:match_pat = s:pat |
675 endif | 678 endif |
676 endif | 679 endif |
677 | 680 |