Add if/when clauses or similar to the keymap system #35169
danielzdev
started this conversation in
Config, Settings and Keymaps
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
The current keymap context functionality in Zed offers powerful customization for when a keymap executes. However, I believe that adding "when" clauses (or more), similar to those found in VS Code, would significantly enhance this capability. For example, many keymaps currently lack a toggle function, requiring separate keybindings for opening and closing. With a "when" clause, I could simply use a single keymap to execute the close command if a specific panel, dock, or other element is already open, providing a more streamlined experience.
Something to the effect of:
{ "context": "Editor" "bindings": { "space e": [ { "command": "workspace::ToggleLeftDock", "when": "ProjectPanel && not_editing" }, { "command": "project_panel::ToggleFocus", "when": "VimControl && !menu || EmptyPane" } ] } }In fact, I would go so far as to say I would prefer this over just being able to have a specific keymap that now toggles, versus just opening and closing, since there's more customization on the users part.
Beta Was this translation helpful? Give feedback.
All reactions