Open jaidetree opened 2 years ago
and must contain whichKeyVisible which limits this shortcut to be only applicable when the which-key menu is visible
I think I missed that caveat. That said is there a way to trigger a submenu without which-key already visible?
Found one solution:
{
"key": "shift+2",
"command": "extension.multiCommand.execute",
"args": {
"sequence": [
"vspacecode.space",
{ "command": "whichkey.triggerKey", "args": "@" },
],
},
"when": "!whichKeyVisible && editorLangId == 'magit' && vim.mode =~ /^(?!SearchInProgressMode|CommandlineInProgress).*$/"
},
It works! But downside is requires the multiCommand extension. If there's a cleaner way, I'd love to see a better solution
Let me make sure I understand the problem. You are trying to have @
to open the which-key menu that's equal to SPC w
when the current editor is magit editor.
Your workaround is probably the best bet currently. I thought about adding keys sequence to the show
API which is used by vspacecode.space
so I user can bind a command to do exactly what you are trying to do.
Also, per buffer remapping in vim was mentioned on https://github.com/VSCodeVim/Vim/issues/4765#issuecomment-706542295
Let me make sure I understand the problem. You are trying to have
@
to open the which-key menu that's equal toSPC w
when the current editor is magit editor.
That’s correct.
Your workaround is probably the best bet currently. I thought about adding keys sequence to the
show
API which is used byvspacecode.space
so I user can bind a command to do exactly what you are trying to do.
I’m willing to give a PR for that a shot if you’re open to it.
Will try the per-buffer remapping approach as well
I’m willing to give a PR for that a shot if you’re open to it.
Sure :) Let me know if you have any questions.
Will try the per-buffer remapping approach as well
Unfortunately, that's just a thread mentioning that functionality doesn't exist today.
I’m willing to give a PR for that a shot if you’re open to it.
Sure :) Let me know if you have any questions.
Great will do!
Will try the per-buffer remapping approach as well
Unfortunately, that's just a thread mentioning that functionality doesn't exist today.
Oh my mistake, I misunderstood there but your reply probably just saved me a good chunk of time 😅
Bug description
Trying to create some bindings to recreate the use of forge to manage pull-requests. Reading the docs suggests triggerKey should do the job. If I bind it from settings.json to go through the
normalModeKeyBindingsNonRecursive
it works, but it rebinds the key everywhere.Ideally the triggerKey binding should only function when in a magit buffer. I copied an example from how the
x
key is bound in magit like the following:To Reproduce
keybindings.json
and add the following:SPC g s
by default I think?shift+2
or@
Expected behavior
Given the configuration, my understanding is that it should trigger the window menu (
SPC w
) to open in the magit buffer. I'm using the window menu for test purposes but it shouldn't matter which menu is chosen, it has not worked with any of them.Actual behavior
Nothing happens, the magit buffer stays open and I don't see the which-key menu.
Additional context
By replacing the command with
workbench.action.showCommands
the binding works and the command panel is displayed as expected which suggestswhichkey.triggerKey
is firing.If you add the following to
settings.json
in avim.normalModeKeyBindingsNonRecursive
:And press
@
anywhere, it works as expected showing the window menuKeybindings
Click to toggle contents of `keybindings.json`
```jsonc // Place your key bindings in this file to override the defaultsauto[] [ { "key": "ctrl+space", "command": "-extension.vim_ctrl+space", "when": "editorTextFocus && vim.active && vim.use && !inDebugRepl && vim.mode != 'Insert'"
},
{
"key": "cmd+k cmd+b",
"command": "workbench.action.toggleSidebarVisibility"
},
{
"key": "ctrl+j",
"command": "workbench.action.focusBelowGroup",
"when": "editorTextFocus && vim.active && vim.use && !inDebugRepl"
},
{
"key": "ctrl+k",
"command": "workbench.action.focusAboveGroup",
"when": "editorTextFocus && vim.active && vim.use && !inDebugRepl"
},
{
"key": "ctrl+h",
"command": "workbench.action.focusLeftGroup",
"when": "editorTextFocus && vim.active && vim.use && !inDebugRepl"
},
{
"key": "ctrl+l",
"command": "workbench.action.focusRightGroup",
"when": "editorTextFocus && vim.active && vim.use && !inDebugRepl"
},
{
"key": "space",
"command": "vspacecode.space",
"when": "activeEditorGroupEmpty && focusedView == '' && !whichkeyActive && !inputFocus"
},
{
"key": "space",
"command": "vspacecode.space",
"when": "sideBarFocus && !inputFocus && !whichkeyActive"
},
{
"key": "tab",
"command": "extension.vim_tab",
"when": "editorFocus && vim.active && !inDebugRepl && vim.mode != 'Insert' && editorLangId != 'magit'"
},
{
"key": "tab",
"command": "-extension.vim_tab",
"when": "editorFocus && vim.active && !inDebugRepl && vim.mode != 'Insert'"
},
{
"key": "x",
"command": "magit.discard-at-point",
"when": "editorTextFocus && editorLangId == 'magit' && vim.mode =~ /^(?!SearchInProgressMode|CommandlineInProgress).*$/"
},
{
"key": "k",
"command": "-magit.discard-at-point"
},
{
"key": "-",
"command": "magit.reverse-at-point",
"when": "editorTextFocus && editorLangId == 'magit' && vim.mode =~ /^(?!SearchInProgressMode|CommandlineInProgress).*$/"
},
{
"key": "v",
"command": "-magit.reverse-at-point"
},
{
"key": "shift+-",
"command": "magit.reverting",
"when": "editorTextFocus && editorLangId == 'magit' && vim.mode =~ /^(?!SearchInProgressMode|CommandlineInProgress).*$/"
},
{
"key": "shift+v",
"command": "-magit.reverting"
},
{
"key": "shift+o",
"command": "magit.resetting",
"when": "editorTextFocus && editorLangId == 'magit' && vim.mode =~ /^(?!SearchInProgressMode|CommandlineInProgress).*$/"
},
{
"key": "shift+x",
"command": "-magit.resetting"
},
{
"key": "x",
"command": "-magit.reset-mixed"
},
{
"key": "ctrl+u x",
"command": "-magit.reset-hard"
},
{
"key": "y",
"command": "-magit.show-refs"
},
{
"key": "y",
"command": "vspacecode.showMagitRefMenu",
"when": "editorTextFocus && editorLangId == 'magit' && vim.mode == 'Normal'"
},
{
"key": "ctrl+j",
"command": "workbench.action.quickOpenSelectNext",
"when": "inQuickOpen"
},
{
"key": "ctrl+k",
"command": "workbench.action.quickOpenSelectPrevious",
"when": "inQuickOpen"
},
{
"key": "ctrl+j",
"command": "selectNextSuggestion",
"when": "suggestWidgetMultipleSuggestions && suggestWidgetVisible && textInputFocus"
},
{
"key": "ctrl+k",
"command": "selectPrevSuggestion",
"when": "suggestWidgetMultipleSuggestions && suggestWidgetVisible && textInputFocus"
},
{
"key": "ctrl+l",
"command": "acceptSelectedSuggestion",
"when": "suggestWidgetMultipleSuggestions && suggestWidgetVisible && textInputFocus"
},
{
"key": "ctrl+j",
"command": "showNextParameterHint",
"when": "editorFocus && parameterHintsMultipleSignatures && parameterHintsVisible"
},
{
"key": "ctrl+k",
"command": "showPrevParameterHint",
"when": "editorFocus && parameterHintsMultipleSignatures && parameterHintsVisible"
},
{
"key": "ctrl+h",
"command": "file-browser.stepOut",
"when": "inFileBrowser"
},
{
"key": "ctrl+l",
"command": "file-browser.stepIn",
"when": "inFileBrowser"
},
{
"key": "shift-2",
"command": "whichkey.triggerKey",
"args": {
"key": "w",
"when": "editorTextFocus && editorLangId == 'magit' && vim.mode =~ /^(?!SearchInProgressMode|CommandlineInProgress).*$/"
},
"when": "editorTextFocus && editorLangId == 'magit' && vim.mode =~ /^(?!SearchInProgressMode|CommandlineInProgress).*$/"
},
]
```
Settings
My settings file is gigantic right now having a copy of all the default which-key-bindings and is 7k lines long about 360 kb.
I've attached it in a zip manually below
settings.json.zip
System information
This tool is still great and I'm looking forward to using it more! 🙂