Skip to content
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

Refactor plugin to use AnActionListener on messageBus #90

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

luqasn
Copy link
Contributor

@luqasn luqasn commented Feb 4, 2025

instead of hooking into ideavim internals.
Also fixes some minor mapping bugs.

  • check g:WhichKeyProcessUnknownMappings=false still works with this

Fixes #88
Fixes #81
Fixes #71
Fixes #52

instead of hooking into ideavim internals.
Also fixes a bug with gg/zz leaving a dangling popup at the end of the
sequence.
@luqasn
Copy link
Contributor Author

luqasn commented Feb 5, 2025

We could let jetbrains know at https://youtrack.jetbrains.com/issue/VIM-3085 after merging (if we merge)

@luqasn
Copy link
Contributor Author

luqasn commented Feb 8, 2025

This new code now also allows to intercept Escape, so I added a commit that allows closing the which-key popup using escape. But I now noticed that it isn't quite that simple, it should also check if which-key is even open and that ESC isn't a valid target given the current key sequence. I'll add that in the coming days.

@luqasn luqasn marked this pull request as draft February 8, 2025 22:25
@luqasn luqasn force-pushed the action-listener-refactor branch from 4f4e50b to 22ace42 Compare February 9, 2025 09:05
@luqasn luqasn marked this pull request as ready for review February 9, 2025 09:06
@luqasn
Copy link
Contributor Author

luqasn commented Feb 9, 2025

This new code now also allows to intercept Escape, so I added a commit that allows closing the which-key popup using escape. But I now noticed that it isn't quite that simple, it should also check if which-key is even open and that ESC isn't a valid target given the current key sequence. I'll add that in the coming days.

Implemented this now, good to go 👍

@luqasn
Copy link
Contributor Author

luqasn commented Feb 9, 2025

I think because this acts after key press now (at least for non-special keys) that it probably broke g:WhichKeyProcessUnknownMappings=false. I'll have to test it.

@TheBlob42
Copy link
Owner

I just tested your PR now with the following .ideavimrc and the bindings for <C-w> don't work, but maybe I am missing something here 🤔 or did I understand your comment here wrong?

set which-key
set notimeout

let g:WhichKey_ShowVimActions = "true"

Also pressing for example gg closes the popup first, but then reopens it again

@luqasn
Copy link
Contributor Author

luqasn commented Feb 9, 2025

Strange, these are all things that should work and that I tested. But not with a minimal config but instead with my lazyvim-oriented config (cufarvid/lazy-idea#3).
I'll test this with a minimal config.

@luqasn
Copy link
Contributor Author

luqasn commented Feb 9, 2025

Tested this with your example config. Very weird, for me <c-W> properly shows the popup, while gdoesn't open the popup at all because the mappingState has an empty key sequence.

Will need to investigate further.

@luqasn
Copy link
Contributor Author

luqasn commented Feb 9, 2025

Okay, interesting learning:
LazyVim has custom actions that start with g, which is why it worked when I had them enabled.
Because as it turns out, what happens is that mappingState only tracks keys for user-defined mappings. If there is no match, the keys get detached, a.k.a. the sequence is cleared, but they are still (or only then?) tracked in commandBuilder.
So I somehow have to come up with a logical way to look at commandBuilder and mappingState in combination.

because these sequences don't get tracked in mappingState if there is no
matching user binding. Instead, they are tracked in commandBuilder.
@luqasn
Copy link
Contributor Author

luqasn commented Feb 9, 2025

I pushed a fix for my own gg issue, please test again. This stuff is so complex, underdocumented and hard to get right...

@luqasn
Copy link
Contributor Author

luqasn commented Feb 9, 2025

This still does not explain why <c-w didn't work for you though. If that still persists, we need to find out what is different between our two setups. I run this with runIde from a 'normal' intelliJ and then a 'bare bones', older intelliJ version with the current dev version of which-key starts in which I test and back in the "original" intelliJ I can put breakpoints and debug.
How do you test this?

@TheBlob42
Copy link
Owner

I usually test by building the plugin and installing it locally (as runIde crashes on my laptop for some reason from time to time). Maybe I installed the wrong version locally, so I'll check that again 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants