2024-08-03 16:28:41 +01:00
|
|
|
# Custom types to be included in `lib.types`
|
2024-07-08 10:29:31 +01:00
|
|
|
{ lib }:
|
2024-01-25 15:43:06 +01:00
|
|
|
let
|
2024-08-30 14:49:20 -05:00
|
|
|
inherit (lib) types;
|
2024-07-08 10:29:31 +01:00
|
|
|
inherit (lib.nixvim)
|
|
|
|
deprecation
|
|
|
|
mkNullOrStr
|
|
|
|
mkNullOrOption
|
|
|
|
;
|
2024-08-30 14:49:20 -05:00
|
|
|
|
2024-01-25 15:43:06 +01:00
|
|
|
strLikeType =
|
|
|
|
description:
|
2024-08-30 14:49:20 -05:00
|
|
|
lib.mkOptionType {
|
2024-01-25 15:43:06 +01:00
|
|
|
name = "str";
|
|
|
|
inherit description;
|
|
|
|
descriptionClass = "noun";
|
2024-08-30 14:49:20 -05:00
|
|
|
check = v: lib.isString v || isRawType v;
|
2024-01-25 15:43:06 +01:00
|
|
|
merge = lib.options.mergeEqualOption;
|
|
|
|
};
|
2024-08-30 14:49:20 -05:00
|
|
|
isRawType = v: v ? __raw && lib.isString v.__raw;
|
2024-01-25 15:43:06 +01:00
|
|
|
in
|
|
|
|
rec {
|
2024-08-03 16:36:50 +01:00
|
|
|
# TODO: deprecate in favor of types.rawLua.check
|
|
|
|
# Or move to utils, lua, etc?
|
2024-06-16 22:39:53 +01:00
|
|
|
inherit isRawType;
|
2024-02-03 20:04:01 +01:00
|
|
|
|
2024-08-30 14:49:20 -05:00
|
|
|
rawLua = lib.mkOptionType {
|
2024-01-25 15:43:06 +01:00
|
|
|
name = "rawLua";
|
|
|
|
description = "raw lua code";
|
|
|
|
descriptionClass = "noun";
|
2024-08-30 14:49:20 -05:00
|
|
|
merge = lib.options.mergeEqualOption;
|
2024-07-08 10:14:53 +02:00
|
|
|
check = v: (isRawType v) || (v ? __empty);
|
2024-01-25 15:43:06 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
maybeRaw = type: types.either type rawLua;
|
|
|
|
|
2024-07-08 10:29:31 +01:00
|
|
|
# Describes an boolean-like integer flag that is either 0 or 1
|
|
|
|
# Has legacy support for boolean definitions, added 2024-09-08
|
|
|
|
intFlag =
|
|
|
|
with types;
|
|
|
|
deprecation.transitionType bool (v: if v then 1 else 0) (enum [
|
|
|
|
0
|
|
|
|
1
|
|
|
|
]);
|
|
|
|
|
2024-01-25 15:43:06 +01:00
|
|
|
border =
|
|
|
|
with types;
|
|
|
|
oneOf [
|
|
|
|
str
|
|
|
|
(listOf str)
|
|
|
|
(listOf (listOf str))
|
|
|
|
];
|
|
|
|
|
2024-04-07 11:30:24 +02:00
|
|
|
logLevel = types.enum [
|
|
|
|
"off"
|
|
|
|
"error"
|
|
|
|
"warn"
|
|
|
|
"info"
|
|
|
|
"debug"
|
|
|
|
"trace"
|
|
|
|
];
|
|
|
|
|
2024-01-25 15:43:06 +01:00
|
|
|
highlight = types.submodule {
|
|
|
|
# Adds flexibility for other keys
|
|
|
|
freeformType = types.attrs;
|
|
|
|
|
|
|
|
# :help nvim_set_hl()
|
|
|
|
options = with types; {
|
|
|
|
fg = mkNullOrStr "Color for the foreground (color name or '#RRGGBB').";
|
|
|
|
bg = mkNullOrStr "Color for the background (color name or '#RRGGBB').";
|
|
|
|
sp = mkNullOrStr "Special color (color name or '#RRGGBB').";
|
|
|
|
blend = mkNullOrOption (numbers.between 0 100) "Integer between 0 and 100.";
|
|
|
|
bold = mkNullOrOption bool "";
|
|
|
|
standout = mkNullOrOption bool "";
|
|
|
|
underline = mkNullOrOption bool "";
|
|
|
|
undercurl = mkNullOrOption bool "";
|
|
|
|
underdouble = mkNullOrOption bool "";
|
|
|
|
underdotted = mkNullOrOption bool "";
|
|
|
|
underdashed = mkNullOrOption bool "";
|
|
|
|
strikethrough = mkNullOrOption bool "";
|
|
|
|
italic = mkNullOrOption bool "";
|
|
|
|
reverse = mkNullOrOption bool "";
|
|
|
|
nocombine = mkNullOrOption bool "";
|
|
|
|
link = mkNullOrStr "Name of another highlight group to link to.";
|
|
|
|
default = mkNullOrOption bool "Don't override existing definition.";
|
|
|
|
ctermfg = mkNullOrStr "Sets foreground of cterm color.";
|
|
|
|
ctermbg = mkNullOrStr "Sets background of cterm color.";
|
2024-04-07 16:55:08 +02:00
|
|
|
cterm = mkNullOrOption (either str attrs) ''
|
2024-01-25 15:43:06 +01:00
|
|
|
cterm attribute map, like |highlight-args|.
|
|
|
|
If not set, cterm attributes will match those from the attribute map documented above.
|
|
|
|
'';
|
|
|
|
};
|
2024-05-05 19:39:35 +02:00
|
|
|
};
|
2024-01-25 15:43:06 +01:00
|
|
|
|
|
|
|
strLua = strLikeType "lua code string";
|
|
|
|
strLuaFn = strLikeType "lua function string";
|
2024-02-03 19:04:09 +01:00
|
|
|
|
|
|
|
# Overridden when building the documentation
|
2024-08-30 14:49:20 -05:00
|
|
|
eitherRecursive = types.either;
|
2024-08-13 08:05:55 -05:00
|
|
|
|
|
|
|
listOfLen =
|
|
|
|
elemType: len:
|
2024-08-30 14:49:20 -05:00
|
|
|
types.addCheck (types.listOf elemType) (v: builtins.length v == len)
|
2024-08-13 08:05:55 -05:00
|
|
|
// {
|
|
|
|
description = "list of ${toString len} ${
|
2024-08-30 14:49:20 -05:00
|
|
|
types.optionDescriptionPhrase (class: class == "noun" || class == "composite") elemType
|
2024-08-13 08:05:55 -05:00
|
|
|
}";
|
|
|
|
};
|
2024-01-25 15:43:06 +01:00
|
|
|
}
|