0

I am using neovim config from custom directory and also want that it stores its data in custom directory. So i set this in my ~/.config/nvimcustom/init.lua :

vim.opt.data_dir = '~/.local/share/nvimcustom/'

But on running nvim -u ~/.config/nvimcustom/init.lua , I am getting this error

Error detected while processing /home/venom/.config/nvimcustom/init.lua:
E5113: Error while calling lua chunk: vim/_meta.lua:0: Invalid option (not found): 'data_dir'
stack traceback:
[C]: in function 'nvim_get_option_info'
vim/_meta.lua: in function '__index'
vim/_meta.lua: in function ''
vim/_meta.lua: in function '__newindex'
/home/venom/.config/nvimcustom/init.lua:2: in main chunk

I just want that my neovim config is present in custom directory and also all the plugins and otther data it stores due to this custom config is stored in a custom directory. How to do that. I want to do it so that when I run normal nvim, I can have different configuration and whne I run nvim using -u flag, I can have different configuration

1

1 Answer 1

0

Here is what I do on Windows. I have introduced a nvimcustom.bat script:

set XDG_CONFIG_HOME=%HOME%\nvimcustom
set XDG_DATA_HOME=%HOME%\nvimcustom
set XDG_STATE_HOME=%HOME%\nvimcustom

start Neovim\bin\nvim-qt.exe %*

On Linux it would be a nvim.sh script:

XDG_CONFIG_HOME=$HOME/nvimcustom
XDG_DATA_HOME=$HOME/nvimcustom
XDG_STATE_HOME=$HOME/nvimcustom

nvim %*

The init.lua should then put into ~/nvimcustom/nvim

4
  • So now when I start neovim normally without the -u flag, would it by default use my custom directory? Commented May 9, 2023 at 15:47
  • Indeed it will load ~/nvimcustom/nvim/init.lua not exactly what you wish (~/nvimcustom/init.lua) but close :-). This is how I run different configuration of Neovim on my machine. Commented May 9, 2023 at 15:55
  • So now if i want to use .config/nvim, what do i type to load that, I am a little bit confused here Commented May 9, 2023 at 16:36
  • If you start nvim (without using the nvim.sh script) then the environment variable will not be defined and the ~/.conifg/nvim will be used. Commented May 11, 2023 at 15:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.