diff --git a/docs/release-notes/rl-0.7.md b/docs/release-notes/rl-0.7.md index 7fd48768..f73786dc 100644 --- a/docs/release-notes/rl-0.7.md +++ b/docs/release-notes/rl-0.7.md @@ -196,3 +196,7 @@ everyone. [Soliprem](https://github.com/Soliprem) - Add LSP and Treesitter support for R under `vim.languages.R`. + +[nezia1](https://github.com/nezia1): + +- Replace [nixpkgs-fmt](https://github.com/nix-community/nixpkgs-fmt) with [nixfmt](https://github.com/NixOS/nixfmt) (nixfmt-rfc-style). diff --git a/modules/plugins/languages/nix.nix b/modules/plugins/languages/nix.nix index 6cf1f90b..e37cc206 100644 --- a/modules/plugins/languages/nix.nix +++ b/modules/plugins/languages/nix.nix @@ -5,6 +5,7 @@ ... }: let inherit (builtins) attrNames; + inherit (lib) concatStringsSep; inherit (lib.options) mkEnableOption mkOption; inherit (lib.modules) mkIf mkMerge; inherit (lib.lists) isList; @@ -62,10 +63,10 @@ command = {"${cfg.format.package}/bin/alejandra", "--quiet"}, }, ''} - ${optionalString (cfg.format.type == "nixpkgs-fmt") + ${optionalString (cfg.format.type == "nixfmt") '' formatting = { - command = {"${cfg.format.package}/bin/nixpkgs-fmt"}, + command = {"${cfg.format.package}/bin/nixfmt"}, }, ''} }, @@ -90,9 +91,16 @@ ''; }; - nixpkgs-fmt = { - package = pkgs.nixpkgs-fmt; - # Never need to use null-ls for nixpkgs-fmt + nixfmt = { + package = pkgs.nixfmt-rfc-style; + nullConfig = '' + table.insert( + ls_sources, + null_ls.builtins.formatting.nixfmt.with({ + command = "${cfg.format.package}/bin/nixfmt" + }) + ) + ''; }; }; @@ -152,7 +160,7 @@ in { type = mkOption { description = "Nix formatter to use"; - type = enum (attrNames formats); + type = enum (attrNames formats ++ ["nixpkgs-fmt"]); # temporary, so it can be asserted against default = defaultFormat; }; package = mkOption { @@ -175,6 +183,12 @@ in { config = mkIf cfg.enable (mkMerge [ { + assertions = [ + { + assertion = cfg.format.type != "nixpkgs-fmt"; + message = "nixpkgs-fmt has been archived and replaced with nixfmt. Please use one of the following instead: ${concatStringsSep ", " (attrNames formats)}"; + } + ]; vim.pluginRC.nix = '' vim.api.nvim_create_autocmd("FileType", { pattern = "nix",