-
Notifications
You must be signed in to change notification settings - Fork 34
Add support for Vim 8.1+ popup windows #99
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
b7fdb69 to
47da31c
Compare
This adds optional support for using Vim popup windows, which must be enabled by setting g:git_messenger_vimpopup_enabled to v:true, and works similar to Neovim with g:git_messenger_always_into_popup set to v:true It does require quite a bit of conditional code as you cannot enter a Vim popup, unlike a Neovim float or the preview window, but it works! Has been tested, manually, with Vim 8.1.2384 (first version of Vim to include support for +popupwin) and with Vim 9.1.950, both work fine. There are some limitations as you can't enter the popup, for example key mappings are specified in a filter function, not as buffer local maps, and there are likely to be some bugs as this is new, but generally it works as you probably expect, the popup opens in the same position as the Neovim floating window, the git-messenger mappings work, running the :GitMessenger command opens and closes the popup, mouse scrolling works, and some keys like CTRL-U, CTRL-D are mapped for scrolling up and down.
These are required for the popup to function correctly, so make it an error to try and override them via g:git_messenger_vimpopup_win_opts
When g:git_messenger_close_on_cursor_moved is set to v:false, plugin-git-messenger-close autocmd won't exist, so use :silent!
This updates the behaviour when Vim popup is enabled to work more like Neovim floating windows or the preview window. Entering a vim popup is emulated by initially disabling popup keymaps, and only enabling them once the popup is marked as "entered", which means the default behaviour is now almost identical for Vim popup, Neovim float and preview window. Running :GitMessenger opens the Vim popup, running it again enables the keymaps so you can navigate within the popup, running it again closes the popup, and g:git_messenger_always_into_popup is also respected.
Needed to ensure the popup is not only closed, but opener buffer local variable storing a reference to the popup object/dict also removed. Without this switching windows or buffers while the popup is open leaves the buffer local var behind and breaks future calls to :GitMessenger
As you can't enter a Vim popup window, you can't easily yank the current commit hash, and that seems a natural thing to want to do (I certainly found myself wanting to do it soon after starting to use git-messenger). To address this, map 'c' to yank the current commit hash to v:register (kind of, while the code behaves the same as using v:register, it doesn't actually use v:register due to some clash with vim-cutlass). While this is added primarily to aid Vim popup users, it doesn't break anything for Neovim floating win or preview window users as the buffer is not modifiable, and it seems a handy mapping for all users anyway.
|
@rhysd Sorry, I'd forgotten to follow up on this... I've been using this code supporting Vim popup windows without any trouble since last May. Most of the changes only apply conditionally when If you have some time to take a look that would be great. Happy to answer any questions, make suggested changes. Thanks! |
This adds optional support for using Vim popup windows, which must be
enabled by setting g:git_messenger_vimpopup_enabled to v:true, and works
similar to Neovim with g:git_messenger_always_into_popup set to v:true
It does require quite a bit of conditional code as you cannot enter a
Vim popup, unlike a Neovim float or the preview window, but it works!
Has been tested, manually, with Vim 8.1.2384 (first version of Vim to
include support for +popupwin) and with Vim 9.1.950, both work fine.
There are some limitations as you can't enter the popup, for example key
mappings are specified in a filter function, not as buffer local maps,
and there are likely to be some bugs as this is new, but generally it
works as you probably expect, the popup opens in the same position as
the Neovim floating window, the git-messenger mappings work, running the
:GitMessenger command opens and closes the popup, mouse scrolling works,
and some keys like CTRL-U, CTRL-D are mapped for scrolling up and down.