Skip to content

Commit

Permalink
Make nix flake respect unused grammars (helix-editor#9326)
Browse files Browse the repository at this point in the history
* Make nix flake respect unused grammars

* Use default value

* Refactor

* Take use-grammars.only into account

---------

Co-authored-by: Sebastian Zivota <[email protected]>
  • Loading branch information
2 people authored and nilium committed Mar 10, 2024
1 parent a2b43ce commit 2c6124b
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion grammars.nix
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,17 @@
owner = builtins.elemAt match 0;
repo = builtins.elemAt match 1;
};
gitGrammars = builtins.filter isGitGrammar languagesConfig.grammar;
# If `use-grammars.only` is set, use only those grammars.
# If `use-grammars.except` is set, use all other grammars.
# Otherwise use all grammars.
useGrammar = grammar:
if languagesConfig?use-grammars.only then
builtins.elem grammar.name languagesConfig.use-grammars.only
else if languagesConfig?use-grammars.except then
!(builtins.elem grammar.name languagesConfig.use-grammars.except)
else true;
grammarsToUse = builtins.filter useGrammar languagesConfig.grammar;
gitGrammars = builtins.filter isGitGrammar grammarsToUse;
buildGrammar = grammar: let
gh = toGitHubFetcher grammar.source.git;
sourceGit = builtins.fetchTree {
Expand Down

0 comments on commit 2c6124b

Please sign in to comment.