mirror of
https://github.com/nix-community/nixvim.git
synced 2025-06-30 04:14:28 +02:00
plugins/cmp: refactor source->plugin association
Introduce the internal option `cmpSourcePlugins` where plugins can register their nvim-cmp source name association.
This commit is contained in:
parent
bd422db9ba
commit
3a8d4fee35
6 changed files with 137 additions and 100 deletions
|
@ -1,30 +1,39 @@
|
|||
{ pkgs, cmp-sources, ... }:
|
||||
{ pkgs, ... }:
|
||||
{
|
||||
all-sources = {
|
||||
plugins = {
|
||||
copilot-lua = {
|
||||
enable = true;
|
||||
module =
|
||||
{ config, ... }:
|
||||
{
|
||||
plugins = {
|
||||
copilot-lua = {
|
||||
enable = true;
|
||||
|
||||
panel.enabled = false;
|
||||
suggestion.enabled = false;
|
||||
panel.enabled = false;
|
||||
suggestion.enabled = false;
|
||||
};
|
||||
|
||||
cmp = {
|
||||
enable = true;
|
||||
settings.sources =
|
||||
with pkgs.lib;
|
||||
let
|
||||
disabledSources = [
|
||||
# We do not provide the required HF_API_KEY environment variable.
|
||||
"cmp_ai"
|
||||
] ++ optional (pkgs.stdenv.hostPlatform.system == "aarch64-linux") "cmp_tabnine";
|
||||
in
|
||||
pipe config.cmpSourcePlugins [
|
||||
# All known source names
|
||||
attrNames
|
||||
# Filter out disabled sources
|
||||
(filter (name: !(elem name disabledSources)))
|
||||
# Convert names to source attributes
|
||||
(map (name: {
|
||||
inherit name;
|
||||
}))
|
||||
];
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
cmp = {
|
||||
enable = true;
|
||||
settings.sources =
|
||||
with pkgs.lib;
|
||||
let
|
||||
disabledSources = [
|
||||
# We do not provide the required HF_API_KEY environment variable.
|
||||
"cmp_ai"
|
||||
] ++ optional (pkgs.stdenv.hostPlatform.system == "aarch64-linux") "cmp_tabnine";
|
||||
|
||||
filterFunc = sourceName: !(elem sourceName disabledSources);
|
||||
|
||||
sourceNames = filter filterFunc (attrNames cmp-sources);
|
||||
in
|
||||
map (sourceName: { name = sourceName; }) sourceNames;
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue