neovim-flake/lib/languages.nix
2025-01-10 17:02:29 +03:00

35 lines
858 B
Nix

# From home-manager: https://github.com/nix-community/home-manager/blob/master/modules/lib/booleans.nix
{lib}: let
inherit (builtins) isString getAttr;
inherit (lib.options) mkOption;
inherit (lib.types) bool;
inherit (lib.nvim.attrsets) mapListToAttrs;
in {
diagnosticsToLua = {
lang,
config,
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;
mkEnable = desc:
mkOption {
default = false;
type = bool;
description = "Turn on ${desc} for enabled languages by default";
};
}