Did you know that you can take your formatters along wherever you install or use your neovim editor by configuring it with nixvim?

It’s really simple actually, you just need to refer to the formatter package in your configuration and Nix will make sure that the formatters are installed.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
{pkgs, ...}: {
  plugins.conform-nvim = {
    enable = true;
    formattersByFt = {
      nix = ["alejandra"];
      rust = ["rustfmt"];
      python = ["isort" "ruff_format"];
      json = ["jq"];
      toml = ["taplo"];
      yaml = ["yamlfmt"];
      lua = ["stylua"];
      "*" = ["trim_whitespace"];
    };
    formatters = {
      alejandra.command = "${pkgs.alejandra}/bin/alejandra";
      rustfmt.command = "${pkgs.rustfmt}/bin/rustfmt";
      isort.command = "${pkgs.python311Packages.isort}/bin/isort";
      ruff_format.command = "${pkgs.ruff}/bin/ruff";
      jq.command = "${pkgs.jq}/bin/jq";
      taplo.command = "${pkgs.taplo}/bin/taplo";
      yamlfmt.command = "${pkgs.yamlfmt}/bin/yamlfmt";
      stylua.command = "${pkgs.stylua}/bin/stylua";
    };

    # ...extra config, like format on save | format command setup
  }
}

With nixvim you don’t really need things like mason.nvim or lazy.nvim

Check the rest of my nixvim flake for the rest of my NeoVim configuration.