Open
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.
Author
|
@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 file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.