mirror of
https://github.com/joshuadavidthomas/django-language-server.git
synced 2025-09-06 18:30:35 +00:00
add publish diagnostics to notifier trait
This commit is contained in:
parent
810a591420
commit
2f9fdd6ceb
1 changed files with 21 additions and 0 deletions
|
@ -1,7 +1,9 @@
|
|||
use anyhow::Result;
|
||||
use tower_lsp::async_trait;
|
||||
use tower_lsp::lsp_types::Diagnostic;
|
||||
use tower_lsp::lsp_types::MessageActionItem;
|
||||
use tower_lsp::lsp_types::MessageType;
|
||||
use tower_lsp::lsp_types::Url;
|
||||
use tower_lsp::Client;
|
||||
|
||||
#[async_trait]
|
||||
|
@ -14,6 +16,12 @@ pub trait Notifier: Send + Sync {
|
|||
msg: &str,
|
||||
actions: Option<Vec<MessageActionItem>>,
|
||||
) -> Result<Option<MessageActionItem>>;
|
||||
fn publish_diagnostics(
|
||||
&self,
|
||||
uri: Url,
|
||||
diagnostics: Vec<Diagnostic>,
|
||||
version: Option<i32>,
|
||||
) -> Result<()>;
|
||||
}
|
||||
|
||||
pub struct TowerLspNotifier {
|
||||
|
@ -56,4 +64,17 @@ impl Notifier for TowerLspNotifier {
|
|||
let msg = msg.to_string();
|
||||
Ok(client.show_message_request(typ, msg, actions).await?)
|
||||
}
|
||||
|
||||
fn publish_diagnostics(
|
||||
&self,
|
||||
uri: Url,
|
||||
diagnostics: Vec<Diagnostic>,
|
||||
version: Option<i32>,
|
||||
) -> Result<()> {
|
||||
let client = self.client.clone();
|
||||
tokio::spawn(async move {
|
||||
client.publish_diagnostics(uri, diagnostics, version).await;
|
||||
});
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue