From 3eb91c64b5960ccd84bd8e6a3318a1ee79cb85c5 Mon Sep 17 00:00:00 2001 From: Folke Lemaitre Date: Fri, 13 Oct 2023 18:03:40 +0200 Subject: [PATCH] feat(conform): make it easier to add `extra_args` --- lua/lazyvim/plugins/formatting.lua | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/lua/lazyvim/plugins/formatting.lua b/lua/lazyvim/plugins/formatting.lua index b40245ea..2053d1a5 100644 --- a/lua/lazyvim/plugins/formatting.lua +++ b/lua/lazyvim/plugins/formatting.lua @@ -61,10 +61,14 @@ return { -- return vim.fs.find({ "dprint.json" }, { path = ctx.filename, upward = true })[1] -- end, -- }, + shfmt = { + extra_args = { "-i", "2", "-ci" }, + }, }, }, ---@param opts ConformOpts config = function(_, opts) + local util = require("conform.util") opts.formatters = opts.formatters or {} for name, formatter in pairs(opts.formatters) do if type(formatter) == "table" then @@ -72,8 +76,13 @@ return { if ok and type(defaults) == "table" then opts.formatters[name] = vim.tbl_deep_extend("force", {}, defaults, formatter) end + if opts.formatters[name].extra_args then + opts.formatters[name].args = + util.extend_args(opts.formatters[name].args or {}, opts.formatters[name].extra_args) + end end end + for _, key in ipairs({ "format_on_save", "format_after_save" }) do if opts[key] then Util.warn(