summaryrefslogtreecommitdiff
path: root/flake.nix
blob: bca4e909344eddd48244f00713e76cdb72a7239d (plain)
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
87
88
89
90
91
92
93
94
95
96
{
  inputs = {
    nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
    nixvim.url = "github:nix-community/nixvim";
  };

  outputs = {
    self,
    nixpkgs,
    nixvim,
  }: let
    pkgs = nixpkgs.legacyPackages.x86_64-linux;
    npkgs = nixvim.legacyPackages.x86_64-linux;
  in {
    packages.x86_64-linux.default = npkgs.makeNixvimWithModule {
      module = {
        config = {
          extraPackages = [
            pkgs.alejandra
            pkgs.black
            pkgs.cargo
            pkgs.cmake-format
            pkgs.go
            pkgs.rustfmt
            pkgs.shfmt
            pkgs.yamlfmt
          ];
          options = {mouse = "";};
          colorschemes.kanagawa = {
            enable = true;
            transparent = true;
          };
          plugins = {
            ledger.enable = true;
            lsp = {
              enable = true;
              servers = {
                bashls.enable = true;
                nixd.enable = true;
                ruff-lsp.enable = true;
                gopls.enable = true;
              };
            };
            rustaceanvim.enable = true;
            conform-nvim = {
              enable = true;
              formatAfterSave.lspFallback = false;
              formattersByFt = {
                cmake = ["cmake_format"];
                go = ["gofmt"];
                nix = ["alejandra"];
                python = ["black"];
                rust = ["rustfmt"];
                yaml = ["yamlfmt"];
                _ = ["shfmt"];
              };
              formatters.shfmt = {
                prepend_args = ["-i" "4" "-s"];
              };
              formatters.rustfmt = {
                prepend_args = ["--edition" "2021"];
              };
            };
            luasnip.enable = true;
            nvim-cmp = {
              enable = true;
              snippet.expand = "luasnip";
              autoEnableSources = true;
              sources = [
                {name = "nvim_lsp";}
                {name = "path";}
                {name = "buffer";}
              ];
              mapping = {
                "<CR>" = "cmp.mapping.confirm({ select = true })";
                "<Tab>" = {
                  action = ''
                    cmp.mapping(function(fallback)
                      if cmp.visible() then
                        cmp.select_next_item({
                          behavior = cmp.SelectBehavior.Select
                        })
                      else
                        fallback()
                      end
                    end, {"i","s","c",})
                  '';
                };
              };
            };
          };
        };
      };
    };
  };
}