7 includeGrammarIf ? _: true,
11 # HACK: nix < 2.6 has a bug in the toml parser, so we convert to JSON
13 languages-json = runCommandLocal "languages-toml-to-json" {} ''
14 ${yj}/bin/yj -t < ${./languages.toml} > $out
17 if lib.versionAtLeast builtins.nixVersion "2.6.0"
18 then builtins.fromTOML (builtins.readFile ./languages.toml)
19 else builtins.fromJSON (builtins.readFile (builtins.toPath languages-json));
20 isGitGrammar = grammar:
21 builtins.hasAttr "source" grammar
22 && builtins.hasAttr "git" grammar.source
23 && builtins.hasAttr "rev" grammar.source;
24 isGitHubGrammar = grammar: lib.hasPrefix "https://github.com" grammar.source.git;
25 toGitHubFetcher = url: let
26 match = builtins.match "https://github\.com/([^/]*)/([^/]*)/?" url;
28 owner = builtins.elemAt match 0;
29 repo = builtins.elemAt match 1;
31 gitGrammars = builtins.filter isGitGrammar languagesConfig.grammar;
32 buildGrammar = grammar: let
33 gh = toGitHubFetcher grammar.source.git;
34 sourceGit = builtins.fetchTree {
36 url = grammar.source.git;
37 rev = grammar.source.rev;
38 ref = grammar.source.ref or "HEAD";
41 sourceGitHub = builtins.fetchTree {
45 inherit (grammar.source) rev;
48 if isGitHubGrammar grammar
53 # see https://github.com/NixOS/nixpkgs/blob/fbdd1a7c0bc29af5325e0d7dd70e804a972eb465/pkgs/development/tools/parsing/tree-sitter/grammar.nix
55 pname = "helix-tree-sitter-${grammar.name}";
56 version = grammar.source.rev;
59 sourceRoot = if builtins.hasAttr "subpath" grammar.source then
60 "source/${grammar.source.subpath}"
80 if [[ -e src/scanner.cc ]]; then
81 $CXX -c src/scanner.cc -o scanner.o $FLAGS
82 elif [[ -e src/scanner.c ]]; then
83 $CC -c src/scanner.c -o scanner.o $FLAGS
86 $CC -c src/parser.c -o parser.o $FLAGS
87 $CXX -shared -o $NAME.so *.o
101 # Strip failed on darwin: strip: error: symbols referenced by indirect symbol table entries that can't be stripped
102 fixupPhase = lib.optionalString stdenv.isLinux ''
108 grammarsToBuild = builtins.filter includeGrammarIf gitGrammars;
109 builtGrammars = builtins.map (grammar: {
110 inherit (grammar) name;
111 value = buildGrammar grammar;
114 lib.makeExtensible (self: builtins.listToAttrs builtGrammars);
115 overlayedGrammars = lib.pipe extensibleGrammars
116 (builtins.map (overlay: grammar: grammar.extend overlay) grammarOverlays);
117 grammarLinks = lib.mapAttrsToList
118 (name: artifact: "ln -s ${artifact}/${name}.so $out/${name}.so")
119 (lib.filterAttrs (n: v: lib.isDerivation v) overlayedGrammars);
121 runCommand "consolidated-helix-grammars" {} ''
123 ${builtins.concatStringsSep "\n" grammarLinks}
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list