Skip to content

Support a per-user config #837

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

Closed
Stebalien opened this issue Feb 22, 2016 · 5 comments
Closed

Support a per-user config #837

Stebalien opened this issue Feb 22, 2016 · 5 comments

Comments

@Stebalien
Copy link
Contributor

I'd like to disable reformatting of my comments globally by-default because it tends to break things more often than not. To do this, rustfmt would need to support global configs. My suggestion is to read ~/.rustfmt.toml as global override and turn it off when rustfmt is passed a --no-user-config flag.

@nrc
Copy link
Member

nrc commented Mar 9, 2016

This sounds like a good idea, however, I'm somewhat concerned about the utility: in order for all users of a project to get consistent formatting we must ignore such a file completely if there is a per-project file. However, if a project is using rustfmt and the defaults, then it won't have a config file, but we should still not use the user's file. That seems an impossible choice for rustfmt to make.

I think it is probably easier to copy/paste a toml file into each new project. In fact this might even be done automatically - I wonder if we could change cargo to copy a user-default file when doing cargo new?

@kamalmarhubi
Copy link
Contributor

This sounds like a good idea, however, I'm somewhat concerned about the utility: in order for all users of a project to get consistent formatting we must ignore such a file completely if there is a per-project file.

I agree with this. I don't think that formatting settings make sense in a per-user file. What might make sense is to have a template that rustfmt offers to install in the project if there is no existing project file. This would be something like git's template facility. This would be a different issue though.

On reformatting comments, I suppose the best thing to do is report bugs as often as possible, and disable it in your projects in the meantime.

@kamalmarhubi
Copy link
Contributor

I just opened #871 to track the user config for non-formatting options like write_mode.

@kamalmarhubi
Copy link
Contributor

I also filed #872 for the template idea.

@Stebalien
Copy link
Contributor Author

I see both of your points. Currently, leaving out Cargo.toml has two possible interpretations:

  1. Use the defaults.
  2. No formatting rules have been specified.

#872 will fix this for crates (use rule 1) but, unfortunately, not for single file programs. My specific use case is,

  1. Open emacs.
  2. Edit some prog.rs file.
  3. Write some code.
  4. Save the file and auto format it.

However, I may be able to fix this in emacs itself.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants