Skip to content
New issue

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

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

Already on GitHub? # to your account

add support for nix #446

Open
adrian-gierakowski opened this issue Apr 27, 2023 · 7 comments
Open

add support for nix #446

adrian-gierakowski opened this issue Apr 27, 2023 · 7 comments
Labels
epic: usability-end-users Relates to the usability of Topiary for endusers to use Topiary as a generic "good enough" formatter P4 unimportant: consider wontfix or other priority type: feature request

Comments

@adrian-gierakowski
Copy link

Is your feature request related to a problem? Please describe.
I'd like to be able to use topiary to format nix code.

Describe the solution you'd like

  1. A tree-sitter grammar for nix to be added and nix as allowed language
  2. minimal demo formatter query file to be included with topiary

Describe alternatives you've considered
nope

Additional context
none

@Xophmeister
Copy link
Member

Thank you for your request 👍

We have so far resisted providing Nix formatting support, due to not wishing to compete with Alejandra. Your issue acts as counter-evidence to this, so we'll look into it.

@adrian-gierakowski
Copy link
Author

Thanks for replying @Xophmeister

Personally I'd love to use Alejandra however it is not customisation and I do not agree with a number of formatting choices it's authors have made.

Moreover there are a lot of issues on it's repo which have not received any attention whatsoever, which doesn't instil much confidence in the projects ability to evolve.

This project seems to provide a way to customise the formatting rules which I find preferable so I was hoping it could be used to better match my preferred style.

@adrian-gierakowski
Copy link
Author

examples ticket I've submitted personally:
kamadorueda/alejandra#350
kamadorueda/alejandra#349

and some submitted by others:
kamadorueda/alejandra#292
kamadorueda/alejandra#221
kamadorueda/alejandra#241

@adrian-gierakowski
Copy link
Author

@Xophmeister would you be able to give me some pointers? I’d be happy to submit a PR. Thanks!

@Xophmeister
Copy link
Member

Apologies @adrian-gierakowski; we didn't mean to leave you unanswered. We will consider adding Nix support. However, it's not a priority for the team, at the moment. Therefore, if you wish to experiment independently and submit a PR, it would be more than welcome 🙏

There is a suggested workflow in the README that describes the procedure for adding language support. Briefly, it involves:

  • Add the language's Tree-sitter grammar crate as a dependency.
  • Update the Rust code appropriately to expose the new language.
  • Write and test the language formatting rules.

The last point is the most involved and can't realistically be done in a single PR, as there will be many syntactic constructs you'll want to target. It's easiest to do these individually. During development of these formatting rules, I would strongly recommend creating "minimal examples" of each construction you are working on and generating their syntax visualisation (with --visualise=dot); examining this output in a GraphViz viewer, I've found, is particularly helpful.

Please let us know if there's anything more specific we can help with.

@adrian-gierakowski
Copy link
Author

Thanks @Xophmeister, I’ll look into it!

@ErinvanderVeen ErinvanderVeen added the P4 unimportant: consider wontfix or other priority label Jul 5, 2023
@ErinvanderVeen
Copy link
Collaborator

Marked as P4, as I think that #4 would already address this use-case, perhaps with a small demo query file for Nix.

@ErinvanderVeen ErinvanderVeen added the epic: usability-end-users Relates to the usability of Topiary for endusers to use Topiary as a generic "good enough" formatter label Sep 28, 2023
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
epic: usability-end-users Relates to the usability of Topiary for endusers to use Topiary as a generic "good enough" formatter P4 unimportant: consider wontfix or other priority type: feature request
Projects
None yet
Development

No branches or pull requests

3 participants