diff --git a/README.md b/README.md index 587fd7a..e05fe07 100644 --- a/README.md +++ b/README.md @@ -269,40 +269,6 @@ Known Issues ----------------------- There are the issues I cannot fix. -Compatible with Vimwiki - [issue #19](https://github.com/jiangmiao/auto-pairs/issues/19) - - Description: When works with vimwiki `` will output `xx_CR()` - Reason: vimwiki uses `` on mapping `` that auto-pairs cannot expanding. - Solution A: Add - - " Copy from vimwiki.vim s:CR function for CR remapping - function! VimwikiCR() - let res = vimwiki#lst#kbd_cr() - if res == "\" && g:vimwiki_table_mappings - let res = vimwiki#tbl#kbd_cr() - endif - return res - endfunction - autocmd filetype vimwiki inoremap =VimwikiCR()=AutoPairsReturn() - - to .vimrc, it will make vimwiki and auto-pairs 'Return' feature works together. - - Solution B: add `let g:AutoPairsMapCR = 0` to .vimrc to disable `` mapping. - -Compatible with viki - [issue #25](https://github.com/jiangmiao/auto-pairs/issues/25) - - Description: When works with viki `` will output viki#ExprMarkInexistentInElement('ParagraphVisible','') - Reason: viki uses `` on mapping `` that auto-pairs cannot expanding. - Solution A: Add - - autocmd filetype viki inoremap =viki#ExprMarkInexistentInElement('ParagraphVisible',"\n")=AutoPairsReturn()` - - to .vimrc, it will make viki and auto-pairs works together. - - Solution B: add `let g:AutoPairsMapCR = 0` to .vimrc to disable `` mapping. - - 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 ``. - Breaks '.' - [issue #3](https://github.com/jiangmiao/auto-pairs/issues/3) Description: After entering insert mode and inputing `[hello` then leave insert diff --git a/plugin/auto-pairs.vim b/plugin/auto-pairs.vim index 925aa35..0941f4e 100644 --- a/plugin/auto-pairs.vim +++ b/plugin/auto-pairs.vim @@ -442,11 +442,10 @@ function! AutoPairsInit() endfunction -function! s:ExpandMap(map) +function! s:ExpandMap(map, sid) let map = a:map - if map =~ '' - let map = substitute(map, '\(\w\+\)', '\=maparg(submatch(1), "i")', 'g') - endif + let map = substitute(map, '\(\w\+\)', '\=maparg(submatch(1), "i")', 'g') + let map = substitute(map, '', '' . a:sid . '_', 'g') return map endfunction @@ -469,26 +468,24 @@ function! AutoPairsTryInit() " Buffer level keys mapping " comptible with other plugin if g:AutoPairsMapCR - let old_cr = maparg('', 'i') - if old_cr == '' - let old_cr = '' + let info = maparg('', 'i', 0, 1) + if !empty(info) + let old_cr = info['rhs'] + if old_cr !~ 'AutoPairsReturn' + let old_cr = s:ExpandMap(old_cr, info['sid']) + if info['expr'] + " remap to OldCR to avoid mix expr and non-expr mode + let name = 'AutoPairsOldCRWrapper' + execute 'inoremap