completion/blink: don't break when modifying built-in sources.providers (#683)
Some checks failed
Check for typos in the source tree / check-typos (push) Has been cancelled

This commit is contained in:
Alfarel 2025-03-16 16:37:07 -04:00 committed by GitHub
parent fc520fa1ab
commit 1d7c27abd9
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 24 additions and 7 deletions

View file

@ -228,8 +228,9 @@
syncing of nvim shell environment with direnv's.
- Add [blink.cmp] source options and some default-disabled sources.
- Add [blink.cmp] option to add
[friendly-snippets](https://github.com/rafamadriz/friendly-snippets) so
blink.cmp can source snippets from it.
[friendly-snippets](https://github.com/rafamadriz/friendly-snippets)
so blink.cmp can source snippets from it.
- Fix [blink.cmp] breaking when built-in sources were modified.
[TheColorman](https://github.com/TheColorman):

View file

@ -21,8 +21,9 @@
freeformType = anything;
options = {
module = mkOption {
type = str;
description = "module of the provider";
type = nullOr str;
default = null;
description = "Provider module.";
};
};
};
@ -40,7 +41,7 @@ in {
providers = mkOption {
type = attrsOf providerType;
default = {};
description = "Settings for completion providers";
description = "Settings for completion providers.";
};
transform_items = mkOption {

View file

@ -6,8 +6,8 @@
inherit (lib.modules) mkIf;
inherit (lib.strings) optionalString;
inherit (lib.generators) mkLuaInline;
inherit (lib.attrsets) attrValues filterAttrs;
inherit (lib.lists) map optional;
inherit (lib.attrsets) attrValues filterAttrs mapAttrsToList;
inherit (lib.lists) map optional elem;
inherit (lib.nvim.lua) toLuaObject;
inherit (builtins) concatStringsSep typeOf tryEval attrNames mapAttrs;
@ -24,7 +24,22 @@
enabledBlinkSources = filterAttrs (_source: definition: definition.enable) cfg.sourcePlugins;
blinkSourcePlugins = map (definition: definition.package) (attrValues enabledBlinkSources);
blinkBuiltins = [
"path"
"lsp"
"snippets"
"buffer"
"omni"
];
in {
assertions =
mapAttrsToList (provider: definition: {
assertion = elem provider blinkBuiltins || definition.module != null;
message = "`config.vim.autocomplete.blink-cmp.setupOpts.sources.providers.${provider}.module` is `null`: non-builtin providers must set `module`.";
})
cfg.setupOpts.sources.providers;
vim = mkIf cfg.enable {
startPlugins = ["blink-compat"] ++ blinkSourcePlugins ++ (optional cfg.friendly-snippets.enable "friendly-snippets");
lazy.plugins = {