Use lowercased language name as language id fallback (#11412)

This commit is contained in:
Kirill Bulatov 2024-05-05 22:27:18 +03:00 committed by GitHub
parent 5a71d8c7f1
commit 1e84f01041
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 27 additions and 21 deletions

View file

@ -152,7 +152,7 @@ pub struct CachedLspAdapter {
pub name: LanguageServerName,
pub disk_based_diagnostic_sources: Vec<String>,
pub disk_based_diagnostics_progress_token: Option<String>,
pub language_ids: HashMap<String, String>,
language_ids: HashMap<String, String>,
pub adapter: Arc<dyn LspAdapter>,
pub reinstall_attempt_count: AtomicU64,
/// Indicates whether this language server is the primary language server
@ -248,6 +248,13 @@ impl CachedLspAdapter {
.await
}
pub fn language_id(&self, language: &Language) -> String {
self.language_ids
.get(language.name().as_ref())
.cloned()
.unwrap_or_else(|| language.lsp_id())
}
#[cfg(any(test, feature = "test-support"))]
fn as_fake(&self) -> Option<&FakeLspAdapter> {
self.adapter.as_fake()
@ -1373,6 +1380,13 @@ impl Language {
pub fn prettier_plugins(&self) -> &Vec<Arc<str>> {
&self.config.prettier_plugins
}
pub fn lsp_id(&self) -> String {
match self.config.name.as_ref() {
"Plain Text" => "plaintext".to_string(),
language_name => language_name.to_lowercase(),
}
}
}
impl LanguageScope {