about summary refs log tree commit diff stats
path: root/templates/shell/treefmt.nix
blob: 540a6cac28200bb5d8527c312100f9caecd0ded4 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
{
  treefmt-nix,
  pkgs,
}:
treefmt-nix.lib.evalModule pkgs (
  {pkgs, ...}: {
    # Used to find the project root
    projectRootFile = "flake.nix";

    programs = {
      alejandra.enable = true;
      rustfmt.enable = true;
      clang-format.enable = true;
      mdformat.enable = true;
      shfmt = {
        enable = true;
        indent_size = 4;
      };
      shellcheck.enable = true;
      prettier = {
        settings = {
          arrowParens = "always";
          bracketSameLine = false;
          bracketSpacing = true;
          editorconfig = true;
          embeddedLanguageFormatting = "auto";
          endOfLine = "lf";
          # experimentalTernaries = false;
          htmlWhitespaceSensitivity = "css";
          insertPragma = false;
          jsxSingleQuote = true;
          printWidth = 80;
          proseWrap = "always";
          quoteProps = "consistent";
          requirePragma = false;
          semi = true;
          singleAttributePerLine = true;
          singleQuote = true;
          trailingComma = "all";
          useTabs = false;
          vueIndentScriptAndStyle = false;

          tabWidth = 4;
          overrides = {
            files = ["*.js"];
            options.tabwidth = 2;
          };
        };
      };
      stylua.enable = true;
      ruff = {
        enable = true;
        format = true;
      };
      taplo.enable = true;
    };

    settings = {
      global.excludes = [
        "CHANGELOG.md"
        "NEWS.md"
        "%INIT_APPLICATION_NAME.1.md"
      ];
      formatter = {
        clang-format = {
          options = ["--style" "GNU"];
        };
        shfmt = {
          includes = ["*.bash"];
        };
      };
    };
  }
)