jiangmiao / auto-pairs

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

AutoPairsJump() to <> #367

Closed sergiza closed 1 year ago

sergiza commented 1 year ago

I've defined some custom pairs but AutoPairsJump() doesn't seem to work with them.

Any way to make it at least work with <> ?

LunarWatcher commented 1 year ago

No. The values are hard-coded. You'd need to manually edit the code to make it work.

My fork supports this though. It auto-generates the regex based on all (active) pairs

sergiza commented 1 year ago

Thanks! I'll try it out.

sergiza commented 1 year ago

@LunarWatcher just one question if you don't mind, is there any quick way to remove all default mappings in your plugin? I just want to map the AutoPairsJump(), AutoPairsShortcutToggle and that's it, don't want anything else mapped.

LunarWatcher commented 1 year ago

Quick? No. You'd have to manually disable them (and I don't have any copypasta handy for it). There aren't that many though, and they're all in https://github.com/LunarWatcher/auto-pairs/blob/18fc5b659c4b0b1b3898f2b513e96bf90045be10/autoload/autopairs/Keybinds.vim#L202.

Could probably add a variable that disables default initialisation of keybind variables, but won't get around to that until tonight

sergiza commented 1 year ago

@LunarWatcher I had inoremap <C-l> <Esc>:call AutoPairsJump()<CR>a mapped, as a way to call AutoPairsJump only from insert mode and also customize a bit the behavior. Is it not possible to call AutoPairsJump() in your fork?

Also in your fork, AutoPairsJump() jumps ( |here| ), while in jiangmiao's version it jumps ()|here|. Wouldn't be an issue if I could :call AutoPairsJump() and just insert a <Right> at the end.

Sorry for bothering here in the comments of this issue, but I don't know if these nitpicks would make a good bug report / feature suggestion.

LunarWatcher commented 1 year ago

I had inoremap <C-l> <Esc>:call AutoPairsJump()<CR>a mapped, as a way to call AutoPairsJump only from insert mode and also customize a bit the behavior. Is it not possible to call AutoPairsJump() in your fork?

It is, but the function has been moved to an autoload script. You'll want inoremap <C-l> <Esc>:call autopairs#AutoPairsJump()<CR>a instead. It's otherwise identical. Most function calls have the autopairs# prefix in my fork, because most of them are in an autoload file. That's one of the incompatible changes between the two, but it makes for some significant QOL improvements with config files, particularly when setting g:AutoPairs (because the function calls can be placed in the .vimrc without an autocmd that's invoked after plugin load, and the files are loaded on-demand)

Also in your fork, AutoPairsJump() jumps ( |here| ), while in jiangmiao's version it jumps ()|here|. Wouldn't be an issue if I could :call AutoPairsJump() and just insert a <Right> at the end.

It should be identical. The only difference in my fork is the regex generation, but it can produce a regex identical to Jiangmiao's regex. Are you sure you're not comparing a manual call to your map? The a at the end is probably why you end up after rather than before

sergiza commented 1 year ago

Recorded a couple of gifs to show you the difference, with no configuration on either side.

jiangmiao : jiangmiao

@LunarWatcher : LunarWatcher

LunarWatcher commented 1 year ago

How do you trigger it? The map you showed earlier?

sergiza commented 1 year ago

Yeah, the only thing I configured in those examples is just let g:AutoPairsShortcutJump = '<c-l>']]. Maybe it's an issue with my mapping that i never realized 😅

LunarWatcher commented 1 year ago

Oh, I see. Might've accidentally changed the map somehow. I'll take a look later

LunarWatcher commented 1 year ago

Found the cause. Looks like there were some migration issues when event ignoring was added. There was an excess command that didn't have a at the end, and the first command was broken. Not entirely sure how I missed this, but whatever.

Fixed it and added regression tests, so should be good now