Project-based, modular Neovim configuration via NixVim.
Nvimx provides many presets based on different language (lsp, treesitter) support and different uses, allowing you to choose what is installed on a neovim instance per project. Works well with direnv.
Nvimx exports different module/package presets:
default/base- Base Neovim instance, contains all plugins, no language support. All other presets automatically includes this base.- Language-based - See the end of this readme.
Additionally, you can set nvimx.treesitter.enableAllGrammars = true to get ts for all languages without individually enabling variants.
- Run directly:
nix run github:allen-liaoo/nvimxYou can run a preset by appending #PRESET.
You may need to enable experimental features by passing in this environment variable:
NIX_CONFIG="extra-experimental-featues = nix-command flakes"
- Construct a module in a flake (i.e. in
devShells). Nvimx flake outputsmakeNvimxWithModule (system: nvimxModule: ...)to be used in this case. Presets have options undernvimx.preset.${PRESET}, and need to be opted in withnvimx.preset.${PRESET}.enable = true.
{
outputs = { self, nixpkgs, nixvim }: let
in {
devShells = let
system = "x86_64-linux";
pkgs = nixpkgs.legacyPackages.${system};
in ${system}.default = pkgs.mkShell (let
nixvimModule = {
# enable the presets you want to use
nvimx.preset.typst.enable = true;
# or add custom nixvim or nvimx options here
plugins.xyz.enable = true;
};
nixvimPkg = nvimx.makeNvimxWithModule system nixvimModule; # package it!
in {
packages = [ nixvimPkg ];
});
};
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
nvimx = {
url = "github:allen-liaoo/nvimx";
inputs.nixpkgs.follows = "nixpkgs";
};
};
}- nix-direnv: Use a preset or project configuration without leaving a trace in the project's repo. Assuming that your project uses a
flake.nixorshell.nixalready for managing developer environments, and you want to use nvimx without tracking it in the repo. Then, in the.envrcfile:
# use project's flake.nix for dev env
use flake
# or, use project's shell.nix
use nix
# nvimx: use preset
nix build --refresh --out-link .direnv/nvimx "github:allen-liaoo/nvimx/main#PRESET"
# or use a config provided externally
nix build --refresh --out-link .direnv/nvimx "github:allen-liaoo/nvimx/main?dir=projects/PROJECT"
PATH_add .direnv/nvimx/binFor more examples, see the projects/ directory.
| Preset | Languages | TreeSitter | LSP | DAP |
|---|---|---|---|---|
c |
C/C++ | ✅ | ccls | dap-lldb |
configs |
ini, json, kdl, toml, yaml | ✅ | — | — |
egglog |
egglog | ✅* | — | — |
java |
Java | ✅ | jdtls | java-debug via jdtls |
latex |
LaTeX | ✅ | texlab | — |
llvm-ir |
LLVM IR | ✅ | llvm-ir-lsp* | — |
lua |
Lua | ✅ | lua-language-server | — |
markdown** |
Markdown | ✅ | marksman | — |
nix |
Nix | ✅ | nixd | — |
rust |
Rust | ✅ | rust-analyzer | dap-lldb |
shells |
bash, fish, zsh | ✅ | bashls (bash only) | — |
typst |
Typst | ✅ | tinymist | — |
*: Manually packaged here (Not in neovim-treesitter or nixvim lsps)
**: Enabled by default (in base preset).
Inspired by ar-at-localhost/np.