1

I'm attempting to create a portable Neovim configuration for Windows. I'm a bit confused about all the directories. Maybe someone can shed a little light on me :)

So I downloaded a pre-built archive from https://github.com/neovim/neovim/releases and extracted it.

I found that nvim will use c:\users\myname\AppDataLocal\nvim-data and c:\users\myname\AppData\Local\nvim\ for stdpath('data') and stdpath('config') by default.

But the archive contains folders like e:\Neovim\share\nvim\runtime\colors\. I can put color schemes there and into c:\users\myname\AppData\Local\nvim\colors\ and even e:\Neovim\share\nvim-qt\runtime\colors. All three will work.

Same for plugins and probably more. So it looks like Neovim is checking all these directories for files it needs. Which would help me with my plans to put a fully functional configuration on my USB thumbdrive.

Having c:\users\myname\AppData\Local\nvim\init.vim isn't very portable.

I tried to put my init.vim into e:\Neovim\share\nvim\runtime\ and e:\Neovim\share\nvim-qt\runtime\ without success although it follows the same logic as the color folder.

So I figured I can load a custom configuration using the -u parameter.

Starting F:\Neovim\bin\nvim-qt.exe -- -u ..\init.vim with F:\Neovim\init.vim is working as expected.

Is there a better/correct way?

Where should I put my init.vim so I don't need the -u option

2
  • 1
    You should probably read :help runtimepath and the various things it links to, and then try :set runtimepath? to see the available directories
    – D. Ben Knoble
    Commented May 18, 2020 at 14:49
  • @D.BenKnoble thanks this helped a lot.
    – Piglet
    Commented May 19, 2020 at 7:57

2 Answers 2

2

Neovim supports a sysinit.vim file whose location usually is $VIM/sysinit.vim (see :help sysinit.vim). From Neovim execute :echo $VIM to get it's value, and from there construct the right path. I don't use Windows, but I'm pretty sure it will work if you put the file on e:\Neovim\share\nvim\sysinit.vim

1

You can put all your personal config under a single directory (use :echo stdpath('config') to see where that directory is on your system). On Linux and Mac, the directory is $HOME/.config/nvim, and on Windows, the directory is C:\Users\USERNAME\AppData\Local\nvim. Under this directory, do whatever you want with Neovim. You might be interested in mine.

As for portability issues, you can manage your configurations using git and GitHub. So your config can be cloned and updated easily no matter where you are.

See also :h init.vim inside Neovim for more info on how Neovim finds its config files.

2
  • 1
    thanks for your answer. unfortunately I need a portable configuration, not an online configuration. I usually work on offline customer computers. so pulling my config from a repo and leaving it on the computers is not an option.
    – Piglet
    Commented May 19, 2020 at 7:45
  • @Piglet That is fine. Just copy all files under nvim config folder to your USB drive and paste it to the destination folder on your destination machine. That is all you need to do :)
    – jdhao
    Commented May 19, 2020 at 7:48

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.