nix-community.nixvim/plugins/by-name/web-devicons/default.nix

50 lines
1.6 KiB
Nix
Raw Normal View History

2024-09-05 16:56:34 +00:00
{ lib, ... }:
let
inherit (lib.nixvim) defaultNullOpts mkNullOrOption toLuaObject;
2024-09-05 16:56:34 +00:00
in
lib.nixvim.neovim-plugin.mkNeovimPlugin {
name = "web-devicons";
packPathName = "nvim-web-devicons";
moduleName = "nvim-web-devicons";
2024-09-05 16:56:34 +00:00
package = "nvim-web-devicons";
maintainers = [ lib.maintainers.refaelsh ];
settingsExample = {
color_icons = true;
strict = true;
};
extraOptions = {
customIcons = defaultNullOpts.mkAttrsOf (lib.types.submodule {
freeformType = lib.types.anything;
options = {
icon = defaultNullOpts.mkStr null "Icon to use.";
color = defaultNullOpts.mkStr null "Color of the icon.";
cterm_color = defaultNullOpts.mkStr null "Cterm color of the icon.";
name = defaultNullOpts.mkStr null "Name to replace with icon.";
};
}) { } ''Custom overrides for icons.'';
defaultIcon = mkNullOrOption (lib.types.submodule {
options = {
icon = defaultNullOpts.mkStr null "Icon to use.";
color = defaultNullOpts.mkStr null "Color of the icon.";
cterm_color = defaultNullOpts.mkStr null "Cterm color of the icon.";
};
}) ''Set the default icon when none is found.'';
};
extraConfig = cfg: {
plugins.web-devicons.luaConfig.post =
lib.optionalString (cfg.customIcons != null) ''
require('nvim-web-devicons').set_icon(${toLuaObject cfg.customIcons})
''
+ lib.optionalString (cfg.defaultIcon != null) ''
require('nvim-web-devicons').set_default_icon(
${toLuaObject cfg.defaultIcon.icon}, ${toLuaObject cfg.defaultIcon.color}, ${toLuaObject cfg.defaultIcon.cterm_color})
'';
};
2024-09-05 16:56:34 +00:00
}