summaryrefslogtreecommitdiffstats
path: root/vim/plugin
diff options
context:
space:
mode:
authorjluehrs2 <jluehrs2@uiuc.edu>2007-09-09 17:48:56 -0500
committerjluehrs2 <jluehrs2@uiuc.edu>2007-09-09 17:48:56 -0500
commit56f101dc02627ba3e428201a3716e2dc36bbf827 (patch)
tree2e9dc7dbbfa3e8073989e5e7e9edce4abf6aa70a /vim/plugin
parent4f13ec9fef25ef0a958b74836e13b342f885feff (diff)
downloadconf-56f101dc02627ba3e428201a3716e2dc36bbf827.tar.gz
conf-56f101dc02627ba3e428201a3716e2dc36bbf827.zip
update matchit vim plugin
Diffstat (limited to 'vim/plugin')
-rw-r--r--vim/plugin/matchit.vim75
1 files changed, 38 insertions, 37 deletions
diff --git a/vim/plugin/matchit.vim b/vim/plugin/matchit.vim
index a2f2050..9508ec7 100644
--- a/vim/plugin/matchit.vim
+++ b/vim/plugin/matchit.vim
@@ -1,7 +1,7 @@
" matchit.vim: (global plugin) Extended "%" matching
-" Last Change: Sun Feb 26 10:00 AM 2006 EST
+" Last Change: Sun Sep 09 09:00 AM 2007 EDT
" Maintainer: Benji Fisher PhD <benji@member.AMS.org>
-" Version: 1.10, for Vim 6.3
+" Version: 1.13.1, for Vim 6.3+
" URL: http://www.vim.org/script.php?script_id=39
" Documentation:
@@ -15,7 +15,7 @@
" Support for many languages by Johannes Zellner
" Suggestions for improvement, bug reports, and support for additional
" languages by Jordi-Albert Batalla, Neil Bird, Servatius Brandt, Mark
-" Collett, Stephen Wall, Dany St-Amant, and Johannes Zellner.
+" Collett, Stephen Wall, Dany St-Amant, Yuheng Xie, and Johannes Zellner.
" Debugging:
" If you'd like to try the built-in debugging commands...
@@ -42,7 +42,7 @@ if exists("loaded_matchit") || &cp
endif
let loaded_matchit = 1
let s:last_mps = ""
-let s:last_words = ""
+let s:last_words = ":"
let s:save_cpo = &cpo
set cpo&vim
@@ -100,13 +100,10 @@ function! s:Match_wrapper(word, forward, mode) range
" In s:CleanUp(), we may need to check whether the cursor moved forward.
let startline = line(".")
let startcol = col(".")
- " Use default behavior if called with a count or if no patterns are defined.
+ " Use default behavior if called with a count.
if v:count
exe "normal! " . v:count . "%"
return s:CleanUp(restore_options, a:mode, startline, startcol)
- elseif !exists("b:match_words") || b:match_words == ""
- silent! normal! %
- return s:CleanUp(restore_options, a:mode, startline, startcol)
end
" First step: if not already done, set the script variables
@@ -114,8 +111,10 @@ function! s:Match_wrapper(word, forward, mode) range
" s:pat parsed version of b:match_words
" s:all regexp based on s:pat and the default groups
"
- " Allow b:match_words = "GetVimMatchWords()" .
- if b:match_words =~ ":"
+ if !exists("b:match_words") || b:match_words == ""
+ let match_words = ""
+ " Allow b:match_words = "GetVimMatchWords()" .
+ elseif b:match_words =~ ":"
let match_words = b:match_words
else
execute "let match_words =" b:match_words
@@ -125,13 +124,6 @@ function! s:Match_wrapper(word, forward, mode) range
\ exists("b:match_debug")
let s:last_words = match_words
let s:last_mps = &mps
- if match_words !~ s:notslash . '\\\d'
- let s:do_BR = 0
- let s:pat = match_words
- else
- let s:do_BR = 1
- let s:pat = s:ParseWords(match_words)
- endif
" The next several lines were here before
" BF started messing with this script.
" quote the special chars in 'matchpairs', replace [,:] with \| and then
@@ -141,8 +133,15 @@ function! s:Match_wrapper(word, forward, mode) range
let default = escape(&mps, '[$^.*~\\/?]') . (strlen(&mps) ? "," : "") .
\ '\/\*:\*\/,#if\%(def\)\=:#else\>:#elif\>:#endif\>'
" s:all = pattern with all the keywords
- let s:all = s:pat . (strlen(s:pat) ? "," : "") . default
- let s:all = substitute(s:all, s:notslash . '\zs[,:]\+', '\\|', 'g')
+ let match_words = match_words . (strlen(match_words) ? "," : "") . default
+ if match_words !~ s:notslash . '\\\d'
+ let s:do_BR = 0
+ let s:pat = match_words
+ else
+ let s:do_BR = 1
+ let s:pat = s:ParseWords(match_words)
+ endif
+ let s:all = substitute(s:pat, s:notslash . '\zs[,:]\+', '\\|', 'g')
let s:all = '\%(' . s:all . '\)'
" let s:all = '\%(' . substitute(s:all, '\\\ze[,:]', '', 'g') . '\)'
if exists("b:match_debug")
@@ -172,15 +171,14 @@ function! s:Match_wrapper(word, forward, mode) range
else " Find the match that ends on or after the cursor and set curcol.
let regexp = s:Wholematch(matchline, s:all, startcol-1)
let curcol = match(matchline, regexp)
- let suf = strlen(matchline) - matchend(matchline, regexp)
- let prefix = (curcol ? '^.\{' . curcol . '}\%(' : '^\%(')
- let suffix = (suf ? '\).\{' . suf . '}$' : '\)$')
- " If the match comes from the defaults, bail out.
- if matchline !~ prefix .
- \ substitute(s:pat, s:notslash.'\zs[,:]\+', '\\|', 'g') . suffix
- silent! norm! %
+ " If there is no match, give up.
+ if curcol == -1
return s:CleanUp(restore_options, a:mode, startline, startcol)
endif
+ let endcol = matchend(matchline, regexp)
+ let suf = strlen(matchline) - endcol
+ let prefix = (curcol ? '^.*\%' . (curcol + 1) . 'c\%(' : '^\%(')
+ let suffix = (suf ? '\)\%' . (endcol + 1) . 'c.*$' : '\)$')
endif
if exists("b:match_debug")
let b:match_match = matchstr(matchline, regexp)
@@ -262,10 +260,11 @@ function! s:Match_wrapper(word, forward, mode) range
normal! H
let restore_cursor = "normal!" . line(".") . "Gzt" . restore_cursor
execute restore_cursor
- normal! 0
- if curcol
- execute "normal!" . curcol . "l"
- endif
+ call cursor(0, curcol + 1)
+ " normal! 0
+ " if curcol
+ " execute "normal!" . curcol . "l"
+ " endif
if skip =~ 'synID' && !(has("syntax") && exists("g:syntax_on"))
let skip = "0"
else
@@ -415,9 +414,9 @@ endfun
" let match = matchstr(getline("."), regexp)
fun! s:Wholematch(string, pat, start)
let group = '\%(' . a:pat . '\)'
- let prefix = (a:start ? '\(^.\{,' . a:start . '}\)\zs' : '^')
+ let prefix = (a:start ? '\(^.*\%<' . (a:start + 2) . 'c\)\zs' : '^')
let len = strlen(a:string)
- let suffix = (a:start+1 < len ? '\(.\{,'.(len-a:start-1).'}$\)\@=' : '$')
+ let suffix = (a:start+1 < len ? '\(\%>'.(a:start+1).'c.*$\)\@=' : '$')
if a:string !~ prefix . group . suffix
let prefix = ''
endif
@@ -649,7 +648,7 @@ fun! s:MultiMatch(spflag, mode)
" s:all regexp based on s:pat and the default groups
" This part is copied and slightly modified from s:Match_wrapper().
let default = escape(&mps, '[$^.*~\\/?]') . (strlen(&mps) ? "," : "") .
- \ '\/\*:\*\/,#if\%(def\)\=:$else\>:#elif\>:#endif\>'
+ \ '\/\*:\*\/,#if\%(def\)\=:#else\>:#elif\>:#endif\>'
" Allow b:match_words = "GetVimMatchWords()" .
if b:match_words =~ ":"
let match_words = b:match_words
@@ -680,10 +679,12 @@ fun! s:MultiMatch(spflag, mode)
" - maybe even more functionality should be split off
" - into separate functions!
let cdefault = (s:pat =~ '[^,]$' ? "," : "") . default
- let open = substitute(s:pat . cdefault, ':[^,]*,', '\\),\\(', 'g')
- let open = '\(' . substitute(open, ':[^,]*$', '\\)', '')
- let close = substitute(s:pat . cdefault, ',[^,]*:', '\\),\\(', 'g')
- let close = substitute(close, '[^,]*:', '\\(', '') . '\)'
+ let open = substitute(s:pat . cdefault,
+ \ s:notslash . '\zs:.\{-}' . s:notslash . ',', '\\),\\(', 'g')
+ let open = '\(' . substitute(open, s:notslash . '\zs:.*$', '\\)', '')
+ let close = substitute(s:pat . cdefault,
+ \ s:notslash . '\zs,.\{-}' . s:notslash . ':', '\\),\\(', 'g')
+ let close = substitute(close, '^.\{-}' . s:notslash . ':', '\\(', '') . '\)'
if exists("b:match_skip")
let skip = b:match_skip
elseif exists("b:match_comment") " backwards compatibility and testing!