custom keybind is lower precedence than vim keybind
Check for existing issues
- [X] Completed
Describe the bug / provide steps to reproduce it
I can't because multiple keybinds work normally while overwriting the default vim keybind, but one doesn't.
Environment
Zed: v0.161.2 (Zed) OS: Linux Wayland nixos 25.05 Memory: 3.5 GiB Architecture: x86_64 GPU: Intel(R) Graphics (ADL-N) || Intel open-source Mesa driver || Mesa 24.2.6
If applicable, add mockups / screenshots to help explain present your vision of the feature
a keybind that works:
and a keybind that doesn't:
(the vim mode was insert, but my screenshot tool updated the context)
If applicable, attach your Zed.log file to this issue.
Zed.log
2024-11-30T11:32:08.313041988+01:00 [INFO] ========== starting zed ==========
2024-11-30T11:32:08.424142075+01:00 [INFO] Opening main db
2024-11-30T11:32:08.426613281+01:00 [INFO] perform;
2024-11-30T11:32:08.426681127+01:00 [INFO] authenticate;
2024-11-30T11:32:08.427500992+01:00 [INFO] read_command;
2024-11-30T11:32:08.432375326+01:00 [INFO] socket reader;
2024-11-30T11:32:08.432696013+01:00 [INFO] new;
2024-11-30T11:32:08.433065404+01:00 [INFO] Opening main db
2024-11-30T11:32:08.435486482+01:00 [INFO] keep_updated;
2024-11-30T11:32:08.441460141+01:00 [INFO] Using git binary path: None
2024-11-30T11:32:08.453260664+01:00 [INFO] no tokio runtime found, creating one for Reqwest...
2024-11-30T11:32:08.488592611+01:00 [INFO] set environment variables from shell:/run/current-system/sw/bin/bash, path:/nix/store/rsl5pj2xkhbrpfw60w8asz6ln27lv5fc-kitty-0.37.0/bin:/nix/store/ym0d0c1hpxinxvr2qrfg1d1b9wnz6i71-imagemagick-7.1.1-40/bin:/nix/store/inpspwqhgpld2zdk89hra7xjh3nxll2x-ncurses-6.4.20221231-dev/bin:/run/wrappers/bin:/home/penzboti/.nix-profile/bin:/nix/profile/bin:/home/penzboti/.local/state/nix/profile/bin:/etc/profiles/per-user/penzboti/bin:/nix/var/nix/profiles/default/bin:/run/current-system/sw/bin:/nix/store/9bacph866qhmr2zfib1h49jixq5hhd01-binutils-wrapper-2.43.1/bin:/nix/store/m3b8p80179lk83w6hpzjxn6wd6hk80xx-pciutils-3.13.0/bin:/nix/store/6rh5syqf6nv5l84vn4a9qp22yrixlaw3-pkgconf-wrapper-2.3.0/bin:/home/penzboti/.spicetify:/nix/store/0xvgzkl74v6jrh79ibh7ss770dh4hb69-nodejs-22.10.0/bin
2024-11-30T11:32:08.528705433+01:00 [ERROR] theme not found: Catppuccin Mocha
2024-11-30T11:32:08.529309816+01:00 [ERROR] No such file or directory (os error 2) about ["/home/penzboti/.config/github-copilot"]
2024-11-30T11:32:08.533453985+01:00 [INFO] initializing context server client
2024-11-30T11:32:08.534692115+01:00 [INFO] Registering built-in prompt template: content_prompt
2024-11-30T11:32:08.536544092+01:00 [INFO] Registering built-in prompt template: project_slash_command
2024-11-30T11:32:08.536627329+01:00 [INFO] Registering built-in prompt template: suggest_edits
2024-11-30T11:32:08.536873803+01:00 [INFO] Registering built-in prompt template: terminal_assistant_prompt
2024-11-30T11:32:08.537656247+01:00 [INFO] No prompt template overrides directory found at /home/penzboti/.local/share/zed/prompt_overrides. Using built-in prompts.
2024-11-30T11:32:08.543424092+01:00 [INFO] extensions updated. loading 4, reloading 0, unloading 0
2024-11-30T11:32:08.558846334+01:00 [INFO] activate is not implemented on Linux, ignoring the call
2024-11-30T11:32:08.573191584+01:00 [INFO] perform;
2024-11-30T11:32:08.573246608+01:00 [INFO] authenticate;
2024-11-30T11:32:08.573304023+01:00 [INFO] read_command;
2024-11-30T11:32:08.574406735+01:00 [INFO] socket reader;
2024-11-30T11:32:08.586177888+01:00 [INFO] Opening main db
2024-11-30T11:32:08.593682438+01:00 [ERROR] DBus error service error org.freedesktop.zbus.Error: The name org.freedesktop.secrets was not provided by any .service files
2024-11-30T11:32:08.676752447+01:00 [INFO] Enabling Vulkan Portability
2024-11-30T11:32:08.676793309+01:00 [INFO] Enabling color space support
2024-11-30T11:32:08.702584766+01:00 [INFO] Adapter: "Intel(R) Graphics (ADL-N)"
2024-11-30T11:32:08.702657965+01:00 [INFO] No ray tracing extensions are supported
2024-11-30T11:32:08.705597219+01:00 [INFO] Using surface present mode MAILBOX
2024-11-30T11:32:08.705982672+01:00 [WARN] Unable to forbid exclusive full screen
2024-11-30T11:32:08.706502278+01:00 [INFO] Creating a descriptor pool for at most 16 sets
2024-11-30T11:32:08.706649082+01:00 [INFO] Creating a descriptor pool for at most 16 sets
2024-11-30T11:32:08.706788914+01:00 [INFO] Initializing Blade pipelines for surface SurfaceInfo { format: Bgra8UnormSrgb, alpha: PreMultiplied }
2024-11-30T11:32:08.723738807+01:00 [INFO] Using GPU: GPUSpecs { is_software_emulated: false, device_name: "Intel(R) Graphics (ADL-N)", driver_name: "Intel open-source Mesa driver", driver_info: "Mesa 24.2.6" }
2024-11-30T11:32:08.72689806+01:00 [INFO] Using surface present mode MAILBOX
2024-11-30T11:32:08.727331721+01:00 [WARN] Unable to forbid exclusive full screen
2024-11-30T11:32:08.727583023+01:00 [INFO] Initializing Blade pipelines for surface SurfaceInfo { format: Bgra8UnormSrgb, alpha: Ignored }
2024-11-30T11:32:08.737680734+01:00 [INFO] Using surface present mode MAILBOX
2024-11-30T11:32:08.738071466+01:00 [WARN] Unable to forbid exclusive full screen
2024-11-30T11:32:08.763559715+01:00 [INFO] Opening main db
2024-11-30T11:32:08.781904736+01:00 [INFO] Using surface present mode MAILBOX
2024-11-30T11:32:08.78256755+01:00 [WARN] Unable to forbid exclusive full screen
2024-11-30T11:32:08.784680176+01:00 [INFO] Using surface present mode MAILBOX
2024-11-30T11:32:08.785443221+01:00 [WARN] Unable to forbid exclusive full screen
2024-11-30T11:32:08.793892528+01:00 [INFO] open paths ["/home/penzboti/.config/zed/keymap.json"]
2024-11-30T11:32:08.806680368+01:00 [INFO] Opening main db
2024-11-30T11:32:08.905188567+01:00 [ERROR] missing field `name` at line 23 column 1
2024-11-30T11:32:08.933920595+01:00 [INFO] using project environment variables from CLI. PATH="/nix/store/rsl5pj2xkhbrpfw60w8asz6ln27lv5fc-kitty-0.37.0/bin:/nix/store/ym0d0c1hpxinxvr2qrfg1d1b9wnz6i71-imagemagick-7.1.1-40/bin:/nix/store/inpspwqhgpld2zdk89hra7xjh3nxll2x-ncurses-6.4.20221231-dev/bin:/run/wrappers/bin:/home/penzboti/.nix-profile/bin:/nix/profile/bin:/home/penzboti/.local/state/nix/profile/bin:/etc/profiles/per-user/penzboti/bin:/nix/var/nix/profiles/default/bin:/run/current-system/sw/bin:/nix/store/9bacph866qhmr2zfib1h49jixq5hhd01-binutils-wrapper-2.43.1/bin:/nix/store/m3b8p80179lk83w6hpzjxn6wd6hk80xx-pciutils-3.13.0/bin:/nix/store/6rh5syqf6nv5l84vn4a9qp22yrixlaw3-pkgconf-wrapper-2.3.0/bin:/home/penzboti/.spicetify"
2024-11-30T11:32:08.971704587+01:00 [INFO] attempting to start language server "json-language-server", path: "/home/penzboti/.config/zed/keymap.json", id: 1
2024-11-30T11:32:08.971835282+01:00 [INFO] Initializing default prettier with plugins {}
2024-11-30T11:32:08.976398276+01:00 [INFO] Initializing default prettier with plugins {}
2024-11-30T11:32:08.977924513+01:00 [INFO] fetching latest version of language server "json-language-server"
2024-11-30T11:32:09.09874079+01:00 [INFO] attempting to start language server "rust-analyzer", path: "/home/penzboti/programming/advent-of-code/2024", id: 2
2024-11-30T11:32:09.099246971+01:00 [INFO] Initializing default prettier with plugins {}
2024-11-30T11:32:09.10107018+01:00 [INFO] found rust-analyzer in PATH. trying to run `rust-analyzer --help`
2024-11-30T11:32:09.622793371+01:00 [INFO] starting language server process. binary path: "/nix/store/0xvgzkl74v6jrh79ibh7ss770dh4hb69-nodejs-22.10.0/bin/node", working directory: "/", args: ["/home/penzboti/.local/share/zed/copilot/copilot-v0.5.0/dist/agent.js", "--stdio"]
2024-11-30T11:32:10.042849288+01:00 [INFO] Initializing default prettier with plugins {}
2024-11-30T11:32:10.386373843+01:00 [ERROR] failed to run rust-analyzer after detecting it in PATH: binary: "/run/current-system/sw/bin/rust-analyzer": exit status: 1, stdout: "", stderr: "error: Unknown binary 'rust-analyzer' in official toolchain 'stable-x86_64-unknown-linux-gnu'.\n"
2024-11-30T11:32:10.386507704+01:00 [INFO] fetching latest version of language server "rust-analyzer"
2024-11-30T11:32:10.67053053+01:00 [INFO] Language server with id 0 sent unhandled notification LogMessage:
{
"level": 0,
"message": "[DEBUG] [agent] [2024-11-30T10:32:10.654Z] Agent service starting",
"metadataStr": "[DEBUG] [agent] [2024-11-30T10:32:10.654Z]",
"extra": [
"Agent service starting"
]
}
2024-11-30T11:32:10.674595768+01:00 [INFO] Language server with id 0 sent unhandled notification client/registerCapability:
{
"registrations": [
{
"id": "227a06bc-315a-4c65-b33d-6db1e416f1a8",
"method": "workspace/didChangeWorkspaceFolders",
"registerOptions": {}
}
]
}
2024-11-30T11:32:10.734623712+01:00 [INFO] Language server with id 0 sent unhandled notification LogMessage:
{
"level": 0,
"message": "[DEBUG] [agent] [2024-11-30T10:32:10.688Z] Telemetry initialized",
"metadataStr": "[DEBUG] [agent] [2024-11-30T10:32:10.688Z]",
"extra": [
"Telemetry initialized"
]
}
2024-11-30T11:32:10.899121534+01:00 [INFO] downloading language server "json-language-server"
2024-11-30T11:32:11.251350599+01:00 [INFO] downloading language server "rust-analyzer"
2024-11-30T11:32:11.251491879+01:00 [INFO] using project environment for language server LanguageServerName("rust-analyzer")
2024-11-30T11:32:11.252023116+01:00 [INFO] starting language server process. binary path: "/home/penzboti/.local/share/zed/languages/rust-analyzer/rust-analyzer-2024-11-25", working directory: "/home/penzboti/programming/advent-of-code/2024", args: []
2024-11-30T11:32:11.286153777+01:00 [INFO] using project environment for language server LanguageServerName("json-language-server")
2024-11-30T11:32:11.286318568+01:00 [INFO] starting language server process. binary path: "/nix/store/0xvgzkl74v6jrh79ibh7ss770dh4hb69-nodejs-22.10.0/bin/node", working directory: "/home/penzboti/.config/zed", args: ["/home/penzboti/.local/share/zed/languages/json-language-server/node_modules/vscode-langservers-extracted/bin/vscode-json-language-server", "--stdio"]
2024-11-30T11:32:12.448697451+01:00 [ERROR] No such file or directory (os error 2) about ["/home/penzboti/.config/rust-analyzer"]
2024-11-30T11:32:14.453230514+01:00 [ERROR] No such file or directory (os error 2) about ["/home/penzboti/.config/rust-analyzer"]
2024-11-30T11:32:14.466486761+01:00 [WARN] Generic lsp request to rust-analyzer failed: content modified
2024-11-30T11:32:14.466833218+01:00 [ERROR] content modified
2024-11-30T11:32:15.365846837+01:00 [WARN] Generic lsp request to rust-analyzer failed: content modified
@penzboti on Linux, ctrl-k is used to namespace a large number of extra Zed commands. If you want to bind to it, you'll want to create a binding to null to disable the other ones.
After setting ctrl-k to null, when no context is present, it does not do anything, even while keymap in the previous picture is still there.
And also, i found out, that lower precedence also applies to keybinds that have never been assigned.
oh. I thought from your previous
I looked into this a bit today, and I can reproduce the problem with ctrl-k; I am not sure yet why it is broken.
You also seem to have issues with é being spelled as eacute - I'd like to fix this when we do the next pass on Linux shortcuts.
Related problem with key precedence: There a number of default bindings that I can't override except with null.
e.g. I was setting up more helix-like tab throughs.:
Defaults
{
"context": "Editor && showing_completions",
"bindings": {
"enter": "editor::ConfirmCompletion",
"tab": "editor::ComposeCompletion"
}
},
Custom -- higher precedence, will override
[
{
"context": "Editor && showing_completions",
"bindings": {
"tab": null,
"shift-tab": null
}
},
Custom -- low precedence, won't work
[
{
"context": "Editor && showing_completions",
"bindings": {
"tab": "menu::SelectNext",
"shift-tab": "editor::ContextMenuPrev"
}
},
(Adjusting the location of the overrides in the keymap.json also had no effect. Precedence viewed with the KeybindDebugger)
Edit
menu::SelectNext ~~> editor::ContextMenuNext does override.
But the failure with menu::SelectNext is "(low precedence)" not "(no match)". The docs suggest that it's the context menu depth && rule ordering to tie break that impact precedence.
Does the command itself carry a precedence modifier? (e.g. related to parent [pre-::])
It does seems like the commands themselves have their own precedence, and that's really confusing and doesn't line up with the documentation.
I'm struggling with a few cases of precedence and now wondering if I am hitting this issue. Discord reference: https://discord.com/channels/869392257814519848/1250470360139300934/1378120458095820891.
I cannot get this key binding to work:
Interesting, making the context be "" worked at least in this case:
{
"context": "",
"bindings": {
"cmd-o": ["projects::OpenRecent", { "create_new_window": true }]
}
}
Ah, just realized that the default bindings are defined thus:
// Standard macOS bindings
{
"use_key_equivalents": true,
And if I omit condition in mine too then that also works (in addition to empty string mentioned above).
I’m also running into this (Zed v0.191.7) – I cannot redefine an existing g … Vim binding nor define one that’s unused in the Zed’s default Vim bindings to execute a command.
{
"context": "VimControl",
"bindings": {
"g m": "agent::Chat"
}
}
When typing the bound keys with key context view open, I see:
I can’t find any value for context which will let the binding activate. Using other modifiers also doesn’t work – if I try ⌘⌥m, which seems to have no default binding:
However I did notice that Zed’s default example binding did work:
{
"context": "Editor",
"bindings": {
"j k": ["workspace::SendKeystrokes", "escape"]
}
}
(not possible to show the key context view output because it shows the out of the Escape key sent by the command)
If I rewrite my desired command to also use SendKeystrokes, it works as intended 😕:
{
"context": "VimControl",
"bindings": {
"g m": [
"workspace::SendKeystrokes",
"cmd-shift-p a g e n t n e w t h r e a d enter"
]
}
}
Hopefully that’s a clue as to the cause of the bug, and a workaround for anyone else finding this thread in the meantime.🫡
Yeah, it feels like the precedence depends on the command that is being executed. It pretty much happens for me as well while trying to rebind the ctrl-g for the editor while trying to emulate a Emacs-like "cancel" command.
The default keybinding is mapped to opening the "go to line window":
{
"context": "Editor && mode == full",
"bindings": {
"ctrl-shift-o": "outline::Toggle",
"ctrl-g": "go_to_line::Toggle"
}
},
And when you try to override it in your own config using the "editor::Cancel" action, it shows a "low precedence" match on the Keyboard context debug view:
{
"context": "Editor && mode == full",
"bindings": {
"ctrl-g": "editor::Cancel"
}
},
However, if you change the "editor::Cancel" by some other action, like, "editor::ShowCompletions", it works as expected.
editor::Cancel hits another problematic edge case which is that it calls cx.propagate() – this is so that menu::Cancel will be triggered when you hit escape in an editor (despite editor::Cancel being first).
The key context view can't currently represent this situation either which doesn't help – it shows the last action dispatched, so whatever the cx.propagate() bubbled to – so I suspect what's happening is that it is doing editor::Cancel, but there are no menus/completions to dismiss, and so it bubbles to call go_to_line::Toggle.
Unfortunately I don't think the current keymaps can give you enough control to deal with this propagation. It seems like either we should:
- Make it so that if you have a
{"ctrl-g": null}in one binding section and then{"ctrl-g": "editor::Cancel"}in another, the null cancels any propagation that would occur after theeditor::Cancel. - Change the way the editor registers actions to only register the cancel action when it would do something.
Both seem a little gnarly though probably the first is better (albeit very hard to discover – we also need to fix the key context view to represent this).
Yeah, as for now I went with the first alternative, that seems to work for my use-case, thanks!
Hi there! 👋 We're working to clean up our issue tracker by closing older issues that might not be relevant anymore. If you are able to reproduce this issue in the latest version of Zed, please let us know by commenting on this issue, and we will keep it open. If you can't reproduce it, feel free to close the issue yourself. Otherwise, we'll close it in 7 days. Thanks for your help!
This issue was closed due to inactivity. If you're still experiencing this problem, please open a new issue with a link to this issue.