mirror of
https://github.com/NotAShelf/nvf.git
synced 2025-02-12 20:13:19 +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
|
||||
inherit (builtins) toJSON;
|
||||
inherit (lib.modules) mkIf;
|
||||
inherit (lib.strings) optionalString;
|
||||
|
||||
cfg = config.vim.assistant.copilot;
|
||||
|
||||
|
@ -59,7 +60,14 @@ in {
|
|||
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]";};
|
||||
|
|
|
@ -15,23 +15,39 @@
|
|||
in {
|
||||
config = mkIf cfg.enable {
|
||||
vim = {
|
||||
startPlugins = ["rtp-nvim"];
|
||||
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;
|
||||
after = ''
|
||||
local path = vim.fn.globpath(vim.o.packpath, 'pack/*/opt/cmp-buffer')
|
||||
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)
|
||||
'';
|
||||
};
|
||||
nvim-cmp = {
|
||||
package = "nvim-cmp";
|
||||
after = ''
|
||||
${optionalString luasnipEnable "local luasnip = require('luasnip')"}
|
||||
require("lz.n").trigger_load("cmp-path")
|
||||
local cmp = require("cmp")
|
||||
cmp.setup(${toLuaObject cfg.setupOpts})
|
||||
|
||||
${
|
||||
optionalString config.vim.lazy.enable ''
|
||||
require("lz.n").trigger_load("cmp-buffer")
|
||||
''
|
||||
}
|
||||
'';
|
||||
|
||||
event = ["InsertEnter" "CmdlineEnter"];
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
...
|
||||
}: let
|
||||
inherit (lib.modules) mkIf;
|
||||
inherit (lib.strings) optionalString;
|
||||
|
||||
cfg = config.vim.snippets.luasnip;
|
||||
in {
|
||||
|
@ -18,7 +19,14 @@ in {
|
|||
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;
|
||||
autocomplete.nvim-cmp.sources = {luasnip = "[LuaSnip]";};
|
||||
|
|
|
@ -21,6 +21,17 @@ in {
|
|||
vim = {
|
||||
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]";};
|
||||
treesitter.grammars = optionals cfg.addDefaultGrammars cfg.defaultGrammars;
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue