aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--README.md5
-rw-r--r--lua/conform/types.lua1
-rw-r--r--lua/conform/util.lua2
3 files changed, 7 insertions, 1 deletions
diff --git a/README.md b/README.md
index 041fcc5..78ad666 100644
--- a/README.md
+++ b/README.md
@@ -515,9 +515,12 @@ require("conform").setup({
},
-- Set to false to disable merging the config with the base definition
inherit = true,
- -- When inherit = true, add these additional arguments to the command.
+ -- When inherit = true, add these additional arguments to the beginning of the command.
-- This can also be a function, like args
prepend_args = { "--use-tabs" },
+ -- When inherit = true, add these additional arguments to the end of the command.
+ -- This can also be a function, like args
+ append_args = { "--trailing-comma" },
},
-- These can also be a function that returns the formatter
other_formatter = function(bufnr)
diff --git a/lua/conform/types.lua b/lua/conform/types.lua
index bd98426..f68c2de 100644
--- a/lua/conform/types.lua
+++ b/lua/conform/types.lua
@@ -35,6 +35,7 @@
---@field inherit? boolean
---@field command? string|fun(self: conform.FormatterConfig, ctx: conform.Context): string
---@field prepend_args? string|string[]|fun(self: conform.FormatterConfig, ctx: conform.Context): string|string[]
+---@field append_args? string|string[]|fun(self: conform.FormatterConfig, ctx: conform.Context): string|string[]
---@field format? fun(self: conform.LuaFormatterConfig, ctx: conform.Context, lines: string[], callback: fun(err: nil|string, new_lines: nil|string[])) Mutually exclusive with command
---@field options? table
diff --git a/lua/conform/util.lua b/lua/conform/util.lua
index 1222af2..4f9b01b 100644
--- a/lua/conform/util.lua
+++ b/lua/conform/util.lua
@@ -170,6 +170,8 @@ M.merge_formatter_configs = function(config, override)
local ret = vim.tbl_deep_extend("force", config, override)
if override.prepend_args then
M.add_formatter_args(ret, override.prepend_args, { append = false })
+ elseif override.append_args then
+ M.add_formatter_args(ret, override.append_args, { append = true })
end
return ret
end