2023-02-20 11:42:13 +01:00
|
|
|
{
|
|
|
|
pkgs,
|
|
|
|
config,
|
|
|
|
lib,
|
2024-03-01 13:24:14 +01:00
|
|
|
helpers,
|
2023-02-20 11:42:13 +01:00
|
|
|
...
|
2023-12-02 17:58:49 +01:00
|
|
|
}:
|
|
|
|
let
|
2024-07-05 18:59:04 +02:00
|
|
|
noneLsBuiltins = import ../../generated/none-ls.nix;
|
2024-03-01 13:24:14 +01:00
|
|
|
|
2024-07-05 18:59:04 +02:00
|
|
|
inherit (import ./packages.nix pkgs) packaged unpackaged;
|
2024-03-01 13:24:14 +01:00
|
|
|
|
2024-07-05 18:59:04 +02:00
|
|
|
# Does this builitin require a package ?
|
|
|
|
builitinNeedsPackage = source: lib.hasAttr source packaged || lib.elem source unpackaged;
|
2023-02-20 11:42:13 +01:00
|
|
|
in
|
|
|
|
{
|
2024-03-01 13:24:14 +01:00
|
|
|
imports = [ ./prettier.nix ];
|
|
|
|
|
2024-07-05 18:59:04 +02:00
|
|
|
options.plugins.none-ls.sources = lib.mapAttrs (
|
2024-03-01 13:24:14 +01:00
|
|
|
sourceType: sources:
|
2024-07-05 18:59:04 +02:00
|
|
|
lib.listToAttrs (
|
|
|
|
lib.map (source: {
|
|
|
|
name = source;
|
|
|
|
value =
|
|
|
|
{
|
|
|
|
enable = lib.mkEnableOption "the ${source} ${sourceType} source for none-ls";
|
|
|
|
withArgs = helpers.mkNullOrOption helpers.nixvimTypes.strLua ''
|
|
|
|
Raw Lua code passed as an argument to the source's `with` method.
|
|
|
|
'';
|
|
|
|
}
|
|
|
|
// lib.optionalAttrs (builitinNeedsPackage source) {
|
|
|
|
package =
|
|
|
|
let
|
|
|
|
pkg = packaged.${source} or null;
|
|
|
|
in
|
|
|
|
lib.mkOption (
|
|
|
|
{
|
|
|
|
type = lib.types.nullOr lib.types.package;
|
|
|
|
description =
|
|
|
|
"Package to use for ${source} by none-ls. "
|
|
|
|
+ (lib.optionalString (pkg == null) ''
|
|
|
|
Not handled in nixvim, either install externally and set to null or set the option with a derivation.
|
|
|
|
'');
|
|
|
|
}
|
|
|
|
// lib.optionalAttrs (pkg != null) { default = pkg; }
|
|
|
|
);
|
|
|
|
};
|
|
|
|
}) sources
|
|
|
|
)
|
2024-03-01 13:24:14 +01:00
|
|
|
) noneLsBuiltins;
|
2022-12-30 22:04:43 +01:00
|
|
|
|
2023-02-20 11:42:13 +01:00
|
|
|
config =
|
|
|
|
let
|
2023-10-13 11:43:42 -06:00
|
|
|
cfg = config.plugins.none-ls;
|
2023-05-21 17:19:38 +02:00
|
|
|
gitsignsEnabled = cfg.sources.code_actions.gitsigns.enable;
|
2024-03-01 13:24:14 +01:00
|
|
|
|
|
|
|
flattenedSources = lib.flatten (
|
|
|
|
lib.mapAttrsToList (
|
|
|
|
sourceType: sources:
|
|
|
|
(lib.mapAttrsToList (sourceName: source: source // { inherit sourceType sourceName; }) sources)
|
|
|
|
) cfg.sources
|
|
|
|
);
|
|
|
|
|
|
|
|
enabledSources = builtins.filter (source: source.enable) flattenedSources;
|
2023-02-20 11:42:13 +01:00
|
|
|
in
|
2024-07-05 18:59:04 +02:00
|
|
|
lib.mkIf cfg.enable {
|
|
|
|
plugins.none-ls.settings.sources = lib.mkIf (enabledSources != [ ]) (
|
2024-06-18 16:39:09 +01:00
|
|
|
map (
|
|
|
|
{
|
|
|
|
sourceType,
|
|
|
|
sourceName,
|
|
|
|
withArgs,
|
|
|
|
...
|
|
|
|
}:
|
|
|
|
"require('null-ls').builtins.${sourceType}.${sourceName}"
|
2024-07-05 18:59:04 +02:00
|
|
|
+ lib.optionalString (withArgs != null) ".with(${withArgs})"
|
2024-06-18 16:39:09 +01:00
|
|
|
) enabledSources
|
|
|
|
);
|
2024-07-05 18:59:04 +02:00
|
|
|
plugins.gitsigns.enable = lib.mkIf gitsignsEnabled true;
|
2024-04-23 16:41:27 +02:00
|
|
|
extraPackages = map (source: source.package or null) enabledSources;
|
2022-12-30 22:04:43 +01:00
|
|
|
};
|
2022-08-05 12:08:19 +00:00
|
|
|
}
|