From acc7d93f4a080fec587a99fcb36cffa29adc4bad Mon Sep 17 00:00:00 2001 From: Steven Arcangeli Date: Wed, 17 Jul 2024 21:53:49 -0700 Subject: fix(shfmt): don't pass indentation if .editorconfig is present (#492) --- lua/conform/formatters/shfmt.lua | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'lua/conform') 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 -- cgit v1.2.3-70-g09d2