Open cormacrelf opened 4 years ago
You make some really good points and thank you for bringing this to my attention. I definitely don’t want to break other plugins or inefficiently set the mappings. I’ll look into it and see what I can do.
Actually, @cormacrelf since you have more opinions on the matter and ways to test it works correctly and solves your problem, would you be up to drafting a PR for this? :)
Bullets adds
autocommands for all its configured mappings. If
g:bullets_enable_in_empty_buffers
is set, then it also addsThe desired effect is that
:enew
empty buffers will have bullets enabled even before you add a filetype. However, this affects the buffers some plugins create that they want to add their own special mappings to. Essentially, UI plugins. I am usinggit-messenger.vim
, which does this:enew
gitmessengerpopup
But being a popup window, you don't BufEnter immediately. You have to trigger git-messenger again to switch into the window.
Bullets.vim's unnamed-buffer autocommands use BufEnter, which fires:
So Bullets.vim's autocommands fire twice: once after enew (step 2), and once again when you enter the popup buffer. Overwriting any configured mappings every time you enter an unnamed buffer. So Bullets.vim is forcing a race between plugins to be the last one to execute their mapping commands, and winning. This is the usual reason for plugins not working well together.
As for solutions? I don't think
g:bullets_enable_in_empty_buffers
should be enabled by default. I don't know if you agree. Either way, you have #4 and #44 specifically for buffers without a filetype, so it would be better not to check the buffer name (ie filename), but instead check whether filetype is empty. After all, we don't generally care whether a buffer has a filename or not when it comes to mappings. An example is in https://stackoverflow.com/a/46681816:So git-messenger.vim buffers, having been given a filetype, would no longer trigger Bullets.vim's mapping autocommands, and could win the race to be last.