J. Doe
J. Doe

Reputation: 231

NeoVIm does not automatically load ~/.nvimrc file

I was looking to get into learning a text editor for programming. However, I've quickly run into a little snag that I can't seem to find a solution to.

I have modified my /home/user/.nvimrc file to add some plugins and I can load it using :source ~/.nvimrc, however, it never loads automatically. :scriptnames shows a list of scripts in /usr/, but mysteriously absent from the list is the .nvimrc file in my home directory. Again, I can load it in the command line, but I'd like to not have to use :so ~/.nvimrc every time I open a file.

I am not using sudo to run vim.

How can I solve this problem? Is this something everybody has to do?

Upvotes: 23

Views: 38291

Answers (4)

Avinash R
Avinash R

Reputation: 3151

If you want to open the RC file without leaving neovim - esp., when you want to install a plugin while working and on windows '~' doesn't get expanded, you can use the command

:execute 'edit ' . stdpath('config') . '/init.vim'

Benefit of using this method is that, it is a cross-platform solution

Ref: https://neovim.io/doc/user/builtin.html#stdpath()

Upvotes: 0

Eric Eskildsen
Eric Eskildsen

Reputation: 4769

:help config lists the paths for each OS:

Unix                    ~/.config/nvim/init.vim         (or init.lua)
Windows                 ~/AppData/Local/nvim/init.vim   (or init.lua)
$XDG_CONFIG_HOME        $XDG_CONFIG_HOME/nvim/init.vim  (or init.lua)

Upvotes: 7

Jim U
Jim U

Reputation: 3366

Instead of referring to your rc file directly, consider using $MYVIMRC:

:e $MYVIMRC
:source $MYVIMRC

Reference: Learn Vim the Hard Way/Editing your vimrc

Upvotes: 3

B.G.
B.G.

Reputation: 6026

Could be this issue: https://github.com/neovim/neovim/issues/3530

Summary:

New location is ~/.config/nvim/init.vim

To keep ~/.nvimrc you can source it from the new location:

mkdir -p ~/.config/nvim
echo 'source ~/.nvimrc' > ~/.config/nvim/init.vim

Upvotes: 40

Related Questions