Add TOML formatter (prettier)
This commit is contained in:
parent
fec10f2cfc
commit
2a26070ea4
3
.prettierrc.js
Normal file
3
.prettierrc.js
Normal file
|
@ -0,0 +1,3 @@
|
|||
module.exports = {
|
||||
"plugins": ["prettier-plugin-toml"],
|
||||
};
|
10
flake.nix
10
flake.nix
|
@ -25,12 +25,18 @@
|
|||
in
|
||||
{
|
||||
|
||||
treefmt = stdenv.mkDerivation {
|
||||
treefmt =
|
||||
let
|
||||
devShell = devShells.default;
|
||||
in
|
||||
stdenv.mkDerivation {
|
||||
name = "treefmt-check";
|
||||
src = self;
|
||||
nativeBuildInputs = devShells.default.nativeBuildInputs;
|
||||
nativeBuildInputs = devShell.nativeBuildInputs;
|
||||
dontConfigure = true;
|
||||
|
||||
inherit (devShell) NODE_PATH;
|
||||
|
||||
buildPhase = ''
|
||||
env HOME=$(mktemp -d) treefmt --fail-on-change
|
||||
'';
|
||||
|
|
|
@ -29,6 +29,7 @@ in
|
|||
pkgs.treefmt
|
||||
pkgs.llvmPackages.clang # clang-format
|
||||
pkgs.nixpkgs-fmt
|
||||
pkgs.nodePackages.prettier
|
||||
|
||||
(pkgs.python3.withPackages (ps: [
|
||||
ps.pytest
|
||||
|
@ -36,6 +37,8 @@ in
|
|||
|
||||
];
|
||||
|
||||
NODE_PATH = "${pkgs.nodePackages.prettier-plugin-toml}/lib/node_modules";
|
||||
|
||||
shellHook = lib.optionalString stdenv.isLinux ''
|
||||
export NIX_DEBUG_INFO_DIRS="${pkgs.curl.debug}/lib/debug:${nix.debug}/lib/debug''${NIX_DEBUG_INFO_DIRS:+:$NIX_DEBUG_INFO_DIRS}"
|
||||
'';
|
||||
|
|
13
treefmt.toml
13
treefmt.toml
|
@ -1,8 +1,17 @@
|
|||
[formatter."c++"]
|
||||
command = "clang-format"
|
||||
options = [ "-i", "-style", "{BasedOnStyle: llvm, IndentWidth: 4, SortIncludes: false}" ]
|
||||
includes = [ "*.c", "*.cpp", "*.cc", "*.h", "*.hpp" ]
|
||||
options = [
|
||||
"-i",
|
||||
"-style",
|
||||
"{BasedOnStyle: llvm, IndentWidth: 4, SortIncludes: false}"
|
||||
]
|
||||
includes = ["*.c", "*.cpp", "*.cc", "*.h", "*.hpp"]
|
||||
|
||||
[formatter.nix]
|
||||
command = "nixpkgs-fmt"
|
||||
includes = ["*.nix"]
|
||||
|
||||
[formatter.toml]
|
||||
command = "prettier"
|
||||
options = ["--write"]
|
||||
includes = ["*.toml"]
|
||||
|
|
Loading…
Reference in a new issue