Skip to content

Commit

Permalink
Merge pull request #86 from mmrwoods/master
Browse files Browse the repository at this point in the history
Possible workaround for compatibility hacks depending on plugin load order
  • Loading branch information
LunarWatcher authored Mar 7, 2024
2 parents 11fec74 + 0f4794a commit cd97efb
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 19 deletions.
22 changes: 22 additions & 0 deletions autoload/autopairs/Compat.vim
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
" Plugin compatibility hacks, one function per hack
" Called from VimEnter autocmd in plugin/autopairs.vim

" https://github.com/mg979/vim-visual-multi
" NOTE: the typo does NOT stem from auto-pairs; blame vim-visual-multi for
" that.
" If it ever changes, this will break. if it does, this is where to look to
" fix it.
fun! autopairs#Compat#visualMulti()
if exists('g:VM_plugins_compatibilty') || exists('*vm#maps#init')
" The test doesn't include any of the `exists`s, because it's pretty damn
" obvious that they exist when the plugin creating them is setting it.
" No need for those checks when it's set like this.
let g:VM_plugins_compatibilty = extend(get(g:, 'VM_plugins_compatibilty', {}), {
\'AutoPairs': {
\ 'test': { -> 1 },
\ 'enable': 'unlet b:autopairs_loaded | call autopairs#AutoPairsTryInit() | let b:autopairs_enabled = 1',
\ 'disable': 'let b:autopairs_enabled = 0',
\}
\})
endif
endfun
22 changes: 3 additions & 19 deletions plugin/autopairs.vim
Original file line number Diff line number Diff line change
Expand Up @@ -31,24 +31,8 @@ command! AutoPairsToggle call autopairs#AutoPairsToggle()
command! AutoPairsDisable let b:autopairs_enabled = 0 | echo "Disabled auto-pairs"
command! AutoPairsEnable let b:autopairs_enabled = 1 | echo "Enabled auto-pairs"

" Plugin compatibility

" https://github.com/mg979/vim-visual-multi
" NOTE: the typo does NOT stem from auto-pairs; blame vim-visual-multi for
" that.
" If it ever changes, this will break. if it does, this is where to look to
" fix it.
if exists('g:VM_plugins_compatibilty') || exists('*vm#maps#init')
" The test doesn't include any of the `exists`s, because it's pretty damn
" obvious that they exist when the plugin creating them is setting it.
" No need for those checks when it's set like this.
let g:VM_plugins_compatibilty = extend(get(g:, 'VM_plugins_compatibilty', {}), {
\'AutoPairs': {
\ 'test': { -> 1 },
\ 'enable': 'unlet b:autopairs_loaded | call autopairs#AutoPairsTryInit() | let b:autopairs_enabled = 1',
\ 'disable': 'let b:autopairs_enabled = 0',
\}
\})
endif
" Plugin compatibility, see autoload/autopairs/Compat.vim
autocmd VimEnter *
\ call autopairs#Compat#visualMulti()

" vim:sw=4:expandtab

0 comments on commit cd97efb

Please sign in to comment.