aboutsummaryrefslogtreecommitdiff
path: root/helix-core/src/syntax.rs
diff options
context:
space:
mode:
authorBlaž Hrastnik2021-02-24 07:07:39 +0000
committerBlaž Hrastnik2021-02-24 07:07:39 +0000
commit87a6d4e73615e17559b99afa065799a38fe6c39e (patch)
tree23e437304421ec88a355e3ef887cf6cb4a322591 /helix-core/src/syntax.rs
parentc6456d04b9f16ed8f5ad0f256a38218b514de5dc (diff)
minor: Simplify some code.
Diffstat (limited to 'helix-core/src/syntax.rs')
-rw-r--r--helix-core/src/syntax.rs13
1 files changed, 5 insertions, 8 deletions
diff --git a/helix-core/src/syntax.rs b/helix-core/src/syntax.rs
index 32974e11..0f6b7319 100644
--- a/helix-core/src/syntax.rs
+++ b/helix-core/src/syntax.rs
@@ -27,12 +27,9 @@ pub struct LanguageConfiguration {
}
impl LanguageConfiguration {
- pub fn highlight_config(
- &self,
- scopes: &[String],
- ) -> Result<Option<&Arc<HighlightConfiguration>>, anyhow::Error> {
+ pub fn highlight_config(&self, scopes: &[String]) -> Option<Arc<HighlightConfiguration>> {
self.highlight_config
- .get_or_try_init(|| {
+ .get_or_init(|| {
// let name = get_language_name(&self.language_id);
let highlights_query =
@@ -46,7 +43,7 @@ impl LanguageConfiguration {
let locals_query = "";
if highlights_query.is_empty() {
- Ok(None)
+ None
} else {
let language = get_language(self.language_id);
let mut config = HighlightConfiguration::new(
@@ -57,10 +54,10 @@ impl LanguageConfiguration {
)
.unwrap(); // TODO: no unwrap
config.configure(&scopes);
- Ok(Some(Arc::new(config)))
+ Some(Arc::new(config))
}
})
- .map(Option::as_ref)
+ .clone()
}
pub fn scope(&self) -> &str {