jiangmiao / auto-pairs

Vim plugin, insert or delete brackets, parens, quotes in pair
http://www.vim.org/scripts/script.php?script_id=3599
4.11k stars 373 forks source link

Adding new pairs to g:AutoPairs does not work #280

Open madmansnest opened 4 years ago

madmansnest commented 4 years ago

Sorry if this is a noob problem, and I am missing something obvious.

I’d like to define more global pairs in addition to default ones. I am trying this by using an example given in the README and changing b:AutoPairs to g:AutoPairs:

let g:AutoPairs = AutoPairsDefine({'«' : '»'})

This is located in my config after Plug 'jiangmiao/auto-pairs' line, plugin is installed and default pairs work.

However, if I save and source the config file, no errors are output but new pairs do not work. But if I quit and reopen vim, I get an Unknown function: AutoPairsDefine error. If I run the line from vim, and then run :echo g:AutoPairs, it shows the new pair, however, it does not work in insert mode still. Using b:AutoPairs gives the same result.

grenzionky commented 4 years ago

i have the same issue https://github.com/jiangmiao/auto-pairs/issues/260

no unicode character works for me

doing =AutoPairsInsert('«') manually actually does work.


the error is in this line

execute 'inoremap <buffer> <silent> '.key." <C-R>=AutoPairsInsert('".escaped_key."')<CR>"

it ends up typing

=AutoPairsInsert('Â)«

instead of

=AutoPairsInsert('«')


EDIT: i figured it out and made a pull request https://github.com/jiangmiao/auto-pairs/pull/284 for the meantime, you can just save ↓ to a file (for the example we'll call it auto-pairs.patch)

494,495c494,495
<     let o = open[-1:-1]
<     let c = close[0]
---
>     let o = open
>     let c = close

put the file in the same directory as the plugin (ie ~/.vim/plugged/auto-pairs/plugin/), then execute

patch < auto-pairs.patch

to enable the fix

dseeni commented 4 years ago

I can't get

let g:AutoPairs['<']='>'

to work either? Anyone else have this issue? The help docs say it's just a matter of adding that line in the .vimrc... not sure what I'm doing wrong.

SwampertX commented 4 years ago

I have the same issue too, using NeoVim 0.5-dev. The variable is simply unchanged.

grenzionky commented 4 years ago

My patch didn't work?

thorlucas commented 4 years ago

I'm not getting < or > to work either. Additionally, actually removing a pairing from the dictionary does not work either. So I can only conclude that the dictionary does nothing. Also on NeoVim