mirror of
https://github.com/LunarVim/LunarVim.git
synced 2024-09-20 18:45:08 +02:00
refactor: add explicit setup for impatient (#1529)
Co-authored-by: kylo252 <59826753+kylo252@users.noreply.github.com>
This commit is contained in:
parent
7a53fc63e0
commit
ad86b19204
3 changed files with 19 additions and 9 deletions
5
init.lua
5
init.lua
|
@ -18,7 +18,10 @@ vim.cmd [[let &packpath = &runtimepath]]
|
|||
-- }}}
|
||||
|
||||
_G.PLENARY_DEBUG = false -- Plenary destroys cache with this undocumented flag set to true by default
|
||||
require("impatient").enable_profile()
|
||||
require("impatient").setup {
|
||||
path = vim.fn.stdpath "cache" .. "/lvim_cache",
|
||||
enable_profiling = true,
|
||||
}
|
||||
|
||||
local config = require "config"
|
||||
config:init()
|
||||
|
|
|
@ -2,13 +2,12 @@
|
|||
|
||||
local vim = vim
|
||||
local uv = vim.loop
|
||||
local impatient_start = uv.hrtime()
|
||||
local impatient_load_start = uv.hrtime()
|
||||
local api = vim.api
|
||||
local ffi = require "ffi"
|
||||
|
||||
local get_option, set_option = api.nvim_get_option, api.nvim_set_option
|
||||
local get_runtime_file = api.nvim_get_runtime_file
|
||||
local home_dir = uv.os_homedir()
|
||||
|
||||
local impatient_dur
|
||||
|
||||
|
@ -16,7 +15,7 @@ local M = {
|
|||
cache = {},
|
||||
profile = nil,
|
||||
dirty = false,
|
||||
path = home_dir .. "/.local/share/lunarvim/cache",
|
||||
path = nil,
|
||||
log = {},
|
||||
}
|
||||
|
||||
|
@ -274,7 +273,17 @@ function M.clear_cache()
|
|||
os.remove(M.path)
|
||||
end
|
||||
|
||||
local function setup()
|
||||
impatient_dur = uv.hrtime() - impatient_load_start
|
||||
|
||||
function M.setup(opts)
|
||||
opts = opts or {}
|
||||
M.path = opts.path or vim.fn.stdpath "cache" .. "/luacache"
|
||||
|
||||
if opts.enable_profiling then
|
||||
M.enable_profile()
|
||||
end
|
||||
|
||||
local impatient_setup_start = uv.hrtime()
|
||||
local stat = uv.fs_stat(M.path)
|
||||
if stat then
|
||||
log("Loading cache file %s", M.path)
|
||||
|
@ -344,10 +353,8 @@ local function setup()
|
|||
command! LuaCacheClear lua _G.__luacache.clear_cache()
|
||||
command! LuaCacheLog lua _G.__luacache.print_log()
|
||||
]]
|
||||
|
||||
impatient_dur = impatient_dur + (uv.hrtime() - impatient_setup_start)
|
||||
end
|
||||
|
||||
setup()
|
||||
|
||||
impatient_dur = uv.hrtime() - impatient_start
|
||||
|
||||
return M
|
||||
|
|
Loading…
Reference in a new issue