|
8 | 8 | inherit (lib.options) mkEnableOption mkOption; |
9 | 9 | inherit (lib.meta) getExe; |
10 | 10 | inherit (lib.modules) mkIf mkMerge; |
11 | | - inherit (lib.types) enum package; |
| 11 | + inherit (lib.types) enum; |
12 | 12 | inherit (lib.nvim.types) mkGrammarOption singleOrListOf; |
13 | 13 | inherit (lib.nvim.attrsets) mapListToAttrs; |
14 | 14 |
|
|
30 | 30 | }; |
31 | 31 | }; |
32 | 32 |
|
33 | | - defaultFormat = "prettier"; |
| 33 | + defaultFormat = ["prettier"]; |
34 | 34 | formats = { |
35 | 35 | prettier = { |
36 | | - package = pkgs.prettier; |
| 36 | + command = getExe pkgs.prettier; |
37 | 37 | }; |
38 | 38 |
|
39 | 39 | prettierd = { |
40 | | - package = pkgs.prettierd; |
41 | | - nullConfig = '' |
42 | | - table.insert( |
43 | | - ls_sources, |
44 | | - null_ls.builtins.formatting.prettier.with({ |
45 | | - command = "${cfg.format.package}/bin/prettierd", |
46 | | - }) |
47 | | - ) |
48 | | - ''; |
| 40 | + command = getExe pkgs.prettierd; |
49 | 41 | }; |
50 | 42 |
|
51 | 43 | biome = { |
52 | | - package = pkgs.biome; |
53 | | - nullConfig = '' |
54 | | - table.insert( |
55 | | - ls_sources, |
56 | | - null_ls.builtins.formatting.biome.with({ |
57 | | - command = "${cfg.format.package}/bin/biome", |
58 | | - }) |
59 | | - ) |
60 | | - ''; |
| 44 | + command = getExe pkgs.biome; |
61 | 45 | }; |
62 | 46 | }; |
63 | 47 | in { |
|
85 | 69 |
|
86 | 70 | type = mkOption { |
87 | 71 | description = "CSS formatter to use"; |
88 | | - type = enum (attrNames formats); |
| 72 | + type = singleOrListOf (enum (attrNames formats)); |
89 | 73 | default = defaultFormat; |
90 | 74 | }; |
91 | | - |
92 | | - package = mkOption { |
93 | | - description = "CSS formatter package"; |
94 | | - type = package; |
95 | | - default = formats.${cfg.format.type}.package; |
96 | | - }; |
97 | 75 | }; |
98 | 76 | }; |
99 | 77 |
|
|
115 | 93 | (mkIf cfg.format.enable { |
116 | 94 | vim.formatter.conform-nvim = { |
117 | 95 | enable = true; |
118 | | - setupOpts.formatters_by_ft.css = [cfg.format.type]; |
119 | | - setupOpts.formatters.${cfg.format.type} = { |
120 | | - command = getExe cfg.format.package; |
| 96 | + setupOpts = { |
| 97 | + formatters_by_ft.css = cfg.format.type; |
| 98 | + formatters = |
| 99 | + mapListToAttrs (name: { |
| 100 | + inherit name; |
| 101 | + value = formats.${name}; |
| 102 | + }) |
| 103 | + cfg.format.type; |
121 | 104 | }; |
122 | 105 | }; |
123 | 106 | }) |
|
0 commit comments