wiki/notebook/editor.neovim.lua.org
2021-11-17 13:33:44 +08:00

2.2 KiB

Neovim Lua integration

  • go-to resource when introducing using Lua into Neovim
  • similar to VimL configs, really
  • init file is ${XDG_CONFIG_HOME}/nvim/init.lua
  • Lua configs doesn't configure much by default
  • you can start with lua-intro help section in the lua help page from Neovim — i.e., :h lua
  • you can still execute Vimscript with vim.cmd; more information is at :h lua-vimscript
  • basics from VimL

    • to set options, it's mostly in vim.opt — e.g., set number relativenumber versus vim.opt.number, vim.opt.relativenumber = true, true
    • highlight options are mostly in vim.highlight — e.g., highlight clear SpellCap versus vim.highlight
    • to set local options, use vim.opt_local — e.g., setlocal spell versus vim.opt_local.spell = true
    • otherwise, to set global options, use vim.opt_global
    • you can access environment variables through vim.env — e.g., vim.env.HOME, vim.env.MYVIMRC
    • you can manipulate variables of various scales 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
    • to run Vimscript, you can use vim.cmd — e.g., vim.cmd "colorscheme nord"
    • interacting with Neovim API through vim.api
  • there are Neovim configurations written in Lua

  • comprehensive examples include Neovim plugins that are already written in Lua

  • for more information to create Lua modules, see lua-require-example help section