@@ -1052,6 +1052,77 @@ fn update(
1055+fn lsp_workspace_command(
1056+ cx: &mut compositor::Context,
1058+ event: PromptEvent,
1059+) -> anyhow::Result<()> {
1060+ if event != PromptEvent::Validate {
1064+ let (_, doc) = current!(cx.editor);
1066+ let language_server = match doc.language_server() {
1067+ Some(language_server) => language_server,
1070+ .set_status("Language server not active for current buffer");
1075+ let options = match &language_server.capabilities().execute_command_provider {
1076+ Some(options) => options,
1079+ .set_status("Workspace commands are not supported for this language server");
1083+ if args.is_empty() {
1084+ let commands = options
1087+ .map(|command| helix_lsp::lsp::Command {
1088+ title: command.clone(),
1089+ command: command.clone(),
1092+ .collect::<Vec<_>>();
1093+ let callback = async move {
1094+ let call: job::Callback = Callback::EditorCompositor(Box::new(
1095+ move |_editor: &mut Editor, compositor: &mut Compositor| {
1096+ let picker = ui::Picker::new(commands, (), |cx, command, _action| {
1097+ execute_lsp_command(cx.editor, command.clone());
1099+ compositor.push(Box::new(overlayed(picker)))
1104+ cx.jobs.callback(callback);
1106+ let command = args.join(" ");
1107+ if options.commands.iter().any(|c| c == &command) {
1108+ execute_lsp_command(
1110+ helix_lsp::lsp::Command {
1111+ title: command.clone(),
1117+ cx.editor.set_status(format!(
1118+ "`{command}` is not supported for this language server"
1055fn lsp_restart(
1126fn lsp_restart(
1056 cx: &mut compositor::Context,
1127 cx: &mut compositor::Context,
1057 _args: &[Cow<str>],
1128 _args: &[Cow<str>],
@@ -1987,6 +2058,13 @@ pub const TYPABLE_COMMAND_LIST: &[TypableCommand] = &[
1987 fun: update,
2058 fun: update,
1988 completer: None,
2059 completer: None,
2062+ name: "lsp-workspace-command",
2064+ doc: "Open workspace command picker",
2065+ fun: lsp_workspace_command,
2066+ completer: Some(completers::lsp_workspace_command),
1990 TypableCommand {
2068 TypableCommand {
1991 name: "lsp-restart",
2069 name: "lsp-restart",
1992 aliases: &[],
2070 aliases: &[],