Obsolete wild close key by default, add custom close key, improve #242
This commit is contained in:
parent
fcf9f00f85
commit
65a9f452f2
10
README.md
10
README.md
@ -248,14 +248,6 @@ Options
|
|||||||
Map <M-(> <M-)> <M-[> <M-]> <M-{> <M-}> <M-"> <M-'> to
|
Map <M-(> <M-)> <M-[> <M-]> <M-{> <M-}> <M-"> <M-'> to
|
||||||
move character under the cursor to the pair.
|
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
|
Buffer Level Pairs Setting
|
||||||
--------------------------
|
--------------------------
|
||||||
|
|
||||||
@ -313,6 +305,7 @@ Multibyte Pairs
|
|||||||
n - do not map the first charactor of closed pair to close key
|
n - do not map the first charactor of closed pair to close key
|
||||||
m - close key jumps through multi line
|
m - close key jumps through multi line
|
||||||
s - close key jumps only in the same 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
|
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":"?>" ? will jump through multi line
|
||||||
"<?php":"?>//s" force ? only jumping in the same line
|
"<?php":"?>//s" force ? only jumping in the same line
|
||||||
"<?": "?>//n" do not jump totally
|
"<?": "?>//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
|
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 = {
|
let allPairs = {
|
||||||
\ 'vim': {'\v^\s*\zs"': ''},
|
\ 'vim': {'\v^\s*\zs"': ''},
|
||||||
\ 'rust': {'\w\zs<': '>', '&\zs''': ''},
|
\ 'rust': {'\w\zs<': '>', '&\zs''': ''},
|
||||||
\ 'php': {'<?': '?>//n', '<?php': '?>//n'}
|
\ 'php': {'<?': '?>//k]', '<?php': '?>//k]'}
|
||||||
\ }
|
\ }
|
||||||
for [filetype, pairs] in items(allPairs)
|
for [filetype, pairs] in items(allPairs)
|
||||||
if &filetype == filetype
|
if &filetype == filetype
|
||||||
@ -52,7 +52,7 @@ if !exists('g:AutoPairsMapCR')
|
|||||||
end
|
end
|
||||||
|
|
||||||
if !exists('g:AutoPairsWildClosedPair')
|
if !exists('g:AutoPairsWildClosedPair')
|
||||||
let g:AutoPairsWildClosedPair = ']'
|
let g:AutoPairsWildClosedPair = ''
|
||||||
end
|
end
|
||||||
|
|
||||||
if !exists('g:AutoPairsMapSpace')
|
if !exists('g:AutoPairsMapSpace')
|
||||||
@ -263,7 +263,7 @@ func! AutoPairsInsert(key)
|
|||||||
if close == ''
|
if close == ''
|
||||||
continue
|
continue
|
||||||
end
|
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
|
" the close pair is in the same line
|
||||||
let m = matchstr(afterline, '^\v\s*\V'.close)
|
let m = matchstr(afterline, '^\v\s*\V'.close)
|
||||||
if m != ''
|
if m != ''
|
||||||
@ -494,6 +494,7 @@ func! AutoPairsInit()
|
|||||||
let o = open[-1:-1]
|
let o = open[-1:-1]
|
||||||
let c = close[0]
|
let c = close[0]
|
||||||
let opt = {'mapclose': 1, 'multiline':1}
|
let opt = {'mapclose': 1, 'multiline':1}
|
||||||
|
let opt['key'] = c
|
||||||
if o == c
|
if o == c
|
||||||
let opt['multiline'] = 0
|
let opt['multiline'] = 0
|
||||||
end
|
end
|
||||||
@ -508,6 +509,11 @@ func! AutoPairsInit()
|
|||||||
if m[2] =~ 's'
|
if m[2] =~ 's'
|
||||||
let opt['multiline'] = 0
|
let opt['multiline'] = 0
|
||||||
end
|
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]
|
let close = m[1]
|
||||||
end
|
end
|
||||||
call AutoPairsMap(o)
|
call AutoPairsMap(o)
|
||||||
|
Loading…
Reference in New Issue
Block a user