minor: Simplify Document.language_id()
This commit is contained in:
parent
b14c258a2c
commit
3d9923969a
1 changed files with 5 additions and 3 deletions
|
@ -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…
Add table
Reference in a new issue