Skip to content

Commit 6c767a6

Browse files
committed
feat: added options to configure change detection. Fixes #32
1 parent cd162f3 commit 6c767a6

File tree

2 files changed

+14
-5
lines changed

2 files changed

+14
-5
lines changed

lua/lazy/core/config.lua

+8-1
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,11 @@ M.defaults = {
5858
notify = true, -- get a notification when new updates are found
5959
frequency = 3600, -- check for updates every hour
6060
},
61+
change_detection = {
62+
-- automatically check for config file changes and reload the ui
63+
enabled = true,
64+
notify = true, -- get a notification when changes are found
65+
},
6166
performance = {
6267
---@type LazyCacheConfig
6368
cache = nil,
@@ -145,7 +150,9 @@ function M.setup(spec, opts)
145150
callback = function()
146151
require("lazy.core.cache").autosave()
147152
require("lazy.view").setup()
148-
require("lazy.manage.reloader").enable()
153+
if M.options.change_detection.enabled then
154+
require("lazy.manage.reloader").enable()
155+
end
149156
if M.options.checker.enabled then
150157
require("lazy.manage.checker").start()
151158
end

lua/lazy/manage/reloader.lua

+6-4
Original file line numberDiff line numberDiff line change
@@ -68,11 +68,13 @@ function M.check(start)
6868

6969
if not (start or #changes == 0) then
7070
vim.schedule(function()
71-
local lines = { "# Config Change Detected. Reloading...", "" }
72-
for _, change in ipairs(changes) do
73-
table.insert(lines, "- **" .. change.what .. "**: `" .. vim.fn.fnamemodify(change.file, ":p:~:.") .. "`")
71+
if Config.options.change_detection.notify then
72+
local lines = { "# Config Change Detected. Reloading...", "" }
73+
for _, change in ipairs(changes) do
74+
table.insert(lines, "- **" .. change.what .. "**: `" .. vim.fn.fnamemodify(change.file, ":p:~:.") .. "`")
75+
end
76+
Util.warn(lines)
7477
end
75-
Util.warn(lines)
7678
Plugin.load()
7779
vim.cmd([[do User LazyRender]])
7880
end)

0 commit comments

Comments
 (0)