2-lazy.lua

 1-- Lazy.nvim config file.
 2
 3-- DESCRIPTION:
 4-- Use this file to configure the way you get updates.
 5
 6--    Sections:
 7--      -> lazy updater options  → choose your lazy updates channel here.
 8--      -> extra behaviors       → extra stuff we add to lazy for better UX.
 9--      -> assign spec           → if channel==stable, uses lazy_snatshot.lua
10--      -> setup using spec      → actual setup.
11
12
13-- lazy updater options
14-- Use the same values you have in the plugin `distroupdate.nvim`
15local updater = {
16  channel = "stable",               -- 'nightly', or 'stable'
17  snapshot_module = "lazy_snapshot" -- snapshot file name without extension.
18}
19
20-- lazyload extra behavior
21--  * If plugins need to be installed         → auto launch lazy at startup.
22--  * When lazy finishes installing plugins   → check for mason updates too.
23--                                              (but not when updating them)
24--  * Then show notifications and stuff.
25local lazypath = vim.fn.stdpath "data" .. "/lazy/lazy.nvim"
26if not vim.uv.fs_stat(lazypath) then
27  local output = vim.fn.system {
28    "git",
29    "clone",
30    "--filter=blob:none",
31    "--branch=stable",
32    "https://github.com/folke/lazy.nvim.git",
33    lazypath,
34  }
35  if vim.api.nvim_get_vvar "shell_error" ~= 0 then
36    vim.api.nvim_err_writeln("Error cloning lazy.nvim repository...\n\n" .. output)
37  end
38  local oldcmdheight = vim.opt.cmdheight:get()
39  vim.opt.cmdheight = 1
40  vim.notify "Please wait while plugins are installed..."
41  vim.api.nvim_create_autocmd("User", {
42    desc = "Load Mason and Treesitter after Lazy installs plugins",
43    once = true,
44    pattern = "LazyInstall",
45    callback = function()
46      vim.cmd.bw()
47      vim.opt.cmdheight = oldcmdheight
48      vim.tbl_map(function(module) pcall(require, module) end, { "nvim-treesitter", "mason" })
49      -- Note: This event will also trigger a Mason update in distroupdate.nvim
50    end,
51  })
52end
53vim.opt.rtp:prepend(lazypath)
54
55-- assign spec (if pin_plugins is true, load ./lua/lazy_snapshot.lua).
56local pin_plugins = updater.channel == "stable"
57local spec = pin_plugins and { { import = updater.snapshot_module } } or {}
58vim.list_extend(spec, { { import = "plugins" } })
59
60-- Require lazy and pass the spec.
61require("lazy").setup({
62  spec = spec,
63  defaults = { lazy = true },
64  performance = {
65    rtp = { -- Use deflate to download faster from the plugin repos.
66      disabled_plugins = {
67        "tohtml", "gzip", "zipPlugin", "netrwPlugin", "tarPlugin"
68      },
69    },
70  },
71  -- Enable luarocks if installed.
72  rocks = { enabled = vim.fn.executable("luarocks") == 1 },
73  -- We don't use this, so create it in a disposable place.
74  lockfile = vim.fn.stdpath("cache") .. "/lazy-lock.json",
75})