From c1bac34c761f47fed1ed01a161ee81a798278f89 Mon Sep 17 00:00:00 2001 From: IWANABETHATGUY Date: Tue, 26 Dec 2023 16:37:25 +0800 Subject: [PATCH] fix(lsp): make the server available in nvim-lspconfig (#1823) 1. It seems that nvim-lspconfig diagnostics handler require **version** of **document**, now we can use `oxc_vscode` language server in neomvin with [nvim-lspconfig](https://github.com/neovim/nvim-lspconfig) ![image](https://github.com/oxc-project/oxc/assets/17974631/6b147333-341f-4226-a466-2b3d17b77215) --- editors/vscode/server/src/main.rs | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/editors/vscode/server/src/main.rs b/editors/vscode/server/src/main.rs index f92a1f7ae..e8f59009f 100644 --- a/editors/vscode/server/src/main.rs +++ b/editors/vscode/server/src/main.rs @@ -173,7 +173,7 @@ impl LanguageServer for Backend { if self.is_ignored(¶ms.text_document.uri).await { return; } - self.handle_file_update(params.text_document.uri, None).await; + self.handle_file_update(params.text_document.uri, None, None).await; } /// When the document changed, it may not be written to disk, so we should @@ -188,7 +188,12 @@ impl LanguageServer for Backend { return; } let content = params.content_changes.first().map(|c| c.text.clone()); - self.handle_file_update(params.text_document.uri, content).await; + self.handle_file_update( + params.text_document.uri, + content, + Some(params.text_document.version), + ) + .await; } async fn did_open(&self, params: DidOpenTextDocumentParams) { @@ -199,7 +204,8 @@ impl LanguageServer for Backend { if self.is_ignored(¶ms.text_document.uri).await { return; } - self.handle_file_update(params.text_document.uri, None).await; + self.handle_file_update(params.text_document.uri, None, Some(params.text_document.version)) + .await; } async fn did_close(&self, params: DidCloseTextDocumentParams) { @@ -304,7 +310,7 @@ impl Backend { .await; } - async fn handle_file_update(&self, uri: Url, content: Option) { + async fn handle_file_update(&self, uri: Url, content: Option, version: Option) { if let Some(Some(root_uri)) = self.root_uri.get() { self.server_linter.make_plugin(root_uri); if let Some(diagnostics) = self.server_linter.run_single(root_uri, &uri, content) {