mirror of
https://github.com/nix-community/nixvim.git
synced 2025-06-22 08:53:28 +02:00
lib/neovim-plugin: support lz-n lazy config
This commit is contained in:
parent
da30527de1
commit
3cfde1554c
3 changed files with 155 additions and 23 deletions
|
@ -116,9 +116,9 @@
|
||||||
|
|
||||||
lazyLoad = lib.nixvim.mkLazyLoadOption {
|
lazyLoad = lib.nixvim.mkLazyLoadOption {
|
||||||
inherit originalName;
|
inherit originalName;
|
||||||
lazyLoadDefaults = (
|
lazyLoadDefaults = lib.optionalAttrs (isColorscheme && colorscheme != null) {
|
||||||
lib.optionalAttrs (isColorscheme && colorscheme != null) { inherit colorscheme; }
|
inherit colorscheme;
|
||||||
);
|
};
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
// lib.optionalAttrs hasSettings {
|
// lib.optionalAttrs hasSettings {
|
||||||
|
@ -171,6 +171,34 @@
|
||||||
# Write the lua configuration `luaConfig.content` to the config file
|
# Write the lua configuration `luaConfig.content` to the config file
|
||||||
(lib.mkIf (!cfg.lazyLoad.enable) (setLuaConfig cfg.luaConfig.content))
|
(lib.mkIf (!cfg.lazyLoad.enable) (setLuaConfig cfg.luaConfig.content))
|
||||||
])
|
])
|
||||||
|
++ (lib.optionals hasConfigAttrs [
|
||||||
|
(lib.mkIf (cfg.lazyLoad.backend == "lz.n") {
|
||||||
|
plugins.lz-n = {
|
||||||
|
# infinite recursion?
|
||||||
|
# enable = true;
|
||||||
|
plugins = [
|
||||||
|
{
|
||||||
|
# TODO: handle this for every plugin properly
|
||||||
|
__unkeyed-1 = originalName;
|
||||||
|
# Use provided after, otherwise fallback to normal lua content
|
||||||
|
after = if cfg.lazyLoad.after != null then cfg.lazyLoad.after else cfg.luaConfig.content;
|
||||||
|
inherit (cfg.lazyLoad)
|
||||||
|
enabled
|
||||||
|
priority
|
||||||
|
before
|
||||||
|
beforeAll
|
||||||
|
event
|
||||||
|
cmd
|
||||||
|
ft
|
||||||
|
keys
|
||||||
|
colorscheme
|
||||||
|
extraSettings
|
||||||
|
;
|
||||||
|
}
|
||||||
|
];
|
||||||
|
};
|
||||||
|
})
|
||||||
|
])
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
|
@ -360,6 +360,15 @@ rec {
|
||||||
lazy-loading for ${originalName}
|
lazy-loading for ${originalName}
|
||||||
'';
|
'';
|
||||||
|
|
||||||
|
backend =
|
||||||
|
mkEnumFirstDefault
|
||||||
|
[
|
||||||
|
"lz.n"
|
||||||
|
]
|
||||||
|
''
|
||||||
|
The lazy-loading backend to use.
|
||||||
|
'';
|
||||||
|
|
||||||
# Spec loading:
|
# Spec loading:
|
||||||
enabled = mkStrLuaFnOr types.bool (lazyLoadDefaults.enabledInSpec or null) ''
|
enabled = mkStrLuaFnOr types.bool (lazyLoadDefaults.enabledInSpec or null) ''
|
||||||
When false, or if the function returns false, then ${originalName} will not be included in the spec.
|
When false, or if the function returns false, then ${originalName} will not be included in the spec.
|
||||||
|
|
|
@ -1,18 +1,16 @@
|
||||||
{
|
{
|
||||||
lazy-load-plugin =
|
lazy-load-neovim-plugin =
|
||||||
{ config, ... }:
|
{ config, ... }:
|
||||||
{
|
{
|
||||||
plugins = {
|
plugins = {
|
||||||
lz-n = {
|
lz-n = {
|
||||||
enable = true;
|
enable = true;
|
||||||
plugins = [
|
};
|
||||||
{
|
|
||||||
__unkeyed-1 = "neotest";
|
neotest = {
|
||||||
after.__raw = ''
|
enable = true;
|
||||||
function()
|
lazyLoad = {
|
||||||
${config.plugins.neotest.luaConfig.content}
|
enable = true;
|
||||||
end
|
|
||||||
'';
|
|
||||||
keys = [
|
keys = [
|
||||||
{
|
{
|
||||||
__unkeyed-1 = "<leader>nt";
|
__unkeyed-1 = "<leader>nt";
|
||||||
|
@ -20,15 +18,112 @@
|
||||||
desc = "Summary toggle";
|
desc = "Summary toggle";
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
assertions = [
|
||||||
|
{
|
||||||
|
assertion = (builtins.length config.plugins.lz-n.plugins) == 1;
|
||||||
|
message = "`lz-n.plugins` should have contained a single plugin configuration, but contained ${builtins.toJSON config.plugins.lz-n.plugins}";
|
||||||
|
}
|
||||||
|
{
|
||||||
|
assertion =
|
||||||
|
let
|
||||||
|
plugin = builtins.head config.plugins.lz-n.plugins;
|
||||||
|
keys = if builtins.isList plugin.keys then plugin.keys else [ ];
|
||||||
|
in
|
||||||
|
(builtins.length keys) == 1;
|
||||||
|
message = "`lz-n.plugins[0].keys` should have contained a configuration.";
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
};
|
};
|
||||||
|
|
||||||
neotest = {
|
lazy-load-lz-n =
|
||||||
|
{ config, ... }:
|
||||||
|
{
|
||||||
|
plugins = {
|
||||||
|
codesnap = {
|
||||||
enable = true;
|
enable = true;
|
||||||
lazyLoad.enable = true;
|
lazyLoad.enable = true;
|
||||||
};
|
};
|
||||||
|
lz-n = {
|
||||||
|
enable = true;
|
||||||
|
plugins = [
|
||||||
|
{
|
||||||
|
__unkeyed-1 = "codesnap";
|
||||||
|
after.__raw = ''
|
||||||
|
function()
|
||||||
|
${config.plugins.codesnap.luaConfig.content}
|
||||||
|
end
|
||||||
|
'';
|
||||||
|
cmd = [
|
||||||
|
"CodeSnap"
|
||||||
|
"CodeSnapSave"
|
||||||
|
"CodeSnapHighlight"
|
||||||
|
"CodeSnapSaveHighlight"
|
||||||
|
];
|
||||||
|
keys = [
|
||||||
|
{
|
||||||
|
__unkeyed-1 = "<leader>cc";
|
||||||
|
__unkeyed-3 = "<cmd>CodeSnap<CR>";
|
||||||
|
desc = "Copy";
|
||||||
|
mode = "v";
|
||||||
|
}
|
||||||
|
{
|
||||||
|
__unkeyed-1 = "<leader>cs";
|
||||||
|
__unkeyed-3 = "<cmd>CodeSnapSave<CR>";
|
||||||
|
desc = "Save";
|
||||||
|
mode = "v";
|
||||||
|
}
|
||||||
|
{
|
||||||
|
__unkeyed-1 = "<leader>ch";
|
||||||
|
__unkeyed-3 = "<cmd>CodeSnapHighlight<CR>";
|
||||||
|
desc = "Highlight";
|
||||||
|
mode = "v";
|
||||||
|
}
|
||||||
|
{
|
||||||
|
__unkeyed-1 = "<leader>cH";
|
||||||
|
__unkeyed-3 = "<cmd>CodeSnapSaveHighlight<CR>";
|
||||||
|
desc = "Save Highlight";
|
||||||
|
mode = "v";
|
||||||
|
}
|
||||||
|
];
|
||||||
|
}
|
||||||
|
];
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
assertions = [
|
||||||
|
{
|
||||||
|
assertion = (builtins.length config.plugins.lz-n.plugins) == 1;
|
||||||
|
message = "`lz-n.plugins` should have contained a single plugin configuration, but contained ${builtins.toJSON config.plugins.lz-n.plugins}";
|
||||||
|
}
|
||||||
|
{
|
||||||
|
assertion =
|
||||||
|
let
|
||||||
|
plugin = builtins.head config.plugins.lz-n.plugins;
|
||||||
|
keys = if builtins.isList plugin.keys then plugin.keys else [ ];
|
||||||
|
in
|
||||||
|
(builtins.length keys) == 4;
|
||||||
|
message =
|
||||||
|
let
|
||||||
|
plugin = builtins.head config.plugins.lz-n.plugins;
|
||||||
|
in
|
||||||
|
"`lz-n.plugins[0].keys` should have contained 4 key configurations, but contained ${builtins.toJSON (plugin.keys)}";
|
||||||
|
}
|
||||||
|
{
|
||||||
|
assertion =
|
||||||
|
let
|
||||||
|
plugin = builtins.head config.plugins.lz-n.plugins;
|
||||||
|
cmd = if builtins.isList plugin.cmd then plugin.cmd else [ ];
|
||||||
|
in
|
||||||
|
(builtins.length cmd) == 4;
|
||||||
|
message =
|
||||||
|
let
|
||||||
|
plugin = builtins.head config.plugins.lz-n.plugins;
|
||||||
|
in
|
||||||
|
"`lz-n.plugins[0].cmd` should have contained 4 cmd configurations, but contained ${builtins.toJSON (plugin.cmd)}";
|
||||||
|
}
|
||||||
|
];
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue