on master help sign in
LSP: No-op client/registerCapability requests (#6258)
4f066b1Michael Davis
helix-lsp/src/lib.rs+5
@@ -526,6 +526,7 @@ pub enum MethodCall {
526 ApplyWorkspaceEdit(lsp::ApplyWorkspaceEditParams),
526 ApplyWorkspaceEdit(lsp::ApplyWorkspaceEditParams),
527 WorkspaceFolders,
527 WorkspaceFolders,
528 WorkspaceConfiguration(lsp::ConfigurationParams),
528 WorkspaceConfiguration(lsp::ConfigurationParams),
529+ RegisterCapability(lsp::RegistrationParams),
529}
530}
530
531
531impl MethodCall {
532impl MethodCall {
@@ -545,6 +546,10 @@ impl MethodCall {
545 let params: lsp::ConfigurationParams = params.parse()?;
546 let params: lsp::ConfigurationParams = params.parse()?;
546 Self::WorkspaceConfiguration(params)
547 Self::WorkspaceConfiguration(params)
547 }
548 }
549+ lsp::request::RegisterCapability::METHOD => {
550+ let params: lsp::RegistrationParams = params.parse()?;
551+ Self::RegisterCapability(params)
552+ }
548 _ => {
553 _ => {
549 return Err(Error::Unhandled);
554 return Err(Error::Unhandled);
550 }
555 }
helix-term/src/application.rs+11
@@ -1014,6 +1014,17 @@ impl Application {
1014 .collect();
1014 .collect();
1015 Ok(json!(result))
1015 Ok(json!(result))
1016 }
1016 }
1017+ Ok(MethodCall::RegisterCapability(_params)) => {
1018+ log::warn!("Ignoring a client/registerCapability request because dynamic capability registration is not enabled. Please report this upstream to the language server");
1019+ // Language Servers based on the `vscode-languageserver-node` library often send
1020+ // client/registerCapability even though we do not enable dynamic registration
1021+ // for any capabilities. We should send a MethodNotFound JSONRPC error in this
1022+ // case but that rejects the registration promise in the server which causes an
1023+ // exit. So we work around this by ignoring the request and sending back an OK
1024+ // response.
1025+
1026+ Ok(serde_json::Value::Null)
1027+ }
1017 };
1028 };
1018
1029
1019 let language_server = match self.editor.language_servers.get_by_id(server_id) {
1030 let language_server = match self.editor.language_servers.get_by_id(server_id) {