|
1 | 1 | {
|
2 | 2 | lib,
|
3 | 3 | config,
|
| 4 | + options, |
4 | 5 | ...
|
5 | 6 | }:
|
6 | 7 | let
|
|
56 | 57 | };
|
57 | 58 |
|
58 | 59 | config = lib.mkIf (cfg.enable && cfg.autoEnableSources) (
|
| 60 | + let |
| 61 | + |
| 62 | + enabledCmpPlugins = lib.pipe options.plugins [ |
| 63 | + # First, a manual blacklist |
| 64 | + (lib.flip builtins.removeAttrs [ |
| 65 | + # lspkind has its own `cmp` options |
| 66 | + "lspkind" |
| 67 | + ]) |
| 68 | + # Filter for non-options (all plugins are plain attrsets, not options) |
| 69 | + # i.e. remove rename aliases |
| 70 | + (lib.filterAttrs (name: opt: !lib.isOption opt)) |
| 71 | + # Filter for plugins that have `cmp` enabled |
| 72 | + (lib.filterAttrs (name: _: config.plugins.${name}.cmp.enable or false)) |
| 73 | + # Collect the enable options' `loc`s |
| 74 | + (lib.mapAttrsToList (_: plugin: plugin.enable)) |
| 75 | + (builtins.catAttrs "loc") |
| 76 | + # Drop the `"enable"` part of the option-loc |
| 77 | + (builtins.map (lib.lists.dropEnd 1)) |
| 78 | + # Render each plugin loc as an option string |
| 79 | + (builtins.map lib.showOption) |
| 80 | + ]; |
| 81 | + in |
59 | 82 | lib.mkMerge [
|
60 | 83 | {
|
61 | 84 | warnings = lib.nixvim.mkWarnings "plugins.cmp" [
|
| 85 | + # Warn when the new and old systems are used together. |
| 86 | + # `autoEnableSources` is incompatible with the new `plugins.*.cmp` options |
| 87 | + # TODO: |
| 88 | + # - Have `autoEnableSources` default to no `plugins.*.cmp` options being enabled? |
| 89 | + # - Maybe warn when `autoEnableSources` has highestPrio 1500? |
| 90 | + # - I'm not sure how best to migrate to having `plugins.*.cmp.enable` default to true... |
| 91 | + { |
| 92 | + when = enabledCmpPlugins != [ ]; |
| 93 | + message = '' |
| 94 | + You have enabled `autoEnableSources` that tells Nixvim to automatically enable the source plugins with respect to the list of sources provided in `settings.sources`. |
| 95 | + However, ${builtins.toString (builtins.length enabledCmpPlugins)} plugins have cmp integration configured via `plugins.*.cmp`:${ |
| 96 | + lib.concatMapStrings (opt: "\n- `${opt}`") enabledCmpPlugins |
| 97 | + } |
| 98 | + ''; |
| 99 | + } |
62 | 100 | # TODO: expand this warning to ft & cmd sources lists and `showDefs` the offending definitions
|
63 | 101 | {
|
64 | 102 | when = lib.types.isRawType cfg.settings.sources;
|
|
0 commit comments