Skip to content

Commit

Permalink
refactor: update impatient (#2477)
Browse files Browse the repository at this point in the history
  • Loading branch information
kylo252 committed Apr 20, 2022
1 parent 3d84142 commit 0481ec8
Show file tree
Hide file tree
Showing 9 changed files with 502 additions and 393 deletions.
1 change: 0 additions & 1 deletion .github/workflows/install.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ jobs:
- runner: macos-10.15
os: osx
runs-on: ${{ matrix.runner }}
if: github.event.pull_request.draft == false
steps:
- uses: actions/checkout@v2

Expand Down
31 changes: 20 additions & 11 deletions lua/lvim/bootstrap.lua
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ function _G.get_runtime_dir()
local lvim_runtime_dir = os.getenv "LUNARVIM_RUNTIME_DIR"
if not lvim_runtime_dir then
-- when nvim is used directly
return vim.fn.stdpath "data"
return vim.call("stdpath", "data")
end
return lvim_runtime_dir
end
Expand All @@ -45,7 +45,7 @@ end
function _G.get_config_dir()
local lvim_config_dir = os.getenv "LUNARVIM_CONFIG_DIR"
if not lvim_config_dir then
return vim.fn.stdpath "config"
return vim.call("stdpath", "config")
end
return lvim_config_dir
end
Expand All @@ -55,7 +55,7 @@ end
function _G.get_cache_dir()
local lvim_cache_dir = os.getenv "LUNARVIM_CACHE_DIR"
if not lvim_cache_dir then
return vim.fn.stdpath "cache"
return vim.call("stdpath", "config")
end
return lvim_cache_dir
end
Expand All @@ -70,6 +70,18 @@ function M:init(base_dir)
self.packer_install_dir = join_paths(self.runtime_dir, "site", "pack", "packer", "start", "packer.nvim")
self.packer_cache_path = join_paths(self.config_dir, "plugin", "packer_compiled.lua")

---@meta overridden to use LUNARVIM_x_DIR instead, since a lot of plugins call this function interally
vim.fn.stdpath = function(what)
if what == "cache" then
return _G.get_cache_dir()
elseif what == "data" then
return _G.get_runtime_dir()
elseif what == "config" then
return _G.get_config_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()
Expand All @@ -78,13 +90,13 @@ function M:init(base_dir)

if os.getenv "LUNARVIM_RUNTIME_DIR" then
-- vim.opt.rtp:append(os.getenv "LUNARVIM_RUNTIME_DIR" .. path_sep .. "lvim")
vim.opt.rtp:remove(join_paths(vim.fn.stdpath "data", "site"))
vim.opt.rtp:remove(join_paths(vim.fn.stdpath "data", "site", "after"))
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, "site", "after"))

vim.opt.rtp:remove(vim.fn.stdpath "config")
vim.opt.rtp:remove(join_paths(vim.fn.stdpath "config", "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"))
-- TODO: we need something like this: vim.opt.packpath = vim.opt.rtp
Expand All @@ -95,10 +107,7 @@ function M:init(base_dir)
-- FIXME: currently unreliable in unit-tests
if not in_headless then
_G.PLENARY_DEBUG = false
require("lvim.impatient").setup {
path = join_paths(self.cache_dir, "lvim_cache"),
enable_profiling = true,
}
require "lvim.impatient"
end

require("lvim.config"):init()
Expand Down

0 comments on commit 0481ec8

Please sign in to comment.