From d6c7cdd60ff3cbede868b7c73d92ce808f7b9ee3 Mon Sep 17 00:00:00 2001 From: Julia Ryan Date: Wed, 7 May 2025 17:26:42 -0700 Subject: [PATCH] Add :h[elp] vim command (#30179) @jyn514 mentioned that this would be nice to have while trying out zed, and it seemed simple enough so I added it. Release Notes: - Added `OpenDocs` action to open Zed's docs in a browser, aliased to `:h[elp]` in vim. --- crates/vim/src/command.rs | 3 ++- crates/zed/src/zed.rs | 5 +++-- crates/zed_actions/src/lib.rs | 1 + 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/crates/vim/src/command.rs b/crates/vim/src/command.rs index 9a30e01515..3c86cfa6a0 100644 --- a/crates/vim/src/command.rs +++ b/crates/vim/src/command.rs @@ -28,7 +28,7 @@ use task::{HideStrategy, RevealStrategy, SpawnInTerminal, TaskId}; use ui::ActiveTheme; use util::ResultExt; use workspace::{SaveIntent, notifications::NotifyResultExt}; -use zed_actions::RevealTarget; +use zed_actions::{OpenDocs, RevealTarget}; use crate::{ ToggleMarksView, ToggleRegistersView, Vim, @@ -888,6 +888,7 @@ fn generate_commands(_: &App) -> Vec { VimCommand::new(("cpp", "link"), editor::actions::CopyPermalinkToLine).range(act_on_range), VimCommand::str(("opt", "ions"), "zed::OpenDefaultSettings"), VimCommand::str(("map", ""), "vim::OpenDefaultKeymap"), + VimCommand::new(("h", "elp"), OpenDocs), ] } diff --git a/crates/zed/src/zed.rs b/crates/zed/src/zed.rs index 71c7bd28bc..c75dbeb2c6 100644 --- a/crates/zed/src/zed.rs +++ b/crates/zed/src/zed.rs @@ -61,7 +61,7 @@ use util::markdown::MarkdownString; use util::{ResultExt, asset_str}; use uuid::Uuid; use vim_mode_setting::VimModeSetting; -use welcome::{BaseKeymap, MultibufferHint}; +use welcome::{BaseKeymap, DOCS_URL, MultibufferHint}; use workspace::notifications::{NotificationId, dismiss_app_notification, show_app_notification}; use workspace::{ AppState, NewFile, NewWindow, OpenLog, Toast, Workspace, WorkspaceSettings, @@ -71,7 +71,7 @@ use workspace::{ use workspace::{CloseIntent, RestoreBanner}; use workspace::{Pane, notifications::DetachAndPromptErr}; use zed_actions::{ - OpenAccountSettings, OpenBrowser, OpenServerSettings, OpenSettings, OpenZedUrl, Quit, + OpenAccountSettings, OpenBrowser, OpenDocs, OpenServerSettings, OpenSettings, OpenZedUrl, Quit, }; actions!( @@ -479,6 +479,7 @@ fn register_actions( ) { workspace .register_action(about) + .register_action(|_, _: &OpenDocs, _, cx| cx.open_url(DOCS_URL)) .register_action(|_, _: &Minimize, window, _| { window.minimize_window(); }) diff --git a/crates/zed_actions/src/lib.rs b/crates/zed_actions/src/lib.rs index 3ebce6a87b..ed02fb13c3 100644 --- a/crates/zed_actions/src/lib.rs +++ b/crates/zed_actions/src/lib.rs @@ -35,6 +35,7 @@ actions!( Quit, OpenKeymap, About, + OpenDocs, OpenLicenses, OpenTelemetryLog, ]