Display language server info in the server logs tab (#22797)
Follow-up of https://github.com/zed-industries/zed/pull/19448 When dealing with issues like https://github.com/zed-industries/zed/issues/22749, it's quite tedious to ask for logs and check them out. This PR attempts to establish a single "diagnose my language server" place in the server logs panel, where server capabilities were already displayed after https://github.com/zed-industries/zed/pull/19448 The design is pretty brutal, but seems to be on par with the previous version and it's a technical corner of Zed, so seems to be ok for now:  Release Notes: - Improved lsp logs view to display more language server data
This commit is contained in:
parent
a653e8adda
commit
a331497367
3 changed files with 71 additions and 63 deletions
|
@ -82,6 +82,7 @@ pub struct LanguageServer {
|
|||
outbound_tx: channel::Sender<String>,
|
||||
name: LanguageServerName,
|
||||
process_name: Arc<str>,
|
||||
binary: LanguageServerBinary,
|
||||
capabilities: RwLock<ServerCapabilities>,
|
||||
code_action_kinds: Option<Vec<CodeActionKind>>,
|
||||
notification_handlers: Arc<Mutex<HashMap<&'static str, NotificationHandler>>>,
|
||||
|
@ -347,7 +348,7 @@ impl LanguageServer {
|
|||
let mut server = util::command::new_smol_command(&binary.path)
|
||||
.current_dir(working_dir)
|
||||
.args(&binary.arguments)
|
||||
.envs(binary.env.unwrap_or_default())
|
||||
.envs(binary.env.clone().unwrap_or_default())
|
||||
.stdin(Stdio::piped())
|
||||
.stdout(Stdio::piped())
|
||||
.stderr(Stdio::piped())
|
||||
|
@ -363,7 +364,7 @@ impl LanguageServer {
|
|||
let stdin = server.stdin.take().unwrap();
|
||||
let stdout = server.stdout.take().unwrap();
|
||||
let stderr = server.stderr.take().unwrap();
|
||||
let mut server = Self::new_internal(
|
||||
let server = Self::new_internal(
|
||||
server_id,
|
||||
server_name,
|
||||
stdin,
|
||||
|
@ -374,6 +375,7 @@ impl LanguageServer {
|
|||
root_path,
|
||||
working_dir,
|
||||
code_action_kinds,
|
||||
binary,
|
||||
cx,
|
||||
move |notification| {
|
||||
log::info!(
|
||||
|
@ -385,10 +387,6 @@ impl LanguageServer {
|
|||
},
|
||||
);
|
||||
|
||||
if let Some(name) = binary.path.file_name() {
|
||||
server.process_name = name.to_string_lossy().into();
|
||||
}
|
||||
|
||||
Ok(server)
|
||||
}
|
||||
|
||||
|
@ -404,6 +402,7 @@ impl LanguageServer {
|
|||
root_path: &Path,
|
||||
working_dir: &Path,
|
||||
code_action_kinds: Option<Vec<CodeActionKind>>,
|
||||
binary: LanguageServerBinary,
|
||||
cx: AsyncAppContext,
|
||||
on_unhandled_notification: F,
|
||||
) -> Self
|
||||
|
@ -466,7 +465,12 @@ impl LanguageServer {
|
|||
response_handlers,
|
||||
io_handlers,
|
||||
name: server_name,
|
||||
process_name: Arc::default(),
|
||||
process_name: binary
|
||||
.path
|
||||
.file_name()
|
||||
.map(|name| Arc::from(name.to_string_lossy()))
|
||||
.unwrap_or_default(),
|
||||
binary,
|
||||
capabilities: Default::default(),
|
||||
code_action_kinds,
|
||||
next_id: Default::default(),
|
||||
|
@ -1055,6 +1059,11 @@ impl LanguageServer {
|
|||
&self.root_path
|
||||
}
|
||||
|
||||
/// Language server's binary information.
|
||||
pub fn binary(&self) -> &LanguageServerBinary {
|
||||
&self.binary
|
||||
}
|
||||
|
||||
/// Sends a RPC request to the language server.
|
||||
///
|
||||
/// [LSP Specification](https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#requestMessage)
|
||||
|
@ -1278,12 +1287,13 @@ impl FakeLanguageServer {
|
|||
root,
|
||||
root,
|
||||
None,
|
||||
binary.clone(),
|
||||
cx.clone(),
|
||||
|_| {},
|
||||
);
|
||||
server.process_name = process_name;
|
||||
let fake = FakeLanguageServer {
|
||||
binary,
|
||||
binary: binary.clone(),
|
||||
server: Arc::new({
|
||||
let mut server = LanguageServer::new_internal(
|
||||
server_id,
|
||||
|
@ -1296,7 +1306,8 @@ impl FakeLanguageServer {
|
|||
root,
|
||||
root,
|
||||
None,
|
||||
cx,
|
||||
binary,
|
||||
cx.clone(),
|
||||
move |msg| {
|
||||
notifications_tx
|
||||
.try_send((
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue