|
|
|
@ -747,6 +747,8 @@ impl LanguageConfiguration {
|
|
|
|
|
// always highlight syntax errors
|
|
|
|
|
// highlights_query += "\n(ERROR) @error";
|
|
|
|
|
|
|
|
|
|
let rainbows_query = read_query(&self.language_id, "rainbows.scm");
|
|
|
|
|
|
|
|
|
|
let injections_query = read_query(&self.language_id, "injections.scm");
|
|
|
|
|
let locals_query = read_query(&self.language_id, "locals.scm");
|
|
|
|
|
|
|
|
|
@ -765,6 +767,7 @@ impl LanguageConfiguration {
|
|
|
|
|
let config = HighlightConfiguration::new(
|
|
|
|
|
language,
|
|
|
|
|
&highlights_query,
|
|
|
|
|
&rainbows_query,
|
|
|
|
|
&injections_query,
|
|
|
|
|
&locals_query,
|
|
|
|
|
)
|
|
|
|
@ -1778,7 +1781,8 @@ pub enum HighlightEvent {
|
|
|
|
|
#[derive(Debug)]
|
|
|
|
|
pub struct HighlightConfiguration {
|
|
|
|
|
pub language: Grammar,
|
|
|
|
|
pub query: Query,
|
|
|
|
|
query: Query,
|
|
|
|
|
rainbow_query: Query,
|
|
|
|
|
injections_query: Query,
|
|
|
|
|
combined_injections_patterns: Vec<usize>,
|
|
|
|
|
highlights_pattern_index: usize,
|
|
|
|
@ -1876,6 +1880,7 @@ impl HighlightConfiguration {
|
|
|
|
|
pub fn new(
|
|
|
|
|
language: Grammar,
|
|
|
|
|
highlights_query: &str,
|
|
|
|
|
rainbow_query: &str,
|
|
|
|
|
injection_query: &str,
|
|
|
|
|
locals_query: &str,
|
|
|
|
|
) -> Result<Self, QueryError> {
|
|
|
|
@ -1895,6 +1900,7 @@ impl HighlightConfiguration {
|
|
|
|
|
highlights_pattern_index += 1;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
let rainbow_query = Query::new(&language, rainbow_query)?;
|
|
|
|
|
|
|
|
|
|
let injections_query = Query::new(&language, injection_query)?;
|
|
|
|
|
let combined_injections_patterns = (0..injections_query.pattern_count())
|
|
|
|
@ -1952,6 +1958,7 @@ impl HighlightConfiguration {
|
|
|
|
|
Ok(Self {
|
|
|
|
|
language,
|
|
|
|
|
query,
|
|
|
|
|
rainbow_query,
|
|
|
|
|
injections_query,
|
|
|
|
|
combined_injections_patterns,
|
|
|
|
|
highlights_pattern_index,
|
|
|
|
@ -2756,7 +2763,7 @@ mod test {
|
|
|
|
|
let textobject = TextObjectQuery { query };
|
|
|
|
|
let mut cursor = QueryCursor::new();
|
|
|
|
|
|
|
|
|
|
let config = HighlightConfiguration::new(language, "", "", "").unwrap();
|
|
|
|
|
let config = HighlightConfiguration::new(language, "", "", "", "").unwrap();
|
|
|
|
|
let syntax = Syntax::new(
|
|
|
|
|
source.slice(..),
|
|
|
|
|
Arc::new(config),
|
|
|
|
@ -2824,6 +2831,7 @@ mod test {
|
|
|
|
|
language,
|
|
|
|
|
&std::fs::read_to_string("../runtime/grammars/sources/rust/queries/highlights.scm")
|
|
|
|
|
.unwrap(),
|
|
|
|
|
"", // rainbows.scm
|
|
|
|
|
&std::fs::read_to_string("../runtime/grammars/sources/rust/queries/injections.scm")
|
|
|
|
|
.unwrap(),
|
|
|
|
|
"", // locals.scm
|
|
|
|
@ -2932,7 +2940,7 @@ mod test {
|
|
|
|
|
.unwrap();
|
|
|
|
|
let language = get_language(language_name).unwrap();
|
|
|
|
|
|
|
|
|
|
let config = HighlightConfiguration::new(language, "", "", "").unwrap();
|
|
|
|
|
let config = HighlightConfiguration::new(language, "", "", "", "").unwrap();
|
|
|
|
|
let syntax = Syntax::new(
|
|
|
|
|
source.slice(..),
|
|
|
|
|
Arc::new(config),
|
|
|
|
|