Skip to content

Commit

Permalink
fix: truncate log file if it becomes too big
Browse files Browse the repository at this point in the history
  • Loading branch information
folke committed Nov 17, 2022
1 parent 1702772 commit 79a5262
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions lua/noice/config/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,7 @@ function M.defaults()
format = {}, --- @see section on formatting
debug = false,
log = vim.fn.stdpath("state") .. "/noice.log",
log_max_size = 1024 * 1024 * 2, -- 10MB
}
return defaults
end
Expand Down Expand Up @@ -236,6 +237,8 @@ function M.setup(options)
},
}, options)

M.truncate_log()

require("noice.config.preset").setup()

if M.options.popupmenu.kind_icons == false then
Expand All @@ -257,6 +260,13 @@ function M.setup(options)
M._running = true
end

function M.truncate_log()
local stat = vim.loop.fs_stat(M.options.log)
if stat and stat.size > M.options.log_max_size then
io.open(M.options.log, "w+"):close()
end
end

---@param opts NoiceConfig
function M.fix_legacy(opts)
if opts.lsp and opts.lsp.signature and type(opts.lsp.signature.auto_open) == "boolean" then
Expand Down

0 comments on commit 79a5262

Please sign in to comment.