Neovim

Related articles
List of applications/Documents#Vi-style text editors
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
AUR
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).
Note
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
:
Gnvim
— An opinionated Neovim GTK GUI.
https://github.com/vhakulinen/gnvim
||
gnvim-git
AUR
FVim
— A cross platform Neovim front-end UI, built with F# + Avalonia.
https://github.com/yatli/fvim
||
fvim
AUR
Neoray
— A Go GUI using GLFW and OpenGL bindings.
https://github.com/hismailbulut/neoray
||
neoray-git
AUR
Neovide
— A simple Rust GUI for Neovim.
https://github.com/neovide/neovide
||
neovide
neovim-gtk
— A GTK UI for neovim written in rust using gtk-rs bindings.
https://github.com/Lyude/neovim-gtk
||
neovim-gtk
AUR
Neovim Qt
— A lightweight cross-platform Neovim GUI written in C++ with Qt.
https://github.com/equalsraf/neovim-qt
||
neovim-qt
Uivonim
— An
inactive
fork of Veonim, "a simple modal IDE built on Neovim and VSCode extensions" written in Electron with WebGL GPU rendering and multithreading.
https://github.com/smolck/uivonim
||
uivonim-git
AUR
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.
[1]
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
AUR
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
AUR
.
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.vim
If you want some lines to be specific to each version, you can use an
if
block:
.vimrc
if has('nvim')
    " Neovim specific commands
else
    " Standard vim specific commands
endif
True 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
AUR
or the
nvimpager-git
AUR
package and set the
PAGER
environment variable
to
nvimpager
.
You can also try
page
, packaged in
page-git
AUR
.
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_APPNAME
variable directly in your shell or configuration file with
export NVIM_APPNAME=foo
. Now the
nvim
command will automatically invoke the
foo
flavor. To restore the default behavior unset the environment variable with
unset NVIM_APPNAME
.
Define an alias, e.g.
alias v=' NVIM_APPNAME=foo 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/nvimLazyvim
Do not forget to remove the
.git
directory:
$ rm -rf ~/.config/nvimLazyvim/.git
To invoke the new
flavor
use the following command:
$ NVIM_APPNAME=nvimLazyvim nvim
An alias to shorten typing can be made in your
shell startup file
by appending following line:
alias v=' NVIM_APPNAME=nvimLazyvim 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
This article or section needs expansion.
Reason:
This is useless without specifying the installed software. (Discuss in
Talk:Neovim
)
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
.
See also
Github repository
Github wiki