Add handlers for LogMessage and statusNotification to copilot LSP

This commit is contained in:
Mikayla Maki 2023-03-31 10:58:18 -07:00
parent 54582fd77f
commit 4865ea2efc
3 changed files with 53 additions and 1 deletions

View file

@ -11,8 +11,10 @@ use gpui::{
Task,
};
use language::{point_from_lsp, point_to_lsp, Anchor, Bias, Buffer, BufferSnapshot, ToPointUtf16};
use log::{debug, error, info, warn};
use lsp::LanguageServer;
use node_runtime::NodeRuntime;
use request::{LogMessage, StatusNotification};
use settings::Settings;
use smol::{fs, io::BufReader, stream::StreamExt};
use std::{
@ -241,6 +243,27 @@ impl Copilot {
local_checks_only: false,
})
.await?;
server
.on_notification::<LogMessage, _>(|params, _cx| {
match params.level {
// Copilot is pretty agressive about logging
0 => debug!("copilot: {}", params.message),
1 => debug!("copilot: {}", params.message),
_ => error!("copilot: {}", params.message),
}
debug!("copilot metadata: {}", params.metadata_str);
debug!("copilot extra: {:?}", params.extra);
})
.detach();
server
.on_notification::<StatusNotification, _>(
|_, _| { /* Silence the notification */ },
)
.detach();
anyhow::Ok((server, status))
};