nvf/lib/languages.nix

36 lines
858 B
Nix
Raw Normal View History

2023-10-22 18:10:28 +03:00
# From home-manager: https://github.com/nix-community/home-manager/blob/master/modules/lib/booleans.nix
2024-03-23 20:14:39 -04:00
{lib}: let
inherit (builtins) isString getAttr;
inherit (lib.options) mkOption;
inherit (lib.types) bool;
inherit (lib.nvim.attrsets) mapListToAttrs;
2024-03-23 20:14:39 -04:00
in {
diagnosticsToLua = {
lang,
config,
2024-03-23 20:14:39 -04:00
diagnosticsProviders,
}:
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 18:36:25 +03:00
mkEnable = desc:
2024-03-23 20:14:39 -04:00
mkOption {
2023-09-23 18:36:25 +03:00
default = false;
2024-12-03 00:52:08 +03:00
type = bool;
description = "Turn on ${desc} for enabled languages by default";
2023-09-23 18:36:25 +03:00
};
}