nix-community / nixvim

Configure Neovim with Nix! [maintainers=@GaetanLepage, @traxys, @mattsturgeon, @khaneliman]
https://nix-community.github.io/nixvim
MIT License
1.75k stars 266 forks source link

[BUG] 'undodir' option does not recognize '~' and '$HOME' #2148

Closed bileamScheuvens closed 1 month ago

bileamScheuvens commented 2 months ago
Field Description
Plugin n/a
Nixpkgs unstable

Description

Setting the undodir option creates the directory locally, even if it begins with '\~' or '$HOME'. It interprets it literally and creates the structure .../'\~'/undodir/. Easy to work around with lua or nix builtins.getEnv "HOME", but IMO unintuitive behavior.

Minimal, Reproducible Example (MRE)

programs.nixvim = {
  config.opts.undodir = "~/undodir";
}
GaetanLepage commented 1 month ago

I think that to get those paths properly expanded, you indeed need to call some lua code. Can you try something like:

config.opts.undodir.__raw = "vim.fs.normalize('~/undodir')";
MattSturgeon commented 1 month ago

Easy to work around with lua or nix builtins.getEnv "HOME", but IMO unintuitive behavior.

If the alternative behaviour is to automatically transform option definitions when detecting ~ or $HOME in the string, this is even less intuitive IMO.

When I configure a nixvim option, I expect the init.lua file to have a lua-equivialent of whatever nix value I defined; without any arbitrary transformations being done without me knowing.

bileamScheuvens commented 1 month ago

Good point, also wasn't aware that the behavior is just how neovim handles paths, went vim -> nixvim. Thanks, I'll close