diff --git a/lua/plenary/log.lua b/lua/plenary/log.lua index 117dcd24..4915b687 100644 --- a/lua/plenary/log.lua +++ b/lua/plenary/log.lua @@ -26,6 +26,9 @@ local default_config = { -- Should write to a file use_file = true, + -- Should write to the quickfix list + use_quickfix = false, + -- Any messages above this level will be logged. level = p_debug and "debug" or "info", @@ -137,6 +140,19 @@ log.new = function(config, standalone) fp:write(str) fp:close() end + + -- Output to quickfix + if config.use_quickfix then + local formatted_msg = string.format("[%s] %s", nameupper, msg) + local qf_entry = { + -- remove the @ getinfo adds to the file path + filename = info.source:sub(2), + lnum = info.currentline, + col = 1, + text = formatted_msg, + } + vim.fn.setqflist({ qf_entry }, "a") + end end for i, x in ipairs(config.modes) do