lsp: Add support for clangd's inactiveRegions
extension (#26146)
Closes #13089 Here we use `experimental` to advertise our support for `inactiveRegions`. Note that clangd does not currently have a stable release that reads the `experimental` object (PR https://github.com/llvm/llvm-project/pull/116531), this can be tested with one of clangd's recent "unstable snapshots" in their [releases](https://github.com/clangd/clangd/releases). Release Notes: - Added support for clangd's `inactiveRegions` extension.  --------- Co-authored-by: Peter Tripp <peter@zed.dev> Co-authored-by: Kirill Bulatov <kirill@zed.dev>
This commit is contained in:
parent
af5af9d7c5
commit
829ecda370
9 changed files with 174 additions and 82 deletions
|
@ -1,9 +1,12 @@
|
|||
pub mod clangd_ext;
|
||||
pub mod lsp_ext_command;
|
||||
pub mod rust_analyzer_ext;
|
||||
|
||||
use crate::{
|
||||
buffer_store::{BufferStore, BufferStoreEvent},
|
||||
deserialize_code_actions,
|
||||
environment::ProjectEnvironment,
|
||||
lsp_command::{self, *},
|
||||
lsp_ext_command,
|
||||
prettier_store::{self, PrettierStore, PrettierStoreEvent},
|
||||
project_settings::{LspSettings, ProjectSettings},
|
||||
project_tree::{AdapterQuery, LanguageServerTree, LaunchDisposition, ProjectTree},
|
||||
|
@ -48,8 +51,8 @@ use lsp::{
|
|||
FileOperationPatternKind, FileOperationRegistrationOptions, FileRename, FileSystemWatcher,
|
||||
InsertTextFormat, LanguageServer, LanguageServerBinary, LanguageServerBinaryOptions,
|
||||
LanguageServerId, LanguageServerName, LspRequestFuture, MessageActionItem, MessageType, OneOf,
|
||||
RenameFilesParams, ServerHealthStatus, ServerStatus, SymbolKind, TextEdit, WillRenameFiles,
|
||||
WorkDoneProgressCancelParams, WorkspaceFolder,
|
||||
RenameFilesParams, SymbolKind, TextEdit, WillRenameFiles, WorkDoneProgressCancelParams,
|
||||
WorkspaceFolder,
|
||||
};
|
||||
use node_runtime::read_package_installed_version;
|
||||
use parking_lot::Mutex;
|
||||
|
@ -841,50 +844,6 @@ impl LocalLspStore {
|
|||
}
|
||||
})
|
||||
.detach();
|
||||
|
||||
language_server
|
||||
.on_notification::<ServerStatus, _>({
|
||||
let this = this.clone();
|
||||
let name = name.to_string();
|
||||
move |params, mut cx| {
|
||||
let this = this.clone();
|
||||
let name = name.to_string();
|
||||
if let Some(ref message) = params.message {
|
||||
let message = message.trim();
|
||||
if !message.is_empty() {
|
||||
let formatted_message = format!(
|
||||
"Language server {name} (id {server_id}) status update: {message}"
|
||||
);
|
||||
match params.health {
|
||||
ServerHealthStatus::Ok => log::info!("{}", formatted_message),
|
||||
ServerHealthStatus::Warning => log::warn!("{}", formatted_message),
|
||||
ServerHealthStatus::Error => {
|
||||
log::error!("{}", formatted_message);
|
||||
let (tx, _rx) = smol::channel::bounded(1);
|
||||
let request = LanguageServerPromptRequest {
|
||||
level: PromptLevel::Critical,
|
||||
message: params.message.unwrap_or_default(),
|
||||
actions: Vec::new(),
|
||||
response_channel: tx,
|
||||
lsp_name: name.clone(),
|
||||
};
|
||||
let _ = this
|
||||
.update(&mut cx, |_, cx| {
|
||||
cx.emit(LspStoreEvent::LanguageServerPrompt(request));
|
||||
})
|
||||
.ok();
|
||||
}
|
||||
ServerHealthStatus::Other(status) => {
|
||||
log::info!(
|
||||
"Unknown server health: {status}\n{formatted_message}"
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
.detach();
|
||||
language_server
|
||||
.on_notification::<lsp::notification::ShowMessage, _>({
|
||||
let this = this.clone();
|
||||
|
@ -970,6 +929,9 @@ impl LocalLspStore {
|
|||
}
|
||||
})
|
||||
.detach();
|
||||
|
||||
rust_analyzer_ext::register_notifications(this.clone(), language_server);
|
||||
clangd_ext::register_notifications(this, language_server, adapter);
|
||||
}
|
||||
|
||||
fn shutdown_language_servers(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue