summary refs log tree commit diff stats
path: root/treefmt.nix
blob: e2c6aeaedcc5a8c8f6e5b13d1f06b77bd5098c45 (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
75
76
77
78
79
80
81
82
83
84
85
86
{
  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;
        settings = {
          sort_requires.enabled = true;
          column_width = 120;
          line_endings = "Unix";
          indent_type = "Spaces";
          indent_width = 2;
          quote_style = "ForceDouble";
          call_parentheses = "Always";
          # space_after_function_names = "Never";
          collapse_simple_statement = "Always";
        };
      };
      ruff = {
        enable = true;
        format = true;
      };
      taplo.enable = true;
    };

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