mirror of
https://github.com/NotAShelf/nvf.git
synced 2025-12-13 15:41:03 +00:00
cmp: install sourcess via cmp.sourcePlugins
This commit is contained in:
parent
0397d0722f
commit
eff15d27b4
7 changed files with 68 additions and 84 deletions
|
|
@ -56,22 +56,13 @@ in {
|
||||||
(mkLuaKeymap ["i"] cfg.mappings.suggestion.prev "function() require('copilot.suggestion').prev() end" "[copilot] previous suggestion" {})
|
(mkLuaKeymap ["i"] cfg.mappings.suggestion.prev "function() require('copilot.suggestion').prev() end" "[copilot] previous suggestion" {})
|
||||||
];
|
];
|
||||||
};
|
};
|
||||||
|
|
||||||
copilot-cmp = mkIf cfg.cmp.enable {
|
|
||||||
package = "copilot-cmp";
|
|
||||||
lazy = true;
|
|
||||||
after = optionalString config.vim.lazy.enable ''
|
|
||||||
local path = vim.fn.globpath(vim.o.packpath, 'pack/*/opt/copilot-cmp')
|
|
||||||
require("rtp_nvim").source_after_plugin_dir(path)
|
|
||||||
require("lz.n").trigger_load("copilot-lua")
|
|
||||||
'';
|
|
||||||
};
|
};
|
||||||
|
|
||||||
nvim-cmp.after = mkIf cfg.cmp.enable "require('lz.n').trigger_load('copilot-cmp')";
|
autocomplete.nvim-cmp = {
|
||||||
|
sources = {copilot = "[Copilot]";};
|
||||||
|
sourcePlugins = ["copilot-cmp"];
|
||||||
};
|
};
|
||||||
|
|
||||||
autocomplete.nvim-cmp.sources = {copilot = "[Copilot]";};
|
|
||||||
|
|
||||||
# Disable plugin handled keymaps.
|
# Disable plugin handled keymaps.
|
||||||
# Setting it here so that it doesn't show up in user docs
|
# Setting it here so that it doesn't show up in user docs
|
||||||
assistant.copilot.setupOpts = {
|
assistant.copilot.setupOpts = {
|
||||||
|
|
|
||||||
|
|
@ -3,38 +3,40 @@
|
||||||
config,
|
config,
|
||||||
...
|
...
|
||||||
}: let
|
}: let
|
||||||
inherit (lib.modules) mkIf;
|
inherit (lib.modules) mkIf mkMerge;
|
||||||
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 (builtins) attrNames;
|
inherit (lib.nvim.attrsets) mapListToAttrs;
|
||||||
|
inherit (builtins) attrNames typeOf tryEval concatStringsSep;
|
||||||
|
|
||||||
cfg = config.vim.autocomplete.nvim-cmp;
|
cfg = config.vim.autocomplete.nvim-cmp;
|
||||||
luasnipEnable = config.vim.snippets.luasnip.enable;
|
luasnipEnable = config.vim.snippets.luasnip.enable;
|
||||||
|
getPluginName = plugin:
|
||||||
|
if typeOf plugin == "string"
|
||||||
|
then plugin
|
||||||
|
else if (plugin ? pname && (tryEval plugin.pname).success)
|
||||||
|
then plugin.pname
|
||||||
|
else plugin.name;
|
||||||
inherit (cfg) mappings;
|
inherit (cfg) mappings;
|
||||||
in {
|
in {
|
||||||
config = mkIf cfg.enable {
|
config = mkIf cfg.enable {
|
||||||
vim = {
|
vim = {
|
||||||
startPlugins = ["rtp-nvim"];
|
startPlugins = ["rtp-nvim"];
|
||||||
lazy.plugins = {
|
lazy.plugins = mkMerge [
|
||||||
# cmp sources are loaded via lzn-auto-require as long as it is defined
|
(mapListToAttrs (package: {
|
||||||
# in cmp sources
|
name = getPluginName package;
|
||||||
cmp-buffer = {
|
value = {
|
||||||
package = "cmp-buffer";
|
inherit package;
|
||||||
lazy = true;
|
lazy = true;
|
||||||
after = ''
|
after = ''
|
||||||
local path = vim.fn.globpath(vim.o.packpath, 'pack/*/opt/cmp-buffer')
|
local path = vim.fn.globpath(vim.o.packpath, 'pack/*/opt/${getPluginName package}')
|
||||||
require("rtp_nvim").source_after_plugin_dir(path)
|
|
||||||
'';
|
|
||||||
};
|
|
||||||
cmp-path = {
|
|
||||||
package = "cmp-path";
|
|
||||||
lazy = true;
|
|
||||||
after = ''
|
|
||||||
local path = vim.fn.globpath(vim.o.packpath, 'pack/*/opt/cmp-path')
|
|
||||||
require("rtp_nvim").source_after_plugin_dir(path)
|
require("rtp_nvim").source_after_plugin_dir(path)
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
|
})
|
||||||
|
cfg.sourcePlugins)
|
||||||
|
{
|
||||||
nvim-cmp = {
|
nvim-cmp = {
|
||||||
package = "nvim-cmp";
|
package = "nvim-cmp";
|
||||||
after = ''
|
after = ''
|
||||||
|
|
@ -43,16 +45,15 @@ in {
|
||||||
local cmp = require("cmp")
|
local cmp = require("cmp")
|
||||||
cmp.setup(${toLuaObject cfg.setupOpts})
|
cmp.setup(${toLuaObject cfg.setupOpts})
|
||||||
|
|
||||||
${
|
${concatStringsSep "\n" (map
|
||||||
optionalString config.vim.lazy.enable ''
|
(package: "require('lz.n').trigger_load(${toLuaObject (getPluginName package)})")
|
||||||
require("lz.n").trigger_load("cmp-buffer")
|
cfg.sourcePlugins)}
|
||||||
''
|
|
||||||
}
|
|
||||||
'';
|
'';
|
||||||
|
|
||||||
event = ["InsertEnter" "CmdlineEnter"];
|
event = ["InsertEnter" "CmdlineEnter"];
|
||||||
};
|
};
|
||||||
};
|
}
|
||||||
|
];
|
||||||
|
|
||||||
autocomplete.nvim-cmp = {
|
autocomplete.nvim-cmp = {
|
||||||
sources = {
|
sources = {
|
||||||
|
|
@ -61,6 +62,8 @@ in {
|
||||||
path = "[Path]";
|
path = "[Path]";
|
||||||
};
|
};
|
||||||
|
|
||||||
|
sourcePlugins = ["cmp-buffer" "cmp-path"];
|
||||||
|
|
||||||
setupOpts = {
|
setupOpts = {
|
||||||
sources = map (s: {name = s;}) (attrNames cfg.sources);
|
sources = map (s: {name = s;}) (attrNames cfg.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;
|
inherit (lib.types) str attrsOf nullOr either listOf;
|
||||||
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;
|
inherit (lib.nvim.types) mkPluginSetupOption luaInline mergelessListOf pluginType;
|
||||||
inherit (lib.nvim.lua) toLuaObject;
|
inherit (lib.nvim.lua) toLuaObject;
|
||||||
inherit (builtins) isString;
|
inherit (builtins) isString;
|
||||||
|
|
||||||
|
|
@ -99,5 +99,11 @@ in {
|
||||||
}
|
}
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
|
|
||||||
|
sourcePlugins = mkOption {
|
||||||
|
type = listOf pluginType;
|
||||||
|
default = [];
|
||||||
|
description = "List of source plugins used by nvim-cmp.";
|
||||||
|
};
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,6 @@
|
||||||
...
|
...
|
||||||
}: let
|
}: let
|
||||||
inherit (lib.modules) mkIf;
|
inherit (lib.modules) mkIf;
|
||||||
inherit (lib.lists) optional;
|
|
||||||
inherit (lib.strings) optionalString;
|
inherit (lib.strings) optionalString;
|
||||||
inherit (lib.trivial) boolToString;
|
inherit (lib.trivial) boolToString;
|
||||||
inherit (lib.nvim.binds) addDescriptionsToMappings;
|
inherit (lib.nvim.binds) addDescriptionsToMappings;
|
||||||
|
|
@ -23,19 +22,10 @@
|
||||||
in {
|
in {
|
||||||
config = mkIf cfg.enable {
|
config = mkIf cfg.enable {
|
||||||
vim = {
|
vim = {
|
||||||
lazy.plugins = {
|
autocomplete.nvim-cmp = {
|
||||||
cmp-nvim-lsp = {
|
sources = {nvim_lsp = "[LSP]";};
|
||||||
package = "cmp-nvim-lsp";
|
sourcePlugins = ["cmp-nvim-lsp"];
|
||||||
lazy = true;
|
|
||||||
after = ''
|
|
||||||
local path = vim.fn.globpath(vim.o.packpath, 'pack/*/opt/cmp-treesitter')
|
|
||||||
require("rtp_nvim").source_after_plugin_dir(path)
|
|
||||||
'';
|
|
||||||
};
|
};
|
||||||
nvim-cmp.after = mkIf usingNvimCmp "require('lz.n').trigger_load('cmp-nvim-lsp')";
|
|
||||||
};
|
|
||||||
|
|
||||||
autocomplete.nvim-cmp.sources = {nvim_lsp = "[LSP]";};
|
|
||||||
|
|
||||||
pluginRC.lsp-setup = ''
|
pluginRC.lsp-setup = ''
|
||||||
vim.g.formatsave = ${boolToString cfg.formatOnSave};
|
vim.g.formatsave = ${boolToString cfg.formatOnSave};
|
||||||
|
|
@ -126,7 +116,7 @@ in {
|
||||||
end
|
end
|
||||||
|
|
||||||
local capabilities = vim.lsp.protocol.make_client_capabilities()
|
local capabilities = vim.lsp.protocol.make_client_capabilities()
|
||||||
${optionalString usingNvimCmp "capabilities = require('cmp_nvim_lsp').default_capabilities()"}
|
-- ${optionalString usingNvimCmp "capabilities = require('cmp_nvim_lsp').default_capabilities()"}
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,6 @@
|
||||||
...
|
...
|
||||||
}: let
|
}: let
|
||||||
inherit (lib.modules) mkIf;
|
inherit (lib.modules) mkIf;
|
||||||
inherit (lib.strings) optionalString;
|
|
||||||
|
|
||||||
cfg = config.vim.snippets.luasnip;
|
cfg = config.vim.snippets.luasnip;
|
||||||
in {
|
in {
|
||||||
|
|
@ -16,20 +15,12 @@ in {
|
||||||
lazy = true;
|
lazy = true;
|
||||||
after = cfg.loaders;
|
after = cfg.loaders;
|
||||||
};
|
};
|
||||||
cmp-luasnip = mkIf config.vim.autocomplete.nvim-cmp.enable {
|
|
||||||
package = "cmp-luasnip";
|
|
||||||
lazy = true;
|
|
||||||
after = ''
|
|
||||||
local path = vim.fn.globpath(vim.o.packpath, 'pack/*/opt/cmp-luasnip')
|
|
||||||
require("rtp_nvim").source_after_plugin_dir(path)
|
|
||||||
'';
|
|
||||||
};
|
|
||||||
nvim-cmp.after = optionalString config.vim.lazy.enable ''
|
|
||||||
require("lz.n").trigger_load("cmp-luasnip")
|
|
||||||
'';
|
|
||||||
};
|
};
|
||||||
startPlugins = cfg.providers;
|
startPlugins = cfg.providers;
|
||||||
autocomplete.nvim-cmp.sources = {luasnip = "[LuaSnip]";};
|
autocomplete.nvim-cmp = {
|
||||||
|
sources = {luasnip = "[LuaSnip]";};
|
||||||
|
sourcePlugins = ["cmp-luasnip"];
|
||||||
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,7 @@
|
||||||
...
|
...
|
||||||
}: let
|
}: let
|
||||||
inherit (lib.modules) mkIf mkMerge;
|
inherit (lib.modules) mkIf mkMerge;
|
||||||
inherit (lib.lists) optional optionals;
|
inherit (lib.lists) optionals;
|
||||||
inherit (lib.nvim.binds) mkSetBinding addDescriptionsToMappings;
|
inherit (lib.nvim.binds) mkSetBinding addDescriptionsToMappings;
|
||||||
inherit (lib.nvim.lua) toLuaObject;
|
inherit (lib.nvim.lua) toLuaObject;
|
||||||
inherit (lib.nvim.dag) entryBefore entryAfter;
|
inherit (lib.nvim.dag) entryBefore entryAfter;
|
||||||
|
|
@ -32,7 +32,11 @@ in {
|
||||||
nvim-cmp.after = mkIf usingNvimCmp "require('lz.n').trigger_load('cmp-treesitter')";
|
nvim-cmp.after = mkIf usingNvimCmp "require('lz.n').trigger_load('cmp-treesitter')";
|
||||||
};
|
};
|
||||||
|
|
||||||
autocomplete.nvim-cmp.sources = {treesitter = "[Treesitter]";};
|
autocomplete.nvim-cmp = {
|
||||||
|
sources = {treesitter = "[Treesitter]";};
|
||||||
|
sourcePlugins = ["cmp-treesitter"];
|
||||||
|
};
|
||||||
|
|
||||||
treesitter.grammars = optionals cfg.addDefaultGrammars cfg.defaultGrammars;
|
treesitter.grammars = optionals cfg.addDefaultGrammars cfg.defaultGrammars;
|
||||||
|
|
||||||
maps = {
|
maps = {
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
|
options,
|
||||||
config,
|
config,
|
||||||
pkgs,
|
|
||||||
lib,
|
lib,
|
||||||
...
|
...
|
||||||
}: let
|
}: let
|
||||||
|
|
@ -11,8 +11,7 @@
|
||||||
inherit (lib.nvim.binds) pushDownDefault mkSetLznBinding;
|
inherit (lib.nvim.binds) pushDownDefault mkSetLznBinding;
|
||||||
|
|
||||||
cfg = config.vim.telescope;
|
cfg = config.vim.telescope;
|
||||||
self = import ./telescope.nix {inherit pkgs lib;};
|
mappingDefinitions = options.vim.telescope.mappings;
|
||||||
mappingDefinitions = self.options.vim.telescope.mappings;
|
|
||||||
|
|
||||||
mappings = addDescriptionsToMappings cfg.mappings mappingDefinitions;
|
mappings = addDescriptionsToMappings cfg.mappings mappingDefinitions;
|
||||||
in {
|
in {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue