Skip to content

Nix2NVimRc is a set of Nix expressions to configure NVim in Nix

License

Notifications You must be signed in to change notification settings

ck3d/nix2nvimrc

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

47 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Nix2NVimRc is a set of Nix functions and Nixpkgs module specification to generate a Neovim configuration (nvimrc) from a given module configuration.

The module provides options to configure following items:

Neovim configuration item Nix2NVimRC module option used Neovim Lua API
Neovim option opts.<name> = <value> vim.opt['<name>'] = <value>
Neovim keymap (see also helper function toKeymap) keymaps[] vim.keymap.set()
Neovim global variable vars.<name> = <value> vim.api.nvim_set_var(<name>, <value>)
Neovim treesitter treesitter.parsers.<name> = <path> vim.treesitter.language.add(<name>, { path: <path> })
Neovim LSP via plugin nvim-lspconfig lspconfig. passed to nix-lspconfig.lua
Lua plugin setup setup. require('...').setup()
Vim expression or file vim[] vim.cmd()
Lua expression or file lua[] inlined
Vim plugin as Nix package plugins[] handled by nixpkgs.vimUtils.packDir

Example

The file ./example-config.nix contains a minimalistic example configuration. To generate and use this configuration, execute following steps:

nix-build -I "$NIX_PATH" -E 'with import <nixpkgs> { }; writeText "init.lua" ((import ./lib.nix).toRc pkgs ./example-config.nix)'
nvim -u NORC --cmd "luafile ./result"

To see a more sophisticated example, go to repository ck3d-nvim-configs.

Design Goals

  1. Output only Lua code for NVim
  2. Keep dependency to nixpkgs as small as possible:
    • lib.: optional, optionals, evalModules, types, mkOption, and toposort
    • pkgs.: vimUtils.packDir
  3. No dependency in the Nix Flake to avoid a lock file

Alternative Projects

About

Nix2NVimRc is a set of Nix expressions to configure NVim in Nix

Topics

Resources

License

Stars

Watchers

Forks