mirror of
https://github.com/NotAShelf/nvf.git
synced 2025-09-05 18:01:32 +00:00
fix(blink-cmp): Fix broken default sources
Currently, regardless of whether nvim-cmp is enabled, nvim-cmp's sources are added as providers. If the nvim-cmp sources "buffer" or "path" are enabled they will override and break blink.cmp's default "path" and "buffer" sources. This fixes the issue by only configuring nvim-cmp sources and providers when nvim-cmp is enabled and, if nvim-cmp is enabled, only configuring nvim-cmp compat providers that are not in the blink.cmp default sources.
This commit is contained in:
parent
22fb0d22cc
commit
626ad99297
2 changed files with 22 additions and 10 deletions
|
@ -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.
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue