mirror of
https://github.com/nix-community/nixvim.git
synced 2025-07-15 11:44:32 +02:00
plugins/lsp: use a no-default option when there is no default provided
This commit is contained in:
parent
0d2751b53c
commit
88302aa17a
2 changed files with 26 additions and 14 deletions
|
@ -8,7 +8,7 @@
|
|||
name,
|
||||
description ? "Enable ${name}.",
|
||||
serverName ? name,
|
||||
package ? name,
|
||||
package ? null,
|
||||
url ? null,
|
||||
cmd ? (cfg: null),
|
||||
settings ? (cfg: cfg),
|
||||
|
@ -50,16 +50,32 @@ in
|
|||
package =
|
||||
if lib.isOption package then
|
||||
package
|
||||
else
|
||||
else if args ? package then
|
||||
lib.mkPackageOption pkgs name {
|
||||
nullable = true;
|
||||
default = package;
|
||||
}
|
||||
else
|
||||
# If we're not provided a package, we should provide a no-default option
|
||||
lib.mkOption {
|
||||
type = types.nullOr types.package;
|
||||
description = ''
|
||||
The package to use for ${name}. Has no default, but can be set to null.
|
||||
'';
|
||||
};
|
||||
|
||||
cmd = mkOption {
|
||||
type = with types; nullOr (listOf str);
|
||||
default =
|
||||
if (cfg.package or null) != null then if builtins.isFunction cmd then cmd cfg else cmd else null;
|
||||
# TODO: do we really only want the default `cmd` when `package` is non-null?
|
||||
if !(opt.package.isDefined or false) then
|
||||
null
|
||||
else if cfg.package == null then
|
||||
null
|
||||
else if builtins.isFunction cmd then
|
||||
cmd cfg
|
||||
else
|
||||
cmd;
|
||||
description = ''
|
||||
A list where each entry corresponds to the blankspace delimited part of the command that
|
||||
launches the server.
|
||||
|
|
|
@ -179,15 +179,6 @@ let
|
|||
|
||||
lspPackages = import ../lsp-packages.nix;
|
||||
|
||||
getLspPackage =
|
||||
name:
|
||||
if lib.hasAttr name lspPackages.packages then
|
||||
{ package = lspPackages.packages.${name}; }
|
||||
else if lib.hasAttr name lspPackages.customCmd then
|
||||
{ inherit (lspPackages.customCmd.${name}) package cmd; }
|
||||
else
|
||||
{ package = null; };
|
||||
|
||||
generatedServers = lib.pipe ../../../generated/lspconfig-servers.json [
|
||||
lib.importJSON
|
||||
(lib.map (
|
||||
|
@ -200,8 +191,13 @@ let
|
|||
inherit name;
|
||||
description = desc;
|
||||
}
|
||||
// (getLspPackage name)
|
||||
// (lspExtraArgs.${name} or { })
|
||||
// lib.optionalAttrs (lspPackages.packages ? ${name}) {
|
||||
package = lspPackages.packages.${name};
|
||||
}
|
||||
// lib.optionalAttrs (lspPackages.customCmd ? ${name}) {
|
||||
inherit (lspPackages.customCmd.${name}) package cmd;
|
||||
}
|
||||
// lspExtraArgs.${name} or { }
|
||||
))
|
||||
];
|
||||
in
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue