diff --git a/modules/plugins/languages/nix.nix b/modules/plugins/languages/nix.nix index 7d126e15..76310459 100644 --- a/modules/plugins/languages/nix.nix +++ b/modules/plugins/languages/nix.nix @@ -60,17 +60,7 @@ ''; }; - nixd = let - settings.nixd = { - inherit (cfg.lsp) options; - formatting.command = - if !cfg.format.enable - then null - else if cfg.format.type == "alejandra" - then ["${cfg.format.package}/bin/alejandra" "--quiet"] - else ["${cfg.format.package}/bin/nixfmt"]; - }; - in { + nixd = { package = pkgs.nixd; internalFormatter = true; lspConfig = '' @@ -82,7 +72,25 @@ else noFormat }, cmd = ${packageToCmd cfg.lsp.package "nixd"}, - settings = ${toLuaObject settings}, + options = ${toLuaObject cfg.lsp.options}, + ${optionalString cfg.format.enable '' + settings = { + nixd = { + ${optionalString (cfg.format.type == "alejandra") + '' + formatting = { + command = {"${cfg.format.package}/bin/alejandra", "--quiet"}, + }, + ''} + ${optionalString (cfg.format.type == "nixfmt") + '' + formatting = { + command = {"${cfg.format.package}/bin/nixfmt"}, + }, + ''} + }, + }, + ''} } ''; };