Cursor keymap (#31702)

To use this, spawn `weclome: toggle base keymap selector` from the
command palette.

<img width="589" alt="Screenshot 2025-05-29 at 14 07 35"
src="https://github.com/user-attachments/assets/0d4c4eff-6a3b-40f4-9032-5d8ca7664d20"
/>

MacOS is well tested to match Cursor. The [curors keymap
documentation](https://docs.cursor.com/kbd) is does not explicitly state
windows/linux keymap entries only "All Cmd keys can be replaced with
Ctrl on Windows." so that is what we've done. We welcome feedback /
refinements.

Note, because this provides a mapping for `cmd-k` (macos) and `ctrl-k`
(linux/windows) using this keymap will disable all of the default
chorded keymap entries which have `cmd-k` / `ctrl-k` as a prefix. For
example `cmd-k cmd-s` for open keymap will no longer function.

Release Notes:

- Added Cursor compatibility keymap

---------

Co-authored-by: Joseph Lyons <joseph@zed.dev>
This commit is contained in:
Peter Tripp 2025-05-29 15:20:58 -04:00 committed by GitHub
parent 070eac28e3
commit 6ea9abdc1b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 185 additions and 9 deletions

View file

@ -16,6 +16,7 @@ pub enum BaseKeymap {
Atom,
TextMate,
Emacs,
Cursor,
None,
}
@ -28,6 +29,7 @@ impl Display for BaseKeymap {
BaseKeymap::Atom => write!(f, "Atom"),
BaseKeymap::TextMate => write!(f, "TextMate"),
BaseKeymap::Emacs => write!(f, "Emacs (beta)"),
BaseKeymap::Cursor => write!(f, "Cursor (beta)"),
BaseKeymap::None => write!(f, "None"),
}
}
@ -35,22 +37,24 @@ impl Display for BaseKeymap {
impl BaseKeymap {
#[cfg(target_os = "macos")]
pub const OPTIONS: [(&'static str, Self); 6] = [
pub const OPTIONS: [(&'static str, Self); 7] = [
("VSCode (Default)", Self::VSCode),
("Atom", Self::Atom),
("JetBrains", Self::JetBrains),
("Sublime Text", Self::SublimeText),
("Emacs (beta)", Self::Emacs),
("TextMate", Self::TextMate),
("Cursor (beta)", Self::Cursor),
];
#[cfg(not(target_os = "macos"))]
pub const OPTIONS: [(&'static str, Self); 5] = [
pub const OPTIONS: [(&'static str, Self); 6] = [
("VSCode (Default)", Self::VSCode),
("Atom", Self::Atom),
("JetBrains", Self::JetBrains),
("Sublime Text", Self::SublimeText),
("Emacs (beta)", Self::Emacs),
("Cursor (beta)", Self::Cursor),
];
pub fn asset_path(&self) -> Option<&'static str> {
@ -61,6 +65,7 @@ impl BaseKeymap {
BaseKeymap::Atom => Some("keymaps/macos/atom.json"),
BaseKeymap::TextMate => Some("keymaps/macos/textmate.json"),
BaseKeymap::Emacs => Some("keymaps/macos/emacs.json"),
BaseKeymap::Cursor => Some("keymaps/macos/cursor.json"),
BaseKeymap::VSCode => None,
BaseKeymap::None => None,
}
@ -71,6 +76,7 @@ impl BaseKeymap {
BaseKeymap::SublimeText => Some("keymaps/linux/sublime_text.json"),
BaseKeymap::Atom => Some("keymaps/linux/atom.json"),
BaseKeymap::Emacs => Some("keymaps/linux/emacs.json"),
BaseKeymap::Cursor => Some("keymaps/linux/cursor.json"),
BaseKeymap::TextMate => None,
BaseKeymap::VSCode => None,
BaseKeymap::None => None,