diff options
author | Blaž Hrastnik | 2022-04-01 02:20:41 +0000 |
---|---|---|
committer | Blaž Hrastnik | 2022-04-01 02:20:41 +0000 |
commit | 8adf0c1b3a7a2173c80a86da5d435288bab456de (patch) | |
tree | e99b3d67ba027fbd1e3f4428a078d6d28a8f2ab2 /helix-term/src | |
parent | 236c6b77077596f8c7b5a5377e23e96ecec45e07 (diff) |
lsp: Implement support for workspace_folders (currently just one)
Refs #1898
Diffstat (limited to 'helix-term/src')
-rw-r--r-- | helix-term/src/application.rs | 65 |
1 files changed, 29 insertions, 36 deletions
diff --git a/helix-term/src/application.rs b/helix-term/src/application.rs index 09b1ff61..ddf9e8d6 100644 --- a/helix-term/src/application.rs +++ b/helix-term/src/application.rs @@ -601,7 +601,7 @@ impl Application { } }; - match call { + let reply = match call { MethodCall::WorkDoneProgressCreate(params) => { self.lsp_progress.create(server_id, params.token); @@ -613,16 +613,8 @@ impl Application { if spinner.is_stopped() { spinner.start(); } - let language_server = - match self.editor.language_servers.get_by_id(server_id) { - Some(language_server) => language_server, - None => { - warn!("can't find language server with id `{}`", server_id); - return; - } - }; - tokio::spawn(language_server.reply(id, Ok(serde_json::Value::Null))); + Ok(serde_json::Value::Null) } MethodCall::ApplyWorkspaceEdit(params) => { apply_workspace_edit( @@ -631,33 +623,19 @@ impl Application { ¶ms.edit, ); + Ok(json!(lsp::ApplyWorkspaceEditResponse { + applied: true, + failure_reason: None, + failed_change: None, + })) + } + MethodCall::WorkspaceFolders => { let language_server = - match self.editor.language_servers.get_by_id(server_id) { - Some(language_server) => language_server, - None => { - warn!("can't find language server with id `{}`", server_id); - return; - } - }; + self.editor.language_servers.get_by_id(server_id).unwrap(); - tokio::spawn(language_server.reply( - id, - Ok(json!(lsp::ApplyWorkspaceEditResponse { - applied: true, - failure_reason: None, - failed_change: None, - })), - )); + Ok(json!(language_server.workspace_folders())) } MethodCall::WorkspaceConfiguration(params) => { - let language_server = - match self.editor.language_servers.get_by_id(server_id) { - Some(language_server) => language_server, - None => { - warn!("can't find language server with id `{}`", server_id); - return; - } - }; let result: Vec<_> = params .items .iter() @@ -668,7 +646,12 @@ impl Application { let doc = self.editor.document_by_path(path)?; doc.language_config()?.config.as_ref()? } - None => language_server.config()?, + None => self + .editor + .language_servers + .get_by_id(server_id) + .unwrap() + .config()?, }; if let Some(section) = item.section.as_ref() { for part in section.split('.') { @@ -678,9 +661,19 @@ impl Application { Some(config) }) .collect(); - tokio::spawn(language_server.reply(id, Ok(json!(result)))); + Ok(json!(result)) } - } + }; + + let language_server = match self.editor.language_servers.get_by_id(server_id) { + Some(language_server) => language_server, + None => { + warn!("can't find language server with id `{}`", server_id); + return; + } + }; + + tokio::spawn(language_server.reply(id, reply)); } Call::Invalid { id } => log::error!("LSP invalid method call id={:?}", id), } |