plugins/mini-icons: add mockDevIcons

This commit is contained in:
Austin Horstman 2024-09-05 18:30:03 -05:00
parent 84249a9dab
commit 9a156ae60c
No known key found for this signature in database
2 changed files with 35 additions and 4 deletions

View file

@ -11,6 +11,14 @@ lib.nixvim.neovim-plugin.mkNeovimPlugin {
package = "mini-nvim";
extraOptions = {
mockDevIcons = lib.mkEnableOption "mockDevIcons" // {
defaultText = lib.literalMD "`false` **NOTE**: This option is experimental and the default value may change without notice.";
description = ''
Whether to tell `mini.icons` to emulate `nvim-web-devicons` for plugins that don't natively support it.
When enabled, you don't need to set `plugins.web-devicons.enable`. This will replace the need for it.
'';
};
modules = lib.mkOption {
type = with lib.types; attrsOf (attrsOf anything);
default = { };
@ -82,9 +90,23 @@ lib.nixvim.neovim-plugin.mkNeovimPlugin {
callSetup = false;
hasSettings = false;
extraConfig = cfg: {
extraConfigLua = lib.foldlAttrs (lines: name: config: ''
${lines}
require(${lib.nixvim.toLuaObject "mini.${name}"}).setup(${lib.nixvim.toLuaObject config})
'') "" cfg.modules;
assertions = [
{
assertion = cfg.mockDevIcons -> cfg.modules ? icons;
message = ''
You have enabled `plugins.mini.mockDevIcons` but have not defined `plugins.mini.modules.icons`.
This setting will have no effect without it.
'';
}
];
extraConfigLua =
lib.foldlAttrs (lines: name: config: ''
${lines}
require(${lib.nixvim.toLuaObject "mini.${name}"}).setup(${lib.nixvim.toLuaObject config})
'') "" cfg.modules
# `MiniIcons` is only in scope if we've called `require('mini.icons')` above
+ lib.optionalString ((cfg.modules ? icons) && cfg.mockDevIcons) ''
MiniIcons.mock_nvim_web_devicons()
'';
};
}

View file

@ -59,6 +59,7 @@
background = "#351721";
foreground = "#cdc4c6";
};
icons = { };
indentscope = { };
jump = { };
jump2d = { };
@ -77,4 +78,12 @@
};
};
};
icons-mock = {
plugins.mini = {
enable = true;
mockDevIcons = true;
modules.icons = { };
};
};
}