- Tidy up vim netrw bindings (c.f.
https://github.com/zed-industries/zed/issues/4270,
https://github.com/zed-industries/zed/pull/7757)
- Add vim commands for panels

Release Notes:

- vim: add commands to toggle panels `:E[xplore]`, `:C[ollab]`,
`:Ch[at]`, `:N[otification]`, `:A[I]`, `:te[rm]` (or `:T[erm]`).
This commit is contained in:
Conrad Irwin 2024-02-17 13:36:08 -07:00 committed by GitHub
parent 8aa5319210
commit 4c781b6455
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 66 additions and 39 deletions

2
Cargo.lock generated
View file

@ -10837,7 +10837,6 @@ dependencies = [
"collections", "collections",
"command_palette", "command_palette",
"copilot", "copilot",
"diagnostics",
"editor", "editor",
"futures 0.3.28", "futures 0.3.28",
"gpui", "gpui",
@ -10849,7 +10848,6 @@ dependencies = [
"nvim-rs", "nvim-rs",
"parking_lot 0.11.2", "parking_lot 0.11.2",
"project", "project",
"project_panel",
"regex", "regex",
"release_channel", "release_channel",
"search", "search",

View file

@ -509,31 +509,25 @@
} }
}, },
{ {
// Directory expansion // netrw compatibility
"context": "ProjectPanel && not_editing", "context": "ProjectPanel && not_editing",
"bindings": { "bindings": {
"escape": "project_panel::ToggleFocus", ":": "command_palette::Toggle",
"enter": "project_panel::Open",
"o": "project_panel::Open",
"t": "project_panel::Open",
"v": "project_panel::Open",
"d": "project_panel::NewDirectory",
"%": "project_panel::NewFile", "%": "project_panel::NewFile",
"shift-r": "project_panel::Rename", "/": "project_panel::NewSearchInDirectory",
"m m": "project_panel::Cut", "d": "project_panel::NewDirectory",
"m c": "project_panel::Copy", "enter": "project_panel::Open",
"m t": "project_panel::Paste", "escape": "project_panel::ToggleFocus",
"x": "project_panel::RevealInFinder",
"l": "project_panel::ExpandSelectedEntry",
"h": "project_panel::CollapseSelectedEntry", "h": "project_panel::CollapseSelectedEntry",
// Move up and down
"j": "menu::SelectNext", "j": "menu::SelectNext",
"k": "menu::SelectPrev", "k": "menu::SelectPrev",
"l": "project_panel::ExpandSelectedEntry",
"o": "project_panel::Open",
"shift-d": "project_panel::Delete", "shift-d": "project_panel::Delete",
"/": "project_panel::NewSearchInDirectory", "shift-r": "project_panel::Rename",
// zed specific "t": "project_panel::Open",
"q p": "project_panel::CopyPath", "v": "project_panel::Open",
"q r": "project_panel::CopyRelativePath" "x": "project_panel::RevealInFinder"
} }
} }
] ]

View file

@ -20,8 +20,6 @@ collections.workspace = true
command_palette.workspace = true command_palette.workspace = true
# HACK: We're only depending on `copilot` here for `CommandPaletteFilter`. See the attached comment on that type. # HACK: We're only depending on `copilot` here for `CommandPaletteFilter`. See the attached comment on that type.
copilot.workspace = true copilot.workspace = true
project_panel.workspace = true
diagnostics.workspace = true
editor.workspace = true editor.workspace = true
gpui.workspace = true gpui.workspace = true
itertools = "0.10" itertools = "0.10"

View file

@ -31,7 +31,7 @@ pub fn register(workspace: &mut Workspace, _: &mut ViewContext<Workspace>) {
}); });
} }
pub fn command_interceptor(mut query: &str, _: &AppContext) -> Option<CommandInterceptResult> { pub fn command_interceptor(mut query: &str, cx: &AppContext) -> Option<CommandInterceptResult> {
// Note: this is a very poor simulation of vim's command palette. // Note: this is a very poor simulation of vim's command palette.
// In the future we should adjust it to handle parsing range syntax, // In the future we should adjust it to handle parsing range syntax,
// and then calling the appropriate commands with/without ranges. // and then calling the appropriate commands with/without ranges.
@ -203,7 +203,10 @@ pub fn command_interceptor(mut query: &str, _: &AppContext) -> Option<CommandInt
), ),
// quickfix / loclist (merged together for now) // quickfix / loclist (merged together for now)
"cl" | "cli" | "clis" | "clist" => ("clist", diagnostics::Deploy.boxed_clone()), "cl" | "cli" | "clis" | "clist" => (
"clist",
cx.build_action("diagnostics::Deploy", None).unwrap(),
),
"cc" => ("cc", editor::actions::Hover.boxed_clone()), "cc" => ("cc", editor::actions::Hover.boxed_clone()),
"ll" => ("ll", editor::actions::Hover.boxed_clone()), "ll" => ("ll", editor::actions::Hover.boxed_clone()),
"cn" | "cne" | "cnex" | "cnext" => ("cnext", editor::actions::GoToDiagnostic.boxed_clone()), "cn" | "cne" | "cnex" | "cnext" => ("cnext", editor::actions::GoToDiagnostic.boxed_clone()),
@ -234,21 +237,55 @@ pub fn command_interceptor(mut query: &str, _: &AppContext) -> Option<CommandInt
"sor i" | "sort i" => ("sort i", SortLinesCaseInsensitive.boxed_clone()), "sor i" | "sort i" => ("sort i", SortLinesCaseInsensitive.boxed_clone()),
// Explore, etc. // Explore, etc.
"E" | "Ex" | "Exp" | "Expl" | "Explo" | "Explor" | "Explore" => { "E" | "Ex" | "Exp" | "Expl" | "Explo" | "Explor" | "Explore" => (
("Explore", project_panel::ToggleFocus.boxed_clone()) "Explore",
} cx.build_action("project_panel::ToggleFocus", None).unwrap(),
"H" | "He" | "Hex" | "Hexp" | "Hexpl" | "Hexplo" | "Hexplor" | "Hexplore" => { ),
("Hexplore", project_panel::ToggleFocus.boxed_clone()) "H" | "He" | "Hex" | "Hexp" | "Hexpl" | "Hexplo" | "Hexplor" | "Hexplore" => (
} "Hexplore",
"L" | "Le" | "Lex" | "Lexp" | "Lexpl" | "Lexplo" | "Lexplor" | "Lexplore" => { cx.build_action("project_panel::ToggleFocus", None).unwrap(),
("Lexplore", project_panel::ToggleFocus.boxed_clone()) ),
} "L" | "Le" | "Lex" | "Lexp" | "Lexpl" | "Lexplo" | "Lexplor" | "Lexplore" => (
"S" | "Se" | "Sex" | "Sexp" | "Sexpl" | "Sexplo" | "Sexplor" | "Sexplore" => { "Lexplore",
("Sexplore", project_panel::ToggleFocus.boxed_clone()) cx.build_action("project_panel::ToggleFocus", None).unwrap(),
} ),
"Ve" | "Vex" | "Vexp" | "Vexpl" | "Vexplo" | "Vexplor" | "Vexplore" => { "S" | "Se" | "Sex" | "Sexp" | "Sexpl" | "Sexplo" | "Sexplor" | "Sexplore" => (
("Vexplore", project_panel::ToggleFocus.boxed_clone()) "Sexplore",
} cx.build_action("project_panel::ToggleFocus", None).unwrap(),
),
"Ve" | "Vex" | "Vexp" | "Vexpl" | "Vexplo" | "Vexplor" | "Vexplore" => (
"Vexplore",
cx.build_action("project_panel::ToggleFocus", None).unwrap(),
),
"te" | "ter" | "term" => (
"term",
cx.build_action("terminal_panel::ToggleFocus", None)
.unwrap(),
),
// Zed panes
"T" | "Te" | "Ter" | "Term" => (
"Term",
cx.build_action("terminal_panel::ToggleFocus", None)
.unwrap(),
),
"C" | "Co" | "Col" | "Coll" | "Colla" | "Collab" => (
"Collab",
cx.build_action("collab_panel::ToggleFocus", None).unwrap(),
),
"Ch" | "Cha" | "Chat" => (
"Chat",
cx.build_action("chat_panel::ToggleFocus", None).unwrap(),
),
"No" | "Not" | "Noti" | "Notif" | "Notifi" | "Notific" | "Notifica" | "Notificat"
| "Notificati" | "Notificatio" | "Notification" => (
"Notifications",
cx.build_action("notification_panel::ToggleFocus", None)
.unwrap(),
),
"A" | "AI" | "Ai" => (
"AI",
cx.build_action("assistant::ToggleFocus", None).unwrap(),
),
// goto (other ranges handled under _ => ) // goto (other ranges handled under _ => )
"$" => ("$", EndOfDocument.boxed_clone()), "$" => ("$", EndOfDocument.boxed_clone()),