Skip to content

Commit

Permalink
write out types for grammars under LanguageConfiguration
Browse files Browse the repository at this point in the history
  • Loading branch information
the-mikedavis committed Feb 14, 2022
1 parent d165681 commit 70a78d3
Show file tree
Hide file tree
Showing 3 changed files with 320 additions and 178 deletions.
1 change: 1 addition & 0 deletions helix-core/src/indent.rs
Original file line number Diff line number Diff line change
Expand Up @@ -445,6 +445,7 @@ where
indent_query: OnceCell::new(),
textobject_query: OnceCell::new(),
}],
grammar: vec![],
});

// set runtime path so we can find the queries
Expand Down
25 changes: 24 additions & 1 deletion helix-core/src/syntax.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ where
#[serde(deny_unknown_fields)]
pub struct Configuration {
pub language: Vec<LanguageConfiguration>,
pub grammar: Vec<GrammarConfiguration>,
}

// largely based on tree-sitter/cli/src/loader.rs
Expand Down Expand Up @@ -147,6 +148,25 @@ pub struct IndentQuery {
pub outdent: HashSet<String>,
}

#[derive(Debug, Serialize, Deserialize)]
pub struct GrammarConfiguration {
#[serde(rename = "name")]
pub grammar_id: String, // c-sharp, rust
pub source: GrammarSource,
pub path: Option<String>,
}

#[derive(Debug, Serialize, Deserialize)]
#[serde(rename_all = "lowercase")]
pub enum GrammarSource {
#[serde(rename = "path")]
Local(String),
Git {
remote: String,
rev: String,
},
}

#[derive(Debug)]
pub struct TextObjectQuery {
pub query: Query,
Expand Down Expand Up @@ -1849,7 +1869,10 @@ mod test {
.map(String::from)
.collect();

let loader = Loader::new(Configuration { language: vec![] });
let loader = Loader::new(Configuration {
language: vec![],
grammar: vec![],
});

let language = get_language(&crate::RUNTIME_DIR, "Rust").unwrap();
let config = HighlightConfiguration::new(
Expand Down
Loading

0 comments on commit 70a78d3

Please sign in to comment.