nvf/modules/plugins/snippets/luasnip/config.nix

36 lines
898 B
Nix
Raw Normal View History

{
config,
lib,
...
}: let
inherit (lib.modules) mkIf;
2024-10-22 13:14:15 +00:00
inherit (lib.strings) optionalString;
cfg = config.vim.snippets.luasnip;
in {
config = mkIf cfg.enable {
vim = {
2024-10-21 16:42:02 +00:00
lazy.plugins = {
luasnip = {
package = "luasnip";
lazy = true;
after = cfg.loaders;
};
cmp-luasnip = mkIf config.vim.autocomplete.nvim-cmp.enable {
package = "cmp-luasnip";
lazy = true;
2024-10-22 13:14:15 +00:00
after = ''
local path = vim.fn.globpath(vim.o.packpath, 'pack/*/opt/cmp-luasnip')
require("rtp_nvim").source_after_plugin_dir(path)
'';
2024-10-21 16:42:02 +00:00
};
2024-10-22 13:14:15 +00:00
nvim-cmp.after = optionalString config.vim.lazy.enable ''
require("lz.n").trigger_load("cmp-luasnip")
'';
2024-10-21 16:42:02 +00:00
};
startPlugins = cfg.providers;
autocomplete.nvim-cmp.sources = {luasnip = "[LuaSnip]";};
};
};
}