diff --git a/lua/astrocommunity/pack/bash/init.lua b/lua/astrocommunity/pack/bash/init.lua index edf1b11dc..f174b0158 100644 --- a/lua/astrocommunity/pack/bash/init.lua +++ b/lua/astrocommunity/pack/bash/init.lua @@ -46,6 +46,21 @@ return { formatters_by_ft = { sh = { "shfmt" }, }, + formatters = { + shfmt = { + prepend_args = function(_, ctx) + local args = {} + local bo = vim.bo[ctx.buf] + if bo.expandtab then + local tab_size = bo.tabstop or 2 + local indent_size = bo.shiftwidth + if indent_size == 0 or not indent_size then indent_size = tab_size end + vim.list_extend(args, { "-i", tostring(indent_size) }) + end + return args + end, + }, + }, }, }, {