cli: Fix loading of parsers with no tree-sitter section in package.json
This commit is contained in:
parent
0dff46865c
commit
4d63697036
1 changed files with 17 additions and 4 deletions
|
|
@ -370,10 +370,6 @@ impl Loader {
|
|||
if let Ok(package_json_contents) = fs::read_to_string(&parser_path.join("package.json")) {
|
||||
let package_json = serde_json::from_str::<PackageJSON>(&package_json_contents);
|
||||
if let Ok(package_json) = package_json {
|
||||
if package_json.tree_sitter.is_empty() {
|
||||
return Ok(&[]);
|
||||
}
|
||||
|
||||
let language_count = self.languages_by_id.len();
|
||||
for config_json in package_json.tree_sitter {
|
||||
// Determine the path to the parser directory. This can be specified in
|
||||
|
|
@ -428,6 +424,23 @@ impl Loader {
|
|||
}
|
||||
}
|
||||
|
||||
if self.language_configurations.len() == initial_language_configuration_count
|
||||
&& parser_path.join("src").join("grammar.json").exists()
|
||||
{
|
||||
self.language_configurations.push(LanguageConfiguration {
|
||||
language_id: self.languages_by_id.len(),
|
||||
scope: None,
|
||||
content_regex: None,
|
||||
injection_regex: None,
|
||||
file_types: Vec::new(),
|
||||
_first_line_regex: None,
|
||||
highlight_property_sheet_path: None,
|
||||
highlight_property_sheet: OnceCell::new(),
|
||||
});
|
||||
self.languages_by_id
|
||||
.push((parser_path.to_owned(), OnceCell::new()));
|
||||
}
|
||||
|
||||
Ok(&self.language_configurations[initial_language_configuration_count..])
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue