diff options
author | Chase Colman <[email protected]> | 2021-09-12 14:15:29 +0800 |
---|---|---|
committer | GitHub <[email protected]> | 2021-09-12 08:15:29 +0200 |
commit | ad86b1920426577ca2d0e6d56c309a190455c14f (patch) | |
tree | 2b1e41377d2ed298a3dcb01c0cd1f73e30e44b3c /lua/impatient.lua | |
parent | 7a53fc63e083c0c48d8de361d82736f844c3c14a (diff) |
refactor: add explicit setup for impatient (#1529)
Co-authored-by: kylo252 <[email protected]>
Diffstat (limited to 'lua/impatient.lua')
-rw-r--r-- | lua/impatient.lua | 23 |
1 files changed, 15 insertions, 8 deletions
diff --git a/lua/impatient.lua b/lua/impatient.lua index 4bb83fb6..ea1369fb 100644 --- a/lua/impatient.lua +++ b/lua/impatient.lua @@ -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() ]] -end - -setup() -impatient_dur = uv.hrtime() - impatient_start + impatient_dur = impatient_dur + (uv.hrtime() - impatient_setup_start) +end return M |