mirror of
https://github.com/NotAShelf/nvf.git
synced 2025-02-20 02:18:06 +00:00
cmp: actually lazy load source
This commit is contained in:
parent
f107cc45eb
commit
4b703964e1
4 changed files with 43 additions and 0 deletions
|
@ -5,6 +5,7 @@
|
||||||
}: let
|
}: let
|
||||||
inherit (builtins) toJSON;
|
inherit (builtins) toJSON;
|
||||||
inherit (lib.modules) mkIf;
|
inherit (lib.modules) mkIf;
|
||||||
|
inherit (lib.strings) optionalString;
|
||||||
|
|
||||||
cfg = config.vim.assistant.copilot;
|
cfg = config.vim.assistant.copilot;
|
||||||
|
|
||||||
|
@ -59,7 +60,14 @@ in {
|
||||||
copilot-cmp = mkIf cfg.cmp.enable {
|
copilot-cmp = mkIf cfg.cmp.enable {
|
||||||
package = "copilot-cmp";
|
package = "copilot-cmp";
|
||||||
lazy = true;
|
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]";};
|
autocomplete.nvim-cmp.sources = {copilot = "[Copilot]";};
|
||||||
|
|
|
@ -15,23 +15,39 @@
|
||||||
in {
|
in {
|
||||||
config = mkIf cfg.enable {
|
config = mkIf cfg.enable {
|
||||||
vim = {
|
vim = {
|
||||||
|
startPlugins = ["rtp-nvim"];
|
||||||
lazy.plugins = {
|
lazy.plugins = {
|
||||||
# cmp sources are loaded via lzn-auto-require as long as it is defined
|
# cmp sources are loaded via lzn-auto-require as long as it is defined
|
||||||
# in cmp sources
|
# in cmp sources
|
||||||
cmp-buffer = {
|
cmp-buffer = {
|
||||||
package = "cmp-buffer";
|
package = "cmp-buffer";
|
||||||
lazy = true;
|
lazy = true;
|
||||||
|
after = ''
|
||||||
|
local path = vim.fn.globpath(vim.o.packpath, 'pack/*/opt/cmp-buffer')
|
||||||
|
require("rtp_nvim").source_after_plugin_dir(path)
|
||||||
|
'';
|
||||||
};
|
};
|
||||||
cmp-path = {
|
cmp-path = {
|
||||||
package = "cmp-path";
|
package = "cmp-path";
|
||||||
lazy = true;
|
lazy = true;
|
||||||
|
after = ''
|
||||||
|
local path = vim.fn.globpath(vim.o.packpath, 'pack/*/opt/cmp-path')
|
||||||
|
require("rtp_nvim").source_after_plugin_dir(path)
|
||||||
|
'';
|
||||||
};
|
};
|
||||||
nvim-cmp = {
|
nvim-cmp = {
|
||||||
package = "nvim-cmp";
|
package = "nvim-cmp";
|
||||||
after = ''
|
after = ''
|
||||||
${optionalString luasnipEnable "local luasnip = require('luasnip')"}
|
${optionalString luasnipEnable "local luasnip = require('luasnip')"}
|
||||||
|
require("lz.n").trigger_load("cmp-path")
|
||||||
local cmp = require("cmp")
|
local cmp = require("cmp")
|
||||||
cmp.setup(${toLuaObject cfg.setupOpts})
|
cmp.setup(${toLuaObject cfg.setupOpts})
|
||||||
|
|
||||||
|
${
|
||||||
|
optionalString config.vim.lazy.enable ''
|
||||||
|
require("lz.n").trigger_load("cmp-buffer")
|
||||||
|
''
|
||||||
|
}
|
||||||
'';
|
'';
|
||||||
|
|
||||||
event = ["InsertEnter" "CmdlineEnter"];
|
event = ["InsertEnter" "CmdlineEnter"];
|
||||||
|
|
|
@ -4,6 +4,7 @@
|
||||||
...
|
...
|
||||||
}: 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 {
|
||||||
|
@ -18,7 +19,14 @@ in {
|
||||||
cmp-luasnip = mkIf config.vim.autocomplete.nvim-cmp.enable {
|
cmp-luasnip = mkIf config.vim.autocomplete.nvim-cmp.enable {
|
||||||
package = "cmp-luasnip";
|
package = "cmp-luasnip";
|
||||||
lazy = true;
|
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]";};
|
||||||
|
|
|
@ -21,6 +21,17 @@ in {
|
||||||
vim = {
|
vim = {
|
||||||
startPlugins = ["nvim-treesitter"] ++ optional usingNvimCmp "cmp-treesitter";
|
startPlugins = ["nvim-treesitter"] ++ optional usingNvimCmp "cmp-treesitter";
|
||||||
|
|
||||||
|
lazy.plugins = {
|
||||||
|
cmp-treesitter = mkIf usingNvimCmp {
|
||||||
|
package = "cmp-treesitter";
|
||||||
|
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 cfg.cmp.enable "require('lz.n').trigger_load('cmp-treesitter')";
|
||||||
|
};
|
||||||
|
|
||||||
autocomplete.nvim-cmp.sources = {treesitter = "[Treesitter]";};
|
autocomplete.nvim-cmp.sources = {treesitter = "[Treesitter]";};
|
||||||
treesitter.grammars = optionals cfg.addDefaultGrammars cfg.defaultGrammars;
|
treesitter.grammars = optionals cfg.addDefaultGrammars cfg.defaultGrammars;
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue