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

Custom Keybinding #10678

Closed
1 task done
danoshi opened this issue Apr 17, 2024 · 1 comment
Closed
1 task done

Custom Keybinding #10678

danoshi opened this issue Apr 17, 2024 · 1 comment
Labels
editor Feedback for code editing, formatting, editor iterations, etc keymap / key binding Feedback for keyboard shortcuts, key mapping, etc support User support (non-defect troubleshooting, documentation, etc) workspace Feedback for workspace management, layout, interactions, etc

Comments

@danoshi
Copy link

danoshi commented Apr 17, 2024

Check for existing issues

  • Completed

Describe the bug / provide steps to reproduce it

I created my own keybindings but it seems they do not work as they should.
I would like to remap the renaming of files from F2 to cmd-y since I am on a mac.
After restarting the IDE the remap did not work out.

Below my custom keymap.json.

[
  {
    "context": "Editor",
    "bindings": {
      "cmd-y": "editor::Rename",
      "shift-y": "project_panel::Rename"
    }
  }
]

Environment

Zed: v0.130.7 (Zed)
OS: macOS 14.4.1
Memory: 32 GiB
Architecture: x86_64

If applicable, add mockups / screenshots to help explain present your vision of the feature

No response

If applicable, attach your ~/Library/Logs/Zed/Zed.log file to this issue.

Zed.log
2024-04-17T12:52:50 02:00 [INFO] downloading language server "json-language-server"
2024-04-17T12:52:50 02:00 [INFO] Node runtime install_if_needed
2024-04-17T12:52:51 02:00 [INFO] starting language server. binary path: "/Users/daniel.kaminski/Library/Application Support/Zed/node/node-v18.15.0-darwin-x64/bin/node", working directory: "/Users/daniel.kaminski/.config/zed", args: ["/Users/daniel.kaminski/Library/Application Support/Zed/languages/json-language-server/node_modules/vscode-json-languageserver/bin/vscode-json-languageserver", "--stdio"]
2024-04-17T12:52:56 02:00 [WARN] Generic lsp request to node failed: Unhandled method textDocument/definition
2024-04-17T12:52:57 02:00 [WARN] Generic lsp request to node failed: Unhandled method textDocument/definition
2024-04-17T12:52:57 02:00 [WARN] Generic lsp request to node failed: Unhandled method textDocument/definition
2024-04-17T12:52:57 02:00 [WARN] Generic lsp request to node failed: Unhandled method textDocument/definition
2024-04-17T12:52:57 02:00 [WARN] Generic lsp request to node failed: Unhandled method textDocument/definition
2024-04-17T12:52:57 02:00 [WARN] Generic lsp request to node failed: Unhandled method textDocument/definition
2024-04-17T12:52:57 02:00 [WARN] Generic lsp request to node failed: Unhandled method textDocument/definition
2024-04-17T12:52:57 02:00 [WARN] Generic lsp request to node failed: Unhandled method textDocument/definition
2024-04-17T12:52:57 02:00 [WARN] Generic lsp request to node failed: Unhandled method textDocument/definition
2024-04-17T12:52:57 02:00 [WARN] Generic lsp request to node failed: Unhandled method textDocument/definition
2024-04-17T12:52:57 02:00 [WARN] Generic lsp request to node failed: Unhandled method textDocument/definition
2024-04-17T12:52:57 02:00 [WARN] Generic lsp request to node failed: Unhandled method textDocument/definition
2024-04-17T12:52:57 02:00 [WARN] Generic lsp request to node failed: Unhandled method textDocument/definition
2024-04-17T12:53:00 02:00 [INFO] Waiting for default prettier to install
2024-04-17T12:53:00 02:00 [INFO] Starting prettier at path "/Users/daniel.kaminski/Library/Application Support/Zed/prettier"
2024-04-17T12:53:00 02:00 [INFO] Node runtime install_if_needed
2024-04-17T12:53:01 02:00 [INFO] starting language server. binary path: "/Users/daniel.kaminski/Library/Application Support/Zed/node/node-v18.15.0-darwin-x64/bin/node", working directory: "/Users/daniel.kaminski/Library/Application Support/Zed/prettier", args: ["/Users/daniel.kaminski/Library/Application Support/Zed/prettier/prettier_server.js", "/Users/daniel.kaminski/Library/Application Support/Zed/prettier"]
2024-04-17T12:53:01 02:00 [INFO] Started default prettier in "/Users/daniel.kaminski/Library/Application Support/Zed/prettier"
2024-04-17T12:54:36 02:00 [WARN] Generic lsp request to node failed: Unhandled method textDocument/definition
2024-04-17T12:57:07 02:00 [ERROR] crates/project/src/project.rs:7396: EOF while parsing a value at line 1 column 0
2024-04-17T12:57:07 02:00 [INFO] starting language server "json-language-server", path: "/Users/daniel.kaminski/priv-danielk/Leetcode-exercises", id: 4
2024-04-17T12:57:07 02:00 [INFO] starting language server. binary path: "/Users/daniel.kaminski/Library/Application Support/Zed/node/node-v18.15.0-darwin-x64/bin/node", working directory: "/Users/daniel.kaminski/priv-danielk/Leetcode-exercises", args: ["/Users/daniel.kaminski/Library/Application Support/Zed/languages/json-language-server/node_modules/vscode-json-languageserver/bin/vscode-json-languageserver", "--stdio"]
2024-04-17T12:57:07 02:00 [INFO] Language server with id 1 sent unhandled notification client/unregisterCapability:
{
  "unregisterations": [
    {
      "id": "67746694-7886-49ba-8d61-a668b6632499",
      "method": "workspace/didChangeWatchedFiles"
    }
  ]
}
2024-04-17T12:57:23 02:00 [ERROR] crates/settings/src/settings_file.rs:83: EOF while parsing a value at line 1 column 0
2024-04-17T12:57:23 02:00 [INFO] open paths ["/Users/daniel.kaminski/.config/zed/settings.json"]
2024-04-17T12:57:23 02:00 [INFO] starting language server "json-language-server", path: "/Users/daniel.kaminski/.config/zed/settings.json", id: 5
2024-04-17T12:57:23 02:00 [INFO] starting language server. binary path: "/Users/daniel.kaminski/Library/Application Support/Zed/node/node-v18.15.0-darwin-x64/bin/node", working directory: "/Users/daniel.kaminski/.config/zed", args: ["/Users/daniel.kaminski/Library/Application Support/Zed/languages/json-language-server/node_modules/vscode-json-languageserver/bin/vscode-json-languageserver", "--stdio"]
2024-04-17T12:57:23 02:00 [INFO] Language server with id 1 sent unhandled notification client/unregisterCapability:
{
  "unregisterations": [
    {
      "id": "2e3394cb-d486-4284-b559-1b89fe76b0f6",
      "method": "workspace/didChangeWatchedFiles"
    }
  ]
}
2024-04-17T12:57:23 02:00 [INFO] Language server with id 1 sent unhandled notification client/unregisterCapability:
{
  "unregisterations": [
    {
      "id": "a6cc6275-c206-4776-a66c-f6393dda3e76",
      "method": "workspace/didChangeWatchedFiles"
    }
  ]
}
2024-04-17T12:57:24 02:00 [INFO] Language server with id 1 sent unhandled notification client/unregisterCapability:
{
  "unregisterations": [
    {
      "id": "56eab6af-a534-42ec-bb0b-35b3e7501f09",
      "method": "workspace/didChangeWatchedFiles"
    }
  ]
}
2024-04-17T12:57:24 02:00 [INFO] Language server with id 1 sent unhandled notification client/unregisterCapability:
{
  "unregisterations": [
    {
      "id": "1666ca28-d626-4151-a5ff-b159eb63967f",
      "method": "workspace/didChangeWatchedFiles"
    }
  ]
}
2024-04-17T12:57:25 02:00 [INFO] set status on client 0: Authenticating
2024-04-17T12:57:27 02:00 [INFO] set status on client 151000: Connecting
2024-04-17T12:57:28 02:00 [INFO] connected to rpc endpoint https://collab.zed.dev/rpc
2024-04-17T12:57:29 02:00 [INFO] add connection to peer
2024-04-17T12:57:29 02:00 [INFO] waiting for server hello
2024-04-17T12:57:29 02:00 [INFO] got server hello
2024-04-17T12:57:29 02:00 [INFO] set status to connected (connection id: ConnectionId { owner_id: 0, id: 0 }, peer id: PeerId { owner_id: 392, id: 772061 })
2024-04-17T12:57:29 02:00 [INFO] set status on client 151000: Connected { peer_id: PeerId { owner_id: 392, id: 772061 }, connection_id: ConnectionId { owner_id: 0, id: 0 } }
2024-04-17T12:57:34 02:00 [ERROR] unexpected item event after pane was dropped
2024-04-17T12:57:34 02:00 [ERROR] crates/lsp/src/lsp.rs:728: oneshot canceled
2024-04-17T12:57:35 02:00 [INFO] Language server with id 1 sent unhandled notification client/unregisterCapability:
{
  "unregisterations": [
    {
      "id": "8f4bf539-f6a5-47e1-8ab4-75196a7b4bdb",
      "method": "workspace/didChangeWatchedFiles"
    }
  ]
}
2024-04-17T12:57:40 02:00 [INFO] open paths ["/Users/daniel.kaminski/.config/zed/keymap.json"]
2024-04-17T12:57:41 02:00 [INFO] Language server with id 1 sent unhandled notification client/unregisterCapability:
{
  "unregisterations": [
    {
      "id": "8e064cb5-6562-411d-9a4e-b2444f62741b",
      "method": "workspace/didChangeWatchedFiles"
    }
  ]
}
2024-04-17T12:58:01 02:00 [ERROR] crates/assistant/src/assistant_panel.rs:1241: credentials not found
@danoshi danoshi added admin read Pending admin review defect [core label] triage Maintainer needs to classify the issue labels Apr 17, 2024
@Moshyfawn Moshyfawn added workspace Feedback for workspace management, layout, interactions, etc editor Feedback for code editing, formatting, editor iterations, etc keymap / key binding Feedback for keyboard shortcuts, key mapping, etc and removed triage Maintainer needs to classify the issue labels Apr 17, 2024
@JosephTLyons JosephTLyons removed the admin read Pending admin review label Apr 19, 2024
@notpeter
Copy link
Member

