Neovim

From wikinotes
Revision as of 01:16, 4 November 2021 by Will (talk | contribs) (→‎Install)

Neovim is a rewrite of vim with some new/alternative features.

Documentation

:help https://neovim.io/doc/user/

Locations

~/.config/nvim/init.vim nvim's vimrc
~/.config/nvim/ginit.vim GUI nvim's vimrc

Install

release

# release
pacman -S neovim
pkg install neovim
brew install neovim

nightly

# archlinux
pacaur -S neovim-nightly-bin

# macos
curl -LO https://github.com/neovim/neovim/releases/download/nightly/nvim-macos.tar.gz \
  && tar -xzf nvim-macos.tar.gz \
  && rsync -avz --delete nvim-osx64/* ~/opt/

Configuration

" ~/.config/nvim/init.vim

" source vimrc from init.vim
set rtp^=HOME/.vim
so ~/.vimrc

Features

Terminal

Neovim has it's own embedded terminal!

:terminal        " open terminal in current tab
<c-leader><c-n>  " escape terminal mode into normal-mode
tnoremap  <c-a>  " keybind namespace for within terminal mode

<c-leader><c-n> (move cursor to filename) gf   "open file in nvim

" ex:  (perhaps bind this to a key)
cd /path/to/src
realpath file.py
<c-leader><c-n>
k
gf

GUI

neovim-qt

Essentially gvim for neovim, and it's beautiful.

:GuiFont DejaVu Sans Mono:h11    " change font/size

Extensions

neovim-remote

Start a neovim-server, neovim connects to this, adding files to the same session.

Common Issues

strange global variable behaviour

neovim saves global variables in ~/.local/share/nvim/shada/main.shada.
If you encountering wonky results when changing your vimrc, delete this file and try again.

neovim crashes terminal

Your terminal probably needs to be recompiled.

scrolling panes is broken in xterm

You may be using xterm, not xterm-256color.
Try export TERM= or export TERM=xterm.