From f4b42001e2fb1bb295653a277fdcd1d4af6b1235 Mon Sep 17 00:00:00 2001
From: Micah Halter <micah@mehalter.com>
Date: Tue, 13 Feb 2024 18:04:54 -0500
Subject: [PATCH] refactor: move `lazy` setup so user never touches `init.lua`

---
 init.lua           | 35 +++--------------------------------
 lua/lazy_setup.lua | 29 +++++++++++++++++++++++++++++
 2 files changed, 32 insertions(+), 32 deletions(-)
 create mode 100644 lua/lazy_setup.lua

diff --git a/init.lua b/init.lua
index bfb86e6..354f5b2 100644
--- a/init.lua
+++ b/init.lua
@@ -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"
diff --git a/lua/lazy_setup.lua b/lua/lazy_setup.lua
new file mode 100644
index 0000000..88116f0
--- /dev/null
+++ b/lua/lazy_setup.lua
@@ -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]])