notpeter commented Jul 8, 2024

Hi @danoshi,

Apologies for the delayed reply. There are currently two distinct rename commands, editor::Rename is used for language-server provided rename refactoring (no available in all languages) so you can for example rename a function and it will attempt to update all the references to map the new name. You could remap this to cmd y using the keymap you provided.

Separately, file rename is only available from within the ProjectPanel context. So if you adjust your keymap to the following I believe it should work as intended.

[
  {
    "context": "Editor",
    "bindings": {
      "cmd-y": "editor::Rename",
    }
  },
  {
    "context": "ProjectPanel && not_editing",
    "bindings": {
      "shift-y": "project_panel::Rename"
    }
  }
]

I tested these and they worked for me on MacOS.

P.S. The && not_editing is only needed because you have a shortcut without a modifier. If you had this under the main ProjectPanel you would be unable to type the Y character. I learned this the hard way here:

@notpeter notpeter closed this as completed Jul 8, 2024
@notpeter notpeter added support User support (non-defect troubleshooting, documentation, etc) and removed defect [core label] labels Jul 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
editor Feedback for code editing, formatting, editor iterations, etc keymap / key binding Feedback for keyboard shortcuts, key mapping, etc support User support (non-defect troubleshooting, documentation, etc) workspace Feedback for workspace management, layout, interactions, etc
Projects
None yet
Development

No branches or pull requests

4 participants