mirror of
https://github.com/RGBCube/alejandra
synced 2025-07-31 12:37:45 +00:00
chore: add treefmt - to format them all
- this is a unified & modern approch to keeping all files according to fmt-spec - has excellent editor integration
This commit is contained in:
parent
b72274b052
commit
0f227ee76a
3 changed files with 77 additions and 1 deletions
39
flake.lock
generated
39
flake.lock
generated
|
@ -21,6 +21,21 @@
|
||||||
"type": "github"
|
"type": "github"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"flake-utils": {
|
||||||
|
"locked": {
|
||||||
|
"lastModified": 1610051610,
|
||||||
|
"narHash": "sha256-U9rPz/usA1/Aohhk7Cmc2gBrEEKRzcW4nwPWMPwja4Y=",
|
||||||
|
"owner": "numtide",
|
||||||
|
"repo": "flake-utils",
|
||||||
|
"rev": "3982c9903e93927c2164caa727cd3f6a0e6d14cc",
|
||||||
|
"type": "github"
|
||||||
|
},
|
||||||
|
"original": {
|
||||||
|
"owner": "numtide",
|
||||||
|
"repo": "flake-utils",
|
||||||
|
"type": "github"
|
||||||
|
}
|
||||||
|
},
|
||||||
"flakeCompat": {
|
"flakeCompat": {
|
||||||
"flake": false,
|
"flake": false,
|
||||||
"locked": {
|
"locked": {
|
||||||
|
@ -73,7 +88,8 @@
|
||||||
"fenix": "fenix",
|
"fenix": "fenix",
|
||||||
"flakeCompat": "flakeCompat",
|
"flakeCompat": "flakeCompat",
|
||||||
"flakeUtils": "flakeUtils",
|
"flakeUtils": "flakeUtils",
|
||||||
"nixpkgs": "nixpkgs"
|
"nixpkgs": "nixpkgs",
|
||||||
|
"treefmt": "treefmt"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"rust-analyzer-src": {
|
"rust-analyzer-src": {
|
||||||
|
@ -92,6 +108,27 @@
|
||||||
"repo": "rust-analyzer",
|
"repo": "rust-analyzer",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
"treefmt": {
|
||||||
|
"inputs": {
|
||||||
|
"flake-utils": "flake-utils",
|
||||||
|
"nixpkgs": [
|
||||||
|
"nixpkgs"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"locked": {
|
||||||
|
"lastModified": 1640364438,
|
||||||
|
"narHash": "sha256-sV1Oa9JVNmpAwZ4cnVs7ovHrKL8EPg3J08jPX/a48LI=",
|
||||||
|
"owner": "numtide",
|
||||||
|
"repo": "treefmt",
|
||||||
|
"rev": "26d7f5f15e5d22d4413ba7c5ae0447fdc0b5cc76",
|
||||||
|
"type": "github"
|
||||||
|
},
|
||||||
|
"original": {
|
||||||
|
"owner": "numtide",
|
||||||
|
"repo": "treefmt",
|
||||||
|
"type": "github"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"root": "root",
|
"root": "root",
|
||||||
|
|
|
@ -5,6 +5,8 @@
|
||||||
flakeCompat.url = github:edolstra/flake-compat;
|
flakeCompat.url = github:edolstra/flake-compat;
|
||||||
flakeCompat.flake = false;
|
flakeCompat.flake = false;
|
||||||
flakeUtils.url = "github:numtide/flake-utils";
|
flakeUtils.url = "github:numtide/flake-utils";
|
||||||
|
treefmt.url = "github:numtide/treefmt";
|
||||||
|
treefmt.inputs.nixpkgs.follows = "nixpkgs";
|
||||||
nixpkgs.url = "github:nixos/nixpkgs/nixpkgs-unstable";
|
nixpkgs.url = "github:nixos/nixpkgs/nixpkgs-unstable";
|
||||||
};
|
};
|
||||||
outputs =
|
outputs =
|
||||||
|
@ -15,6 +17,7 @@
|
||||||
let
|
let
|
||||||
nixpkgs = import inputs.nixpkgs { inherit system; };
|
nixpkgs = import inputs.nixpkgs { inherit system; };
|
||||||
cargoToml = builtins.fromTOML ( builtins.readFile ./Cargo.toml );
|
cargoToml = builtins.fromTOML ( builtins.readFile ./Cargo.toml );
|
||||||
|
treefmt = inputs.treefmt.defaultPackage.${ system };
|
||||||
fenix = inputs.fenix.packages.${ system };
|
fenix = inputs.fenix.packages.${ system };
|
||||||
fenixPlatform = nixpkgs.makeRustPlatform { inherit ( fenix.latest ) cargo rustc; };
|
fenixPlatform = nixpkgs.makeRustPlatform { inherit ( fenix.latest ) cargo rustc; };
|
||||||
in
|
in
|
||||||
|
@ -53,7 +56,11 @@
|
||||||
fenix.latest.rust-src
|
fenix.latest.rust-src
|
||||||
fenix.latest.rustc
|
fenix.latest.rustc
|
||||||
fenix.latest.rustfmt
|
fenix.latest.rustfmt
|
||||||
|
treefmt
|
||||||
|
nixpkgs.shfmt
|
||||||
|
nixpkgs.nodePackages.prettier
|
||||||
];
|
];
|
||||||
|
shellHook = "cargo build";
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
32
treefmt.toml
Normal file
32
treefmt.toml
Normal file
|
@ -0,0 +1,32 @@
|
||||||
|
# One CLI to format the code tree - https://github.com/numtide/treefmt
|
||||||
|
|
||||||
|
[formatter.nix]
|
||||||
|
command = "./target/debug/alejandra"
|
||||||
|
includes = ["*.nix"]
|
||||||
|
|
||||||
|
[formatter.prettier]
|
||||||
|
command = "prettier"
|
||||||
|
options = ["--write"]
|
||||||
|
includes = [
|
||||||
|
"*.css",
|
||||||
|
"*.html",
|
||||||
|
"*.js",
|
||||||
|
"*.json",
|
||||||
|
"*.jsx",
|
||||||
|
"*.md",
|
||||||
|
"*.mdx",
|
||||||
|
"*.scss",
|
||||||
|
"*.ts",
|
||||||
|
"*.yaml",
|
||||||
|
]
|
||||||
|
|
||||||
|
[formatter.shell]
|
||||||
|
command = "shfmt"
|
||||||
|
options = [
|
||||||
|
"-i",
|
||||||
|
"2", # indent 2
|
||||||
|
"-s", # simplify the code
|
||||||
|
"-w", # write back to the file
|
||||||
|
]
|
||||||
|
includes = ["*.sh"]
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue