mirror of
				https://github.com/jiangmiao/auto-pairs.git
				synced 2025-11-04 11:29:22 +08:00 
			
		
		
		
	Obsolete wild close key by default, add custom close key, improve #242
This commit is contained in:
		
							
								
								
									
										10
									
								
								README.md
									
									
									
									
									
								
							
							
						
						
									
										10
									
								
								README.md
									
									
									
									
									
								
							@ -248,14 +248,6 @@ Options
 | 
			
		||||
        Map <M-(> <M-)> <M-[> <M-]> <M-{> <M-}> <M-"> <M-'> to
 | 
			
		||||
        move character under the cursor to the pair.
 | 
			
		||||
 | 
			
		||||
*   g:AutoPairsWildClosedPair
 | 
			
		||||
 | 
			
		||||
        Default: ']'
 | 
			
		||||
 | 
			
		||||
        Jump over following closed pair
 | 
			
		||||
        for pair {'begin': 'end//n]'}, e is not mapped, use wild closed pair ] to jump over 'end'
 | 
			
		||||
        use <M-b> to back insert ] after jumping
 | 
			
		||||
 | 
			
		||||
Buffer Level Pairs Setting
 | 
			
		||||
--------------------------
 | 
			
		||||
 | 
			
		||||
@ -313,6 +305,7 @@ Multibyte Pairs
 | 
			
		||||
        n - do not map the first charactor of closed pair to close key
 | 
			
		||||
        m - close key jumps through multi line
 | 
			
		||||
        s - close key jumps only in the same line
 | 
			
		||||
        k[KEY] - map the close key to [KEY]
 | 
			
		||||
 | 
			
		||||
            by default if open key equals close key the multi line is turn off
 | 
			
		||||
 | 
			
		||||
@ -321,6 +314,7 @@ Multibyte Pairs
 | 
			
		||||
            "<?php":"?>"    ? will jump through multi line
 | 
			
		||||
            "<?php":"?>//s" force ? only jumping in the same line
 | 
			
		||||
            "<?": "?>//n"   do not jump totally
 | 
			
		||||
            "<?": "?>//k]"  use key ] to jump through ?>
 | 
			
		||||
 | 
			
		||||
        for 'begin' 'end' pair, e is a charactor, if map e to jump will be annoy, so use modifier 'n' to skip key map
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -25,7 +25,7 @@ func! AutoPairsDefaultPairs()
 | 
			
		||||
  let allPairs = {
 | 
			
		||||
        \ 'vim': {'\v^\s*\zs"': ''},
 | 
			
		||||
        \ 'rust': {'\w\zs<': '>', '&\zs''': ''},
 | 
			
		||||
        \ 'php': {'<?': '?>//n', '<?php': '?>//n'}
 | 
			
		||||
        \ 'php': {'<?': '?>//k]', '<?php': '?>//k]'}
 | 
			
		||||
        \ }
 | 
			
		||||
  for [filetype, pairs] in items(allPairs)
 | 
			
		||||
    if &filetype == filetype
 | 
			
		||||
@ -52,7 +52,7 @@ if !exists('g:AutoPairsMapCR')
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
if !exists('g:AutoPairsWildClosedPair')
 | 
			
		||||
  let g:AutoPairsWildClosedPair = ']'
 | 
			
		||||
  let g:AutoPairsWildClosedPair = ''
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
if !exists('g:AutoPairsMapSpace')
 | 
			
		||||
@ -263,7 +263,7 @@ func! AutoPairsInsert(key)
 | 
			
		||||
    if close == ''
 | 
			
		||||
      continue
 | 
			
		||||
    end
 | 
			
		||||
    if a:key == g:AutoPairsWildClosedPair || opt['mapclose'] && close[0] == a:key
 | 
			
		||||
    if a:key == g:AutoPairsWildClosedPair || opt['mapclose'] && opt['key'] == a:key
 | 
			
		||||
      " the close pair is in the same line
 | 
			
		||||
      let m = matchstr(afterline, '^\v\s*\V'.close)
 | 
			
		||||
      if m != ''
 | 
			
		||||
@ -494,6 +494,7 @@ func! AutoPairsInit()
 | 
			
		||||
    let o = open[-1:-1]
 | 
			
		||||
    let c = close[0]
 | 
			
		||||
    let opt = {'mapclose': 1, 'multiline':1}
 | 
			
		||||
    let opt['key'] = c
 | 
			
		||||
    if o == c
 | 
			
		||||
      let opt['multiline'] = 0
 | 
			
		||||
    end
 | 
			
		||||
@ -508,6 +509,11 @@ func! AutoPairsInit()
 | 
			
		||||
      if m[2] =~ 's'
 | 
			
		||||
        let opt['multiline'] = 0
 | 
			
		||||
      end
 | 
			
		||||
      let ks = matchlist(m[2], '\vk(.)')
 | 
			
		||||
      if len(ks) > 0
 | 
			
		||||
        let opt['key'] = ks[1]
 | 
			
		||||
        let c = opt['key']
 | 
			
		||||
      end
 | 
			
		||||
      let close = m[1]
 | 
			
		||||
    end
 | 
			
		||||
    call AutoPairsMap(o)
 | 
			
		||||
 | 
			
		||||
		Reference in New Issue
	
	Block a user