mirror of
https://github.com/NotAShelf/nvf.git
synced 2025-09-06 02:11:33 +00:00
feature: add base16 support (#389)
* modules: add base16 Theming support theme/theme.nix: fix formatting supported-themes.nix: formatting clean up base16-colors.nix theme: fix plugin setup, change base16 flake input * theme/theme.nix: fix formatting * types/theme.nix: add check regex matching types/theme.nix: fixed regex matching * lib/types: rename custom.nix to types.nix, mov theme.nix into types.nix * plugins/theme: apply requested changes types/types.nix: remove unneeded inherit theme/theme.nix: remove commented inherit * theme/theme.nix: fix up base16 helper func Co-authored-by: diniamo <55629891+diniamo@users.noreply.github.com> * theme/theme.nix: move listToAttrs inheriting, fix base16-colors declaration * theme/theme.nix: add documentation to vim.theme.name * release-notes/rl-0.7.md: add changelog entry for base16 * theme/theme.nix: fix documentation rendering --------- Co-authored-by: diniamo <55629891+diniamo@users.noreply.github.com>
This commit is contained in:
parent
6670d752c7
commit
bdf777dc8a
7 changed files with 71 additions and 8 deletions
|
@ -1,61 +0,0 @@
|
|||
{lib}: let
|
||||
inherit (lib) isStringLike showOption showFiles getFiles mergeOneOption mergeEqualOption mkOptionType;
|
||||
inherit (lib.types) anything attrsOf;
|
||||
inherit (lib.nvim.types) anythingConcatLists;
|
||||
inherit (builtins) typeOf isAttrs any head concatLists stringLength;
|
||||
in {
|
||||
# HACK: Does this break anything in our case?
|
||||
# A modified version of the nixpkgs anything type that concatenates lists
|
||||
# This isn't the default because the order in which the lists are concatenated depends on the order in which the modules are imported,
|
||||
# which makes it non-deterministic
|
||||
anythingConcatLists =
|
||||
anything
|
||||
// {
|
||||
merge = loc: defs: let
|
||||
getType = value:
|
||||
if isAttrs value && isStringLike value
|
||||
then "stringCoercibleSet"
|
||||
else typeOf value;
|
||||
|
||||
# Throw an error if not all defs have the same type
|
||||
checkType = getType (head defs).value;
|
||||
commonType =
|
||||
if any (def: getType def.value != checkType) defs
|
||||
then throw "The option `${showOption loc}' has conflicting option types in ${showFiles (getFiles defs)}"
|
||||
else checkType;
|
||||
|
||||
mergeFunctions = {
|
||||
# Recursively merge attribute sets
|
||||
set = (attrsOf anythingConcatLists).merge;
|
||||
|
||||
# Overridden behavior for lists, that concatenates lists
|
||||
list = _: defs: concatLists (map (e: e.value) defs);
|
||||
|
||||
# This means it's a package, only accept a single definition
|
||||
stringCoercibleSet = mergeOneOption;
|
||||
|
||||
# This works by passing the argument to the functions,
|
||||
# and merging their returns values instead
|
||||
lambda = loc: defs: arg:
|
||||
anythingConcatLists.merge
|
||||
(loc ++ ["<function body>"])
|
||||
(map (def: {
|
||||
inherit (def) file;
|
||||
value = def.value arg;
|
||||
})
|
||||
defs);
|
||||
};
|
||||
in
|
||||
# Merge the defs with the correct function from above, if available
|
||||
# otherwise only allow equal values
|
||||
(mergeFunctions.${commonType} or mergeEqualOption) loc defs;
|
||||
};
|
||||
|
||||
char = mkOptionType {
|
||||
name = "char";
|
||||
description = "character";
|
||||
descriptionClass = "noun";
|
||||
check = value: stringLength value < 2;
|
||||
merge = mergeEqualOption;
|
||||
};
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue