diff --git a/docs/release-notes/rl-0.8.md b/docs/release-notes/rl-0.8.md index 21e655d2..d2a1a098 100644 --- a/docs/release-notes/rl-0.8.md +++ b/docs/release-notes/rl-0.8.md @@ -486,3 +486,9 @@ - Add [nvim-biscuits] to show block context. Available at `vim.utility.nvim-biscuits`. + +[JManch](https://github.com/JManch): + +- Fix default [blink.cmp] sources "path" and "buffer" not working when + `autocomplete.nvim-cmp.enable` was disabled and + `autocomplete.nvim-cmp.sources` had not been modified. diff --git a/modules/plugins/completion/blink-cmp/config.nix b/modules/plugins/completion/blink-cmp/config.nix index 2efd8d79..5789c514 100644 --- a/modules/plugins/completion/blink-cmp/config.nix +++ b/modules/plugins/completion/blink-cmp/config.nix @@ -5,11 +5,12 @@ }: let inherit (lib.modules) mkIf; inherit (lib.strings) optionalString; + inherit (lib.attrsets) optionalAttrs; inherit (lib.generators) mkLuaInline; inherit (lib.attrsets) attrValues filterAttrs mapAttrsToList; - inherit (lib.lists) map optional elem; + inherit (lib.lists) map optional optionals elem; inherit (lib.nvim.lua) toLuaObject; - inherit (builtins) concatStringsSep typeOf tryEval attrNames mapAttrs; + inherit (builtins) concatStringsSep typeOf tryEval attrNames mapAttrs removeAttrs; cfg = config.vim.autocomplete.blink-cmp; cmpCfg = config.vim.autocomplete.nvim-cmp; @@ -55,7 +56,7 @@ in { after = # lua '' - ${optionalString config.vim.lazy.enable + ${optionalString (config.vim.lazy.enable && cmpCfg.enable) (concatStringsSep "\n" (map (package: "require('lz.n').trigger_load(${toLuaObject (getPluginName package)})") cmpCfg.sourcePlugins))} @@ -66,7 +67,10 @@ in { autocomplete = { enableSharedCmpSources = true; blink-cmp.setupOpts = { - sources = { + sources = let + # We do not want nvim-cmp compat sources overriding built-in blink sources + filteredCmpSources = removeAttrs cmpCfg.sources blinkBuiltins; + in { default = [ "lsp" @@ -74,14 +78,16 @@ in { "snippets" "buffer" ] - ++ (attrNames cmpCfg.sources) + ++ optionals cmpCfg.enable (attrNames filteredCmpSources) ++ (attrNames enabledBlinkSources); providers = - mapAttrs (name: _: { - inherit name; - module = "blink.compat.source"; - }) - cmpCfg.sources + optionalAttrs cmpCfg.enable ( + mapAttrs (name: _: { + inherit name; + module = "blink.compat.source"; + }) + filteredCmpSources + ) // (mapAttrs (name: definition: { inherit name; inherit (definition) module;