Skip to content

Commit

Permalink
LSP: No-op client/registerCapability requests (helix-editor#6258)
Browse files Browse the repository at this point in the history
  • Loading branch information
the-mikedavis authored and wes-adams committed Jul 3, 2023
1 parent 235ed3f commit 604bb23
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
5 changes: 5 additions & 0 deletions helix-lsp/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -526,6 +526,7 @@ pub enum MethodCall {
ApplyWorkspaceEdit(lsp::ApplyWorkspaceEditParams),
WorkspaceFolders,
WorkspaceConfiguration(lsp::ConfigurationParams),
RegisterCapability(lsp::RegistrationParams),
}

impl MethodCall {
Expand All @@ -545,6 +546,10 @@ impl MethodCall {
let params: lsp::ConfigurationParams = params.parse()?;
Self::WorkspaceConfiguration(params)
}
lsp::request::RegisterCapability::METHOD => {
let params: lsp::RegistrationParams = params.parse()?;
Self::RegisterCapability(params)
}
_ => {
return Err(Error::Unhandled);
}
Expand Down
11 changes: 11 additions & 0 deletions helix-term/src/application.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1014,6 +1014,17 @@ impl Application {
.collect();
Ok(json!(result))
}
Ok(MethodCall::RegisterCapability(_params)) => {
log::warn!("Ignoring a client/registerCapability request because dynamic capability registration is not enabled. Please report this upstream to the language server");
// Language Servers based on the `vscode-languageserver-node` library often send
// client/registerCapability even though we do not enable dynamic registration
// for any capabilities. We should send a MethodNotFound JSONRPC error in this
// case but that rejects the registration promise in the server which causes an
// exit. So we work around this by ignoring the request and sending back an OK
// response.

Ok(serde_json::Value::Null)
}
};

let language_server = match self.editor.language_servers.get_by_id(server_id) {
Expand Down

0 comments on commit 604bb23

Please sign in to comment.