lazy.nvim and the Lockfile
On this page
lazy.nvim and the Lockfile
Bootstrap
lua/config/lazy.lua installs the manager itself if missing, puts it on the
runtime path, and points it at your plugin specs:
local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim"
-- (clone lazy.nvim into lazypath here if it does not exist)
vim.opt.rtp:prepend(lazypath)
require("lazy").setup({ spec = { { import = "plugins" } } })import = "plugins" means: load every file in lua/plugins/ as a
plugin spec. One file per concern — ui.lua, git.lua, lsp.lua — and
adding a plugin never touches init.lua again.
A spec file
lua/plugins/ui.lua:
return {
{ "nvim-lualine/lualine.nvim", opts = {} },
}A spec is a plain Lua table returned from the file. opts = {} tells lazy
to call the plugin’s setup() with those options. Specs can also declare
lazy-loading triggers (event, cmd, keys, ft) so plugins cost nothing
until used.
Open the manager any time:
:LazyThe lockfile is the point
lazy.nvim writes lazy-lock.json next to your config — every plugin pinned
to an exact commit. Commit that file to your dotfiles repo and any machine
rebuilds the identical editor: clone, open Neovim once, done.
That is exactly how the
course companion repo works —
its nvim/lazy-lock.json pins the versions used on screen, and
:Lazy restore reproduces them anywhere.