summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoropalmay <[email protected]>2023-02-24 17:06:06 +0200
committeropalmay <[email protected]>2023-02-24 17:18:10 +0200
commit9c907aa68599e1c136c6a52dccd357de867af0db (patch)
treed2ccb9de346518442daf4a94fdaefc0448df2397
parentbddae6bb56e16c02bf97e1eb88f64daa259b2ee1 (diff)
refactor: revert some of the changes to make this non-breakingnvim_appname-refactor
-rw-r--r--lua/lvim/bootstrap.lua44
1 files changed, 41 insertions, 3 deletions
diff --git a/lua/lvim/bootstrap.lua b/lua/lvim/bootstrap.lua
index 9db7a50a..51bcfec4 100644
--- a/lua/lvim/bootstrap.lua
+++ b/lua/lvim/bootstrap.lua
@@ -26,19 +26,32 @@ _G.reload = require("lvim.utils.modules").reload
---Get the full path to stdpath("data")
---@return string|nil
function _G.get_runtime_dir()
- return vim.call("stdpath", "data")
+ local lvim_runtime_dir = os.getenv "LUNARVIM_RUNTIME_DIR"
+ if not lvim_runtime_dir then
+ -- when nvim is used directly
+ return vim.call("stdpath", "data")
+ end
+ return lvim_runtime_dir
end
---Get the full path to stdpath("config")
---@return string|nil
function _G.get_config_dir()
- return vim.call("stdpath", "config")
+ local lvim_config_dir = os.getenv "LUNARVIM_CONFIG_DIR"
+ if not lvim_config_dir then
+ return vim.call("stdpath", "config")
+ end
+ return lvim_config_dir
end
---Get the full path to stdpath("cache")
---@return string|nil
function _G.get_cache_dir()
- return vim.call("stdpath", "cache")
+ local lvim_cache_dir = os.getenv "LUNARVIM_CACHE_DIR"
+ if not lvim_cache_dir then
+ return vim.call("stdpath", "cache")
+ end
+ return lvim_cache_dir
end
---Initialize the `&runtimepath` variables and prepare for startup
@@ -55,12 +68,37 @@ function M:init(base_dir)
self.pack_dir = join_paths(self.runtime_dir, "site", "pack")
self.lazy_install_dir = join_paths(self.pack_dir, "lazy", "opt", "lazy.nvim")
+ ---@meta overridden to use LUNARVIM_CACHE_DIR instead, since a lot of plugins call this function internally
+ ---NOTE: changes to "data" are currently unstable, see #2507
+ ---@diagnostic disable-next-line: duplicate-set-field
+ vim.fn.stdpath = function(what)
+ if what == "cache" then
+ return _G.get_cache_dir()
+ end
+ return vim.call("stdpath", what)
+ end
+
---Get the full path to LunarVim's base directory
---@return string
function _G.get_lvim_base_dir()
return base_dir
end
+ if os.getenv "LUNARVIM_RUNTIME_DIR" then
+ vim.opt.rtp:remove(join_paths(vim.call("stdpath", "data"), "site"))
+ vim.opt.rtp:remove(join_paths(vim.call("stdpath", "data"), "site", "after"))
+ -- vim.opt.rtp:prepend(join_paths(self.runtime_dir, "site"))
+ vim.opt.rtp:append(join_paths(self.runtime_dir, "lvim", "after"))
+ vim.opt.rtp:append(join_paths(self.runtime_dir, "site", "after"))
+
+ vim.opt.rtp:remove(vim.call("stdpath", "config"))
+ vim.opt.rtp:remove(join_paths(vim.call("stdpath", "config"), "after"))
+ vim.opt.rtp:prepend(self.config_dir)
+ vim.opt.rtp:append(join_paths(self.config_dir, "after"))
+
+ vim.opt.packpath = vim.opt.rtp:get()
+ end
+
require("lvim.plugin-loader").init {
package_root = self.pack_dir,
install_path = self.lazy_install_dir,