Skip to content

Commit 2f9fdd6

Browse files
add publish diagnostics to notifier trait
1 parent 810a591 commit 2f9fdd6

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

crates/djls/src/notifier.rs

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
use anyhow::Result;
22
use tower_lsp::async_trait;
3+
use tower_lsp::lsp_types::Diagnostic;
34
use tower_lsp::lsp_types::MessageActionItem;
45
use tower_lsp::lsp_types::MessageType;
6+
use tower_lsp::lsp_types::Url;
57
use tower_lsp::Client;
68

79
#[async_trait]
@@ -14,6 +16,12 @@ pub trait Notifier: Send + Sync {
1416
msg: &str,
1517
actions: Option<Vec<MessageActionItem>>,
1618
) -> Result<Option<MessageActionItem>>;
19+
fn publish_diagnostics(
20+
&self,
21+
uri: Url,
22+
diagnostics: Vec<Diagnostic>,
23+
version: Option<i32>,
24+
) -> Result<()>;
1725
}
1826

1927
pub struct TowerLspNotifier {
@@ -56,4 +64,17 @@ impl Notifier for TowerLspNotifier {
5664
let msg = msg.to_string();
5765
Ok(client.show_message_request(typ, msg, actions).await?)
5866
}
67+
68+
fn publish_diagnostics(
69+
&self,
70+
uri: Url,
71+
diagnostics: Vec<Diagnostic>,
72+
version: Option<i32>,
73+
) -> Result<()> {
74+
let client = self.client.clone();
75+
tokio::spawn(async move {
76+
client.publish_diagnostics(uri, diagnostics, version).await;
77+
});
78+
Ok(())
79+
}
5980
}

0 commit comments

Comments
 (0)