|
|
@ -399,28 +399,15 @@ impl LanguageConfiguration {
|
|
|
|
|
|
|
|
|
|
|
|
pub fn indent_query(&self) -> Option<&Query> {
|
|
|
|
pub fn indent_query(&self) -> Option<&Query> {
|
|
|
|
self.indent_query
|
|
|
|
self.indent_query
|
|
|
|
.get_or_init(|| {
|
|
|
|
.get_or_init(|| self.load_query("indents.scm"))
|
|
|
|
let lang_name = self.language_id.to_ascii_lowercase();
|
|
|
|
|
|
|
|
let query_text = read_query(&lang_name, "indents.scm");
|
|
|
|
|
|
|
|
if query_text.is_empty() {
|
|
|
|
|
|
|
|
return None;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
let lang = self.highlight_config.get()?.as_ref()?.language;
|
|
|
|
|
|
|
|
Query::new(lang, &query_text).ok()
|
|
|
|
|
|
|
|
})
|
|
|
|
|
|
|
|
.as_ref()
|
|
|
|
.as_ref()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
pub fn textobject_query(&self) -> Option<&TextObjectQuery> {
|
|
|
|
pub fn textobject_query(&self) -> Option<&TextObjectQuery> {
|
|
|
|
self.textobject_query
|
|
|
|
self.textobject_query
|
|
|
|
.get_or_init(|| -> Option<TextObjectQuery> {
|
|
|
|
.get_or_init(|| {
|
|
|
|
let lang_name = self.language_id.to_ascii_lowercase();
|
|
|
|
self.load_query("textobjects.scm")
|
|
|
|
let query_text = read_query(&lang_name, "textobjects.scm");
|
|
|
|
.map(|query| TextObjectQuery { query })
|
|
|
|
let lang = self.highlight_config.get()?.as_ref()?.language;
|
|
|
|
|
|
|
|
let query = Query::new(lang, &query_text)
|
|
|
|
|
|
|
|
.map_err(|e| log::error!("Failed to parse textobjects.scm queries: {}", e))
|
|
|
|
|
|
|
|
.ok()?;
|
|
|
|
|
|
|
|
Some(TextObjectQuery { query })
|
|
|
|
|
|
|
|
})
|
|
|
|
})
|
|
|
|
.as_ref()
|
|
|
|
.as_ref()
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -428,6 +415,18 @@ impl LanguageConfiguration {
|
|
|
|
pub fn scope(&self) -> &str {
|
|
|
|
pub fn scope(&self) -> &str {
|
|
|
|
&self.scope
|
|
|
|
&self.scope
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
fn load_query(&self, kind: &str) -> Option<Query> {
|
|
|
|
|
|
|
|
let lang_name = self.language_id.to_ascii_lowercase();
|
|
|
|
|
|
|
|
let query_text = read_query(&lang_name, kind);
|
|
|
|
|
|
|
|
if query_text.is_empty() {
|
|
|
|
|
|
|
|
return None;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
let lang = self.highlight_config.get()?.as_ref()?.language;
|
|
|
|
|
|
|
|
Query::new(lang, &query_text)
|
|
|
|
|
|
|
|
.map_err(|e| log::error!("Failed to parse {} queries for {}: {}", kind, lang_name, e))
|
|
|
|
|
|
|
|
.ok()
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Expose loader as Lazy<> global since it's always static?
|
|
|
|
// Expose loader as Lazy<> global since it's always static?
|
|
|
|