2022-08-05 12:08:19 +00:00
|
|
|
{
|
2023-02-20 11:42:13 +01:00
|
|
|
mkServer = {
|
|
|
|
name,
|
|
|
|
sourceType,
|
2023-10-13 11:43:42 -06:00
|
|
|
description ? "${name} source, for none-ls.",
|
2023-02-20 11:42:13 +01:00
|
|
|
package ? null,
|
|
|
|
extraPackages ? [],
|
|
|
|
...
|
|
|
|
}:
|
|
|
|
# returns a module
|
|
|
|
{
|
|
|
|
pkgs,
|
|
|
|
config,
|
|
|
|
lib,
|
2024-02-09 14:31:04 +01:00
|
|
|
helpers,
|
2023-02-20 11:42:13 +01:00
|
|
|
...
|
2024-02-09 14:31:04 +01:00
|
|
|
}:
|
2023-02-20 11:42:13 +01:00
|
|
|
with lib; let
|
2023-10-13 11:43:42 -06:00
|
|
|
cfg = config.plugins.none-ls.sources.${sourceType}.${name};
|
2023-02-20 11:42:13 +01:00
|
|
|
# does this evaluate package?
|
|
|
|
packageOption =
|
|
|
|
if package == null
|
|
|
|
then {}
|
|
|
|
else {
|
2023-01-19 10:45:15 +00:00
|
|
|
package = mkOption {
|
|
|
|
type = types.package;
|
|
|
|
default = package;
|
2023-10-13 11:43:42 -06:00
|
|
|
description = "Package to use for ${name} by none-ls";
|
2023-01-19 10:45:15 +00:00
|
|
|
};
|
|
|
|
};
|
2023-02-20 11:42:13 +01:00
|
|
|
in {
|
2023-10-13 11:43:42 -06:00
|
|
|
options.plugins.none-ls.sources.${sourceType}.${name} =
|
2023-02-20 11:42:13 +01:00
|
|
|
{
|
2022-09-18 11:19:23 +01:00
|
|
|
enable = mkEnableOption description;
|
2022-08-05 12:08:19 +00:00
|
|
|
|
2022-09-18 11:19:23 +01:00
|
|
|
# TODO: withArgs can exist outside of the module in a generalized manner
|
|
|
|
withArgs = mkOption {
|
|
|
|
default = null;
|
|
|
|
type = with types; nullOr str;
|
|
|
|
description = ''Raw Lua code to be called with the with function'';
|
|
|
|
# Not sure that it makes sense to have the same example for all servers
|
|
|
|
# example = ''
|
|
|
|
# '\'{ extra_args = { "--no-semi", "--single-quote", "--jsx-single-quote" } }'\'
|
|
|
|
# '';
|
2022-08-05 12:08:19 +00:00
|
|
|
};
|
2023-02-20 11:42:13 +01:00
|
|
|
}
|
|
|
|
// packageOption;
|
2022-08-05 12:08:19 +00:00
|
|
|
|
2023-02-20 11:42:13 +01:00
|
|
|
config = mkIf cfg.enable {
|
|
|
|
# Does this evaluate package?
|
|
|
|
extraPackages = extraPackages ++ optional (package != null) cfg.package;
|
2022-08-05 12:08:19 +00:00
|
|
|
|
2023-02-20 11:42:13 +01:00
|
|
|
# Add source to list of sources
|
2023-10-13 11:43:42 -06:00
|
|
|
plugins.none-ls.sourcesItems = let
|
2023-02-20 11:42:13 +01:00
|
|
|
sourceItem = "${sourceType}.${name}";
|
|
|
|
withArgs =
|
2023-05-22 15:45:47 +05:30
|
|
|
if (cfg.withArgs == null)
|
2023-02-20 11:42:13 +01:00
|
|
|
then sourceItem
|
|
|
|
else "${sourceItem}.with ${cfg.withArgs}";
|
|
|
|
finalString = ''require("null-ls").builtins.${withArgs}'';
|
|
|
|
in [(helpers.mkRaw finalString)];
|
2022-09-18 11:19:23 +01:00
|
|
|
};
|
2023-02-20 11:42:13 +01:00
|
|
|
};
|
2022-08-05 12:08:19 +00:00
|
|
|
}
|