Skip to content

Commit c5b4f93

Browse files
jiangmiaovim-scripts
authored andcommitted
Version 1.2.7: fixes #24 when equalprg is set 'Return' feature cannot work well
1 parent ec1cb81 commit c5b4f93

File tree

2 files changed

+38
-3
lines changed

2 files changed

+38
-3
lines changed

README.md

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,35 @@ Compatible with Vimwiki - [issue #19](https://github.com/jiangmiao/auto-pairs/is
242242

243243
Description: When works with vimwiki `<CR>` will output `<SNR>xx_CR()`
244244
Reason: vimwiki uses `<expr>` on mapping `<CR>` that auto-pairs cannot expanding.
245-
Solution: add `let g:AutoPairsMapCR = 0` to .vimrc to disable `<CR>` mapping.
245+
Solution A: Add
246+
247+
" Copy from vimwiki.vim s:CR function for CR remapping
248+
function! VimwikiCR()
249+
let res = vimwiki#lst#kbd_cr()
250+
if res == "\<CR>" && g:vimwiki_table_mappings
251+
let res = vimwiki#tbl#kbd_cr()
252+
endif
253+
return res
254+
endfunction
255+
autocmd filetype vimwiki inoremap <buffer> <silent> <CR> <C-R>=VimwikiCR()<CR><C-R>=AutoPairsReturn()<CR>
256+
257+
to .vimrc, it will make vimwiki and auto-pairs 'Return' feature works together.
258+
259+
Solution B: add `let g:AutoPairsMapCR = 0` to .vimrc to disable `<CR>` mapping.
260+
261+
Compatible with viki - [issue #25](https://github.com/jiangmiao/auto-pairs/issues/25)
262+
263+
Description: When works with viki `<CR>` will output viki#ExprMarkInexistentInElement('ParagraphVisible','<CR>')
264+
Reason: viki uses `<expr>` on mapping `<CR>` that auto-pairs cannot expanding.
265+
Solution A: Add
266+
267+
autocmd filetype viki inoremap <buffer> <silent> <CR> <C-R>=viki#ExprMarkInexistentInElement('ParagraphVisible',"\n")<CR><C-R>=AutoPairsReturn()<CR>`
268+
269+
to .vimrc, it will make viki and auto-pairs works together.
270+
271+
Solution B: add `let g:AutoPairsMapCR = 0` to .vimrc to disable `<CR>` mapping.
272+
273+
Remarks: Solution A need NOT add `let g:AutoPairsMapCR = 0` to .vimrc, if Solution A still cannot work, then have to use Solution B to disable auto-pairs `<CR>`.
246274

247275
Breaks '.' - [issue #3](https://github.com/jiangmiao/auto-pairs/issues/3)
248276

plugin/auto-pairs.vim

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
" Insert or delete brackets, parens, quotes in pairs.
22
" Maintainer: JiangMiao <jiangfriend@gmail.com>
33
" Contributor: camthompson
4-
" Last Change: 2012-10-17
5-
" Version: 1.2.6
4+
" Last Change: 2012-11-02
5+
" Version: 1.2.7
66
" Homepage: http://www.vim.org/scripts/script.php?script_id=3599
77
" Repository: https://github.com/jiangmiao/auto-pairs
88

@@ -281,6 +281,13 @@ function! AutoPairsReturn()
281281
" Use \<DEL> is a bit wierd. the character before cursor need to be deleted.
282282
let cmd = " \<C-O>zz\<ESC>cl"
283283
end
284+
285+
" If equalprg has been set, then avoid call =
286+
" https://github.com/jiangmiao/auto-pairs/issues/24
287+
if &equalprg != ''
288+
return "\<ESC>O".cmd
289+
endif
290+
284291
" conflict with javascript and coffee
285292
" javascript need indent new line
286293
" coffeescript forbid indent new line

0 commit comments

Comments
 (0)