diff options
author | Steven Arcangeli <stevearc@stevearc.com> | 2023-08-29 19:08:37 -0700 |
---|---|---|
committer | Steven Arcangeli <stevearc@stevearc.com> | 2023-08-29 19:11:38 -0700 |
commit | c9327f2af541e4a17a6e2e05682122f8c8455d29 (patch) | |
tree | 87e5bf7d368a47bd232436296089289d7a748562 /lua/conform/health.lua | |
parent | b426bfff29cd67ceedfb2e67401a1fce2e0fdb60 (diff) |
feat: display last few lines of the log file in :ConformInfo
Diffstat (limited to 'lua/conform/health.lua')
-rw-r--r-- | lua/conform/health.lua | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/lua/conform/health.lua b/lua/conform/health.lua index f285011..195a331 100644 --- a/lua/conform/health.lua +++ b/lua/conform/health.lua @@ -43,7 +43,21 @@ M.show_window = function() local lines = {} local highlights = {} local log = require("conform.log") - table.insert(lines, string.format("Log file: %s", log.get_logfile())) + local logfile = log.get_logfile() + table.insert(lines, string.format("Log file: %s", logfile)) + table.insert(highlights, { "Title", #lines, 0, 10 }) + if vim.fn.filereadable(logfile) == 1 then + local f = io.open(logfile, "r") + if f then + f:seek("end", -1024) + local text = f:read("*a") + f:close() + local log_lines = vim.split(text, "\n", { plain = true, trimempty = true }) + for i = 2, #log_lines do + table.insert(lines, string.rep(" ", 10) .. log_lines[i]) + end + end + end table.insert(lines, "") ---@param formatters conform.FormatterInfo[] @@ -69,6 +83,7 @@ M.show_window = function() end table.insert(lines, "Formatters for this buffer:") + table.insert(highlights, { "Title", #lines, 0, -1 }) local seen = {} local buf_formatters = conform.list_formatters_for_buffer() for _, formatter in ipairs(buf_formatters) do @@ -78,6 +93,7 @@ M.show_window = function() table.insert(lines, "") table.insert(lines, "Other formatters:") + table.insert(highlights, { "Title", #lines, 0, -1 }) local all_formatters = vim.tbl_filter(function(f) return not seen[f.name] end, conform.list_all_formatters()) |