forked from mirrors/nixpkgs
tree-sitter: add buildGrammar
to passthru
`buildGrammar` is useful for building custom grammars. Also, improve perf by moving `callPackage` out of the fn call. Use more precise var name: `change` -> `build`.
This commit is contained in:
parent
109fc99d1c
commit
99225ef64d
|
@ -51,10 +51,13 @@ let
|
|||
'' + (lib.concatStrings (lib.mapAttrsToList
|
||||
(name: grammar: "ln -s ${if grammar ? src then grammar.src else fetchGrammar grammar} $out/${name}\n")
|
||||
(import ./grammars { inherit lib; }))));
|
||||
|
||||
buildGrammar = callPackage ./grammar.nix { };
|
||||
|
||||
builtGrammars =
|
||||
let
|
||||
change = name: grammar:
|
||||
callPackage ./grammar.nix { } {
|
||||
build = name: grammar:
|
||||
buildGrammar {
|
||||
language = if grammar ? language then grammar.language else name;
|
||||
inherit version;
|
||||
source = if grammar ? src then grammar.src else fetchGrammar grammar;
|
||||
|
@ -70,7 +73,7 @@ let
|
|||
{ tree-sitter-markdown = grammars'.tree-sitter-markdown // { location = "tree-sitter-markdown"; }; } //
|
||||
{ tree-sitter-markdown-inline = grammars'.tree-sitter-markdown // { language = "markdown_inline"; location = "tree-sitter-markdown-inline"; }; };
|
||||
in
|
||||
lib.mapAttrs change (grammars);
|
||||
lib.mapAttrs build (grammars);
|
||||
|
||||
# Usage:
|
||||
# pkgs.tree-sitter.withPlugins (p: [ p.tree-sitter-c p.tree-sitter-java ... ])
|
||||
|
@ -142,7 +145,7 @@ rustPlatform.buildRustPackage {
|
|||
updater = {
|
||||
inherit update-all-grammars;
|
||||
};
|
||||
inherit grammars builtGrammars withPlugins allGrammars;
|
||||
inherit grammars buildGrammar builtGrammars withPlugins allGrammars;
|
||||
|
||||
tests = {
|
||||
# make sure all grammars build
|
||||
|
|
Loading…
Reference in a new issue