wiki/notebook/editor.neovim.lua.org
Gabriel Arazas a5b3c7a8a1 Update various notes on things
Still cannot make up a good note-taking habit especially that I archive
more than taking notes. Though, this same cannot be said for my course
notes so that's a plus.
2022-05-22 22:47:20 +08:00

3.1 KiB

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 the lua-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 versus vim.highlight.
  • You can manipulate variables of various scopes from vim.{g,b,..,t}. To see more details, see lua-vim-variables help section.
  • vim.opt will return an Option object, it has a common API. to learn more about it, see vim.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.

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.