neovim-flake/lib/types/languages.nix

38 lines
1,011 B
Nix
Raw Normal View History

{lib}: let
inherit (lib.options) mkOption mkPackageOption;
inherit (lib.attrsets) attrNames;
inherit (lib.types) listOf either enum submodule package;
2023-09-23 17:36:25 +02:00
diagnosticSubmodule = _: {
options = {
type = mkOption {
description = "Type of diagnostic to enable";
type = attrNames diagnostics;
};
package = mkOption {
type = package;
description = "Diagnostics package";
};
};
};
diagnostics = {
langDesc,
2024-03-24 01:14:39 +01:00
diagnosticsProviders,
defaultDiagnosticsProvider,
}:
mkOption {
type = listOf (either (enum (attrNames diagnosticsProviders)) (submodule diagnosticSubmodule));
2024-03-24 01:14:39 +01:00
default = defaultDiagnosticsProvider;
description = "List of ${langDesc} diagnostics to enable";
};
2023-04-17 23:55:27 +02:00
mkGrammarOption = pkgs: grammar:
mkPackageOption pkgs ["${grammar} treesitter"] {
default = ["vimPlugins" "nvim-treesitter" "builtGrammars" grammar];
};
in {
inherit diagnostics diagnosticSubmodule mkGrammarOption;
}