I have extra checks in the lazy init/bootstrap process for my own sanity. These just make sure git is actually installed, and you have internet.
90 lines
2.3 KiB
Lua
90 lines
2.3 KiB
Lua
-- Boostrap Lazy plugin manager
|
|
local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim"
|
|
|
|
-- It is possible to install this config via tarball,
|
|
-- or inherit it when copying my user config to a new machine.
|
|
--
|
|
-- It is also possible that git can be installed but not in $PATH
|
|
-- especially when linux DE's are started via `exec env`
|
|
--
|
|
-- as such the system installing it may not have git avaialable
|
|
-- This is a failure condition as we cannot bootstrap,
|
|
-- nor manage plugins without it.
|
|
if vim.fn.executable("git") == 0 then
|
|
vim.api.nvim_echo(
|
|
{
|
|
{ "git is not installed, will be unable to use Lazy\n", "ErrorMsg"},
|
|
{ "your PATH is: ", "WarningMsg" },
|
|
{ vim.env.PATH, "WarningMsg"}, -- output path for debugging purposes
|
|
{ "\nPress any key to exit..."}
|
|
}, true, {} )
|
|
vim.fn.getchar()
|
|
os.exit(1)
|
|
end
|
|
|
|
|
|
-- Standard bootstrapping process.
|
|
if not (vim.uv or vim.loop).fs_stat(lazypath) then
|
|
local lazyrepo = "https://github.com/folke/lazy.nvim.git"
|
|
|
|
|
|
local out = vim.fn.system({ "git", "clone", "--filter=blob:none", "--branch=stable", lazyrepo, lazypath })
|
|
if vim.v.shell_error ~= 0 then
|
|
vim.api.nvim_echo({
|
|
{ "Failed to clone lazy.nvim:\n", "ErrorMsg" },
|
|
{ out, "WarningMsg" },
|
|
{ "\nPress any key to exit..." },
|
|
}, true, {} )
|
|
vim.fn.getchar()
|
|
os.exit(1)
|
|
end
|
|
end
|
|
vim.opt.rtp:prepend(lazypath)
|
|
|
|
-- Check for internet, if we have curl..
|
|
-- This check is intentionally placed after the bootstrapping
|
|
-- as bootstrapping will fail if we don't have internet anyway.
|
|
-- and outside of that it is not a failure condition
|
|
if vim.fn.executable("curl") == 1 then
|
|
local out = vim.fn.system({
|
|
"curl",
|
|
"-sS" , -- only output errors
|
|
"--head", -- only get headers
|
|
"www.google.com",
|
|
"-o", -- send any output to /dev/null
|
|
"/dev/null"
|
|
})
|
|
|
|
if vim.v.shell_error ~= 0 then
|
|
vim.api.nvim_echo({
|
|
{ "We can't connect to the internet\n", "WarningMsg"},
|
|
{ "This is what curl said: ", "WarningMsg" },
|
|
{ out, "WarningMsg" },
|
|
{ "Packages can load, but we cannot install/update\n" },
|
|
{ "Press any key to continue...\n" }
|
|
}, true, {})
|
|
end
|
|
end
|
|
|
|
-- Actually load Lazy and get it going
|
|
require("lazy").setup({
|
|
spec = {
|
|
{ import = "plugins.spec" },
|
|
},
|
|
|
|
checker = { enabled = true },
|
|
|
|
performance = {
|
|
rtp = {
|
|
disabled_plugins ={
|
|
"netrwPlugin",
|
|
"gzip",
|
|
"tarPlugin",
|
|
"tohtml",
|
|
"tutor",
|
|
"zipPlugin"
|
|
}
|
|
}
|
|
}
|
|
})
|