From 0bbe83830be5a07a1161bb1a23d7280310656177 Mon Sep 17 00:00:00 2001 From: Steven Arcangeli Date: Sat, 4 Nov 2023 13:24:48 -0700 Subject: feat: allow formatters_by_ft to be a function (#174) --- lua/conform/health.lua | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'lua/conform/health.lua') diff --git a/lua/conform/health.lua b/lua/conform/health.lua index 7132007..3a1c9f6 100644 --- a/lua/conform/health.lua +++ b/lua/conform/health.lua @@ -12,8 +12,14 @@ local function get_formatter_filetypes(name) local conform = require("conform") local filetypes = {} for filetype, formatters in pairs(conform.formatters_by_ft) do + if type(formatters) == "function" then + formatters = formatters(0) -- support the old structure where formatters could be a subkey - if not vim.tbl_islist(formatters) then + elseif not vim.tbl_islist(formatters) then + vim.notify_once( + "Using deprecated structure for formatters_by_ft. See :help conform-options for details.", + vim.log.levels.ERROR + ) ---@diagnostic disable-next-line: undefined-field formatters = formatters.formatters end -- cgit v1.2.3-70-g09d2