diff options
-rw-r--r-- | lua/conform/formatters/shfmt.lua | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/lua/conform/formatters/shfmt.lua b/lua/conform/formatters/shfmt.lua index 6a75ff9..c736be8 100644 --- a/lua/conform/formatters/shfmt.lua +++ b/lua/conform/formatters/shfmt.lua @@ -7,7 +7,11 @@ return { command = "shfmt", args = function(_, ctx) local args = { "-filename", "$FILENAME" } - if vim.bo[ctx.buf].expandtab then + local has_editorconfig = vim.fs.find(".editorconfig", { path = ctx.dirname, upward = true })[1] + ~= nil + -- If there is an editorconfig, don't pass any args because shfmt will apply settings from there + -- when no command line args are passed. + if not has_editorconfig and vim.bo[ctx.buf].expandtab then vim.list_extend(args, { "-i", ctx.shiftwidth }) end return args |