mirror of
https://github.com/NotAShelf/neovim-flake.git
synced 2024-11-08 04:35: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.strings) optionalString;
|
||||
inherit (lib.generators) mkLuaInline;
|
||||
inherit (lib.nvim.dag) entryAfter;
|
||||
inherit (lib.nvim.lua) toLuaObject;
|
||||
inherit (builtins) attrNames;
|
||||
|
||||
|
@ -16,19 +15,38 @@
|
|||
in {
|
||||
config = mkIf cfg.enable {
|
||||
vim = {
|
||||
startPlugins = [
|
||||
"nvim-cmp"
|
||||
"cmp-buffer"
|
||||
"cmp-path"
|
||||
];
|
||||
lazy.plugins = {
|
||||
# cmp sources are loaded via lzn-auto-require as long as it is defined
|
||||
# in cmp sources
|
||||
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;
|
||||
buffer = "[Buffer]";
|
||||
path = "[Path]";
|
||||
};
|
||||
|
||||
autocomplete.nvim-cmp.setupOpts = {
|
||||
setupOpts = {
|
||||
sources = map (s: {name = s;}) (attrNames cfg.sources);
|
||||
|
||||
# TODO: try to get nvim-cmp to follow global border style
|
||||
|
@ -40,14 +58,8 @@ in {
|
|||
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
|
||||
autocomplete.nvim-cmp.setupOpts.mapping = {
|
||||
setupOpts.mapping = {
|
||||
${mappings.complete} = mkLuaInline "cmp.mapping.complete()";
|
||||
${mappings.close} = mkLuaInline "cmp.mapping.abort()";
|
||||
${mappings.scrollDocsUp} = mkLuaInline "cmp.mapping.scroll_docs(-4)";
|
||||
|
@ -91,4 +103,5 @@ in {
|
|||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue