Reputation: 6891
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.
Upvotes: 96
Views: 167373
Reputation: 28359
Neovim config file is named init.vim
[^1] and its location varies depending on your system:
$HOME/.config/nvim/init.vim
~/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 if you want to. However, it is often advised to split your config to various files, and then either source those files manually or let Nvim do it for you. An excellent article on how to split your config is from .vimrc to .vim. 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.
Another great plugin manager is packer.nvim, which is written in Lua and has all the fancy features (lazy loading, pint commits, etc.) you will ever want.
Other plugin managers you may want to try: dein, minpac.
[1]: for nvim v0.5+, you can also use init.lua
as your config entry point, see here.
Upvotes: 22
Reputation: 31
Neovim uses either vim or lua plugins.
Init config files are located under the ~/.config/nvim directory as:
init.lua (holds the 'requires ')
init.vim (can reference ~/.vimrc)
Lua config files (*.lua) are usually found in:
~/.config/nvim/lua
Ex. ~/.config/nvim/lua/plugins.lua holds the references to plugins
Vim and lua plugins can be added into the ~/.local directory tree.
From h: add-global-plugin
mkdir -p ~/.local/share/nvim/site/plugin
cp /tmp/yourplugin.vim ~/.local/share/nvim/site/plugin
Ex. cp ./termdebug.vim ~/.local/share/nvim/site/plugin/
Restart nvim and termdebug should be available from the command prompt:
:Termdebug
:Termdebugcommand
Upvotes: 1
Reputation: 219
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.
Upvotes: 21
Reputation: 81
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!
Upvotes: 7
Reputation: 1523
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.
Upvotes: 107
Reputation: 1131
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
Upvotes: 6