2024-03-23 20:14:39 -04:00
|
|
|
{lib}: let
|
|
|
|
|
inherit (builtins) isString getAttr;
|
|
|
|
|
inherit (lib.options) mkOption;
|
2025-05-22 14:48:14 +01:00
|
|
|
inherit (lib.types) listOf bool str submodule attrsOf anything either nullOr;
|
2024-10-09 19:50:34 +02:00
|
|
|
inherit (lib.nvim.attrsets) mapListToAttrs;
|
2025-02-16 12:48:40 +03:00
|
|
|
inherit (lib.nvim.types) luaInline;
|
2024-03-23 20:14:39 -04:00
|
|
|
in {
|
2025-04-05 23:17:18 +03:00
|
|
|
# TODO: remove
|
2023-04-17 23:27:27 +03:00
|
|
|
diagnosticsToLua = {
|
|
|
|
|
lang,
|
|
|
|
|
config,
|
2024-03-23 20:14:39 -04:00
|
|
|
diagnosticsProviders,
|
2023-04-17 23:27:27 +03:00
|
|
|
}:
|
2024-10-09 19:50:34 +02:00
|
|
|
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
|
|
|
};
|
2025-02-16 12:48:40 +03:00
|
|
|
|
|
|
|
|
lspOptions = submodule {
|
|
|
|
|
freeformType = attrsOf anything;
|
|
|
|
|
options = {
|
2025-04-05 23:17:18 +03:00
|
|
|
enable = mkOption {
|
|
|
|
|
type = bool;
|
|
|
|
|
default = true;
|
|
|
|
|
description = "Whether to enable this LSP server.";
|
|
|
|
|
};
|
|
|
|
|
|
2025-02-16 12:48:40 +03:00
|
|
|
capabilities = mkOption {
|
2025-04-05 23:17:18 +03:00
|
|
|
type = nullOr (either luaInline (attrsOf anything));
|
|
|
|
|
default = null;
|
2025-02-16 12:48:40 +03:00
|
|
|
description = "LSP capabilitiess to pass to lspconfig";
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
on_attach = mkOption {
|
2025-04-05 23:17:18 +03:00
|
|
|
type = nullOr luaInline;
|
|
|
|
|
default = null;
|
2025-02-16 12:48:40 +03:00
|
|
|
description = "Function to execute when an LSP server attaches to a buffer";
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
filetypes = mkOption {
|
2025-04-05 23:17:18 +03:00
|
|
|
type = nullOr (listOf str);
|
|
|
|
|
default = null;
|
2025-02-16 12:48:40 +03:00
|
|
|
description = "Filetypes to auto-attach LSP in";
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
cmd = mkOption {
|
2025-04-05 23:17:18 +03:00
|
|
|
type = nullOr (listOf str);
|
|
|
|
|
default = null;
|
2025-02-16 12:48:40 +03:00
|
|
|
description = "Command used to start the LSP server";
|
|
|
|
|
};
|
2025-04-05 22:47:10 +03:00
|
|
|
|
|
|
|
|
root_markers = mkOption {
|
2025-04-05 23:17:18 +03:00
|
|
|
type = nullOr (listOf str);
|
|
|
|
|
default = null;
|
2025-04-05 22:47:10 +03:00
|
|
|
description = ''
|
|
|
|
|
"root markers" used to determine the root directory of the workspace, and
|
|
|
|
|
the filetypes associated with this LSP server.
|
|
|
|
|
'';
|
|
|
|
|
};
|
2025-02-16 12:48:40 +03:00
|
|
|
};
|
|
|
|
|
};
|
2023-04-17 23:27:27 +03:00
|
|
|
}
|