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) --- doc/conform.txt | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'doc') diff --git a/doc/conform.txt b/doc/conform.txt index f5dede6..e30eef4 100644 --- a/doc/conform.txt +++ b/doc/conform.txt @@ -17,9 +17,17 @@ OPTIONS *conform-option formatters_by_ft = { lua = { "stylua" }, -- Conform will run multiple formatters sequentially - python = { "isort", "black" }, + go = { "goimports", "gofmt" }, -- Use a sub-list to run only the first available formatter javascript = { { "prettierd", "prettier" } }, + -- You can use a function here to determine the formatters dynamically + python = function(bufnr) + if require("conform").get_formatter_info("ruff_format", bufnr).available then + return { "ruff_format" } + else + return { "isort", "black" } + end + end, -- Use the "*" filetype to run formatters on all filetypes. ["*"] = { "codespell" }, -- Use the "_" filetype to run formatters on filetypes that don't -- cgit v1.2.3-70-g09d2