diff options
-rw-r--r-- | README.md | 8 | ||||
-rw-r--r-- | doc/conform.txt | 8 | ||||
-rw-r--r-- | lua/conform/init.lua | 13 | ||||
-rw-r--r-- | scripts/options_doc.lua | 8 |
4 files changed, 30 insertions, 7 deletions
@@ -240,10 +240,14 @@ require("conform").setup({ python = { "isort", "black" }, -- Use a sub-list to run only the first available formatter javascript = { { "prettierd", "prettier" } }, - -- Use the "*" filetype to run formatters on all files. + -- Use the "*" filetype to run formatters on all filetypes. -- Note that if you use this, you may want to set lsp_fallback = "always" -- (see :help conform.format) - ["*"] = { "trim_whitespace" }, + ["*"] = { "codespell" }, + -- Use the "_" filetype to run formatters on all filetypes + -- that don't have other formatters configured. Again, you may want to + -- set lsp_fallback = "always" when using this value. + ["_"] = { "trim_whitespace" }, }, -- If this is set, Conform will run the formatter on save. -- It will pass the table to conform.format(). diff --git a/doc/conform.txt b/doc/conform.txt index 1787f2c..bb3d90d 100644 --- a/doc/conform.txt +++ b/doc/conform.txt @@ -20,10 +20,14 @@ OPTIONS *conform-option python = { "isort", "black" }, -- Use a sub-list to run only the first available formatter javascript = { { "prettierd", "prettier" } }, - -- Use the "*" filetype to run formatters on all files. + -- Use the "*" filetype to run formatters on all filetypes. -- Note that if you use this, you may want to set lsp_fallback = "always" -- (see :help conform.format) - ["*"] = { "trim_whitespace" }, + ["*"] = { "codespell" }, + -- Use the "_" filetype to run formatters on all filetypes + -- that don't have other formatters configured. Again, you may want to + -- set lsp_fallback = "always" when using this value. + ["_"] = { "trim_whitespace" }, }, -- If this is set, Conform will run the formatter on save. -- It will pass the table to conform.format(). diff --git a/lua/conform/init.lua b/lua/conform/init.lua index 07c46a3..aadec4d 100644 --- a/lua/conform/init.lua +++ b/lua/conform/init.lua @@ -171,7 +171,7 @@ M.list_formatters_for_buffer = function(bufnr) end end - table.insert(filetypes, "*") + table.insert(filetypes, "_") for _, filetype in ipairs(filetypes) do ---@type conform.FormatterUnit[] local ft_formatters = M.formatters_by_ft[filetype] @@ -183,7 +183,18 @@ M.list_formatters_for_buffer = function(bufnr) end dedupe_formatters(ft_formatters, formatters) + break + end + end + + local ft_formatters = M.formatters_by_ft["*"] + if ft_formatters then + -- support the old structure where formatters could be a subkey + if not vim.tbl_islist(ft_formatters) then + ---@diagnostic disable-next-line: undefined-field + ft_formatters = ft_formatters.formatters end + dedupe_formatters(ft_formatters, formatters) end return formatters diff --git a/scripts/options_doc.lua b/scripts/options_doc.lua index af7b10c..bce6908 100644 --- a/scripts/options_doc.lua +++ b/scripts/options_doc.lua @@ -6,10 +6,14 @@ require("conform").setup({ python = { "isort", "black" }, -- Use a sub-list to run only the first available formatter javascript = { { "prettierd", "prettier" } }, - -- Use the "*" filetype to run formatters on all files. + -- Use the "*" filetype to run formatters on all filetypes. -- Note that if you use this, you may want to set lsp_fallback = "always" -- (see :help conform.format) - ["*"] = { "trim_whitespace" }, + ["*"] = { "codespell" }, + -- Use the "_" filetype to run formatters on all filetypes + -- that don't have other formatters configured. Again, you may want to + -- set lsp_fallback = "always" when using this value. + ["_"] = { "trim_whitespace" }, }, -- If this is set, Conform will run the formatter on save. -- It will pass the table to conform.format(). |