Enable clangd's dot-to-arrow feature (#21142)

Closes #20815


![dot2arrow1127](https://github.com/user-attachments/assets/d825f9bf-52ae-47ee-b3a3-5f952b6e8979)

Release Notes:
- Enabled clangd's dot-to-arrow feature
This commit is contained in:
feeiyu 2024-11-28 16:43:25 +08:00 committed by GitHub
parent a4584c9d13
commit c2c968f2de
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 62 additions and 17 deletions

View file

@ -4,10 +4,11 @@ use futures::StreamExt;
use gpui::AsyncAppContext;
use http_client::github::{latest_github_release, GitHubLspBinaryVersion};
pub use language::*;
use lsp::{LanguageServerBinary, LanguageServerName};
use lsp::{InitializeParams, LanguageServerBinary, LanguageServerName};
use serde_json::json;
use smol::fs::{self, File};
use std::{any::Any, env::consts, path::PathBuf, sync::Arc};
use util::{fs::remove_matching, maybe, ResultExt};
use util::{fs::remove_matching, maybe, merge_json_value_into, ResultExt};
pub struct CLspAdapter;
@ -257,6 +258,26 @@ impl super::LspAdapter for CLspAdapter {
filter_range,
})
}
fn prepare_initialize_params(
&self,
mut original: InitializeParams,
) -> Result<InitializeParams> {
// enable clangd's dot-to-arrow feature.
let experimental = json!({
"textDocument": {
"completion" : {
"editsNearCursor": true
}
}
});
if let Some(ref mut original_experimental) = original.capabilities.experimental {
merge_json_value_into(experimental, original_experimental);
} else {
original.capabilities.experimental = Some(experimental);
}
Ok(original)
}
}
async fn get_cached_server_binary(container_dir: PathBuf) -> Option<LanguageServerBinary> {