2023-11-23 13:53:22 +01:00
|
|
|
{
|
|
|
|
config,
|
|
|
|
lib,
|
|
|
|
pkgs,
|
|
|
|
...
|
|
|
|
}:
|
|
|
|
let
|
2024-10-05 15:55:49 +02:00
|
|
|
cfg = config.plugins.lsp.servers.rust_analyzer;
|
2024-12-14 21:09:46 +01:00
|
|
|
inherit (lib) mkPackageOption types;
|
|
|
|
inherit (lib.nixvim) mkNullOrOption';
|
|
|
|
|
2025-06-08 23:30:08 +01:00
|
|
|
extraPackages =
|
|
|
|
lib.optional (cfg.installCargo == true) cfg.cargoPackage
|
|
|
|
++ lib.optional (cfg.installRustc == true) cfg.rustcPackage
|
|
|
|
++ lib.optional (cfg.installRustfmt == true) cfg.rustfmtPackage;
|
|
|
|
|
2023-11-23 13:53:22 +01:00
|
|
|
in
|
|
|
|
{
|
2024-10-05 15:55:49 +02:00
|
|
|
options.plugins.lsp.servers.rust_analyzer = {
|
2023-11-23 13:53:22 +01:00
|
|
|
# https://github.com/nix-community/nixvim/issues/674
|
2024-12-14 21:09:46 +01:00
|
|
|
installCargo = mkNullOrOption' {
|
|
|
|
type = types.bool;
|
2023-11-23 13:53:22 +01:00
|
|
|
example = true;
|
|
|
|
description = "Whether to install `cargo`.";
|
|
|
|
};
|
|
|
|
|
2024-09-03 16:30:01 +01:00
|
|
|
# TODO: make nullable?
|
2024-12-14 21:09:46 +01:00
|
|
|
cargoPackage = lib.mkPackageOption pkgs "cargo" { };
|
2023-11-23 13:53:22 +01:00
|
|
|
|
2024-12-14 21:09:46 +01:00
|
|
|
installRustc = mkNullOrOption' {
|
|
|
|
type = types.bool;
|
2023-11-23 13:53:22 +01:00
|
|
|
example = true;
|
|
|
|
description = "Whether to install `rustc`.";
|
|
|
|
};
|
|
|
|
|
2024-09-03 16:30:01 +01:00
|
|
|
# TODO: make nullable
|
|
|
|
rustcPackage = mkPackageOption pkgs "rustc" { };
|
2024-11-07 11:19:58 -07:00
|
|
|
|
2024-12-14 21:09:46 +01:00
|
|
|
installRustfmt = mkNullOrOption' {
|
|
|
|
type = types.bool;
|
2024-11-07 11:19:58 -07:00
|
|
|
example = true;
|
|
|
|
description = "Whether to install `rustfmt`.";
|
|
|
|
};
|
|
|
|
|
|
|
|
# TODO: make nullable
|
|
|
|
rustfmtPackage = mkPackageOption pkgs "rustfmt" { };
|
2023-11-23 13:53:22 +01:00
|
|
|
};
|
2024-12-14 21:09:46 +01:00
|
|
|
config = lib.mkIf cfg.enable {
|
2025-01-29 14:16:00 +01:00
|
|
|
warnings = lib.nixvim.mkWarnings "plugins.lsp.servers.rust_analyzer" [
|
|
|
|
{
|
|
|
|
when = cfg.installCargo == null;
|
|
|
|
|
|
|
|
message = ''
|
|
|
|
`rust_analyzer` relies on `cargo`.
|
|
|
|
- Set `plugins.lsp.servers.rust_analyzer.installCargo = true` to install it automatically
|
|
|
|
with Nixvim.
|
|
|
|
You can customize which package to install by changing
|
|
|
|
`plugins.lsp.servers.rust_analyzer.cargoPackage`.
|
|
|
|
- Set `plugins.lsp.servers.rust_analyzer.installCargo = false` to not have it install
|
|
|
|
through Nixvim.
|
|
|
|
By doing so, you will dismiss this warning.
|
|
|
|
'';
|
|
|
|
}
|
|
|
|
{
|
|
|
|
when = cfg.installRustc == null;
|
|
|
|
|
|
|
|
message = ''
|
|
|
|
`rust_analyzer` relies on `rustc`.
|
|
|
|
- Set `plugins.lsp.servers.rust_analyzer.installRustc = true` to install it automatically
|
|
|
|
with Nixvim.
|
|
|
|
You can customize which package to install by changing
|
|
|
|
`plugins.lsp.servers.rust_analyzer.rustcPackage`.
|
|
|
|
- Set `plugins.lsp.servers.rust_analyzer.installRustc = false` to not have it install
|
|
|
|
through Nixvim.
|
|
|
|
By doing so, you will dismiss this warning.
|
|
|
|
'';
|
|
|
|
}
|
|
|
|
];
|
2023-11-23 13:53:22 +01:00
|
|
|
|
2025-06-08 23:30:08 +01:00
|
|
|
extraPackages = lib.optionals (!cfg.packageFallback) extraPackages;
|
|
|
|
extraPackagesAfter = lib.optionals cfg.packageFallback extraPackages;
|
2023-11-23 13:53:22 +01:00
|
|
|
};
|
|
|
|
}
|