summaryrefslogtreecommitdiffstatshomepage
path: root/treefmt.nix
blob: 1716d457c04c2a4c84a7416d82e5abe9349c37b0 (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
{
  pkgs,
  excludes ? [ ],
  ...
}:
{
  projectRootFile = "flake.nix";

  programs = {
    gofmt = {
      enable = true;
    };

    mdformat = {
      enable = true;

      package = pkgs.mdformat.withPlugins (
        p: with p; [
          # add support for github flavored markdown
          mdformat-gfm
          mdformat-gfm-alerts

          # add support for markdown tables
          mdformat-tables

          # add the following comment before running `nix fmt` to generate a
          # table of contents in markdown files:
          #     <!-- mdformat-toc start -->
          mdformat-toc
        ]
      );

      settings = {
        end-of-line = "lf";
        number = true;
        wrap = 80;
      };
    };

    nixfmt = {
      enable = true;
      strict = true;
    };

    # this is disabled due to `//webui` not yet being integrated with the flake.
    # the entire package directory is ignored below in
    # `settings.global.excludes`.
    prettier = {
      enable = false;

      settings = {
        singleQuote = true;
        trailingComma = "es5";
      };
    };

    shfmt = {
      enable = true;
    };

    yamlfmt = {
      enable = true;

      settings.formatter = {
        eof_newline = true;
        include_document_start = true;
        retain_line_breaks_single = true;
        trim_trailing_whitespace = true;
      };
    };
  };

  settings.global.excludes =
    pkgs.lib.lists.unique [
      "*.graphql"
      "*.png"
      "*.svg"
      "*.txt"
      "doc/man/*.1" # generated via //doc:generate.go
      "doc/md/*" # generated via //doc:generate.go
      "misc/completion/*/*"
      "webui/*" # not currently supported, //webui is not yet flakeified
      "Makefile"
    ]
    ++ excludes;
}