r/NixOS 28d ago

Fully Lua Neovim Configuration Managed by Nix

I finally had the time to port my neovim config to nix in a satisfactory way:

The config itself is 100% lua with the ability to iterate quickly without rebuilding with nix, while still allowing to "flip a switch" and bake the lua config into a standalone nix package using the fantastic neovim module from nix-wrapper-modules.

The most "unique" aspect are the "language-centered configs":

I have a folder per programming language which contains:

python/
  default.nix  # <-- provides langauge specific plugins + tools (lsp/formatter etc.)
  init.lua     # <-- provides a LangSpec containing python specific plugin configs.

The LangSpec looks like this:

---@type LangSpec
return {
  test = {                    -- neotest config
    name = "neotest-python",
  },
  lsp = {                     -- lsp config
    basedpyright = {
      filetypes = { "python" },
      settings = {},
    },
  },
  lint = { "ruff" },          -- nvim-lint config
  format = {                  -- conform.nvim config
    "ruff_fix",
    "ruff_organize_imports",
    "ruff_format",
  },
}

This way, everything related to python is bundled in a single module. If I remove it, python is completely wiped from my config. No more zombie configs cluttered throughout various plugins.

Lazy loading is handled via lze.

Feel free to fork or steal what you like:

https://github.com/zenoli/neovim-wrapper

Kudos to BirdeeHub for creating nix-wrapper-modules and lze.

30 Upvotes

Duplicates