Skip to content

Commit

Permalink
feat: added options to configure change detection. Fixes #32
Browse files Browse the repository at this point in the history
  • Loading branch information
folke committed Dec 20, 2022
1 parent cd162f3 commit 6c767a6
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 5 deletions.
9 changes: 8 additions & 1 deletion lua/lazy/core/config.lua
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,11 @@ M.defaults = {
notify = true, -- get a notification when new updates are found
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 = {
---@type LazyCacheConfig
cache = nil,
Expand Down Expand Up @@ -145,7 +150,9 @@ function M.setup(spec, opts)
callback = function()
require("lazy.core.cache").autosave()
require("lazy.view").setup()
require("lazy.manage.reloader").enable()
if M.options.change_detection.enabled then
require("lazy.manage.reloader").enable()
end
if M.options.checker.enabled then
require("lazy.manage.checker").start()
end
Expand Down
10 changes: 6 additions & 4 deletions lua/lazy/manage/reloader.lua
Original file line number Diff line number Diff line change
Expand Up @@ -68,11 +68,13 @@ function M.check(start)

if not (start or #changes == 0) then
vim.schedule(function()
local lines = { "# Config Change Detected. Reloading...", "" }
for _, change in ipairs(changes) do
table.insert(lines, "- **" .. change.what .. "**: `" .. vim.fn.fnamemodify(change.file, ":p:~:.") .. "`")
if Config.options.change_detection.notify then
local lines = { "# Config Change Detected. Reloading...", "" }
for _, change in ipairs(changes) do
table.insert(lines, "- **" .. change.what .. "**: `" .. vim.fn.fnamemodify(change.file, ":p:~:.") .. "`")
end
Util.warn(lines)
end
Util.warn(lines)
Plugin.load()
vim.cmd([[do User LazyRender]])
end)
Expand Down

0 comments on commit 6c767a6

Please sign in to comment.