Skip to content
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.

rustfmt configuration file #5456

Closed
ivanceras opened this issue Mar 30, 2020 · 4 comments
Closed

rustfmt configuration file #5456

ivanceras opened this issue Mar 30, 2020 · 4 comments

Comments

@ivanceras
Copy link

There is no rustfmt.tomlused in the code, except for .editorconfig
I'm trying to replicate the configurations used in substrate code to rustfmt.toml,

unstable_features = true
max_width = 100
# substrate devs uses hardtabs as convention
hard_tabs = true
# prevent reorder imports
reorder_imports = false
# prevent reorder of module declarations
reorder_modules = false
imports_layout = "Mixed"
use_small_heuristics = "Max"

but everytime I invoke cargo fmt there are a lot of changes to the code.
I'm curious to find out how the substrate devs are synchronizing their format configurations.

@bkchr
Copy link
Member

bkchr commented Mar 31, 2020

Hey, we don't use rustfmt in Substrate.

Here you can find our style guide.

@bkchr bkchr closed this as completed Mar 31, 2020
@clearloop
Copy link
Contributor

clearloop commented May 21, 2020

but everytime I invoke cargo fmt there are a lot of changes to the code.
I'm curious to find out how the substrate devs are synchronizing their format configurations.

Same, used to add one line in a .rs file and it changes more than 50+ lines after saving...one of a branch on my fork added 3 methods and 2 structs, it changes more than 5000+ lines, this is horrible.

✄ ----------cargo:clippy-------------

To avoid unnecessary changes, I have to use TextEditor to apply the modification...

@burdges
Copy link

burdges commented May 21, 2020

Appears rustfmt.toml can disable rustfmt entirely by saying ignore = ["/"] after rust-lang/rustfmt#3388, which causes errors on stable, but that's fine.

@cecton cecton mentioned this issue Jun 2, 2020
@clearloop
Copy link
Contributor

In case somebody using emacs, and have (rust-format-on-save t) working in the configuration.

(lambda ()
  (if (string-match "substrate" buffer-file-name)
    (rust-disable-format-on-save)))

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

No branches or pull requests

4 participants