refactor: reduce duplicate code

This commit is contained in:
Ching Pei Yang 2024-03-10 18:40:33 +00:00
parent 4b79c50201
commit 7e16923952

View file

@ -7,6 +7,12 @@
inherit (lib.types) nullOr listOf enum bool str int; inherit (lib.types) nullOr listOf enum bool str int;
inherit (lib.modules) mkRenamedOptionModule; inherit (lib.modules) mkRenamedOptionModule;
inherit (lib.nvim.types) mkPluginSetupOption; inherit (lib.nvim.types) mkPluginSetupOption;
mkSimpleIconOption = default:
mkOption {
inherit default;
type = str;
description = "";
};
in { in {
imports = let imports = let
renameSetupOpt = oldPath: newPath: renameSetupOpt = oldPath: newPath:
@ -277,23 +283,9 @@ in {
node_markers = { node_markers = {
enable = mkEnableOption "node markers"; enable = mkEnableOption "node markers";
icons = { icons = {
leaf = mkOption { leaf = mkSimpleIconOption " ";
type = str; leaf_selected = mkSimpleIconOption " ";
default = " "; branch = mkSimpleIconOption " ";
description = "";
};
leaf_selected = mkOption {
type = str;
default = " ";
description = "";
};
branch = mkOption {
type = str;
default = " ";
description = "";
};
}; };
}; };
@ -338,166 +330,34 @@ in {
}; };
icons = { icons = {
File = mkOption { File = mkSimpleIconOption "󰈙 ";
type = str; Module = mkSimpleIconOption " ";
default = "󰈙 "; Namespace = mkSimpleIconOption "󰌗 ";
description = ""; Package = mkSimpleIconOption " ";
}; Class = mkSimpleIconOption "󰌗 ";
Property = mkSimpleIconOption " ";
Module = mkOption { Field = mkSimpleIconOption " ";
type = str; Constructor = mkSimpleIconOption " ";
default = " "; Enum = mkSimpleIconOption "󰕘";
description = ""; Interface = mkSimpleIconOption "󰕘";
}; Function = mkSimpleIconOption "󰊕 ";
Variable = mkSimpleIconOption "󰆧 ";
Namespace = mkOption { Constant = mkSimpleIconOption "󰏿 ";
type = str; String = mkSimpleIconOption " ";
default = "󰌗 "; Number = mkSimpleIconOption "󰎠 ";
description = ""; Boolean = mkSimpleIconOption " ";
}; Array = mkSimpleIconOption "󰅪 ";
Object = mkSimpleIconOption "󰅩 ";
Package = mkOption { Method = mkSimpleIconOption "󰆧 ";
type = str; Key = mkSimpleIconOption "󰌋 ";
default = " "; Null = mkSimpleIconOption "󰟢 ";
description = ""; EnumMember = mkSimpleIconOption "󰕘 ";
}; Struct = mkSimpleIconOption "󰌗 ";
Event = mkSimpleIconOption " ";
Class = mkOption { Operator = mkSimpleIconOption "󰆕 ";
type = str; TypeParameter = mkSimpleIconOption "󰊄 ";
default = "󰌗 ";
description = "";
};
Property = mkOption {
type = str;
default = " ";
description = "";
};
Field = mkOption {
type = str;
default = " ";
description = "";
};
Constructor = mkOption {
type = str;
default = " ";
description = "";
};
Enum = mkOption {
type = str;
default = "󰕘";
description = "";
};
Interface = mkOption {
type = str;
default = "󰕘";
description = "";
};
Function = mkOption {
type = str;
default = "󰊕 ";
description = "";
};
Variable = mkOption {
type = str;
default = "󰆧 ";
description = "";
};
Constant = mkOption {
type = str;
default = "󰏿 ";
description = "";
};
String = mkOption {
type = str;
default = " ";
description = "";
};
Number = mkOption {
type = str;
default = "󰎠 ";
description = "";
};
Boolean = mkOption {
type = str;
default = " ";
description = "";
};
Array = mkOption {
type = str;
default = "󰅪 ";
description = "";
};
Object = mkOption {
type = str;
default = "󰅩 ";
description = "";
};
Method = mkOption {
type = str;
default = "󰆧 ";
description = "";
};
Key = mkOption {
type = str;
default = "󰌋 ";
description = "";
};
Null = mkOption {
type = str;
default = "󰟢 ";
description = "";
};
EnumMember = mkOption {
type = str;
default = "󰕘 ";
description = "";
};
Struct = mkOption {
type = str;
default = "󰌗 ";
description = "";
};
Event = mkOption {
type = str;
default = " ";
description = "";
};
Operator = mkOption {
type = str;
default = "󰆕 ";
description = "";
};
TypeParameter = mkOption {
type = str;
default = "󰊄 ";
description = "";
}; };
}; };
}; };
# there probably is a better way to do this
# alas, I am not a nix wizard
};
}; };
} }