diff --git a/lua/lazy/core/config.lua b/lua/lazy/core/config.lua index cc27d0c..f4405e8 100644 --- a/lua/lazy/core/config.lua +++ b/lua/lazy/core/config.lua @@ -4,6 +4,7 @@ local M = {} ---@class LazyConfig M.defaults = { + root = vim.fn.stdpath("data") .. "/lazy", -- directory where plugins will be installed defaults = { lazy = false, -- should plugins be loaded at startup? version = nil, @@ -17,10 +18,6 @@ M.defaults = { log = { "--since=1 days ago" }, -- commits from the last 3 days timeout = 120, -- processes taking over 2 minutes will be killed }, - package = { - path = vim.fn.stdpath("data") .. "/site", - name = "lazy", -- plugins will be installed under package.path/pack/{name}/opt - }, -- Any plugin spec that contains one of the patterns will use your -- local repo in the projects folder instead of fetchig it from github -- Mostly useful for plugin developers. @@ -66,9 +63,6 @@ M.ns = vim.api.nvim_create_namespace("lazy") ---@type string|LazySpec Should be either a string pointing to a module, or a spec M.spec = nil ----@type string Opt directory where plugins will be installed -M.root = nil - ---@type table M.plugins = {} @@ -86,12 +80,8 @@ function M.setup(spec, opts) M.options.performance.cache = require("lazy.core.cache") table.insert(M.options.install.colorscheme, "habamax") - M.root = M.options.package.path .. "/pack/" .. M.options.package.name .. "/opt" - if M.options.performance.reset_packpath then - vim.go.packpath = M.options.package.path - else - vim.opt.packpath:prepend(M.options.package.path) + vim.go.packpath = "" end vim.api.nvim_create_autocmd("User", { diff --git a/lua/lazy/core/loader.lua b/lua/lazy/core/loader.lua index 36a1f68..f187dcc 100644 --- a/lua/lazy/core/loader.lua +++ b/lua/lazy/core/loader.lua @@ -102,11 +102,12 @@ function M.load(plugins, reason) end ---@param plugin LazyPlugin -function M.packadd(plugin) +---@param force? boolean +function M.packadd(plugin, force) -- FIXME: investigate further what else is needed -- vim.cmd.packadd(plugin.name) -- M.source_runtime(plugin, "/after/plugin") - if M.init_done then + if M.init_done or force then M.source_runtime(plugin, "/plugin") if vim.g.did_load_filetypes == 1 then M.source_runtime(plugin, "/ftdetect") diff --git a/lua/lazy/core/plugin.lua b/lua/lazy/core/plugin.lua index 659c45f..fde3acf 100644 --- a/lua/lazy/core/plugin.lua +++ b/lua/lazy/core/plugin.lua @@ -147,7 +147,7 @@ end function M.update_state() ---@type table local installed = {} - Util.ls(Config.root, function(_, name, type) + Util.ls(Config.options.root, function(_, name, type) if type == "directory" or type == "link" then installed[name] = type end @@ -169,7 +169,7 @@ function M.update_state() plugin.dir = plugin.uri plugin._.installed = true -- user should make sure the directory exists else - plugin.dir = Config.root .. "/" .. plugin.name + plugin.dir = Config.options.root .. "/" .. plugin.name plugin._.installed = installed[plugin.name] ~= nil installed[plugin.name] = nil end @@ -179,7 +179,7 @@ function M.update_state() for pack, dir_type in pairs(installed) do table.insert(Config.to_clean, { name = pack, - dir = Config.root .. "/" .. pack, + dir = Config.options.root .. "/" .. pack, _ = { installed = true, is_symlink = dir_type == "link", diff --git a/lua/lazy/core/util.lua b/lua/lazy/core/util.lua index fb93edd..cd73492 100644 --- a/lua/lazy/core/util.lua +++ b/lua/lazy/core/util.lua @@ -40,8 +40,8 @@ function M.try(fn, msg) end if info.what ~= "C" and not info.source:find("lazy.nvim") then local source = info.source:sub(2) - if source:find(Config.root, 1, true) == 1 then - source = source:sub(#Config.root + 1) + if source:find(Config.options.root, 1, true) == 1 then + source = source:sub(#Config.options.root + 1) end source = vim.fn.fnamemodify(source, ":p:~:.") local line = " - " .. source .. ":" .. info.currentline diff --git a/lua/lazy/manage/task/fs.lua b/lua/lazy/manage/task/fs.lua index 57839f4..9386f76 100644 --- a/lua/lazy/manage/task/fs.lua +++ b/lua/lazy/manage/task/fs.lua @@ -10,7 +10,7 @@ M.clean = { end, run = function(self) local dir = self.plugin.dir:gsub("/+$", "") - assert(dir:find(Config.root, 1, true) == 1, self.plugin.dir .. " should be under packpath!") + assert(dir:find(Config.options.root, 1, true) == 1, self.plugin.dir .. " should be under packpath!") local stat = vim.loop.fs_lstat(dir) assert(stat.type == "directory", self.plugin.dir .. " should be a directory!") diff --git a/lua/lazy/manage/task/plugin.lua b/lua/lazy/manage/task/plugin.lua index 329d75c..7fcf815 100644 --- a/lua/lazy/manage/task/plugin.lua +++ b/lua/lazy/manage/task/plugin.lua @@ -10,6 +10,9 @@ M.build = { end, run = function(self) Loader.load(self.plugin, { task = "build" }) + -- when installing during startup, add the package + -- to make sure all runtime files are loaded + Loader.packadd(self.plugin, true) local build = self.plugin.build if build then