From cd75be867f2331b22905f47d28c0c270a69466aa Mon Sep 17 00:00:00 2001 From: Micah Halter Date: Mon, 1 Jul 2024 13:58:55 -0400 Subject: feat(shfmt): add automatic indentation detection (#481) * feat(shfmt): automatically detect indentation * fix(markdown-toc): improve correctness of indentation size calculation * fix(djlint): improve correctness of indentation size calculation * feat: add effective `shiftwidth` to `conform.Context` this also refactors formatters that automatically set indentation level to use the new shiftwidth context --- lua/conform/runner.lua | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'lua/conform/runner.lua') diff --git a/lua/conform/runner.lua b/lua/conform/runner.lua index 3831198..c0a19cd 100644 --- a/lua/conform/runner.lua +++ b/lua/conform/runner.lua @@ -450,6 +450,11 @@ M.build_context = function(bufnr, config, range) end local filename = vim.api.nvim_buf_get_name(bufnr) + local shiftwidth = vim.bo[bufnr].shiftwidth + if shiftwidth == 0 then + shiftwidth = vim.bo[bufnr].tabstop + end + -- Hack around checkhealth. For buffers that are not files, we need to fabricate a filename if vim.bo[bufnr].buftype ~= "" then filename = "" @@ -482,6 +487,7 @@ M.build_context = function(bufnr, config, range) filename = filename, dirname = dirname, range = range, + shiftwidth = shiftwidth, } end -- cgit v1.2.3-70-g09d2