Skip to content

Commit 78e5144

Browse files
ribru17amaanq
authored andcommitted
feat: generate schema in tree-sitter.json
1 parent 05b2f44 commit 78e5144

File tree

2 files changed

+7
-0
lines changed

2 files changed

+7
-0
lines changed

cli/loader/src/lib.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,8 @@ pub struct LanguageConfigurationJSON {
140140
#[derive(Serialize, Deserialize)]
141141
#[serde(rename_all = "kebab-case")]
142142
pub struct TreeSitterJSON {
143+
#[serde(rename = "$schema")]
144+
pub schema: Option<String>,
143145
pub grammars: Vec<Grammar>,
144146
pub metadata: Metadata,
145147
#[serde(default)]

cli/src/init.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,9 @@ const TEST_BINDING_PY_TEMPLATE: &str = include_str!("./templates/test_binding.py
9393
const PACKAGE_SWIFT_TEMPLATE: &str = include_str!("./templates/package.swift");
9494
const TESTS_SWIFT_TEMPLATE: &str = include_str!("./templates/tests.swift");
9595

96+
const TREE_SITTER_JSON_SCHEMA: &str =
97+
"https://tree-sitter.github.io/tree-sitter/assets/schemas/config.schema.json";
98+
9699
#[must_use]
97100
pub fn path_in_ignore(repo_path: &Path) -> bool {
98101
[
@@ -133,6 +136,7 @@ impl JsonConfigOpts {
133136
#[must_use]
134137
pub fn to_tree_sitter_json(self) -> TreeSitterJSON {
135138
TreeSitterJSON {
139+
schema: Some(TREE_SITTER_JSON_SCHEMA.to_string()),
136140
grammars: vec![Grammar {
137141
name: self.name.clone(),
138142
camelcase: Some(self.camelcase),
@@ -226,6 +230,7 @@ pub fn migrate_package_json(repo_path: &Path) -> Result<bool> {
226230
let name = old_config.name.replace("tree-sitter-", "");
227231

228232
let new_config = TreeSitterJSON {
233+
schema: Some(TREE_SITTER_JSON_SCHEMA.to_string()),
229234
grammars: old_config
230235
.tree_sitter
231236
.unwrap()

0 commit comments

Comments
 (0)