ArchWiki / Neovim
ArchWiki / Neovim
es:Neovim ja:Neovim pl:Neovim pt:Neovim zh-hans:Neovim
Neovim is a fork of Vim aiming to improve the codebase, allowing for easier implementation of APIs, improved user experience and plugin implementation. Neovim inspired editors like Helix.
Installation
Install the neovim package, or neovim-git for the latest development version, which strongly encourages the use of Lua as its main configuration language. To make the system clipboard work with Neovim, you may need to install xclip (X11) or wl-clipboard (Wayland).
With neovim, some of its features are delegated to external "providers". For Python providers, use python-pynvim. For clipboard providers, see provider-clipboard or the :help provider-clipboard neovim command.
It is also possible to install one of many GUIs and other related projects:
Configuration
Nvim stores configuration, data, and logs in standard locations conforming with the XDG Base Directory specification. Plugins are encouraged but not required to follow this convention.
Nvim's user-level configuration file is named init.lua or init.vim. Only one can be used and must be located in the $XDG_CONFIG_HOME/nvim/ directory. See the Lua guide for an introduction to the use of Lua in Nvim. When the system-wide configuration file does not exist, Nvim checks for /usr/share/nvim/sysinit.vim, which is not intended to be edited by users.https://github.com/neovim/neovim/blob/master/runtime/doc/starting.txt#L439 By default, the former global configuration file does not exist. If you create the former file, you may wish to have it source the latter if you still want the functionality it provides, which is allowing pacman-installed vim packages to work with Nvim.
Nvim is compatible with most of Vim's options. Options specific to Nvim can be found in Nvim's documentation, either online or by running :help options in Nvim.
Migrating from Vim
If you wish to migrate your existing Vim configuration to Nvim, simply copy your ~/.vimrc to ~/.config/nvim/init.vim. If applicable, copy the contents of ~/.vim/autoload/ to ~/.local/share/nvim/site/autoload/.
Shared configuration between Vim and Nvim
Neovim uses $XDG_CONFIG_HOME/nvim instead of ~/.vim as its main configuration directory and $XDG_CONFIG_HOME/nvim/init.vim instead of ~/.vimrc as its main configuration file.
If you wish to continue using Vim and wish to source your existing Vim configuration in Nvim, see nvim-from-vim or the :help nvim-from-vim neovim command.
Loading plugins
Vim/Nvim plugins installed from official repositories or AUR get automatically sourced by /etc/xdg/nvim/sysinit.vim, so there is no need to take any extra steps. A vast amount of plugins can be found on both places, but the most recommended way to add plugins is by using a plugin manager, most commonly used are vim-plug which works for both Vim and Nvim, and lazy.nvim which only works on Nvim and is written in Lua. Both of them allow for expressive configurations, ranging from github branch to runtime commands.
Most plugins written for vim work without much effort on Nvim, but not every plugin written for Nvim works for Vim, so if your intention is to ensure a compatible configuration, stick to a traditional init.vim or .vimrc
Tips and tricks
Replacing vi and vim with neovim
Setting $VISUAL and $EDITOR environment variables should be sufficient in most cases.
Some applications may hardcode vi or vim as default editor; to use neovim in their place, install neovim-symlinks.
Symlinking init.vim to .vimrc
As neovim is mostly compatible with standard vim, you can symlink nvim/init.vim to your old .vimrc to keep old configuration options:
$ ln -s ~/.vimrc ~/.config/nvim/init.vimIf you want some lines to be specific to each version, you can use an if block:
if has('nvim')
" Neovim specific commands
else
" Standard vim specific commands
endif.vimrcTrue color support
The READMEs of this project explain how to add 24-bits "True Color" support to your syntax highlighting and how to use a color picker to see how it looks in real-time. Comes with the syntax highlighting of the author (if installed) for C++.
Lastplace cursor support
If you like to keep your last position of cursor to be saved, lastplace.lua is quite useful. It just needs to be placed in ~/.config/nvim/plugin/ or in the system-wide directory /usr/share/nvim/runtime/plugin/.
Language Server Protocol
Neovim contains a built-in Language Server Protocol client and the nvim-lspconfig plugin provides common configurations for it.
See Language Server Protocol for a list of Arch packages.
Use as a pager
You can use the :Man command to open manual pages. To open all manual pages with neovim set the MANPAGER environment variable to nvim +Man!.
For other pager support install either the nvimpager or the nvimpager-git package and set the PAGER environment variable to nvimpager.
You can also try page, packaged in page-git.
Multiple isolated nvim configurations
Several nvim flavors can be installed side by side using the NVIM_APPNAME environment variable. Create a directory in your XDG_CONFIG_HOME, e.g. ~/.config/foo and put your new nvim configuration into it.
To run nvim using a specified configuration:
Set the
NVIM_APPNAMEvariable directly in your shell or configuration file withexport NVIM_APPNAME=foo. Now thenvimcommand will automatically invoke the foo flavor. To restore the default behavior unset the environment variable withunset NVIM_APPNAME.Define an alias, e.g.
alias v=' NVIM_APPNAMEfoo nvim'
Install LazyVim beside your native nvim configuration
If you would like to install the popular LazyVim flavor beside your native nvim configuration, follow the install instructions. But keep in mind that you do not have to delete or move the following directories of your actual nvim configuration: ~/.config/nvim, ~/.local/share/nvim, ~/.local/state/nvim and ~/.cache/nvim.
Hence, clone the starter repository to a directory name of your choice in your .config path. The commands below are using nvimLazyvim as target directory:
$ git clone https://github.com/LazyVim/starter ~/.config/nvimLazyvimDo not forget to remove the .git directory:
$ rm -rf ~/.config/nvimLazyvim/.gitTo invoke the new flavor use the following command:
$ NVIM_APPNAME=nvimLazyvim nvimAn alias to shorten typing can be made in your shell startup file by appending following line:
alias v=' NVIM_APPNAMEnvimLazyvim nvim'Troubleshooting
Cursor is not restored to previous state after exit
If the cursor keeps blinking after exiting neovim, see the solution in the neovim FAQ.
Tree-sitter parser error after system upgrade
After updating the system, it is advised to sync neovim's packages, e.g :Lazy sync, then manually force update parsers by :TSUpdate. Removing neovim's cache files in ~/.local/share/nvim may fix issues.
Tree-sitter executable not found
The tree-sitter package provides only the library. If the tree-sitter executable is needed, install tree-sitter-cli.