From 85e135d302be88a6d72fb277d709cb1ce7edc078 Mon Sep 17 00:00:00 2001 From: Damien Cassou Date: Mon, 9 Oct 2023 06:56:49 +0200 Subject: [PATCH 1/2] tree-sitter-grammars: add proto The tree-sitter-proto.json file was created by running the update script as described in tree-sitter/default.nix. --- .../tools/parsing/tree-sitter/grammars/default.nix | 1 + .../tree-sitter/grammars/tree-sitter-proto.json | 12 ++++++++++++ .../development/tools/parsing/tree-sitter/update.nix | 4 ++++ 3 files changed, 17 insertions(+) create mode 100644 pkgs/development/tools/parsing/tree-sitter/grammars/tree-sitter-proto.json diff --git a/pkgs/development/tools/parsing/tree-sitter/grammars/default.nix b/pkgs/development/tools/parsing/tree-sitter/grammars/default.nix index 0140f1236439..836f0c848538 100644 --- a/pkgs/development/tools/parsing/tree-sitter/grammars/default.nix +++ b/pkgs/development/tools/parsing/tree-sitter/grammars/default.nix @@ -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; diff --git a/pkgs/development/tools/parsing/tree-sitter/grammars/tree-sitter-proto.json b/pkgs/development/tools/parsing/tree-sitter/grammars/tree-sitter-proto.json new file mode 100644 index 000000000000..0bea1a55e3e0 --- /dev/null +++ b/pkgs/development/tools/parsing/tree-sitter/grammars/tree-sitter-proto.json @@ -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 +} diff --git a/pkgs/development/tools/parsing/tree-sitter/update.nix b/pkgs/development/tools/parsing/tree-sitter/update.nix index b2267f33c7bf..274d932dfe7f 100644 --- a/pkgs/development/tools/parsing/tree-sitter/update.nix +++ b/pkgs/development/tools/parsing/tree-sitter/update.nix @@ -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"; From 632c4140e90583338bc00469faf32e768aeb84e0 Mon Sep 17 00:00:00 2001 From: Damien Cassou Date: Mon, 9 Oct 2023 06:58:54 +0200 Subject: [PATCH 2/2] tree-sitter: let nixpkgs-format reformat the buffer --- .../tools/parsing/tree-sitter/update.nix | 68 ++++++++++--------- 1 file changed, 35 insertions(+), 33 deletions(-) diff --git a/pkgs/development/tools/parsing/tree-sitter/update.nix b/pkgs/development/tools/parsing/tree-sitter/update.nix index 274d932dfe7f..fffab5ea3f5f 100644 --- a/pkgs/development/tools/parsing/tree-sitter/update.nix +++ b/pkgs/development/tools/parsing/tree-sitter/update.nix @@ -407,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"; @@ -418,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. @@ -433,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. @@ -447,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; + } + })" '';