@@ -3277,12 +3277,19 @@ pub fn code_action(cx: &mut Context) {
32773277 move |editor, code_action, _action| match code_action {
32783278 lsp::CodeActionOrCommand::Command(command) => {
32793279 log::debug!("code action command: {:?}", command);
3280− editor.set_error(String::from("Handling code action command is not implemented yet, see https://github.com/helix-editor/helix/issues/183"));
3280+ execute_lsp_command(editor, command.clone());
32813281 }
32823282 lsp::CodeActionOrCommand::CodeAction(code_action) => {
32833283 log::debug!("code action: {:?}", code_action);
32843284 if let Some(ref workspace_edit) = code_action.edit {
3285− apply_workspace_edit(editor, offset_encoding, workspace_edit)
3285+ log::debug!("edit: {:?}", workspace_edit);
3286+ apply_workspace_edit(editor, offset_encoding, workspace_edit);
3287+ }
3288+
3289+ // if code action provides both edit and command first the edit
3290+ // should be applied and then the command
3291+ if let Some(command) = &code_action.command {
3292+ execute_lsp_command(editor, command.clone());
32863293 }
32873294 }
32883295 },
@@ -3293,6 +3300,26 @@ pub fn code_action(cx: &mut Context) {
32933300 )
32943301}
32953302
3303+pub fn execute_lsp_command(editor: &mut Editor, cmd: lsp::Command) {
3304+ let (_view, doc) = current!(editor);
3305+
3306+ let language_server = match doc.language_server() {
3307+ Some(language_server) => language_server,
3308+ None => return,
3309+ };
3310+
3311+ // the command is executed on the server and communicated back
3312+ // to the client asynchronously using workspace edits
3313+ let command_future = language_server.command(cmd);
3314+ tokio::spawn(async move {
3315+ let res = command_future.await;
3316+
3317+ if let Err(e) = res {
3318+ log::error!("execute LSP command: {}", e);
3319+ }
3320+ });
3321+}
3322+
32963323pub fn apply_document_resource_op(op: &lsp::ResourceOp) -> std::io::Result<()> {
32973324 use lsp::ResourceOp;
32983325 use std::fs;
@@ -3346,7 +3373,7 @@ pub fn apply_document_resource_op(op: &lsp::ResourceOp) -> std::io::Result<()> {
33463373 }
33473374}
33483375
3349−fn apply_workspace_edit(
3376+pub fn apply_workspace_edit(
33503377 editor: &mut Editor,
33513378 offset_encoding: OffsetEncoding,
33523379 workspace_edit: &lsp::WorkspaceEdit,