Merge pull request #259909 from DamienCassou/treesitter-grammar-proto

This commit is contained in:
Damien Cassou 2023-10-12 11:33:56 +02:00 committed by GitHub
commit 888764eaf3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 52 additions and 33 deletions

View File

@ -66,6 +66,7 @@
tree-sitter-php = lib.importJSON ./tree-sitter-php.json;
tree-sitter-pioasm = lib.importJSON ./tree-sitter-pioasm.json;
tree-sitter-prisma = lib.importJSON ./tree-sitter-prisma.json;
tree-sitter-proto = lib.importJSON ./tree-sitter-proto.json;
tree-sitter-pug = lib.importJSON ./tree-sitter-pug.json;
tree-sitter-python = lib.importJSON ./tree-sitter-python.json;
tree-sitter-ql = lib.importJSON ./tree-sitter-ql.json;

View File

@ -0,0 +1,12 @@
{
"url": "https://github.com/mitchellh/tree-sitter-proto",
"rev": "42d82fa18f8afe59b5fc0b16c207ee4f84cb185f",
"date": "2021-06-12T09:29:04-07:00",
"path": "/nix/store/dsfx2jxc6nll0324pl3w6qcdv5acvyj5-tree-sitter-proto",
"sha256": "001y2z2683fagryqj5f0gs3rcgx2nbw3x3r9afydhss80ihb8zvi",
"hash": "sha256-cX+0YARIa9i8UymPPviyoj+Wh37AFYl9fsoNZMQXPgA=",
"fetchLFS": false,
"fetchSubmodules": false,
"deepClone": false,
"leaveDotGit": false
}

View File

@ -126,6 +126,10 @@ let
orga = "MDeiml";
repo = "tree-sitter-markdown";
};
"tree-sitter-proto" = {
orga = "mitchellh";
repo = "tree-sitter-proto";
};
"tree-sitter-rego" = {
orga = "FallenAngel97";
repo = "tree-sitter-rego";
@ -403,7 +407,8 @@ let
jsonFile = name: val: (formats.json { }).generate name val;
# implementation of the updater
updateImpl = passArgs "updateImpl-with-args" {
updateImpl = passArgs "updateImpl-with-args"
{
binaries = {
curl = "${curl}/bin/curl";
nix-prefetch-git = "${nix-prefetch-git}/bin/nix-prefetch-git";
@ -414,9 +419,10 @@ let
ignoredTreeSitterOrgRepos
;
}
(writers.writePython3 "updateImpl" {
flakeIgnore = ["E501"];
} ./update_impl.py);
(writers.writePython3 "updateImpl"
{
flakeIgnore = [ "E501" ];
} ./update_impl.py);
# Pass the given arguments to the command, in the ARGS environment variable.
# The arguments are just a json object that should be available in the script.
@ -429,7 +435,7 @@ let
lib.concatMapStringsSep "\n" f
(lib.mapAttrsToList (k: v: { name = k; } // v) attrs);
jsonNewlines = lib.concatMapStringsSep "\n" (lib.generators.toJSON {});
jsonNewlines = lib.concatMapStringsSep "\n" (lib.generators.toJSON { });
# Run the given script for each of the attr list.
# The attrs are passed to the script as a json value.
@ -443,34 +449,34 @@ let
outputDir = "${toString ./.}/grammars";
update-all-grammars = writeShellScript "update-all-grammars.sh" ''
set -euo pipefail
${updateImpl} fetch-and-check-tree-sitter-repos '{}'
echo "writing files to ${outputDir}" 1>&2
mkdir -p "${outputDir}"
${forEachParallel
"repos-to-fetch"
(writeShellScript "fetch-repo" ''
${updateImpl} fetch-repo "$1"
'')
(lib.mapAttrsToList
(nixRepoAttrName: attrs: attrs // {
inherit
nixRepoAttrName
outputDir;
})
allGrammars)
}
${updateImpl} print-all-grammars-nix-file "$(< ${
jsonFile "all-grammars.json" {
allGrammars =
(lib.mapAttrsToList
(nixRepoAttrName: attrs: attrs // {
inherit nixRepoAttrName;
})
allGrammars);
inherit outputDir;
}
})"
set -euo pipefail
${updateImpl} fetch-and-check-tree-sitter-repos '{}'
echo "writing files to ${outputDir}" 1>&2
mkdir -p "${outputDir}"
${forEachParallel
"repos-to-fetch"
(writeShellScript "fetch-repo" ''
${updateImpl} fetch-repo "$1"
'')
(lib.mapAttrsToList
(nixRepoAttrName: attrs: attrs // {
inherit
nixRepoAttrName
outputDir;
})
allGrammars)
}
${updateImpl} print-all-grammars-nix-file "$(< ${
jsonFile "all-grammars.json" {
allGrammars =
(lib.mapAttrsToList
(nixRepoAttrName: attrs: attrs // {
inherit nixRepoAttrName;
})
allGrammars);
inherit outputDir;
}
})"
'';