Only a few days months left until Neovim 0.5 stable release, with the support of init.lua as default user config. Here’s a quick guide (more like a cheat sheet) to help someone with no Lua experience like me to save a few hours 🌔

Config path



" init.vim
" This is a comment
-- init.lua
-- This is a comment


" init.vim
set mouse=a
set tabstop=4
set number
set shortmess+=c
-- init.lua
vim.opt.mouse = 'a'
vim.opt.tabstop = 4
vim.opt.number = true
vim.opt.shortmess = vim.opt.shortmess + 'c'

Global variables

Simmilar to the above

" init.vim
let g:mapleader = ' '
-- init.lua
vim.g.mapleader = ' '

For variables with namespace, Lua doesn’t support # so you have to put them in ['']:

" init.vim
let g:sneak#label = 1
-- init.lua
vim.g['sneak#label'] = 1

Key mappings

" init.vim
nnoremap <C-s> :write<CR>
-- init.lua
--                       <mode>  <keys>    <actions>       <options>
vim.api.nvim_set_keymap( 'n',   '<C-s>', ':write<CR>', {noremap = true})

Plugin manager

I’ve switched to paq-nvim, written in Lua, very similar to vim-plug.

Install the plugin manager:

-- init.lua
-- Auto install if not exist
local install_path = fn.stdpath('data')..'/site/pack/paqs/opt/paq-nvim'

if fn.empty(fn.glob(install_path)) > 0 then
  cmd('!git clone --depth 1 '..install_path)

-- Load the plugin manager
cmd 'packadd paq-nvim'

-- Set the short hand
local plug = require('paq-nvim').paq

-- Make paq manage it self
plug {'savq/paq-nvim', opt=true}

Install your plugins:

-- init.lua
plug 'joshdick/onedark.vim'
plug 'justinmk/vim-sneak'
plug 'neovim/nvim-lspconfig'

The commands is very similar too:



You can compare my old init.vim and the new init.lua.

September 2021 update: I’ve switched to packer.nvim, you can checkout my lastest config here