Nix Extra
lang.nix adds Nix support through the nil language server with nixfmt
formatting. Install nixfmt with Nix itself, or add it to your home-manager
packages or a project dev shell:
nix profile install nixpkgs#nixfmtEnable it
Section titled “Enable it”-- ~/.config/blak/lua/blak/user.luareturn { extras = { enabled = { "lang.nix", }, },}Or enable it interactively:
:BlakExtras enable lang.nixWhat it adds
Section titled “What it adds”| Surface | Contribution |
|---|---|
| Treesitter | nix |
| LSP | nil_ls |
| Formatting | nixfmt for nix |
Mason installs nil for nil_ls, and Blak starts the server once that
install succeeds. Mason’s nil package compiles from source, so it needs both
cargo and nix on $PATH. Without them, every launch reports
failed to install nil_ls and the details are in :MasonLog. Mason’s nixfmt
package only ships a linux x64 binary, so Blak does not install it. Until
nixfmt is on $PATH, saving a .nix file reports
Formatters unavailable for nix file and leaves the buffer as it is.
Format with alejandra instead
Section titled “Format with alejandra instead”To format with alejandra instead of nixfmt, install it
(nix profile install nixpkgs#alejandra) and override the formatter:
return { extras = { enabled = { "lang.nix" } }, format = { formatters_by_ft = { nix = { "alejandra" }, }, },}Install and verify
Section titled “Install and verify”:BlakToolsInstall:BlakTreesitterInstall:BlakDoctorOpen a .nix file and check :checkhealth vim.lsp for nil_ls.