aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSteven Arcangeli <stevearc@stevearc.com>2024-07-17 21:53:49 -0700
committerSteven Arcangeli <stevearc@stevearc.com>2024-07-17 21:53:58 -0700
commitacc7d93f4a080fec587a99fcb36cffa29adc4bad (patch)
tree0f435bc1a548bdad198e456a1393664cbc2336fd
parent310e2e95a4f832163f3f7a9fedebb1a4afc0db69 (diff)
fix(shfmt): don't pass indentation if .editorconfig is present (#492)
-rw-r--r--lua/conform/formatters/shfmt.lua6
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