2023-10-22 15:10:28 +00:00
|
|
|
# From home-manager: https://github.com/nix-community/home-manager/blob/master/modules/lib/booleans.nix
|
2024-03-24 00:14:39 +00:00
|
|
|
{lib}: let
|
|
|
|
inherit (builtins) isString getAttr;
|
|
|
|
inherit (lib.options) mkOption;
|
|
|
|
inherit (lib.attrsets) listToAttrs;
|
|
|
|
inherit (lib.types) bool;
|
|
|
|
in {
|
2023-10-22 15:10:28 +00:00
|
|
|
# Converts a boolean to a yes/no string. This is used in lots of
|
|
|
|
# configuration formats.
|
2023-04-17 20:27:27 +00:00
|
|
|
diagnosticsToLua = {
|
|
|
|
lang,
|
|
|
|
config,
|
2024-03-24 00:14:39 +00:00
|
|
|
diagnosticsProviders,
|
2023-04-17 20:27:27 +00:00
|
|
|
}:
|
2024-03-24 00:14:39 +00:00
|
|
|
listToAttrs
|
2023-04-17 20:27:27 +00:00
|
|
|
(map (v: let
|
|
|
|
type =
|
2024-03-24 00:14:39 +00:00
|
|
|
if isString v
|
2023-04-17 20:27:27 +00:00
|
|
|
then v
|
2024-03-24 00:14:39 +00:00
|
|
|
else getAttr v.type;
|
2023-04-17 20:27:27 +00:00
|
|
|
package =
|
2024-03-24 00:14:39 +00:00
|
|
|
if isString v
|
|
|
|
then diagnosticsProviders.${type}.package
|
2023-04-17 20:27:27 +00:00
|
|
|
else v.package;
|
|
|
|
in {
|
|
|
|
name = "${lang}-diagnostics-${type}";
|
2024-03-24 00:14:39 +00:00
|
|
|
value = diagnosticsProviders.${type}.nullConfig package;
|
2023-04-17 20:27:27 +00:00
|
|
|
})
|
|
|
|
config);
|
2023-09-23 15:36:25 +00:00
|
|
|
|
|
|
|
mkEnable = desc:
|
2024-03-24 00:14:39 +00:00
|
|
|
mkOption {
|
2023-09-23 15:36:25 +00:00
|
|
|
description = "Turn on ${desc} for enabled languages by default";
|
2024-03-24 00:14:39 +00:00
|
|
|
type = bool;
|
2023-09-23 15:36:25 +00:00
|
|
|
default = false;
|
|
|
|
};
|
2023-04-17 20:27:27 +00:00
|
|
|
}
|