Use new language server info on remote servers (#35682)
* Straightens out the `*_ext.rs` workflow for clangd and rust-analyzer: no need to asynchronously query for the language server, as we sync that information already. * Fixes inlay hints editor menu toggle not being shown in the remote sessions Release Notes: - Fixed inlay hints editor menu toggle not being shown in the remote sessions
This commit is contained in:
parent
cc93175256
commit
9caa9d042a
14 changed files with 176 additions and 291 deletions
|
@ -3,12 +3,12 @@ use std::sync::Arc;
|
|||
use ::serde::{Deserialize, Serialize};
|
||||
use gpui::WeakEntity;
|
||||
use language::{CachedLspAdapter, Diagnostic, DiagnosticSourceKind};
|
||||
use lsp::LanguageServer;
|
||||
use lsp::{LanguageServer, LanguageServerName};
|
||||
use util::ResultExt as _;
|
||||
|
||||
use crate::LspStore;
|
||||
|
||||
pub const CLANGD_SERVER_NAME: &str = "clangd";
|
||||
pub const CLANGD_SERVER_NAME: LanguageServerName = LanguageServerName::new_static("clangd");
|
||||
const INACTIVE_REGION_MESSAGE: &str = "inactive region";
|
||||
const INACTIVE_DIAGNOSTIC_SEVERITY: lsp::DiagnosticSeverity = lsp::DiagnosticSeverity::INFORMATION;
|
||||
|
||||
|
@ -34,7 +34,7 @@ pub fn is_inactive_region(diag: &Diagnostic) -> bool {
|
|||
&& diag
|
||||
.source
|
||||
.as_ref()
|
||||
.is_some_and(|v| v == CLANGD_SERVER_NAME)
|
||||
.is_some_and(|v| v == &CLANGD_SERVER_NAME.0)
|
||||
}
|
||||
|
||||
pub fn is_lsp_inactive_region(diag: &lsp::Diagnostic) -> bool {
|
||||
|
@ -43,7 +43,7 @@ pub fn is_lsp_inactive_region(diag: &lsp::Diagnostic) -> bool {
|
|||
&& diag
|
||||
.source
|
||||
.as_ref()
|
||||
.is_some_and(|v| v == CLANGD_SERVER_NAME)
|
||||
.is_some_and(|v| v == &CLANGD_SERVER_NAME.0)
|
||||
}
|
||||
|
||||
pub fn register_notifications(
|
||||
|
@ -51,7 +51,7 @@ pub fn register_notifications(
|
|||
language_server: &LanguageServer,
|
||||
adapter: Arc<CachedLspAdapter>,
|
||||
) {
|
||||
if language_server.name().0 != CLANGD_SERVER_NAME {
|
||||
if language_server.name() != CLANGD_SERVER_NAME {
|
||||
return;
|
||||
}
|
||||
let server_id = language_server.server_id();
|
||||
|
|
|
@ -2,12 +2,12 @@ use ::serde::{Deserialize, Serialize};
|
|||
use anyhow::Context as _;
|
||||
use gpui::{App, Entity, Task, WeakEntity};
|
||||
use language::ServerHealth;
|
||||
use lsp::LanguageServer;
|
||||
use lsp::{LanguageServer, LanguageServerName};
|
||||
use rpc::proto;
|
||||
|
||||
use crate::{LspStore, LspStoreEvent, Project, ProjectPath, lsp_store};
|
||||
|
||||
pub const RUST_ANALYZER_NAME: &str = "rust-analyzer";
|
||||
pub const RUST_ANALYZER_NAME: LanguageServerName = LanguageServerName::new_static("rust-analyzer");
|
||||
pub const CARGO_DIAGNOSTICS_SOURCE_NAME: &str = "rustc";
|
||||
|
||||
/// Experimental: Informs the end user about the state of the server
|
||||
|
@ -97,13 +97,9 @@ pub fn cancel_flycheck(
|
|||
|
||||
cx.spawn(async move |cx| {
|
||||
let buffer = buffer.await?;
|
||||
let Some(rust_analyzer_server) = project
|
||||
.update(cx, |project, cx| {
|
||||
buffer.update(cx, |buffer, cx| {
|
||||
project.language_server_id_for_name(buffer, RUST_ANALYZER_NAME, cx)
|
||||
})
|
||||
})?
|
||||
.await
|
||||
let Some(rust_analyzer_server) = project.read_with(cx, |project, cx| {
|
||||
project.language_server_id_for_name(buffer.read(cx), &RUST_ANALYZER_NAME, cx)
|
||||
})?
|
||||
else {
|
||||
return Ok(());
|
||||
};
|
||||
|
@ -148,13 +144,9 @@ pub fn run_flycheck(
|
|||
|
||||
cx.spawn(async move |cx| {
|
||||
let buffer = buffer.await?;
|
||||
let Some(rust_analyzer_server) = project
|
||||
.update(cx, |project, cx| {
|
||||
buffer.update(cx, |buffer, cx| {
|
||||
project.language_server_id_for_name(buffer, RUST_ANALYZER_NAME, cx)
|
||||
})
|
||||
})?
|
||||
.await
|
||||
let Some(rust_analyzer_server) = project.read_with(cx, |project, cx| {
|
||||
project.language_server_id_for_name(buffer.read(cx), &RUST_ANALYZER_NAME, cx)
|
||||
})?
|
||||
else {
|
||||
return Ok(());
|
||||
};
|
||||
|
@ -204,13 +196,9 @@ pub fn clear_flycheck(
|
|||
|
||||
cx.spawn(async move |cx| {
|
||||
let buffer = buffer.await?;
|
||||
let Some(rust_analyzer_server) = project
|
||||
.update(cx, |project, cx| {
|
||||
buffer.update(cx, |buffer, cx| {
|
||||
project.language_server_id_for_name(buffer, RUST_ANALYZER_NAME, cx)
|
||||
})
|
||||
})?
|
||||
.await
|
||||
let Some(rust_analyzer_server) = project.read_with(cx, |project, cx| {
|
||||
project.language_server_id_for_name(buffer.read(cx), &RUST_ANALYZER_NAME, cx)
|
||||
})?
|
||||
else {
|
||||
return Ok(());
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue