chore: clean up grammars.nix (#13506)

pull/13508/head
bloxx12 2025-05-10 12:58:48 +00:00 committed by GitHub
parent cb1ecc9128
commit 9bb370c91e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 1 additions and 10 deletions

View File

@ -1,22 +1,13 @@
{ {
stdenv, stdenv,
lib, lib,
runCommandLocal,
runCommand, runCommand,
yj,
includeGrammarIf ? _: true, includeGrammarIf ? _: true,
grammarOverlays ? [], grammarOverlays ? [],
... ...
}: let }: let
# HACK: nix < 2.6 has a bug in the toml parser, so we convert to JSON
# before parsing
languages-json = runCommandLocal "languages-toml-to-json" {} ''
${yj}/bin/yj -t < ${./languages.toml} > $out
'';
languagesConfig = languagesConfig =
if lib.versionAtLeast builtins.nixVersion "2.6.0" builtins.fromTOML (builtins.readFile ./languages.toml);
then builtins.fromTOML (builtins.readFile ./languages.toml)
else builtins.fromJSON (builtins.readFile (builtins.toPath languages-json));
isGitGrammar = grammar: isGitGrammar = grammar:
builtins.hasAttr "source" grammar builtins.hasAttr "source" grammar
&& builtins.hasAttr "git" grammar.source && builtins.hasAttr "git" grammar.source