Merge fa4d41e617c61b538aae36409ceb725daf9b182f into 39f06b873a8449af8ff6a3eee716d3da14d63a76

This commit is contained in:
Matthew 2019-03-27 03:28:47 +00:00 committed by GitHub
commit 63e756b566
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 34 additions and 2 deletions

View File

@ -248,6 +248,18 @@ Options
Map <M-(> <M-)> <M-[> <M-]> <M-{> <M-}> <M-"> <M-'> to
move character under the cursor to the pair.
* g:AutoPairsFormat
Default: 1
Use vim to automatically format code upon <CR>.
* g:AutoPairsIndent
Default: 0
Automatically indent cursor upon <CR>.
Buffer Level Pairs Setting
--------------------------

View File

@ -63,6 +63,14 @@ if !exists('g:AutoPairsCenterLine')
let g:AutoPairsCenterLine = 1
end
if !exists('g:AutoPairsFormat')
let g:AutoPairsFormat = 1
end
if !exists('g:AutoPairsIndent')
let g:AutoPairsIndent = 0
end
if !exists('g:AutoPairsShortcutToggle')
let g:AutoPairsShortcutToggle = '<M-p>'
end
@ -389,6 +397,8 @@ func! AutoPairsReturn()
let before = getline(line('.')-1)
let [ig, ig, afterline] = s:getline()
let cmd = ''
let format = ''
let indent = ''
for [open, close, opt] in b:AutoPairsList
if close == ''
continue
@ -407,13 +417,23 @@ func! AutoPairsReturn()
return "\<ESC>".cmd."O"
endif
if g:AutoPairsFormat == 1
" Use vim to to automatically format content
let format = "="
end
if g:AutoPairsIndent == 1
" Indent new line when using <CR> between pairs
let indent = "\t"
end
" conflict with javascript and coffee
" javascript need indent new line
" coffeescript forbid indent new line
if &filetype == 'coffeescript' || &filetype == 'coffee'
return "\<ESC>".cmd."k==o"
return "\<ESC>".cmd."k".format.format."o".indent
else
return "\<ESC>".cmd."=ko"
return "\<ESC>".cmd.format."ko".indent
endif
end
endfor