|
1 | 1 | { pkgs, ... }:
|
| 2 | +let |
| 3 | + # TODO: move into the relevant module once we only have one "all" test |
| 4 | + disabledSources = |
| 5 | + [ |
| 6 | + # We do not provide the required HF_API_KEY environment variable. |
| 7 | + "cmp-ai" |
| 8 | + # Triggers the warning complaining about treesitter highlighting being disabled |
| 9 | + "otter" |
| 10 | + # Invokes the `nix` command at startup which is not available in the sandbox |
| 11 | + "cmp-nixpkgs-maintainers" |
| 12 | + # lspkind has its own `cmp` options, but isn't a nvim-cmp source |
| 13 | + "lspkind" |
| 14 | + ] |
| 15 | + # TODO: why is this disabled? |
| 16 | + ++ pkgs.lib.optionals (pkgs.stdenv.hostPlatform.system == "aarch64-linux") [ |
| 17 | + "cmp-tabnine" |
| 18 | + ]; |
| 19 | +in |
2 | 20 | {
|
3 | 21 | all-sources =
|
4 | 22 | {
|
5 | 23 | config,
|
6 | 24 | options,
|
7 | 25 | lib,
|
8 |
| - pkgs, |
9 | 26 | ...
|
10 | 27 | }:
|
11 | 28 | {
|
|
26 | 43 | };
|
27 | 44 | }
|
28 | 45 | {
|
29 |
| - plugins = |
30 |
| - let |
31 |
| - disabledSources = |
32 |
| - [ |
33 |
| - # We do not provide the required HF_API_KEY environment variable. |
34 |
| - "cmp-ai" |
35 |
| - # Triggers the warning complaining about treesitter highlighting being disabled |
36 |
| - "otter" |
37 |
| - # Invokes the `nix` command at startup which is not available in the sandbox |
38 |
| - "cmp-nixpkgs-maintainers" |
39 |
| - # lspkind has its own `cmp` options, but isn't a nvim-cmp source |
40 |
| - "lspkind" |
41 |
| - ] |
42 |
| - # TODO: why is this disabled? |
43 |
| - ++ lib.optionals (pkgs.stdenv.hostPlatform.system == "aarch64-linux") [ |
44 |
| - "cmp-tabnine" |
45 |
| - ]; |
46 |
| - cmpPluginNames = lib.pipe options.plugins [ |
47 |
| - # First, a manual blacklist |
48 |
| - (lib.flip builtins.removeAttrs disabledSources) |
49 |
| - # Filter for non-options (all plugins are plain attrsets, not options) |
50 |
| - # i.e. remove rename aliases |
51 |
| - (lib.filterAttrs (name: opt: !lib.isOption opt)) |
52 |
| - # Collect the plugin names |
53 |
| - builtins.attrNames |
54 |
| - # Filter for plugins that have a `cmp` option |
55 |
| - (builtins.filter (name: config.plugins.${name} ? cmp)) |
56 |
| - ]; |
57 |
| - in |
58 |
| - lib.genAttrs cmpPluginNames (name: { |
| 46 | + plugins = lib.pipe options.plugins [ |
| 47 | + # First, a manual blacklist |
| 48 | + (lib.flip builtins.removeAttrs disabledSources) |
| 49 | + # Filter for non-options (all plugins are plain attrsets, not options) |
| 50 | + # i.e. remove rename aliases |
| 51 | + (lib.filterAttrs (name: opt: !lib.isOption opt)) |
| 52 | + # Collect the plugin names |
| 53 | + builtins.attrNames |
| 54 | + # Filter for plugins that have a `cmp` option |
| 55 | + (builtins.filter (name: config.plugins.${name} ? cmp)) |
| 56 | + (lib.flip lib.genAttrs (name: { |
59 | 57 | enable = true;
|
60 | 58 | cmp.enable = true;
|
61 |
| - }); |
| 59 | + })) |
| 60 | + ]; |
62 | 61 | }
|
63 | 62 | ];
|
64 | 63 | };
|
65 | 64 |
|
66 | 65 | auto-enable-sources =
|
67 |
| - { config, ... }: |
| 66 | + { |
| 67 | + config, |
| 68 | + options, |
| 69 | + lib, |
| 70 | + ... |
| 71 | + }: |
68 | 72 | {
|
69 | 73 | plugins = {
|
70 | 74 | copilot-lua = {
|
|
78 | 82 |
|
79 | 83 | cmp = {
|
80 | 84 | enable = true;
|
81 |
| - settings.sources = |
82 |
| - with pkgs.lib; |
83 |
| - let |
84 |
| - disabledSources = [ |
85 |
| - # We do not provide the required HF_API_KEY environment variable. |
86 |
| - "cmp_ai" |
87 |
| - # Triggers the warning complaining about treesitter highlighting being disabled |
88 |
| - "otter" |
89 |
| - # Invokes the `nix` command at startup which is not available in the sandbox |
90 |
| - "nixpkgs_maintainers" |
91 |
| - ] ++ optional (pkgs.stdenv.hostPlatform.system == "aarch64-linux") "cmp_tabnine"; |
92 |
| - in |
93 |
| - pipe config.cmpSourcePlugins [ |
94 |
| - # All known source names |
95 |
| - attrNames |
96 |
| - # Filter out disabled sources |
97 |
| - (filter (name: !(elem name disabledSources))) |
98 |
| - # Convert names to source attributes |
99 |
| - (map (name: { |
100 |
| - inherit name; |
101 |
| - })) |
102 |
| - ]; |
| 85 | + settings.sources = lib.pipe options.plugins [ |
| 86 | + # First, a manual blacklist |
| 87 | + (lib.flip builtins.removeAttrs disabledSources) |
| 88 | + # Filter for non-options (all plugins are plain attrsets, not options) |
| 89 | + # i.e. remove rename aliases |
| 90 | + (lib.filterAttrs (name: opt: !lib.isOption opt)) |
| 91 | + # Collect the plugin names |
| 92 | + builtins.attrNames |
| 93 | + # Filter for plugins that have a `cmp` option |
| 94 | + (builtins.filter (name: config.plugins.${name} ? cmp)) |
| 95 | + # Map to the source name |
| 96 | + (builtins.map (name: config.plugins.${name}.cmp.name)) |
| 97 | + # Map to a plugin definition |
| 98 | + (builtins.map (name: { |
| 99 | + inherit name; |
| 100 | + })) |
| 101 | + ]; |
103 | 102 | };
|
104 | 103 | };
|
105 | 104 | };
|
|
0 commit comments