Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make nix flake respect unused grammars #9326

Merged
merged 4 commits into from Jan 14, 2024

Conversation

loewenheim
Copy link
Contributor

@loewenheim loewenheim commented Jan 12, 2024

17dd102 marked some grammars as "do not use", but the nix flake doesn't respect this setting. This is my attempt to rectify this situation.

@the-mikedavis the-mikedavis linked an issue Jan 13, 2024 that may be closed by this pull request
Copy link
Member

@the-mikedavis the-mikedavis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Other than except, only is also possible and I think we should have grammars.nix respect it even if we don't currently use it in languages.toml: https://docs.helix-editor.com/languages.html#choosing-grammars

Here's where we do it in the source:

let grammars = match config.grammar_selection {
Some(GrammarSelection::Only { only: selections }) => config
.grammar
.into_iter()
.filter(|grammar| selections.contains(&grammar.grammar_id))
.collect(),
Some(GrammarSelection::Except { except: rejections }) => config
.grammar
.into_iter()
.filter(|grammar| !rejections.contains(&grammar.grammar_id))
.collect(),
None => config.grammar,
};

I believe if both only and except are defined then we prefer only (ignoring except).

@the-mikedavis the-mikedavis added C-enhancement Category: Improvements A-packaging Area: Packaging and bundling S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Jan 13, 2024
@loewenheim
Copy link
Contributor Author

Thanks for the heads-up, will refactor.

Copy link
Member

@the-mikedavis the-mikedavis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@the-mikedavis the-mikedavis added S-waiting-on-review Status: Awaiting review from a maintainer. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Jan 14, 2024
@pascalkuthe pascalkuthe merged commit a0b0210 into helix-editor:master Jan 14, 2024
6 checks passed
dgkf pushed a commit to dgkf/helix that referenced this pull request Jan 30, 2024
* 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>
nilium pushed a commit to nilium/helix that referenced this pull request Mar 10, 2024
* 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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-packaging Area: Packaging and bundling C-enhancement Category: Improvements S-waiting-on-review Status: Awaiting review from a maintainer.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Nix build error due to missing sources
3 participants