From aabbd60633947baba11db44df84f402edc241440 Mon Sep 17 00:00:00 2001 From: Katherine Jamison Date: Thu, 7 Nov 2024 11:19:58 -0700 Subject: [PATCH] plugins/lsp: enable auto-installing rustfmt --- plugins/lsp/language-servers/rust-analyzer.nix | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/plugins/lsp/language-servers/rust-analyzer.nix b/plugins/lsp/language-servers/rust-analyzer.nix index 465c8693..28e5c07c 100644 --- a/plugins/lsp/language-servers/rust-analyzer.nix +++ b/plugins/lsp/language-servers/rust-analyzer.nix @@ -30,6 +30,16 @@ in # TODO: make nullable rustcPackage = mkPackageOption pkgs "rustc" { }; + + installRustfmt = mkOption { + type = with types; nullOr bool; + default = null; + example = true; + description = "Whether to install `rustfmt`."; + }; + + # TODO: make nullable + rustfmtPackage = mkPackageOption pkgs "rustfmt" { }; }; config = mkIf cfg.enable { warnings = @@ -56,7 +66,8 @@ in extraPackages = with pkgs; - (optional ((isBool cfg.installCargo) && cfg.installCargo) cfg.cargoPackage) - ++ (optional ((isBool cfg.installRustc) && cfg.installRustc) cfg.rustcPackage); + optional (isBool cfg.installCargo && cfg.installCargo) cfg.cargoPackage + ++ optional (isBool cfg.installRustc && cfg.installRustc) cfg.rustcPackage + ++ optional (isBool cfg.installRustfmt && cfg.installRustfmt) cfg.rustfmtPackage; }; }