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 mtoohey31 committed Jun 2, 2024
1 parent 85b35a1 commit 58c69dc
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 @@ -28,7 +28,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 58c69dc

Please sign in to comment.