diff --git a/flake.lock b/flake.lock index 8b637c3..3422f25 100644 --- a/flake.lock +++ b/flake.lock @@ -1,5 +1,26 @@ { "nodes": { + "fenix": { + "inputs": { + "nixpkgs": [ + "nixpkgs" + ], + "rust-analyzer-src": "rust-analyzer-src" + }, + "locked": { + "lastModified": 1657434367, + "narHash": "sha256-GR/3TFaG/77MQEYjvRRueELUrbz10fa68xcU1Ej4Ww0=", + "owner": "nix-community", + "repo": "fenix", + "rev": "a73d841dbc39cdd881ae2ee7cb3991e357f9f9cc", + "type": "github" + }, + "original": { + "owner": "nix-community", + "repo": "fenix", + "type": "github" + } + }, "flakeCompat": { "flake": false, "locked": { @@ -34,9 +55,27 @@ }, "root": { "inputs": { + "fenix": "fenix", "flakeCompat": "flakeCompat", "nixpkgs": "nixpkgs" } + }, + "rust-analyzer-src": { + "flake": false, + "locked": { + "lastModified": 1657398392, + "narHash": "sha256-HU1+Rql35ouZe0lx1ftCMDDwC9lqN3COudvMe+8XIx0=", + "owner": "rust-lang", + "repo": "rust-analyzer", + "rev": "5342f47f4276641ddb5f0a5e08fb307742d6cdc4", + "type": "github" + }, + "original": { + "owner": "rust-lang", + "ref": "nightly", + "repo": "rust-analyzer", + "type": "github" + } } }, "root": "root", diff --git a/flake.nix b/flake.nix index 4137baf..cadec60 100644 --- a/flake.nix +++ b/flake.nix @@ -2,6 +2,9 @@ description = "The Uncompromising Nix Code Formatter"; inputs = { + fenix.url = "github:nix-community/fenix"; + fenix.inputs.nixpkgs.follows = "nixpkgs"; + flakeCompat.url = github:edolstra/flake-compat; flakeCompat.flake = false; @@ -103,6 +106,7 @@ cargo-tarpaulin clippy jq + inputs.fenix.packages."x86_64-linux".latest.rustfmt linuxPackages_latest.perf nodejs nodePackages.prettier diff --git a/rustfmt.toml b/rustfmt.toml index 7a70519..fa252a1 100644 --- a/rustfmt.toml +++ b/rustfmt.toml @@ -1,18 +1,25 @@ +# https://github.com/kamadorueda/machine/blob/main/nixos-modules/editor/rustfmt.toml edition = "2021" enum_discrim_align_threshold = 999 +# force_multiline_blocks = true format_code_in_doc_comments = true format_generated_files = true format_macro_bodies = true format_macro_matchers = true format_strings = true +group_imports = "StdExternalCrate" hex_literal_case = "Lower" imports_granularity = "Item" imports_layout = "Vertical" +# match_block_trailing_comma = true max_width = 80 normalize_comments = true normalize_doc_attributes = true +overflow_delimited_expr = true reorder_impl_items = true struct_field_align_threshold = 999 unstable_features = true +use_field_init_shorthand = true use_small_heuristics = "Max" version = "Two" +wrap_comments = true diff --git a/src/alejandra_cli/src/cli.rs b/src/alejandra_cli/src/cli.rs index e508d19..7e120b7 100644 --- a/src/alejandra_cli/src/cli.rs +++ b/src/alejandra_cli/src/cli.rs @@ -29,11 +29,13 @@ struct Args { #[clap(long, short, multiple_occurrences = true)] exclude: Vec, - /// Check if the input is already formatted and disable writing in-place the modified content + /// Check if the input is already formatted and disable writing in-place + /// the modified content #[clap(long, short)] check: bool, - /// Number of formatting threads to spawn. Defaults to the number of logical CPUs. + /// Number of formatting threads to spawn. Defaults to the number of + /// logical CPUs. #[clap(long, short)] threads: Option,