diff --git a/lua/noice/config/init.lua b/lua/noice/config/init.lua index 2bcf3e1e..ac5ba1f2 100644 --- a/lua/noice/config/init.lua +++ b/lua/noice/config/init.lua @@ -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 @@ -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 @@ -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