refactor: move `lazy` setup so user never touches `init.lua`

pull/7/head
Micah Halter 2024-02-13 18:04:54 -05:00
parent 75d2b26b6e
commit f4b42001e2
No known key found for this signature in database
GPG Key ID: 4224A6EA9A8CAAA8
2 changed files with 32 additions and 32 deletions

View File

@ -6,42 +6,13 @@ if not (vim.env.LAZY or vim.loop.fs_stat(lazypath)) then
end
vim.opt.rtp:prepend(lazypath)
local lazy_loaded, lazy = pcall(require, "lazy") -- validate that lazy is available
if not lazy_loaded then
-- validate that lazy is available
if not pcall(require, "lazy") then
-- stylua: ignore
vim.api.nvim_echo({ { ("Unable to load lazy from: %s\n"):format(lazypath), "ErrorMsg" }, { "Press any key to exit...", "MoreMsg" } }, true, {})
vim.fn.getchar()
vim.cmd.quit()
end
lazy.setup({
{
"AstroNvim/AstroNvim",
branch = "v4", -- TODO: change `branch="v4"` to `version="^4"` on release
import = "astronvim.plugins",
opts = { -- AstroNvim options must be set with the `import` key
mapleader = " ", -- This ensures the leader key must be configured before Lazy is set up
maplocalleader = ",", -- This ensures the localleader key must be configured before Lazy is set up
icons_enabled = true, -- Set to false to disable icons (if no Nerd Font is available)
pin_plugins = nil, -- Default will pin plugins when tracking `version` of AstroNvim, set to true/false to override
},
},
{ import = "community" },
{ import = "plugins" },
} --[[@as LazySpec]], {
install = { colorscheme = { "astrodark", "habamax" } },
performance = {
rtp = {
-- disable some rtp plugins, add more to your liking
disabled_plugins = {
"gzip",
"netrwPlugin",
"tarPlugin",
"tohtml",
"zipPlugin",
},
},
},
} --[[@as LazyConfig]])
require "lazy_setup"
require "polish"

29
lua/lazy_setup.lua Normal file
View File

@ -0,0 +1,29 @@
require("lazy").setup({
{
"AstroNvim/AstroNvim",
branch = "v4", -- TODO: change `branch="v4"` to `version="^4"` on release
import = "astronvim.plugins",
opts = { -- AstroNvim options must be set here with the `import` key
mapleader = " ", -- This ensures the leader key must be configured before Lazy is set up
maplocalleader = ",", -- This ensures the localleader key must be configured before Lazy is set up
icons_enabled = true, -- Set to false to disable icons (if no Nerd Font is available)
pin_plugins = nil, -- Default will pin plugins when tracking `version` of AstroNvim, set to true/false to override
},
},
{ import = "community" },
{ import = "plugins" },
} --[[@as LazySpec]], {
install = { colorscheme = { "astrodark", "habamax" } },
performance = {
rtp = {
-- disable some rtp plugins, add more to your liking
disabled_plugins = {
"gzip",
"netrwPlugin",
"tarPlugin",
"tohtml",
"zipPlugin",
},
},
},
} --[[@as LazyConfig]])