mirror of
https://github.com/NotAShelf/neovim-flake.git
synced 2025-01-09 16:39:51 +01:00
cmp: move source plugin into parent option
This commit is contained in:
parent
05e5f5e399
commit
cb136a9485
5 changed files with 77 additions and 52 deletions
34
modules/plugins/completion/config.nix
Normal file
34
modules/plugins/completion/config.nix
Normal file
|
@ -0,0 +1,34 @@
|
||||||
|
{
|
||||||
|
lib,
|
||||||
|
config,
|
||||||
|
...
|
||||||
|
}: let
|
||||||
|
inherit (builtins) typeOf tryEval;
|
||||||
|
inherit (lib.modules) mkIf;
|
||||||
|
inherit (lib.nvim.attrsets) mapListToAttrs;
|
||||||
|
cfg = config.vim.autocomplete;
|
||||||
|
|
||||||
|
getPluginName = plugin:
|
||||||
|
if typeOf plugin == "string"
|
||||||
|
then plugin
|
||||||
|
else if (plugin ? pname && (tryEval plugin.pname).success)
|
||||||
|
then plugin.pname
|
||||||
|
else plugin.name;
|
||||||
|
in {
|
||||||
|
vim = mkIf cfg.enableSharedCmpSources {
|
||||||
|
startPlugins = ["rtp-nvim"];
|
||||||
|
lazy.plugins =
|
||||||
|
mapListToAttrs (package: {
|
||||||
|
name = getPluginName package;
|
||||||
|
value = {
|
||||||
|
inherit package;
|
||||||
|
lazy = true;
|
||||||
|
after = ''
|
||||||
|
local path = vim.fn.globpath(vim.o.packpath, 'pack/*/opt/${getPluginName package}')
|
||||||
|
require("rtp_nvim").source_after_plugin_dir(path)
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
})
|
||||||
|
cfg.sourcePlugins;
|
||||||
|
};
|
||||||
|
}
|
|
@ -1,5 +1,8 @@
|
||||||
{
|
{
|
||||||
imports = [
|
imports = [
|
||||||
|
./config.nix
|
||||||
|
./options.nix
|
||||||
|
|
||||||
./nvim-cmp
|
./nvim-cmp
|
||||||
./blink-cmp
|
./blink-cmp
|
||||||
];
|
];
|
||||||
|
|
|
@ -3,11 +3,10 @@
|
||||||
config,
|
config,
|
||||||
...
|
...
|
||||||
}: let
|
}: let
|
||||||
inherit (lib.modules) mkIf mkMerge;
|
inherit (lib.modules) mkIf;
|
||||||
inherit (lib.strings) optionalString;
|
inherit (lib.strings) optionalString;
|
||||||
inherit (lib.generators) mkLuaInline;
|
inherit (lib.generators) mkLuaInline;
|
||||||
inherit (lib.nvim.lua) toLuaObject;
|
inherit (lib.nvim.lua) toLuaObject;
|
||||||
inherit (lib.nvim.attrsets) mapListToAttrs;
|
|
||||||
inherit (builtins) attrNames typeOf tryEval concatStringsSep;
|
inherit (builtins) attrNames typeOf tryEval concatStringsSep;
|
||||||
|
|
||||||
borders = config.vim.ui.borders.plugins.nvim-cmp;
|
borders = config.vim.ui.borders.plugins.nvim-cmp;
|
||||||
|
@ -24,21 +23,9 @@
|
||||||
in {
|
in {
|
||||||
config = mkIf cfg.enable {
|
config = mkIf cfg.enable {
|
||||||
vim = {
|
vim = {
|
||||||
startPlugins = ["rtp-nvim"];
|
autocomplete.enableSharedCmpSources = true;
|
||||||
lazy.plugins = mkMerge [
|
|
||||||
(mapListToAttrs (package: {
|
lazy.plugins = {
|
||||||
name = getPluginName package;
|
|
||||||
value = {
|
|
||||||
inherit package;
|
|
||||||
lazy = true;
|
|
||||||
after = ''
|
|
||||||
local path = vim.fn.globpath(vim.o.packpath, 'pack/*/opt/${getPluginName package}')
|
|
||||||
require("rtp_nvim").source_after_plugin_dir(path)
|
|
||||||
'';
|
|
||||||
};
|
|
||||||
})
|
|
||||||
cfg.sourcePlugins)
|
|
||||||
{
|
|
||||||
nvim-cmp = {
|
nvim-cmp = {
|
||||||
package = "nvim-cmp";
|
package = "nvim-cmp";
|
||||||
after = ''
|
after = ''
|
||||||
|
@ -68,8 +55,7 @@ in {
|
||||||
|
|
||||||
event = ["InsertEnter" "CmdlineEnter"];
|
event = ["InsertEnter" "CmdlineEnter"];
|
||||||
};
|
};
|
||||||
}
|
};
|
||||||
];
|
|
||||||
|
|
||||||
autocomplete.nvim-cmp = {
|
autocomplete.nvim-cmp = {
|
||||||
sources = {
|
sources = {
|
||||||
|
|
|
@ -4,10 +4,10 @@
|
||||||
...
|
...
|
||||||
}: let
|
}: let
|
||||||
inherit (lib.options) mkEnableOption mkOption literalExpression literalMD;
|
inherit (lib.options) mkEnableOption mkOption literalExpression literalMD;
|
||||||
inherit (lib.types) str attrsOf nullOr either listOf;
|
inherit (lib.types) str attrsOf nullOr either;
|
||||||
inherit (lib.generators) mkLuaInline;
|
inherit (lib.generators) mkLuaInline;
|
||||||
inherit (lib.nvim.binds) mkMappingOption;
|
inherit (lib.nvim.binds) mkMappingOption;
|
||||||
inherit (lib.nvim.types) mkPluginSetupOption luaInline mergelessListOf pluginType;
|
inherit (lib.nvim.types) mkPluginSetupOption luaInline mergelessListOf;
|
||||||
inherit (lib.nvim.lua) toLuaObject;
|
inherit (lib.nvim.lua) toLuaObject;
|
||||||
inherit (builtins) isString;
|
inherit (builtins) isString;
|
||||||
|
|
||||||
|
@ -107,11 +107,5 @@ in {
|
||||||
}
|
}
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
|
|
||||||
sourcePlugins = mkOption {
|
|
||||||
type = listOf pluginType;
|
|
||||||
default = [];
|
|
||||||
description = "List of source plugins used by nvim-cmp.";
|
|
||||||
};
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,15 @@
|
||||||
{lib, ...}: let
|
{lib, ...}: let
|
||||||
inherit (lib.options) mkEnableOption;
|
inherit (lib.options) mkEnableOption mkOption;
|
||||||
|
inherit (lib.types) listOf;
|
||||||
|
inherit (lib.nvim.types) pluginType;
|
||||||
in {
|
in {
|
||||||
options.vim.autocomplete = {
|
options.vim.autocomplete = {
|
||||||
enableSharedCmpSources = mkEnableOption "cmp sources that can work in nvim-cmp and blink.cmp";
|
enableSharedCmpSources = mkEnableOption "cmp sources shared by nvim-cmp and blink.cmp";
|
||||||
|
|
||||||
|
cmpSourcePlugins = mkOption {
|
||||||
|
type = listOf pluginType;
|
||||||
|
default = [];
|
||||||
|
description = "List of cmp source plugins.";
|
||||||
|
};
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue