Nix2vim prerelease?

I have been working a little on this project GitHub - gytis-ivaskevicius/nix2vim: [WIP] Nix to Lua parser meant to be used for configuring neovim which is basically lua neovim configuration generation from nix code.

At this point it is in quite a usable shape but is completely undocumented and still has a couple of quirks.
Available options module system options:

Configuration examples:

How to use it:

(Add flake → apply overlay → pkgs.neovimBuilder {enableViAlias = true;}

5 Likes

is there a function to call to just generate lua from the nix files?

Should not be a problem to add this, will do that at some point :slight_smile:

I wonder if you are interested in improving nixpkgs neovim support ?
The system you have in your flake is similar to what exists in home-manager (maybe it was one of your inspiration ?) and I tried to port it to nixpkgs:
https://github.com/NixOS/nixpkgs/pull/170533

I’ve also ported my config to lua and right now nixpkgs neovim wrapper cant generate an init.lua . Would you be interested in adding this (I started adding the luaRc to the attrsset generated by makeNeovimConfig but cant continue right now).

1 Like

Yeah, I’d be down for pushing this to nixpkgs tho I bet that it would be a pain to do so since nixpkgs is not a big fan of large changesets that does not bring much value (one may just simply write their config in lua, and forget about this)

I am not convinced either that going so far into the abstraction is useful (which is why we have flakes).
I was only referencing the possibility in nixpkgs to start with an init.lua rather than an init.vim. How I see it, we would add a luaRcContent alongside neovimRcContent in makeNeovimConfig https://github.com/NixOS/nixpkgs/blob/7ab4ac4a104fc875db01770e48a69bb2848411dd/pkgs/applications/editors/neovim/utils.nix#L129 and if luaRcContent != null then we would use it instead of neovimRcContent.

May I ask, perhaps a silly question, but is it not possible to use init.lua right now, somehow via nixpkg option, or using a home-manager? :thinking:

Looking for anything, even if for a work-around or hack, as I am trying to find a way to migrate the contents of my init.lua to be “controlled” by nix.

Disclaimer: I am new to nix ecosystem and still struggling to grasp the basic concepts in order to migrate my.

There’s no way to define the individual attributes in Nix natively, but home-manager can at least write arbitrary text to your config directory:

xdg.configFile."nvim/init.lua".source = ./init.lua;

This at least gives you the option of storing your config in a controlled location and declaring it with Nix.

1 Like

home manager now defaults to init.lua