The Bootstrap File

Make the folder from inside the editor

:!mkdir -p ~/.config/nvim/lua/config
:e ~/.config/nvim/lua/config/lazy.lua

The bootstrap

local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim"
if not (vim.uv or vim.loop).fs_stat(lazypath) then
  vim.fn.system({ "git", "clone", "--filter=blob:none", "--branch=stable",
    "https://github.com/folke/lazy.nvim.git", lazypath })
end
vim.opt.rtp:prepend(lazypath)

require("lazy").setup({ spec = { { import = "plugins" } } })

Line by line:

  • stdpath("data") — where Neovim keeps data, so this works on Linux, macOS and Windows unchanged
  • fs_stat — is it already there? If yes, skip the clone
  • --filter=blob:none — a shallow-ish clone that fetches only what it needs
  • rtp:prepend — put it on the runtime path so require can find it
  • import = "plugins" — read every file in lua/plugins/ and treat each as a plugin spec

Wire it up

In init.lua:

require("config.lazy")

Restart, and lazy.nvim clones itself and installs whatever specs it finds. :Lazy shows the result.