Neovim Lua integration
with Lua integration, you can create Neovim Lua modules
you can start with
lua-intro
section from Neovim help system; it gives all of the information on the things you need to get started with configuring Neovim with Lua as well as pointers for more things to do with Lua;Neovim also extends the Lua standard library found in
vim
object; see thelua-stdlib
in Neovim help system
Setting configuration with Lua
There are some equivalent setting values in Lua versus Vimscript.
For more information, see the lua-vimscript
help section.
Description | Vimscript statement | Lua equivalent |
---|---|---|
Setting options | set number relativenumber | vim.opt.number, vim.opt.relativenumber = true, true |
Setting local options | setlocal spell | vim.opt_local.spell = true |
Running Vimscript commands | colorscheme nord | vim.cmd "colorscheme nord" |
Setting buffer-specific options | b:ale-enabled=1 | vim.b["ale-enabled"] = 1 |
Some more general things you generally want to know:
You can still execute Vimscript with
vim.cmd
. For more information, see:h lua-vimscript
from the help system.You can access environment variables through
vim.env
— e.g.,vim.env.HOME
,vim.env.MYVIMRC
.Highlight options are mostly in
vim.highlight
— e.g.,highlight clear SpellCap
versusvim.highlight
.You can manipulate variables of various scopes from
vim.{g,b,..,t}
. To see more details, seelua-vim-variables
help section.vim.opt
will return an Option object, it has a common API. to learn more about it, seevim.opt
and its subsections.
Real-life examples making use of Neovim Lua API
This is a list of Neovim Lua modules that can serve as a basis for learning to interact Neovim with Lua.
paq-nvim is a simple Neovim package manager
packer.nvim is a more comprehensive package manager
LuaSnip is a snippet engine
telescope.nvim is a fuzzy finder integrated inside Neovim
Several people have already replaced their already existing Vim configurations with Neovim.
TJ DeVries' Neovim config is fully written in Lua complete with his own plugins.
ThePrimeagen's public dotfiles contains Neovim config written in Lua.