neovim-flake/lib/languages.nix

38 lines
973 B
Nix
Raw Normal View History

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.attrsets) listToAttrs;
inherit (lib.types) bool;
in {
2023-10-22 17:10:28 +02:00
# Converts a boolean to a yes/no string. This is used in lots of
# configuration formats.
diagnosticsToLua = {
lang,
config,
2024-03-24 01:14:39 +01:00
diagnosticsProviders,
}:
2024-03-24 01:14:39 +01:00
listToAttrs
(map (v: let
type =
2024-03-24 01:14:39 +01:00
if isString v
then v
2024-03-24 01:14:39 +01:00
else getAttr v.type;
package =
2024-03-24 01:14:39 +01:00
if isString v
then diagnosticsProviders.${type}.package
else v.package;
in {
name = "${lang}-diagnostics-${type}";
2024-03-24 01:14:39 +01:00
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
description = "Turn on ${desc} for enabled languages by default";
2024-03-24 01:14:39 +01:00
type = bool;
2023-09-23 17:36:25 +02:00
default = false;
};
}