Lazy Setup

I recently wrote some of this up for some slides, so I’m going to slurp that info into here. I suggested starting with an empty init.lua and doing the following:

mkdir -p ~/.config/nvim/
cat > ~/.config/nvim/init.lua << "EOF"
-- Install lazy for plugins
local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim"
if not vim.loop.fs_stat(lazypath) then
    vim.fn.system({
        "git",
        "clone",
        "--filter=blob:none",
        "https://github.com/folke/lazy.nvim.git",
        "--branch=stable", -- latest stable release
        lazypath,
    })
end
vim.opt.rtp:prepend(lazypath)
plugins = {}
lazy_opts = {}

require("lazy").setup(plugins, lazy_opts)
EOF

I provided the following explanation:

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

plugins = {}                                                 -- (4)
lazy_opts = {}                                               -- (4)

require("lazy").setup(plugins, lazy_opts)                    -- (5)

1. compute a path for storing plugin data

2. clone the lazy plugin to that directory

3. stick that path at the front of the run-time path (rtp)

4. for later we will set up options here

5. load it and call setup

Tags: nvim

Tags

#nvim

Navigation

index
tags

Backlinks

2025-01-23 - Neovim Telescope for links
2025-01-11 - syntax highlight via treesitter in telescope
2025-01-10 - enabling marksman

created: 2025-01-10

updated: 2025-01-11 18:43:09

(re)generated: 2025-11-27