From be343e10c6de106a03dd067460b46dc36112ecbd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jozef=20Steinh=C3=BCbl?= Date: Fri, 19 Jul 2024 15:07:59 +0200 Subject: [PATCH] refactor: cleanup --- lsp/src/discord.rs | 13 +++++++++---- lsp/src/main.rs | 45 +++------------------------------------------ 2 files changed, 12 insertions(+), 46 deletions(-) diff --git a/lsp/src/discord.rs b/lsp/src/discord.rs index 74881dd..a31af12 100644 --- a/lsp/src/discord.rs +++ b/lsp/src/discord.rs @@ -35,6 +35,12 @@ impl Discord { result.unwrap(); } + pub fn kill(&self) { + let mut client = self.get_client(); + let result = client.close(); + result.unwrap(); + } + pub fn change_file(&self, filename: &str, workspace: &str) { self.change_activity( format!("Working on {}", filename), @@ -58,12 +64,11 @@ impl Discord { .details(details.as_str()) .timestamps(Timestamps::new().start(timestamp)), ) - .expect( - format!( + .unwrap_or_else(|_| { + panic!( "Failed to set activity with state {} and details {}", state, details ) - .as_str(), - ); + }); } } diff --git a/lsp/src/main.rs b/lsp/src/main.rs index 6e6e663..839c14d 100644 --- a/lsp/src/main.rs +++ b/lsp/src/main.rs @@ -96,7 +96,7 @@ impl LanguageServer for Backend { }), capabilities: ServerCapabilities { text_document_sync: Some(TextDocumentSyncCapability::Kind( - TextDocumentSyncKind::NONE, + TextDocumentSyncKind::INCREMENTAL, )), ..Default::default() }, @@ -113,6 +113,8 @@ impl LanguageServer for Backend { } async fn shutdown(&self) -> Result<()> { + self.discord.kill(); + Ok(()) } @@ -125,47 +127,6 @@ impl LanguageServer for Backend { self.on_change(Document::new(params.text_document.uri)) .await; } - - async fn did_save(&self, params: DidSaveTextDocumentParams) { - self.on_change(Document::new(params.text_document.uri)) - .await; - } - - async fn hover(&self, params: HoverParams) -> Result> { - self.on_change(Document::new( - params.text_document_position_params.text_document.uri, - )) - .await; - - return Ok(None); - } - - async fn folding_range(&self, params: FoldingRangeParams) -> Result>> { - self.on_change(Document::new(params.text_document.uri)) - .await; - - return Ok(Some(vec![])); - } - - async fn semantic_tokens_full( - &self, - params: SemanticTokensParams, - ) -> Result> { - self.on_change(Document::new(params.text_document.uri)) - .await; - - return Ok(None); - } - - async fn semantic_tokens_full_delta( - &self, - params: SemanticTokensDeltaParams, - ) -> Result> { - self.on_change(Document::new(params.text_document.uri)) - .await; - - return Ok(None); - } } #[tokio::main]