Skip to content

Commit 2c6124b

Browse files
loewenheimSebastian Zivota
authored andcommitted
Make nix flake respect unused grammars (helix-editor#9326)
* Make nix flake respect unused grammars * Use default value * Refactor * Take use-grammars.only into account --------- Co-authored-by: Sebastian Zivota <sebastian.zivota@mailbox.org>
1 parent a2b43ce commit 2c6124b

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

grammars.nix

+11-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,17 @@
2727
owner = builtins.elemAt match 0;
2828
repo = builtins.elemAt match 1;
2929
};
30-
gitGrammars = builtins.filter isGitGrammar languagesConfig.grammar;
30+
# If `use-grammars.only` is set, use only those grammars.
31+
# If `use-grammars.except` is set, use all other grammars.
32+
# Otherwise use all grammars.
33+
useGrammar = grammar:
34+
if languagesConfig?use-grammars.only then
35+
builtins.elem grammar.name languagesConfig.use-grammars.only
36+
else if languagesConfig?use-grammars.except then
37+
!(builtins.elem grammar.name languagesConfig.use-grammars.except)
38+
else true;
39+
grammarsToUse = builtins.filter useGrammar languagesConfig.grammar;
40+
gitGrammars = builtins.filter isGitGrammar grammarsToUse;
3141
buildGrammar = grammar: let
3242
gh = toGitHubFetcher grammar.source.git;
3343
sourceGit = builtins.fetchTree {

0 commit comments

Comments
 (0)