mirror of
https://github.com/NotAShelf/nvf.git
synced 2025-09-05 18:01:32 +00:00
feat: refactor and separate LSP/language configurations
This commit is contained in:
parent
7a71f06763
commit
6b512f132a
30 changed files with 1266 additions and 522 deletions
|
@ -2,4 +2,5 @@
|
|||
dag = import ./dag.nix {inherit lib;};
|
||||
booleans = import ./booleans.nix {inherit lib;};
|
||||
types = import ./types {inherit lib;};
|
||||
languages = import ./languages.nix {inherit lib;};
|
||||
}
|
||||
|
|
25
lib/languages.nix
Normal file
25
lib/languages.nix
Normal file
|
@ -0,0 +1,25 @@
|
|||
# From home-manager: https://github.com/nix-community/home-manager/blob/master/modules/lib/booleans.nix
|
||||
{lib}: {
|
||||
# Converts a boolean to a yes/no string. This is used in lots of
|
||||
# configuration formats.
|
||||
diagnosticsToLua = {
|
||||
lang,
|
||||
config,
|
||||
diagnostics,
|
||||
}:
|
||||
lib.listToAttrs
|
||||
(map (v: let
|
||||
type =
|
||||
if builtins.isString v
|
||||
then v
|
||||
else builtins.getAttr v.type;
|
||||
package =
|
||||
if builtins.isString v
|
||||
then diagnostics.${type}.package
|
||||
else v.package;
|
||||
in {
|
||||
name = "${lang}-diagnostics-${type}";
|
||||
value = diagnostics.${type}.nullConfig package;
|
||||
})
|
||||
config);
|
||||
}
|
|
@ -1,7 +1,9 @@
|
|||
{lib}: let
|
||||
typesDag = import ./dag.nix {inherit lib;};
|
||||
typesPlugin = import ./plugins.nix {inherit lib;};
|
||||
typesLanguage = import ./languages.nix {inherit lib;};
|
||||
in {
|
||||
inherit (typesDag) dagOf;
|
||||
inherit (typesPlugin) pluginsOpt;
|
||||
inherit (typesLanguage) diagnostics;
|
||||
}
|
||||
|
|
26
lib/types/languages.nix
Normal file
26
lib/types/languages.nix
Normal file
|
@ -0,0 +1,26 @@
|
|||
{lib}:
|
||||
with lib; let
|
||||
diagnosticSubmodule = {...}: {
|
||||
options = {
|
||||
type = mkOption {
|
||||
description = "Type of diagnostic to enable";
|
||||
type = attrNames diagnostics;
|
||||
};
|
||||
package = mkOption {
|
||||
description = "Diagnostics package";
|
||||
type = types.package;
|
||||
};
|
||||
};
|
||||
};
|
||||
in {
|
||||
diagnostics = {
|
||||
langDesc,
|
||||
diagnostics,
|
||||
defaultDiagnostics,
|
||||
}:
|
||||
mkOption {
|
||||
description = "List of ${langDesc} diagnostics to enable";
|
||||
type = with types; listOf (either (enum (attrNames diagnostics)) (submodule diagnosticSubmodule));
|
||||
default = defaultDiagnostics;
|
||||
};
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue