irongit

My nvim configuration

hygo-nvim/lua/lazy-bootstrap.lua
51 lines1.4 KBLua
1-- Lazy Bootstrapper
2-- Usage:
3-- ```lua
4-- load(vim.fn.system("curl -s https://raw.githubusercontent.com/folke/lazy.nvim/main/bootstrap.lua"))()
5-- ```
6local M = {}
7
8function M.setup()
9 local uv = vim.uv or vim.loop
10 if vim.env.LAZY_STDPATH then
11 local root = vim.fn.fnamemodify(vim.env.LAZY_STDPATH, ":p"):gsub("[\\/]$", "")
12 for _, name in ipairs({ "config", "data", "state", "cache" }) do
13 vim.env[("XDG_%s_HOME"):format(name:upper())] = root .. "/" .. name
14 end
15 end
16
17 if vim.env.LAZY_PATH and not uv.fs_stat(vim.env.LAZY_PATH) then
18 vim.env.LAZY_PATH = nil
19 end
20
21 local lazypath = vim.env.LAZY_PATH or vim.fn.stdpath("data") .. "/lazy/lazy.nvim"
22 if not vim.env.LAZY_PATH and not uv.fs_stat(lazypath) then
23 vim.api.nvim_echo({
24 {
25 "Cloning lazy.nvim\n\n",
26 "DiagnosticInfo",
27 },
28 }, true, {})
29 local lazyrepo = "https://github.com/folke/lazy.nvim.git"
30 local ok, out = pcall(vim.fn.system, {
31 "git",
32 "clone",
33 "--filter=blob:none",
34 lazyrepo,
35 lazypath,
36 })
37 if not ok or vim.v.shell_error ~= 0 then
38 vim.api.nvim_echo({
39 { "Failed to clone lazy.nvim\n", "ErrorMsg" },
40 { vim.trim(out or ""), "WarningMsg" },
41 { "\nPress any key to exit...", "MoreMsg" },
42 }, true, {})
43 vim.fn.getchar()
44 os.exit(1)
45 end
46 end
47 vim.opt.rtp:prepend(lazypath)
48end
49M.setup()
50
51return M