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