mirror of
https://github.com/NotAShelf/neovim-flake.git
synced 2024-11-08 08:05:58 +01:00
cmp: lazy load
this moves cmp itself to lazy.plugins but other plugins that call cmp are not yet lazy so cmp is technically not yet lazy
This commit is contained in:
parent
b636b22046
commit
46a1f0427f
1 changed files with 76 additions and 63 deletions
|
@ -6,7 +6,6 @@
|
||||||
inherit (lib.modules) mkIf;
|
inherit (lib.modules) mkIf;
|
||||||
inherit (lib.strings) optionalString;
|
inherit (lib.strings) optionalString;
|
||||||
inherit (lib.generators) mkLuaInline;
|
inherit (lib.generators) mkLuaInline;
|
||||||
inherit (lib.nvim.dag) entryAfter;
|
|
||||||
inherit (lib.nvim.lua) toLuaObject;
|
inherit (lib.nvim.lua) toLuaObject;
|
||||||
inherit (builtins) attrNames;
|
inherit (builtins) attrNames;
|
||||||
|
|
||||||
|
@ -16,19 +15,38 @@
|
||||||
in {
|
in {
|
||||||
config = mkIf cfg.enable {
|
config = mkIf cfg.enable {
|
||||||
vim = {
|
vim = {
|
||||||
startPlugins = [
|
lazy.plugins = {
|
||||||
"nvim-cmp"
|
# cmp sources are loaded via lzn-auto-require as long as it is defined
|
||||||
"cmp-buffer"
|
# in cmp sources
|
||||||
"cmp-path"
|
cmp-buffer = {
|
||||||
];
|
package = "cmp-buffer";
|
||||||
|
lazy = true;
|
||||||
|
};
|
||||||
|
cmp-path = {
|
||||||
|
package = "cmp-path";
|
||||||
|
lazy = true;
|
||||||
|
};
|
||||||
|
nvim-cmp = {
|
||||||
|
package = "nvim-cmp";
|
||||||
|
after = ''
|
||||||
|
${optionalString luasnipEnable "local luasnip = require('luasnip')"}
|
||||||
|
local cmp = require("cmp")
|
||||||
|
cmp.setup(${toLuaObject cfg.setupOpts})
|
||||||
|
'';
|
||||||
|
|
||||||
autocomplete.nvim-cmp.sources = {
|
event = ["InsertEnter" "CmdlineEnter"];
|
||||||
|
lazy = true;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
autocomplete.nvim-cmp = {
|
||||||
|
sources = {
|
||||||
nvim-cmp = null;
|
nvim-cmp = null;
|
||||||
buffer = "[Buffer]";
|
buffer = "[Buffer]";
|
||||||
path = "[Path]";
|
path = "[Path]";
|
||||||
};
|
};
|
||||||
|
|
||||||
autocomplete.nvim-cmp.setupOpts = {
|
setupOpts = {
|
||||||
sources = map (s: {name = s;}) (attrNames cfg.sources);
|
sources = map (s: {name = s;}) (attrNames cfg.sources);
|
||||||
|
|
||||||
# TODO: try to get nvim-cmp to follow global border style
|
# TODO: try to get nvim-cmp to follow global border style
|
||||||
|
@ -40,14 +58,8 @@ in {
|
||||||
formatting.format = cfg.format;
|
formatting.format = cfg.format;
|
||||||
};
|
};
|
||||||
|
|
||||||
pluginRC.nvim-cmp = mkIf cfg.enable (entryAfter ["autopairs" "luasnip"] ''
|
|
||||||
${optionalString luasnipEnable "local luasnip = require('luasnip')"}
|
|
||||||
local cmp = require("cmp")
|
|
||||||
cmp.setup(${toLuaObject cfg.setupOpts})
|
|
||||||
'');
|
|
||||||
|
|
||||||
# `cmp` and `luasnip` are defined above, in the `nvim-cmp` section
|
# `cmp` and `luasnip` are defined above, in the `nvim-cmp` section
|
||||||
autocomplete.nvim-cmp.setupOpts.mapping = {
|
setupOpts.mapping = {
|
||||||
${mappings.complete} = mkLuaInline "cmp.mapping.complete()";
|
${mappings.complete} = mkLuaInline "cmp.mapping.complete()";
|
||||||
${mappings.close} = mkLuaInline "cmp.mapping.abort()";
|
${mappings.close} = mkLuaInline "cmp.mapping.abort()";
|
||||||
${mappings.scrollDocsUp} = mkLuaInline "cmp.mapping.scroll_docs(-4)";
|
${mappings.scrollDocsUp} = mkLuaInline "cmp.mapping.scroll_docs(-4)";
|
||||||
|
@ -91,4 +103,5 @@ in {
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue