41
votes

Does NeoVim have it's own config file just like vim's .vimrc ? If so where can I get that file in the home directory to make my own custom changes.

5

5 Answers

65
votes

Both VIm 8.0 and Neovim have their own built-in package manager.

In VIm 8.0, create the following directories:

  • ~/.vim/pack/*/start (where * may be any name e.g. ~/.vim/pack/jimmy/start): Clone your required plugin into the start directory just as you would if you were installing it for Pathogen. You need nothing more and no commands in your .vimrc file.
  • ~/.vim/pack/*/opt (e.g. ~/.vim/pack/jimmy/opt) for plugins that only need to be loaded as required. For colours, add a directory to the opt directory and then your colours e.g. ~/.vim/pack/jimmy/opt/mycolors/colors/dracula.vim.

In Neovim, the directory structure follows the freedesktop's XDG Base Directory Specification. Your configuration file is in ~/.config/nvim/init.vim, but your plugins go into:

  • ~/.local/share/nvim/site/pack/*/start

See :h packages (VIm 8.0 and Neovim) for more information.

11
votes

Neovim config file is named init.vim and its location varies depending on your system:

  • Linux (including Mac): $HOME/.config/nvim/init.vim
  • Windows: ~/AppData/Local/nvim/init.vim

You can also use the command :echo stdpath('config') inside neovim to find the config directory.

All your settings can be put into this file. You can find my example configuration here for a reference.

As for installing plugins, it is easy for beginners to use a plugin manager to do all the chores for you. vim-plug is a good choice. You can use it both on Windows, Linux, and Mac. It is fast and reliable. Follow the documentation of vim-plug to learn how to use it.

Other plugin managers you may want to try: dein, minpac, plugpac (a wrapper around minpac).

5
votes

try :h init.vim or :h vimrc. You'll see there all the info you're looking for.

Assuming you're on unix machine: If you still wish this file in you home directory than you may symlink it there with:

ln

  Creates links to files and folders.

   - Create a symbolic link to a file (or folder):
     ln -s path/to/file path/to/symlink

optionally you may start nvim with the -u flag and tell it what you wish to use as your initialization file, so you can just nvim -u ~/.vimrc. Finally you may add the following in your terminal initialization file(.bashrc/.zshrc or whatever terminal you're using) alias vim='nvim -u ~/.vimrc' if you really really want to use this file in your home directory without symlinking it but I wouldn't advice to work this way

3
votes

I will explain it with itchy/calendar example.

Make a folder in: ~/.config/nvim/pack/

Can be like this: mkdir ~/.config/nvim/pack/calendar/start/

go to the folder: cd ~/.config/nvim/pack/calendar/start/

Then clone the repo: git clone https://github.com/itchyny/calendar.vim.git

Do the config on your init.vim file if needed and it is done!

2
votes

After two days working on this -- dozens of websites gone through, numbing confusion, pulling my hair out -- I FINALLY managed to get plug.vim working. The whole secret (buried deep, believe me) is that autoload files in the MISSING autoload directory load before the ill-named 'init' file. So, in ~/.config/nvim/ you put init.vim, then create an autoload directory right beside it in the same directory, i.e., ~/.config/nvim/autoload/. That is where plug.vim goes. That's right, the autoload directory and its contents plug.vim does NOT go where the documentation says it should, in ~/local/nvim/site/. Then you create some deep hole well away from any of the aforementioned, for instance, ~/.neovim-plugins, to use for your private, vim-plug-ins directory. Put the path to that that private directory in single quotes inside the parentheses of plug#begin() in your init file ~/.config/nvim/init.vim. Make sure you uncomment both it as well as plug#end() by removing the initial doublequote " from their lines. This works on Ubuntu 20.04. NOW, erase the plugins that you have been given (after PLUG) in your init file. According to the author of vim-plug, these plugins were just 'examples' and you should come up with your own to put after PLUG. I won't go into that, you will be working on that for quite a while. Try the Rust plugin by the Rust language team, for instance. Man, that is one great language, even better than Java.