-
Notifications
You must be signed in to change notification settings - Fork 35
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
Open
mmrwoods
wants to merge
7
commits into
rhysd:master
Choose a base branch
from
mmrwoods:vim-popupwin
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Conversation
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
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.
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.