19

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?

J. Doe
  • 191
  • 1
  • 1
  • 3

4 Answers4

33

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
Doktor OSwaldo
  • 5,732
  • 20
  • 41
4

: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)
Eric Eskildsen
  • 4,269
  • 2
  • 38
  • 55
  • on Windows nothing is in the folder specified: the folder does not exist. Do you happen to know where it actually is? – Antonio Sesto Feb 03 '23 at 06:10
  • 1
    @AntonioSesto That's the location where Neovim will look for the file once you create it. Just create the directory and an empty file there. Then you can start putting settings in it. – Eric Eskildsen Feb 03 '23 at 17:29
  • you can also use this command in nvim to open the file `:execute 'edit ' . stdpath('config') . '\init.vim'` (it should be cross-platform as well) – Avinash R Aug 03 '23 at 06:09
3

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

:e $MYVIMRC
:source $MYVIMRC

Reference: Learn Vim the Hard Way/Editing your vimrc

Jim U
  • 3,318
  • 1
  • 14
  • 24
0

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()

Avinash R
  • 3,101
  • 1
  • 27
  • 47