minor: Simplify Document.language_id()

pull/2683/head
Blaž Hrastnik 2 years ago
parent b14c258a2c
commit 3d9923969a
No known key found for this signature in database
GPG Key ID: 1238B9C4AD889640

@ -854,9 +854,11 @@ impl Document {
/// `language-server` configuration, or the document language if no /// `language-server` configuration, or the document language if no
/// `language-id` has been specified. /// `language-id` has been specified.
pub fn language_id(&self) -> Option<&str> { pub fn language_id(&self) -> Option<&str> {
self.language_config() self.language_config()?
.and_then(|config| config.language_server.as_ref()) .language_server
.and_then(|lsp_config| lsp_config.language_id.as_deref()) .as_ref()?
.language_id
.as_deref()
.or_else(|| Some(self.language()?.rsplit_once('.')?.1)) .or_else(|| Some(self.language()?.rsplit_once('.')?.1))
} }

Loading…
Cancel
Save