From a814883cd40be772d52bb8e7424326021fdb0e0e Mon Sep 17 00:00:00 2001 From: Michael Bolin Date: Wed, 10 Jul 2019 20:44:23 -0700 Subject: [PATCH 1/2] Ignore workspace/didChangeConfiguration notifications. --- crates/ra_lsp_server/src/main_loop.rs | 6 ++++++ crates/ra_lsp_server/src/req.rs | 9 +++++---- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/crates/ra_lsp_server/src/main_loop.rs b/crates/ra_lsp_server/src/main_loop.rs index f7becd8fba..668d2fd729 100644 --- a/crates/ra_lsp_server/src/main_loop.rs +++ b/crates/ra_lsp_server/src/main_loop.rs @@ -431,6 +431,12 @@ fn on_notification( } Err(not) => not, }; + let not = match not.cast::() { + Ok(_params) => { + return Ok(()); + } + Err(not) => not, + }; log::error!("unhandled notification: {:?}", not); Ok(()) } diff --git a/crates/ra_lsp_server/src/req.rs b/crates/ra_lsp_server/src/req.rs index 27f2deb347..11af41a1da 100644 --- a/crates/ra_lsp_server/src/req.rs +++ b/crates/ra_lsp_server/src/req.rs @@ -5,10 +5,11 @@ use url_serde; pub use lsp_types::{ notification::*, request::*, ApplyWorkspaceEditParams, CodeActionParams, CodeLens, - CodeLensParams, CompletionParams, CompletionResponse, DocumentOnTypeFormattingParams, - DocumentSymbolParams, DocumentSymbolResponse, ExecuteCommandParams, Hover, InitializeResult, - MessageType, PublishDiagnosticsParams, ReferenceParams, ShowMessageParams, SignatureHelp, - TextDocumentEdit, TextDocumentPositionParams, TextEdit, WorkspaceEdit, WorkspaceSymbolParams, + CodeLensParams, CompletionParams, CompletionResponse, DidChangeConfigurationParams, + DocumentOnTypeFormattingParams, DocumentSymbolParams, DocumentSymbolResponse, + ExecuteCommandParams, Hover, InitializeResult, MessageType, PublishDiagnosticsParams, + ReferenceParams, ShowMessageParams, SignatureHelp, TextDocumentEdit, + TextDocumentPositionParams, TextEdit, WorkspaceEdit, WorkspaceSymbolParams, }; pub enum AnalyzerStatus {} From e81a47b8ebce9bcf680b15c6e0c1e879200f75df Mon Sep 17 00:00:00 2001 From: Michael Bolin Date: Wed, 10 Jul 2019 22:49:29 -0700 Subject: [PATCH 2/2] Remove executeCommandProvider: apply_code_action. This appears to have been introduced ages ago in https://github.com/rust-analyzer/rust-analyzer/commit/be742a587704f27f4e503c50f549aa9ec1527fcc but has since been removed. As it stands, it is problematic if multiple instances of the rust-analyzer LSP are launched during the same VS Code session because VS Code complains about multiple LSP servers trying to register the same command. Most LSP servers workaround this by parameterizing the command by the process id. For example, this is where `rls` does this: https://github.com/rust-lang/rls/blob/ff0b9057c8f62bc4f8113d741e96c9587ef1a817/rls/src/server/mod.rs#L413-L421 Though `apply_code_action` does not seems to be used, so it seems better to delete it than to parameterize it. --- crates/ra_lsp_server/src/caps.rs | 10 ++++------ crates/ra_lsp_server/src/req.rs | 8 ++++---- docs/dev/lsp-features.md | 2 -- 3 files changed, 8 insertions(+), 12 deletions(-) diff --git a/crates/ra_lsp_server/src/caps.rs b/crates/ra_lsp_server/src/caps.rs index 3851aadf24..bb9205aed4 100644 --- a/crates/ra_lsp_server/src/caps.rs +++ b/crates/ra_lsp_server/src/caps.rs @@ -1,8 +1,8 @@ use lsp_types::{ CodeActionProviderCapability, CodeLensOptions, CompletionOptions, - DocumentOnTypeFormattingOptions, ExecuteCommandOptions, FoldingRangeProviderCapability, - GenericCapability, ImplementationProviderCapability, RenameOptions, RenameProviderCapability, - ServerCapabilities, SignatureHelpOptions, TextDocumentSyncCapability, TextDocumentSyncKind, + DocumentOnTypeFormattingOptions, FoldingRangeProviderCapability, GenericCapability, + ImplementationProviderCapability, RenameOptions, RenameProviderCapability, ServerCapabilities, + SignatureHelpOptions, TextDocumentSyncCapability, TextDocumentSyncKind, TextDocumentSyncOptions, TypeDefinitionProviderCapability, }; @@ -44,9 +44,7 @@ pub fn server_capabilities() -> ServerCapabilities { prepare_provider: Some(true), })), color_provider: None, - execute_command_provider: Some(ExecuteCommandOptions { - commands: vec!["apply_code_action".to_string()], - }), + execute_command_provider: None, workspace: None, } } diff --git a/crates/ra_lsp_server/src/req.rs b/crates/ra_lsp_server/src/req.rs index 11af41a1da..8d39b04a74 100644 --- a/crates/ra_lsp_server/src/req.rs +++ b/crates/ra_lsp_server/src/req.rs @@ -6,10 +6,10 @@ use url_serde; pub use lsp_types::{ notification::*, request::*, ApplyWorkspaceEditParams, CodeActionParams, CodeLens, CodeLensParams, CompletionParams, CompletionResponse, DidChangeConfigurationParams, - DocumentOnTypeFormattingParams, DocumentSymbolParams, DocumentSymbolResponse, - ExecuteCommandParams, Hover, InitializeResult, MessageType, PublishDiagnosticsParams, - ReferenceParams, ShowMessageParams, SignatureHelp, TextDocumentEdit, - TextDocumentPositionParams, TextEdit, WorkspaceEdit, WorkspaceSymbolParams, + DocumentOnTypeFormattingParams, DocumentSymbolParams, DocumentSymbolResponse, Hover, + InitializeResult, MessageType, PublishDiagnosticsParams, ReferenceParams, ShowMessageParams, + SignatureHelp, TextDocumentEdit, TextDocumentPositionParams, TextEdit, WorkspaceEdit, + WorkspaceSymbolParams, }; pub enum AnalyzerStatus {} diff --git a/docs/dev/lsp-features.md b/docs/dev/lsp-features.md index 28bae59bb1..d3e79b8bee 100644 --- a/docs/dev/lsp-features.md +++ b/docs/dev/lsp-features.md @@ -16,8 +16,6 @@ This list documents LSP features, supported by rust-analyzer. - [ ] [workspace/configuration](https://microsoft.github.io/language-server-protocol/specification#workspace_configuration) - [x] [workspace/didChangeWatchedFiles](https://microsoft.github.io/language-server-protocol/specification#workspace_didChangeWatchedFiles) - [x] [workspace/symbol](https://microsoft.github.io/language-server-protocol/specification#workspace_symbol) -- [x] [workspace/executeCommand](https://microsoft.github.io/language-server-protocol/specification#workspace_executeCommand) - - `apply_code_action` - [ ] [workspace/applyEdit](https://microsoft.github.io/language-server-protocol/specification#workspace_applyEdit) ## Text Synchronization