Scripting neovim config#
An excellent lua crash course for Neovim is TJ’s YouTube video
“Everything You Need To Start Writing Lua”.
In Neovim, the lua scripting API consists of 3 layers
The “Vim API”, inherited from Vim.
These are accessed through vim.cmd and
vim.fnrespectively.
The “Lua API” written in and specifically for Lua. These are any other functions accessible through
vim.*not mentioned already. See lua-stdlib for more.
The lua-guide is worth reading through in its entirety and is pretty good.
Logging during plugin development#
Neovim has a built-in way to log thing which show up in :messages by
default. We use nvim-lua/plenary.nvim to log things specific to something
as follows
return require("plenary.log").new({
plugin = "vvn.precious",
level = "info",
})
Then use it as follows
local log = require("vvn.log")
-- log.info("something")
The contents will show up in :messages as well as the log file vvn.precious.log in the log directory of stdpath, which is ~/.local/state/nvim/vvn.precious.log.
Tip
To see where stdpath is, run :=vim.fn.stdpath("log").