diff --git a/cli/loader/src/lib.rs b/cli/loader/src/lib.rs index 9f83b521..c58add8d 100644 --- a/cli/loader/src/lib.rs +++ b/cli/loader/src/lib.rs @@ -140,6 +140,8 @@ pub struct LanguageConfigurationJSON { #[derive(Serialize, Deserialize)] #[serde(rename_all = "kebab-case")] pub struct TreeSitterJSON { + #[serde(rename = "$schema")] + pub schema: Option, pub grammars: Vec, pub metadata: Metadata, #[serde(default)] diff --git a/cli/src/init.rs b/cli/src/init.rs index 0db4b5d9..819842c8 100644 --- a/cli/src/init.rs +++ b/cli/src/init.rs @@ -93,6 +93,9 @@ const TEST_BINDING_PY_TEMPLATE: &str = include_str!("./templates/test_binding.py const PACKAGE_SWIFT_TEMPLATE: &str = include_str!("./templates/package.swift"); const TESTS_SWIFT_TEMPLATE: &str = include_str!("./templates/tests.swift"); +const TREE_SITTER_JSON_SCHEMA: &str = + "https://tree-sitter.github.io/tree-sitter/assets/schemas/config.schema.json"; + #[must_use] pub fn path_in_ignore(repo_path: &Path) -> bool { [ @@ -133,6 +136,7 @@ impl JsonConfigOpts { #[must_use] pub fn to_tree_sitter_json(self) -> TreeSitterJSON { TreeSitterJSON { + schema: Some(TREE_SITTER_JSON_SCHEMA.to_string()), grammars: vec![Grammar { name: self.name.clone(), camelcase: Some(self.camelcase), @@ -226,6 +230,7 @@ pub fn migrate_package_json(repo_path: &Path) -> Result { let name = old_config.name.replace("tree-sitter-", ""); let new_config = TreeSitterJSON { + schema: Some(TREE_SITTER_JSON_SCHEMA.to_string()), grammars: old_config .tree_sitter .unwrap()