Skip to content

About

standalone neovim flake with my configuration

Topics

Resources

Stars

21 stars

Watchers

1 watching

Forks

Repository files navigation

Actions Status Actions Status

Neovim Flake

Neovim in nix.

Try it out:

$ nix run github:konradmalik/neovim-flake

Development

Enter the devshell with nix develop (or direnv, see .envrc). It links a generated .luarc.json into nvim and spec, so lua-language-server knows about Neovim and the plugins.

$ nix fmt
$ nix flake check

nix fmt formats everything through treefmt (treefmt.nix). nix flake check covers formatting, shellcheck, luacheck, typecheck via lua-language-server, and the tests (busted using nvim as an interpreter). In the devshell, busted runs the tests directly.

Assumptions

  • keeps all Neovim config in lua as it's supposed to be
  • uses nix for system dependencies, plugins, and packaging

That way nix is a layer on top, just used for packaging and reproducibility. It does not interfere with the standard way to configure Neovim.

Language servers, formatters, linters

Those are managed by nix and appended to the end of PATH for Neovim. This allows Neovim to use them, but also to use other versions by prepending them to PATH.

An example - you can have some project which uses an older version of black which formats files a bit differently. Assuming that this project has a devshell defined, you can just enter that devshell and run Neovim. The older black from the devshell will take precedence over the one provided by this flake, because devshell works by prepending to PATH.

Experimentation

One of the cons of using Neovim in nix is - no "dirty" modifications to Neovim to try something out quickly. Experimentation becomes harder. You always need to rebuild it, but nix build and then ./result/bin/nvim is quick and easy enough for it to not be a deal-breaker.

Another solution implemented in this repo is the nvim-dev command that becomes available inside the devshell. It runs the neovim package defined in the repo with plugins and extraPackages provided, but the lua config gets read "live" from ~/.config/nvim-dev, which the devshell links to the nvim folder here in the repo. This allows for instant feedback and dynamic development just like when using neovim without nix.

Credits

Inspired by:

About

standalone neovim flake with my configuration

Topics

Resources

Stars

21 stars

Watchers

1 watching

Forks

Used by

Contributors

Languages