Skip to content

Commit

Permalink
syntax: Don't force lower-case for filenames (#4346)
Browse files Browse the repository at this point in the history
Just like for grammars we currently force a lower-case of the name for
some actions (like filesystem lookup). To make this consistent and less
surprising for users, we remove this lower-casing here.

Note: it is still the preferred way to name both language and grammar in
lower-case

Signed-off-by: Christian Speich <[email protected]>
  • Loading branch information
Christian Speich committed Oct 19, 2022
1 parent f77d360 commit 5a06fff
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions helix-core/src/syntax.rs
Original file line number Diff line number Diff line change
Expand Up @@ -355,14 +355,12 @@ pub fn read_query(language: &str, filename: &str) -> String {

impl LanguageConfiguration {
fn initialize_highlight(&self, scopes: &[String]) -> Option<Arc<HighlightConfiguration>> {
let language = self.language_id.to_ascii_lowercase();

let highlights_query = read_query(&language, "highlights.scm");
let highlights_query = read_query(&self.language_id, "highlights.scm");
// always highlight syntax errors
// highlights_query += "\n(ERROR) @error";

let injections_query = read_query(&language, "injections.scm");
let locals_query = read_query(&language, "locals.scm");
let injections_query = read_query(&self.language_id, "injections.scm");
let locals_query = read_query(&self.language_id, "locals.scm");

if highlights_query.is_empty() {
None
Expand Down Expand Up @@ -426,14 +424,20 @@ impl LanguageConfiguration {
}

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);
let query_text = read_query(&self.language_id, 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))
.map_err(|e| {
log::error!(
"Failed to parse {} queries for {}: {}",
kind,
self.language_id,
e
)
})
.ok()
}
}
Expand Down

0 comments on commit 5a06fff

Please sign in to comment.