LunarWatcher / auto-pairs

Vim plugin, insert or delete brackets, parentheses, and quotes in pairs
MIT License
173 stars 6 forks source link

Providing an option to skip setting up key maps in a file type? #67

Closed Frederick888 closed 2 years ago

Frederick888 commented 2 years ago

Another plugin that I use (registers.nvim) recently started using insert mode pop-ups, and I got hit by a compatibility issue between it and auto-pairs: https://github.com/tversteeg/registers.nvim/pull/68#issuecomment-1250607358

I had a glance at the code and it seems a clean solution is to simply skip setting up auto-pairs key maps if file type is registers.

I understand the long-term goal is skipping key maps while allowing auto-pairs to be re-enabled even if a buffer is in g:AutoPairsDirectoryBlacklist or g:AutoPairsFiletypeBlacklist, but in this case I really don't have the need to re-enable. So I wonder if it's ok to have some new options to achieve this for now? This seems quite straightforward and I'm happy to submit a PR. Thank you.

LunarWatcher commented 2 years ago

Nvim strikes again.

I assume you're referring to this:

https://github.com/LunarWatcher/auto-pairs/blob/8d00c1b1765935cf382465124eb07ced580621f0/autoload/autopairs.vim#L618-L619

What I have there is a hack. The long term is switching it out with a return, which will prevent auto-pairs from initialising altogether, but provide a non-standard alternative for manually enabling it (like a command). The idea there was to not initialise auto-pairs at all if it's a blacklisted directory or filetype.

I'm doubting whether an explicit reenable is needed though. I think, for now anyway, just switching it to a return is good enough. If that breaks someone's workflow, I can deal with that later. It's not too hard to implement anyway, but a secondary init command does potentially bring with it some edge-cases, particularly if it's incorrectly used.

A PR would be appreciated. I have a lot of stuff to do at the moment :upside_down_face: The docs for both variables also need to be updated to reflect that auto-pairs actually can't be enabled if those are triggered