Skip to content

Commit

Permalink
fix: disable pull diagnostics
Browse files Browse the repository at this point in the history
  • Loading branch information
washanhanzi committed Nov 21, 2024
1 parent 003908c commit 10530fa
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 47 deletions.
30 changes: 12 additions & 18 deletions src/controller/diagnostic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,7 @@ impl DiagnosticController {
let rev = self.rev.entry(uri.clone()).or_insert(0);
*rev += 1;
let diags: Vec<Diagnostic> = diags_map.values().cloned().collect();
self.client
.publish_diagnostics(uri.clone(), diags, Some(*rev))
.await;
publish(&self.client, uri, diags).await;
}

pub async fn add_parse_diagnostic(&mut self, uri: &Uri, id: &str, diag: Diagnostic) {
Expand All @@ -66,9 +64,7 @@ impl DiagnosticController {
let diags_map = self.diagnostics.get(uri).unwrap();
// Update the revision number for the given URI
let diags: Vec<Diagnostic> = diags_map.values().cloned().collect();
self.client
.publish_diagnostics(uri.clone(), diags, None)
.await;
publish(&self.client, uri, diags).await;
}

pub async fn clear_cargo_diagnostics(&mut self, uri: &Uri) {
Expand All @@ -77,9 +73,7 @@ impl DiagnosticController {

// Update diagnostics display
let diags: Vec<Diagnostic> = diags_map.values().cloned().collect();
self.client
.publish_diagnostics(uri.clone(), diags, None)
.await;
publish(&self.client, uri, diags).await;
}
}

Expand All @@ -89,9 +83,7 @@ impl DiagnosticController {

// Update diagnostics display
let diags: Vec<Diagnostic> = diags_map.values().cloned().collect();
self.client
.publish_diagnostics(uri.clone(), diags, None)
.await;
publish(&self.client, uri, diags).await;
}
}

Expand All @@ -106,9 +98,7 @@ impl DiagnosticController {
let diags_map = self.diagnostics.get(uri).unwrap();
// Update the revision number for the given URI
let diags: Vec<Diagnostic> = diags_map.values().cloned().collect();
self.client
.publish_diagnostics(uri.clone(), diags, None)
.await;
publish(&self.client, uri, diags).await;
}

pub async fn clear_audit_diagnostics(&mut self) {
Expand All @@ -117,9 +107,13 @@ impl DiagnosticController {

// Update diagnostics display
let diags: Vec<Diagnostic> = diags_map.values().cloned().collect();
self.client
.publish_diagnostics(uri.clone(), diags, None)
.await;
publish(&self.client, uri, diags).await;
}
}
}

async fn publish(client: &Client, uri: &Uri, diags: Vec<Diagnostic>) {
if !diags.is_empty() {
client.publish_diagnostics(uri.clone(), diags, None).await
}
}
5 changes: 4 additions & 1 deletion src/decoration/inlay_hint.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ use tower_lsp::{
lsp_types::{InlayHint, InlayHintLabel, InlayHintLabelPart, Position, Uri},
Client,
};
use tracing::error;

use crate::config::GLOBAL_CONFIG;

Expand Down Expand Up @@ -146,7 +147,9 @@ impl InlayHintDecoration {
inlay_hint_decoration_state::update_range(&state, &uri, &id, range);
}
}
client.inlay_hint_refresh().await.unwrap();
if let Err(e) = client.inlay_hint_refresh().await {
error!("inlay hint refresh error: {}", e);
}
}
});
render_tx
Expand Down
28 changes: 0 additions & 28 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -80,23 +80,6 @@ impl LanguageServer for CargoAppraiser {
file_operations: None,
}),
inlay_hint_provider: Some(OneOf::Left(true)),
diagnostic_provider: Some(DiagnosticServerCapabilities::RegistrationOptions(
DiagnosticRegistrationOptions {
text_document_registration_options: TextDocumentRegistrationOptions {
document_selector: Some(vec![DocumentFilter {
language: Some("toml".to_string()),
pattern: Some("**/Cargo.toml".to_string()),
scheme: None,
}]),
},
diagnostic_options: DiagnosticOptions {
workspace_diagnostics: false,
inter_file_dependencies: false,
..Default::default()
},
..Default::default()
},
)),
..Default::default()
},
..Default::default()
Expand All @@ -107,17 +90,6 @@ impl LanguageServer for CargoAppraiser {
info!("cargo-appraiser server initialized!");
}

async fn diagnostic(
&self,
_: DocumentDiagnosticParams,
) -> Result<DocumentDiagnosticReportResult> {
Ok(DocumentDiagnosticReportResult::Partial(
DocumentDiagnosticReportPartialResult {
related_documents: None,
},
))
}

async fn goto_definition(
&self,
params: GotoDefinitionParams,
Expand Down

0 comments on commit 10530fa

Please sign in to comment.