mirror of https://github.com/folke/lazy.nvim.git
feat: added options to configure change detection. Fixes #32
This commit is contained in:
parent
cd162f342a
commit
6c767a604d
|
@ -58,6 +58,11 @@ M.defaults = {
|
||||||
notify = true, -- get a notification when new updates are found
|
notify = true, -- get a notification when new updates are found
|
||||||
frequency = 3600, -- check for updates every hour
|
frequency = 3600, -- check for updates every hour
|
||||||
},
|
},
|
||||||
|
change_detection = {
|
||||||
|
-- automatically check for config file changes and reload the ui
|
||||||
|
enabled = true,
|
||||||
|
notify = true, -- get a notification when changes are found
|
||||||
|
},
|
||||||
performance = {
|
performance = {
|
||||||
---@type LazyCacheConfig
|
---@type LazyCacheConfig
|
||||||
cache = nil,
|
cache = nil,
|
||||||
|
@ -145,7 +150,9 @@ function M.setup(spec, opts)
|
||||||
callback = function()
|
callback = function()
|
||||||
require("lazy.core.cache").autosave()
|
require("lazy.core.cache").autosave()
|
||||||
require("lazy.view").setup()
|
require("lazy.view").setup()
|
||||||
|
if M.options.change_detection.enabled then
|
||||||
require("lazy.manage.reloader").enable()
|
require("lazy.manage.reloader").enable()
|
||||||
|
end
|
||||||
if M.options.checker.enabled then
|
if M.options.checker.enabled then
|
||||||
require("lazy.manage.checker").start()
|
require("lazy.manage.checker").start()
|
||||||
end
|
end
|
||||||
|
|
|
@ -68,11 +68,13 @@ function M.check(start)
|
||||||
|
|
||||||
if not (start or #changes == 0) then
|
if not (start or #changes == 0) then
|
||||||
vim.schedule(function()
|
vim.schedule(function()
|
||||||
|
if Config.options.change_detection.notify then
|
||||||
local lines = { "# Config Change Detected. Reloading...", "" }
|
local lines = { "# Config Change Detected. Reloading...", "" }
|
||||||
for _, change in ipairs(changes) do
|
for _, change in ipairs(changes) do
|
||||||
table.insert(lines, "- **" .. change.what .. "**: `" .. vim.fn.fnamemodify(change.file, ":p:~:.") .. "`")
|
table.insert(lines, "- **" .. change.what .. "**: `" .. vim.fn.fnamemodify(change.file, ":p:~:.") .. "`")
|
||||||
end
|
end
|
||||||
Util.warn(lines)
|
Util.warn(lines)
|
||||||
|
end
|
||||||
Plugin.load()
|
Plugin.load()
|
||||||
vim.cmd([[do User LazyRender]])
|
vim.cmd([[do User LazyRender]])
|
||||||
end)
|
end)
|
||||||
|
|
Loading…
Reference in New Issue