Neovim is symlinking my home directory everywhere (I think, though I am probably wrong)

So I am pretty sure this is happening with the latest neovim I installed because its only happening in directories that I open with neovim. I don’t have a clue what is causing this but when I list the directories I find '~' in places it should not be. I remove them, and then they come back the next time I work in the directories.

Help >.<

Does this happen as soon as you start Neovim, or after some time working
on files?

It is usually after working for a bit with some files

Okay so I finally figured out what this is. My init.lua file is setting the global option for the undodir to ~/.config/nvim/undodir and for whatever reason, it is being misinterpreted and whenever I undo something it is looking for this path in the directory I am working in and therefore it creates ./'~'/.config/nvim/undodir. What I can’t figure out is why that is being interpreted that way instead of actually using the home directory. Should I change it to $HOME/.config/nvim/undodir?

Try vim.fn.getenv(“HOME”)… “/.config/nvim/undodir”

1 Like

Thanks @mjlbach that did the trick. I thought just setting the string value would work like it does in vim but I see that does not work as I thought it would. I think that fixed the issue!

Lua doesn’t expand “~” :slight_smile:

1 Like

there is also stdpath(‘config’)

2 Likes

os.getenv("HOME") is same no need to get through vim function for that :wink: . If using vim function vim.fn.glob() is probably better choice as it expands ‘~’ .

except neovim config is not in $HOME/.config but $XDG_CONFIG_HOME and if its not set os.getenv("XDG_CONFIG_HOME") handling gets messier plus it’s less portable (eg., on windows)

1 Like