diff --git a/lua/conform/health.lua b/lua/conform/health.lua index 134bbc0ec9d..cbe6b36a267 100644 --- a/lua/conform/health.lua +++ b/lua/conform/health.lua @@ -101,12 +101,15 @@ M.show_window = function() ---@param formatter conform.FormatterInfo local function append_formatter_info(formatter) if not formatter.available then - local line = string.format("%s unavailable: %s", formatter.name, formatter.available_msg) + local type_label = formatter.error and "error" or "unavailable" + + local line = string.format("%s %s: %s", formatter.name, type_label, formatter.available_msg) + table.insert(lines, line) - table.insert( - highlights, - { "DiagnosticWarn", #lines, formatter.name:len(), formatter.name:len() + 12 } - ) + + local hl = formatter.error and "DiagnosticError" or "DiagnosticWarn" + local hl_start = formatter.name:len() + 1 + table.insert(highlights, { hl, #lines, hl_start, hl_start + type_label:len() }) else local filetypes = get_formatter_filetypes(formatter.name) local filetypes_list = table.concat(filetypes, ", ") diff --git a/lua/conform/init.lua b/lua/conform/init.lua index 443b2c1ca0c..90574403995 100644 --- a/lua/conform/init.lua +++ b/lua/conform/init.lua @@ -782,7 +782,8 @@ M.get_formatter_info = function(formatter, bufnr) name = formatter, command = formatter, available = false, - available_msg = "Formatter config missing or incomplete", + available_msg = "Unknown formatter. Formatter config missing or incomplete", + error = true, } end diff --git a/lua/conform/types.lua b/lua/conform/types.lua index 0d10a30373a..5027c729d29 100644 --- a/lua/conform/types.lua +++ b/lua/conform/types.lua @@ -4,6 +4,7 @@ ---@field cwd? string ---@field available boolean ---@field available_msg? string +---@field error? boolean ---@class (exact) conform.JobFormatterConfig ---@field command string|fun(self: conform.JobFormatterConfig, ctx: conform.Context): string diff --git a/tests/api_spec.lua b/tests/api_spec.lua index ea26343800b..929c8ffe370 100644 --- a/tests/api_spec.lua +++ b/tests/api_spec.lua @@ -12,6 +12,7 @@ describe("api", function() assert.equal("stylua", info.name) assert.equal("stylua", info.command) assert.equal("boolean", type(info.available)) + assert.is_nil(info.error) end) it("retrieves unavailable info if formatter does not exist", function() @@ -19,6 +20,7 @@ describe("api", function() assert.equal("asdf", info.name) assert.equal("asdf", info.command) assert.falsy(info.available) + assert.truthy(info.error) end) describe("list_formatters", function()