nix: fix nixd option

This commit is contained in:
Ching Pei Yang 2025-09-15 18:44:30 +02:00
commit 96e1004e55
No known key found for this signature in database
GPG key ID: B3841364253DC4C8

View file

@ -60,7 +60,17 @@
''; '';
}; };
nixd = { 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 {
package = pkgs.nixd; package = pkgs.nixd;
internalFormatter = true; internalFormatter = true;
lspConfig = '' lspConfig = ''
@ -72,25 +82,7 @@
else noFormat else noFormat
}, },
cmd = ${packageToCmd cfg.lsp.package "nixd"}, cmd = ${packageToCmd cfg.lsp.package "nixd"},
options = ${toLuaObject cfg.lsp.options}, settings = ${toLuaObject settings},
${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"},
},
''}
},
},
''}
} }
''; '';
}; };