aboutsummaryrefslogtreecommitdiff
path: root/helix-lsp
diff options
context:
space:
mode:
authorMatouš Dzivjak2021-12-21 09:21:45 +0000
committerGitHub2021-12-21 09:21:45 +0000
commit75a8b789d20edf8b2e1d3da75497a9936953de68 (patch)
treeff103bc9d916223df04451fce7ba40117e9e11a5 /helix-lsp
parent600ce70cf6d50ce37b96bfde90c6ade8db6cd8c3 (diff)
LSP code action commands (#1304)
* feat(lsp): codeAction commands * Don't block on command call * Fix lifetime of command execution * Fix lint issues
Diffstat (limited to 'helix-lsp')
-rw-r--r--helix-lsp/src/client.rs14
-rw-r--r--helix-lsp/src/lib.rs7
2 files changed, 20 insertions, 1 deletions
diff --git a/helix-lsp/src/client.rs b/helix-lsp/src/client.rs
index 271fd9d5..f1de8752 100644
--- a/helix-lsp/src/client.rs
+++ b/helix-lsp/src/client.rs
@@ -202,7 +202,7 @@ impl Client {
Ok(result) => Output::Success(Success {
jsonrpc: Some(Version::V2),
id,
- result,
+ result: serde_json::to_value(result)?,
}),
Err(error) => Output::Failure(Failure {
jsonrpc: Some(Version::V2),
@@ -800,4 +800,16 @@ impl Client {
let response = self.request::<lsp::request::Rename>(params).await?;
Ok(response.unwrap_or_default())
}
+
+ pub fn command(&self, command: lsp::Command) -> impl Future<Output = Result<Value>> {
+ let params = lsp::ExecuteCommandParams {
+ command: command.command,
+ arguments: command.arguments.unwrap_or_default(),
+ work_done_progress_params: lsp::WorkDoneProgressParams {
+ work_done_token: None,
+ },
+ };
+
+ self.call::<lsp::request::ExecuteCommand>(params)
+ }
}
diff --git a/helix-lsp/src/lib.rs b/helix-lsp/src/lib.rs
index 15cae582..8fb321bc 100644
--- a/helix-lsp/src/lib.rs
+++ b/helix-lsp/src/lib.rs
@@ -203,6 +203,7 @@ pub mod util {
#[derive(Debug, PartialEq, Clone)]
pub enum MethodCall {
WorkDoneProgressCreate(lsp::WorkDoneProgressCreateParams),
+ ApplyWorkspaceEdit(lsp::ApplyWorkspaceEditParams),
}
impl MethodCall {
@@ -215,6 +216,12 @@ impl MethodCall {
.expect("Failed to parse WorkDoneCreate params");
Self::WorkDoneProgressCreate(params)
}
+ lsp::request::ApplyWorkspaceEdit::METHOD => {
+ let params: lsp::ApplyWorkspaceEditParams = params
+ .parse()
+ .expect("Failed to parse ApplyWorkspaceEdit params");
+ Self::ApplyWorkspaceEdit(params)
+ }
_ => {
log::warn!("unhandled lsp request: {}", method);
return None;